/* ownCloud Android client application\r
* Copyright (C) 2011 Bartek Przybylski\r
+ * Copyright (C) 2012-2013 ownCloud Inc.\r
*\r
* This program is free software: you can redistribute it and/or modify\r
* it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
+ * the Free Software Foundation, either version 2 of the License, or\r
* (at your option) any later version.\r
*\r
* This program is distributed in the hope that it will be useful,\r
import android.content.IntentFilter;\r
import android.content.ServiceConnection;\r
import android.content.SharedPreferences;\r
+import android.content.SharedPreferences.Editor;\r
import android.content.pm.PackageInfo;\r
import android.content.pm.PackageManager.NameNotFoundException;\r
import android.content.res.Resources.NotFoundException;\r
import com.owncloud.android.operations.SynchronizeFileOperation;\r
import com.owncloud.android.operations.RemoteOperationResult.ResultCode;\r
import com.owncloud.android.syncadapter.FileSyncService;\r
+import com.owncloud.android.ui.dialog.ChangelogDialog;\r
import com.owncloud.android.ui.dialog.SslValidatorDialog;\r
import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;\r
import com.owncloud.android.ui.fragment.FileDetailFragment;\r
private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 4;\r
private static final int DIALOG_SSL_VALIDATOR = 5;\r
private static final int DIALOG_CERT_NOT_SAVED = 6;\r
+ private static final String DIALOG_CHANGELOG_TAG = "DIALOG_CHANGELOG";\r
\r
\r
private static final int ACTION_SELECT_CONTENT_FROM_APPS = 1;\r
super.onCreate(savedInstanceState);\r
\r
/// Load of parameters from received intent\r
- mCurrentDir = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE); // no check necessary, mCurrenDir == null if the parameter is not in the intent\r
Account account = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT);\r
- if (account != null)\r
- AccountUtils.setCurrentOwnCloudAccount(this, account.name);\r
+ if (account != null && AccountUtils.setCurrentOwnCloudAccount(this, account.name)) {\r
+ mCurrentDir = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE); \r
+ }\r
\r
/// Load of saved instance state: keep this always before initDataFromCurrentAccount()\r
if(savedInstanceState != null) {\r
// Drop-down navigation \r
mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);\r
OCFile currFile = mCurrentDir;\r
- while(currFile != null && currFile.getFileName() != OCFile.PATH_SEPARATOR) {\r
+ while(mStorageManager != null && currFile != null && currFile.getFileName() != OCFile.PATH_SEPARATOR) {\r
mDirectories.add(currFile.getFileName());\r
currFile = mStorageManager.getFileById(currFile.getParentId());\r
}\r
actionBar.setListNavigationCallbacks(mDirectories, this);\r
setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to workaround bug in its implementation\r
\r
+ \r
+ // show changelog, if needed\r
+ //showChangeLog();\r
+ \r
Log.d(getClass().toString(), "onCreate() end");\r
}\r
\r
\r
/**\r
+ * Shows a dialog with the change log of the current version after each app update\r
+ * \r
+ * TODO make it permanent; by now, only to advice the workaround app for 4.1.x\r
+ */\r
+ private void showChangeLog() {\r
+ if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.JELLY_BEAN) {\r
+ final String KEY_VERSION = "version";\r
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());\r
+ int currentVersionNumber = 0;\r
+ int savedVersionNumber = sharedPref.getInt(KEY_VERSION, 0);\r
+ try {\r
+ PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);\r
+ currentVersionNumber = pi.versionCode;\r
+ } catch (Exception e) {}\r
+ \r
+ if (currentVersionNumber > savedVersionNumber) {\r
+ ChangelogDialog.newInstance(true).show(getSupportFragmentManager(), DIALOG_CHANGELOG_TAG);\r
+ Editor editor = sharedPref.edit();\r
+ editor.putInt(KEY_VERSION, currentVersionNumber);\r
+ editor.commit();\r
+ }\r
+ }\r
+ }\r
+ \r
+\r
+ /**\r
* Launches the account creation activity. To use when no ownCloud account is available\r
*/\r
private void createFirstAccount() {\r
*/\r
public void onActivityResult(int requestCode, int resultCode, Intent data) {\r
\r
- if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && resultCode == RESULT_OK) {\r
- requestSimpleUpload(data);\r
+ if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {\r
+ requestSimpleUpload(data, resultCode);\r
\r
- } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES && resultCode == RESULT_OK) {\r
- requestMultipleUpload(data);\r
+ } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {\r
+ requestMultipleUpload(data, resultCode);\r
\r
}\r
}\r
\r
- private void requestMultipleUpload(Intent data) {\r
+ private void requestMultipleUpload(Intent data, int resultCode) {\r
String[] filePaths = data.getStringArrayExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES);\r
if (filePaths != null) {\r
String[] remotePaths = new String[filePaths.length];\r
i.putExtra(FileUploader.KEY_LOCAL_FILE, filePaths);\r
i.putExtra(FileUploader.KEY_REMOTE_FILE, remotePaths);\r
i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_MULTIPLE_FILES);\r
+ if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)\r
+ i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);\r
startService(i);\r
\r
} else {\r
}\r
\r
\r
- private void requestSimpleUpload(Intent data) {\r
+ private void requestSimpleUpload(Intent data, int resultCode) {\r
String filepath = null;\r
try {\r
Uri selectedImageUri = data.getData();\r
i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);\r
i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);\r
i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);\r
+ if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)\r
+ i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);\r
startService(i);\r
}\r
\r
if (item == 0) {\r
//if (!mDualPane) { \r
Intent action = new Intent(FileDisplayActivity.this, UploadFilesActivity.class);\r
+ action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(FileDisplayActivity.this));\r
startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES);\r
//} else {\r
// TODO create and handle new fragment LocalFileListFragment\r
}\r
\r
setSupportProgressBarIndeterminateVisibility(inProgress);\r
+ removeStickyBroadcast(intent);\r
\r
}\r
\r