From: tobiasKaminsky Date: Fri, 20 Nov 2015 17:51:37 +0000 (+0100) Subject: Merge remote-tracking branch 'remotes/upstream/bug_1251' into beta X-Git-Tag: beta-20151122~7 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/5780aca37f2c8d74058b57be6e7f7b3024c26132?ds=inline;hp=-c Merge remote-tracking branch 'remotes/upstream/bug_1251' into beta --- 5780aca37f2c8d74058b57be6e7f7b3024c26132 diff --combined CHANGELOG.md index 050ec9ea,099a4456..97ea0e30 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@@ -1,51 -1,60 +1,55 @@@ -## 1.8.0 (September 2015) -- New MATERIAL DESIGN theme -- Updated FILE TYPE ICONS -- Preview TXT files within the app -- COPY files & folders -- Preview the full file/folder name from the long press menu -- Set a file as FAVORITE (kept-in-sync) from the CONTEXT MENU -- Updated CONFLICT RESOLUTION dialog (wording) -- Updated background for images with TRANSPARENCY in GALLERY -- Hidden files will not enforce list view instead of GRID VIEW (folders from Picasa & others) -- Security: - + Updated network stack with security fixes (Jackrabbit 2.10.1) -- Bugs fixed: - + Fixed crash when ETag is lost - + Passcode creation not restarted on device rotation - + Recovered share icon shown on folders 'shared with me' - + User name added to subject when sending a share link through e-mail (fixed on SAMLed apps) - -## 1.7.2 (July 2015) -- New navigation drawer -- Improved Passcode -- Automatic grid view just for folders full of images -- More characters allowed in file names -- Support for servers in same domain, different path -- Bugs fixed: - + Frequent crashes in folder with several images - + Sync error in servers with huge quota and external storage enable - + Share by link error - + Some other crashes and minor bugs - -## 1.7.1 (April 2015) - -- Share link even with password enforced by server -- Get the app ready for oc 8.1 servers -- Added option to create new folder in uploads from external apps -- Improved management of deleted users -- Bugs fixed - + Fixed crash on Android 2.x devices - + Improvements on uploads - -## 1.7.0 (February 2015) - -- Download full folders -- Grid view for images -- Remote thumbnails (OC Server 8.0+) -- Added number of files and folders at the end of the list -- "Open with" in contextual menu -- Downloads added to Media Provider -- Uploads: - + Local thumbnails in section "Files" - + Multiple selection in "Content from other apps" (Android 4.3+) -- Gallery: - + proper handling of EXIF - + obey sorting in the list of files -- Settings view updated -- Improved subjects in e-mails -- Bugs fixed - - - ++# 2015-11-20 ++- PR [#1293] (https://github.com/owncloud/android/pull/1293) "External SD by przybylski" merged ++- PR [#1296] (https://github.com/owncloud/android/pull/1296) "Don't allow to remove passcode without entering it. Don't allow to set incomplete passcode by przybylski" merged ++ +# 2015-11-18 +- update all PR +- fix #1259 + +# 2015-11-13 +- update all PR + +# 2015-11-10 +- update master +- PR [#1277] (https://github.com/owncloud/android/pull/1277) "Optimized uploader layout and user configured sorting" merged + +# 2015-11-05 +- update master +- fix #1244 +- add changelog +- add check for update of beta version + +# 2015-11-02 +- PR [#1240](https://github.com/owncloud/android/pull/1240) "Set as wallpaper" merged +- updated other PRs + +# 2015-11-01 +- PR [#1236](https://github.com/owncloud/android/pull/1236) "Streaming video/audio" merged +- PR [#1035](https://github.com/owncloud/android/pull/1035) "Enable video thumbnail" merged + +# 2015-10-31 +- updated all PR +- bugfix: #1234, #1230 +- implement Crash Handler +- implement direct download of latest apk in settings -> last item on bottom + +# 2015-10-30 +- fixed problem with Authority + +# 2015-10-29 +- PR [#1099](https://github.com/owncloud/android/pull/1099) "Switch list vs grid" merged +- PR [#1100](https://github.com/owncloud/android/pull/1100) "Material FAB with speed dial implementation" merged +- PR [#1209](https://github.com/owncloud/android/pull/1209) "Material buttons - before in #1090" merged +- PR [#1205](https://github.com/owncloud/android/pull/1205) "Switch between online and offline files" merged +- PR [#1195](https://github.com/owncloud/android/pull/1195) "Resize Cache" merged +- PR [#1187](https://github.com/owncloud/android/pull/1187) "Video: Big thumbnails" merged +- PR [#1058](https://github.com/owncloud/android/pull/1058) "add sort to UploadFileActiviy" merged +- PR [#1168](https://github.com/owncloud/android/pull/1168) "Avoid duplicate files" merged +- PR [#1176](https://github.com/owncloud/android/pull/1176) "Multi select" merged + + +# 2015-10-26 +- start of branch +- PR [#745](https://github.com/owncloud/android/pull/745) merged +- PR [#1044](https://github.com/owncloud/android/pull/1044) merged: < 8.1: GalleryPlus app needed, >= 8.2 Gallery app needed +- PR [#1111](https://github.com/owncloud/android/pull/1111) merged diff --combined src/com/owncloud/android/ui/activity/PassCodeActivity.java index cc4170fe,135fe041..d06306ba --- a/src/com/owncloud/android/ui/activity/PassCodeActivity.java +++ b/src/com/owncloud/android/ui/activity/PassCodeActivity.java @@@ -24,6 -24,7 +24,7 @@@ package com.owncloud.android.ui.activit import java.util.Arrays; + import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@@ -45,18 -46,18 +46,18 @@@ public class PassCodeActivity extends A private static final String TAG = PassCodeActivity.class.getSimpleName(); - public final static String ACTION_ENABLE = PassCodeActivity.class.getCanonicalName() + - ".ENABLE"; - public final static String ACTION_DISABLE = PassCodeActivity.class.getCanonicalName() + - ".DISABLE"; - public final static String ACTION_REQUEST = PassCodeActivity.class.getCanonicalName() + - ".REQUEST"; + public final static String ACTION_REQUEST_WITH_RESULT = "ACTION_REQUEST_WITH_RESULT"; + public final static String ACTION_CHECK_WITH_RESULT = "ACTION_CHECK_WITH_RESULT"; + public final static String ACTION_CHECK = "ACTION_CHECK"; + + public final static String KEY_PASSCODE = "KEY_PASSCODE"; + public final static String KEY_CHECK_RESULT = "KEY_CHECK_RESULT"; private Button mBCancel; private TextView mPassCodeHdr; private TextView mPassCodeHdrExplanation; private EditText[] mPassCodeEditTexts = new EditText[4]; - + private String [] mPassCodeDigits = {"","","",""}; private static String KEY_PASSCODE_DIGITS = "PASSCODE_DIGITS"; private boolean mConfirmingPassCode = false; @@@ -88,13 -89,13 +89,13 @@@ mPassCodeEditTexts[2] = (EditText) findViewById(R.id.txt2); mPassCodeEditTexts[3] = (EditText) findViewById(R.id.txt3); - if (ACTION_REQUEST.equals(getIntent().getAction())) { + if (ACTION_CHECK.equals(getIntent().getAction())) { /// this is a pass code request; the user has to input the right value mPassCodeHdr.setText(R.string.pass_code_enter_pass_code); mPassCodeHdrExplanation.setVisibility(View.INVISIBLE); setCancelButtonEnabled(false); // no option to cancel - } else if (ACTION_ENABLE.equals(getIntent().getAction())) { + } else if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction())) { if (savedInstanceState != null) { mConfirmingPassCode = savedInstanceState.getBoolean(PassCodeActivity.KEY_CONFIRMING_PASSCODE); mPassCodeDigits = savedInstanceState.getStringArray(PassCodeActivity.KEY_PASSCODE_DIGITS); @@@ -112,7 -113,7 +113,7 @@@ setCancelButtonEnabled(true); } - } else if (ACTION_DISABLE.equals(getIntent().getAction())) { + } else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) { /// pass code preference has just been disabled in Preferences; // will confirm user knows pass code, then remove it mPassCodeHdr.setText(R.string.pass_code_remove_your_pass_code); @@@ -284,7 -285,7 +285,7 @@@ * the previously typed pass code, if any. */ private void processFullPassCode() { - if (ACTION_REQUEST.equals(getIntent().getAction())) { + if (ACTION_CHECK.equals(getIntent().getAction())) { if (checkPassCode()) { /// pass code accepted in request, user is allowed to access the app finish(); @@@ -294,24 -295,20 +295,20 @@@ View.INVISIBLE); } - } else if (ACTION_DISABLE.equals(getIntent().getAction())) { + } else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) { if (checkPassCode()) { - /// pass code accepted when disabling, pass code is removed - SharedPreferences.Editor appPrefs = PreferenceManager - .getDefaultSharedPreferences(getApplicationContext()).edit(); - appPrefs.putBoolean("set_pincode", false); // TODO remove; this should be - // unnecessary, was done before entering in the activity - appPrefs.commit(); - - Toast.makeText(PassCodeActivity.this, R.string.pass_code_removed, Toast.LENGTH_LONG).show(); - finish(); + Intent resultIntent = new Intent(); + resultIntent.putExtra(KEY_CHECK_RESULT, true); + setResult(RESULT_OK, resultIntent); + + finish(); } else { showErrorAndRestart(R.string.pass_code_wrong, R.string.pass_code_enter_pass_code, View.INVISIBLE); } - } else if (ACTION_ENABLE.equals(getIntent().getAction())) { + } else if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction())) { /// enabling pass code if (!mConfirmingPassCode) { requestPassCodeConfirmation(); @@@ -403,7 -400,7 +400,7 @@@ /** * Overrides click on the BACK arrow to correctly cancel ACTION_ENABLE or ACTION_DISABLE, while - * preventing than ACTION_REQUEST may be worked around. + * preventing than ACTION_CHECK may be worked around. * * @param keyCode Key code of the key that triggered the down event. * @param event Event triggered. @@@ -412,8 -409,8 +409,8 @@@ @Override public boolean onKeyDown(int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount()== 0){ - if (ACTION_ENABLE.equals(getIntent().getAction()) || - ACTION_DISABLE.equals(getIntent().getAction())) { + if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction()) || + ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) { revertActionAndExit(); } return true; @@@ -427,16 -424,12 +424,12 @@@ protected void savePassCodeAndExit() { SharedPreferences.Editor appPrefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()).edit(); - - appPrefs.putString("PrefPinCode1", mPassCodeDigits[0]); - appPrefs.putString("PrefPinCode2", mPassCodeDigits[1]); - appPrefs.putString("PrefPinCode3", mPassCodeDigits[2]); - appPrefs.putString("PrefPinCode4", mPassCodeDigits[3]); - appPrefs.putBoolean("set_pincode", true); /// TODO remove; unnecessary, - // Preferences did it before entering here - appPrefs.commit(); - - Toast.makeText(this, R.string.pass_code_stored, Toast.LENGTH_LONG).show(); + + Intent resultIntent = new Intent(); + resultIntent.putExtra(KEY_PASSCODE, + mPassCodeDigits[0] + mPassCodeDigits[1] + mPassCodeDigits[2] + mPassCodeDigits[3]); + + setResult(RESULT_OK, resultIntent); finish(); } @@@ -467,7 -460,6 +460,6 @@@ outState.putStringArray(PassCodeActivity.KEY_PASSCODE_DIGITS, mPassCodeDigits); } - private class PassCodeDigitTextWatcher implements TextWatcher { private int mIndex = -1; @@@ -534,4 -526,5 +526,4 @@@ } - } diff --combined src/com/owncloud/android/ui/activity/Preferences.java index 6d677cd3,fcee70e5..863a0e4b --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@@ -34,9 -34,7 +34,9 @@@ import android.content.pm.PackageInfo import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.net.Uri; +import android.os.AsyncTask; import android.os.Bundle; +import android.os.Environment; import android.os.Handler; import android.os.IBinder; import android.preference.CheckBoxPreference; @@@ -73,25 -71,15 +73,25 @@@ import com.owncloud.android.authenticat import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.datamodel.ThumbnailsCacheManager; import com.owncloud.android.db.DbHandler; import com.owncloud.android.files.FileOperationsHelper; import com.owncloud.android.files.services.FileDownloader; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.services.OperationsService; +import com.owncloud.android.ui.PreferenceWithLongSummary; import com.owncloud.android.ui.RadioButtonPreference; import com.owncloud.android.utils.DisplayUtils; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.concurrent.ExecutionException; +import java.io.File; + /** * An Activity that allows the user to change the application's settings. @@@ -106,8 -94,8 +106,10 @@@ public class Preferences extends Prefer private static final int ACTION_SELECT_UPLOAD_PATH = 1; private static final int ACTION_SELECT_UPLOAD_VIDEO_PATH = 2; + private static final int ACTION_REQUEST_PASSCODE = 5; + private static final int ACTION_CONFIRM_PASSCODE = 6; + private static final int ACTION_SELECT_STORAGE_PATH = 3; + private static final int ACTION_PERFORM_MIGRATION = 4; private DbHandler mDbHandler; private CheckBoxPreference pCode; @@@ -131,9 -119,8 +133,10 @@@ protected FileDownloader.FileDownloaderBinder mDownloaderBinder = null; protected FileUploader.FileUploaderBinder mUploaderBinder = null; private ServiceConnection mDownloadServiceConnection, mUploadServiceConnection = null; + private PreferenceWithLongSummary mPrefStoragePath; + private String mStoragePath; + @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { @@@ -236,49 -223,34 +239,53 @@@ registerForContextMenu(getListView()); pCode = (CheckBoxPreference) findPreference("set_pincode"); - if (pCode != null){ + if (pCode != null) { pCode.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Intent i = new Intent(getApplicationContext(), PassCodeActivity.class); - Boolean enable = (Boolean) newValue; + Boolean incoming = (Boolean) newValue; + i.setAction( - enable.booleanValue() ? PassCodeActivity.ACTION_ENABLE : - PassCodeActivity.ACTION_DISABLE + incoming.booleanValue() ? PassCodeActivity.ACTION_REQUEST_WITH_RESULT : + PassCodeActivity.ACTION_CHECK_WITH_RESULT ); - startActivity(i); - - return true; + + startActivityForResult(i, incoming.booleanValue() ? ACTION_REQUEST_PASSCODE : + ACTION_CONFIRM_PASSCODE); + + // Don't update just yet, we will decide on it in onActivityResult + return false; } - }); + }); } - + final Preference pCacheSize = findPreference("pref_cache_size"); + if (pCacheSize != null){ + final SharedPreferences appPrefs = + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + Long cacheSize = ThumbnailsCacheManager.getMaxSize(); + pCacheSize.setSummary(cacheSize + " Mb"); + pCacheSize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + Long size = Long.decode((String) newValue); + if (ThumbnailsCacheManager.setMaxSize(size)){ + appPrefs.edit().putString("pref_cache_size", size.toString()); + pCacheSize.setSummary(size + " MB"); + return true; + } else { + return false; + } + } + }); + } PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("more"); boolean helpEnabled = getResources().getBoolean(R.bool.help_enabled); - Preference pHelp = findPreference("help"); + Preference pHelp = findPreference("help"); if (pHelp != null ){ if (helpEnabled) { pHelp.setOnPreferenceClickListener(new OnPreferenceClickListener() { @@@ -300,7 -272,7 +307,7 @@@ } if (BuildConfig.DEBUG) { - Preference pLog = findPreference("log"); + Preference pLog = findPreference("log"); if (pLog != null ){ pLog.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override @@@ -343,7 -315,7 +350,7 @@@ intent.putExtra(Intent.EXTRA_TEXT, recommendText); startActivity(intent); - return(true); + return true; } }); @@@ -360,10 -332,9 +367,10 @@@ pFeedback.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { - String feedbackMail =(String) getText(R.string.mail_feedback); - String feedback =(String) getText(R.string.prefs_feedback) + " - android v" + appVersion; - Intent intent = new Intent(Intent.ACTION_SENDTO); + String feedbackMail = (String) getText(R.string.mail_feedback); + String feedback = String.format("%s - android v%s", getText(R.string.prefs_feedback), appVersion); + Intent intent = new Intent(Intent.ACTION_SENDTO); + intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, feedback); @@@ -402,29 -373,7 +409,29 @@@ } } - mPrefInstantUploadPath = findPreference("instant_upload_path"); + mPrefStoragePath = (PreferenceWithLongSummary)findPreference("storage_path"); + if (mPrefStoragePath != null) { + + mPrefStoragePath.setOnPreferenceClickListener(new OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + Intent intent = new Intent(Preferences.this, LocalDirectorySelectorActivity.class); + intent.putExtra(UploadFilesActivity.KEY_DIRECTORY_PATH, mStoragePath); + startActivityForResult(intent, ACTION_SELECT_STORAGE_PATH); + return true; + } + }); + + mPrefStoragePath.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + MainApp.setStoragePath((String) newValue); + return true; + } + }); + } + + mPrefInstantUploadPath = (PreferenceWithLongSummary)findPreference("instant_upload_path"); if (mPrefInstantUploadPath != null){ mPrefInstantUploadPath.setOnPreferenceClickListener(new OnPreferenceClickListener() { @@@ -444,7 -393,7 +451,7 @@@ mPrefInstantUploadCategory = (PreferenceCategory) findPreference("instant_uploading_category"); - mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi"); + mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi"); mPrefInstantUpload = findPreference("instant_uploading"); toggleInstantPictureOptions(((CheckBoxPreference) mPrefInstantUpload).isChecked()); @@@ -490,21 -439,13 +497,21 @@@ }); /* About App */ - pAboutApp = (Preference) findPreference("about_app"); + pAboutApp = findPreference("about_app"); if (pAboutApp != null) { - pAboutApp.setTitle(String.format(getString(R.string.about_android), getString(R.string.app_name))); - pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion)); + pAboutApp.setTitle(String.format(getString(R.string.about_android), + getString(R.string.app_name))); + try { + Integer currentVersion = getPackageManager().getPackageInfo + (getPackageName(), 0).versionCode; + pAboutApp.setSummary(String.format(getString(R.string.about_version), + currentVersion)); + } catch (NameNotFoundException e) { + } } loadInstantUploadPath(); + loadStoragePath(); loadInstantUploadVideoPath(); /* ComponentsGetter */ @@@ -519,65 -460,6 +526,65 @@@ Context.BIND_AUTO_CREATE); } + /* Link to Beta apks */ + Preference pBetaLink = findPreference("beta_link"); + if (pBetaLink != null ){ + pBetaLink.setOnPreferenceClickListener(new OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + Integer latestVersion = -1; + Integer currentVersion = -1; + try { + currentVersion = getPackageManager().getPackageInfo + (getPackageName(), 0).versionCode; + LoadingVersionNumberTask loadTask = new LoadingVersionNumberTask(); + loadTask.execute(); + latestVersion = loadTask.get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } catch (NameNotFoundException e) { + e.printStackTrace(); + } + if (latestVersion == -1 || currentVersion == -1) { + Toast.makeText(getApplicationContext(), "No information available!", + Toast.LENGTH_SHORT).show(); + } + if (latestVersion > currentVersion) { + String betaLinkWeb = (String) getText(R.string.beta_link) + + latestVersion + ".apk"; + if (betaLinkWeb != null && betaLinkWeb.length() > 0) { + Uri uriUrl = Uri.parse(betaLinkWeb); + Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl); + startActivity(intent); + return true; + } + } else { + Toast.makeText(getApplicationContext(), "No new version available!", + Toast.LENGTH_SHORT).show(); + return true; + } + return true; + } + }); + } + + /* Link to Beta apks */ + Preference pChangelogLink = findPreference("changelog_link"); + if (pChangelogLink != null) { + pChangelogLink.setOnPreferenceClickListener(new OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + String betaLinkWeb = getString(R.string.changelog); + if (betaLinkWeb != null && betaLinkWeb.length() > 0) { + Uri uriUrl = Uri.parse(betaLinkWeb); + Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl); + startActivity(intent); + return true; + } + return true; + } + }); + } } private void toggleInstantPictureOptions(Boolean value){ @@@ -585,8 -467,8 +592,8 @@@ mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPathWiFi); mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPath); } else { - mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPathWiFi); - mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPath); +// mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPathWiFi); +// mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPath); } } @@@ -595,8 -477,8 +602,8 @@@ mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi); mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPath); } else { - mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPathWiFi); - mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPath); +// mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPathWiFi); +// mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPath); } } @@@ -682,7 -564,8 +689,7 @@@ if (requestCode == ACTION_SELECT_UPLOAD_PATH && resultCode == RESULT_OK){ - OCFile folderToUpload = - (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER); + OCFile folderToUpload = data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER); mUploadPath = folderToUpload.getRemotePath(); @@@ -693,9 -576,10 +700,9 @@@ saveInstantUploadPathOnPreferences(); - } else if (requestCode == ACTION_SELECT_UPLOAD_VIDEO_PATH && resultCode == RESULT_OK){ + } else if (requestCode == ACTION_SELECT_UPLOAD_VIDEO_PATH && resultCode == RESULT_OK) { - OCFile folderToUploadVideo = - (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER); + OCFile folderToUploadVideo = data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER); mUploadVideoPath = folderToUploadVideo.getRemotePath(); @@@ -705,21 -589,29 +712,44 @@@ mPrefInstantVideoUploadPath.setSummary(mUploadVideoPath); saveInstantUploadVideoPathOnPreferences(); + } else if (requestCode == ACTION_SELECT_STORAGE_PATH && resultCode == RESULT_OK) { + File currentStorageDir = new File(mStoragePath); + File upcomingStorageDir = new File(data.getStringExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES)); + + if (currentStorageDir != upcomingStorageDir) { + Intent migrationIntent = new Intent(this, StorageMigrationActivity.class); + migrationIntent.putExtra(StorageMigrationActivity.KEY_MIGRATION_SOURCE_DIR, + currentStorageDir.getAbsolutePath()); + migrationIntent.putExtra(StorageMigrationActivity.KEY_MIGRATION_TARGET_DIR, + upcomingStorageDir.getAbsolutePath()); + startActivityForResult(migrationIntent, ACTION_PERFORM_MIGRATION); + } + } else if (requestCode == ACTION_PERFORM_MIGRATION && resultCode == RESULT_OK) { + String resultStorageDir = data.getStringExtra(StorageMigrationActivity.KEY_MIGRATION_TARGET_DIR); + saveStoragePath(resultStorageDir); + } else if (requestCode == ACTION_REQUEST_PASSCODE && resultCode == RESULT_OK) { + String passcode = data.getStringExtra(PassCodeActivity.KEY_PASSCODE); + if (passcode != null && passcode.length() == 4) { + SharedPreferences.Editor appPrefs = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()).edit(); + + for (int i = 1; i <= 4; ++i) { + appPrefs.putString("PrefPinCode" + i, passcode.substring(i-1, i)); + } + appPrefs.putBoolean("set_pincode", true); + appPrefs.commit(); + Toast.makeText(this, R.string.pass_code_stored, Toast.LENGTH_LONG).show(); + } + } else if (requestCode == ACTION_CONFIRM_PASSCODE && resultCode == RESULT_OK) { + if (data.getBooleanExtra(PassCodeActivity.KEY_CHECK_RESULT, false)) { + + SharedPreferences.Editor appPrefs = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()).edit(); + appPrefs.putBoolean("set_pincode", false); + appPrefs.commit(); + + Toast.makeText(this, R.string.pass_code_removed, Toast.LENGTH_LONG).show(); + } } } @@@ -744,7 -636,6 +774,7 @@@ public void setContentView(View view) { getDelegate().setContentView(view); } + @Override public void setContentView(View view, ViewGroup.LayoutParams params) { getDelegate().setContentView(view, params); @@@ -930,31 -821,6 +960,31 @@@ } /** + * Save storage path + */ + private void saveStoragePath(String newStoragePath) { + SharedPreferences appPrefs = + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + mStoragePath = newStoragePath; + MainApp.setStoragePath(mStoragePath); + SharedPreferences.Editor editor = appPrefs.edit(); + editor.putString("storage_path", mStoragePath); + editor.commit(); + mPrefStoragePath.setSummary(mStoragePath); + } + + /** + * Load storage path set on preferences + */ + private void loadStoragePath() { + SharedPreferences appPrefs = + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + mStoragePath = appPrefs.getString("storage_path", Environment.getExternalStorageDirectory() + .getAbsolutePath()); + mPrefStoragePath.setSummary(mStoragePath); + } + + /** * Save the "Instant Upload Path" on preferences */ private void saveInstantUploadPathOnPreferences() { @@@ -969,7 -835,10 +999,7 @@@ * Load upload video path set on preferences */ private void loadInstantUploadVideoPath() { - SharedPreferences appPrefs = - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); - mUploadVideoPath = appPrefs.getString("instant_video_upload_path", getString(R.string.instant_upload_path)); - mPrefInstantVideoUploadPath.setSummary(mUploadVideoPath); + mPrefInstantVideoUploadPath.setSummary(MainApp.getStoragePath()); } /** @@@ -983,7 -852,7 +1013,7 @@@ editor.commit(); } - // Methods for ComponetsGetter + // Methods for ComponentsGetter @Override public FileDownloader.FileDownloaderBinder getFileDownloaderBinder() { return mDownloaderBinder; @@@ -1022,10 -891,14 +1052,10 @@@ if (component.equals(new ComponentName(Preferences.this, FileDownloader.class))) { mDownloaderBinder = (FileDownloader.FileDownloaderBinder) service; - } else if (component.equals(new ComponentName(Preferences.this, FileUploader.class))) { Log_OC.d(TAG, "Upload service connected"); mUploaderBinder = (FileUploader.FileUploaderBinder) service; - } else { - return; } - } @Override @@@ -1039,29 -912,4 +1069,29 @@@ } } }; + + /** + * + * Class for loading the version number + * + */ + private class LoadingVersionNumberTask extends AsyncTask { + protected Integer doInBackground(Void... args) { + try { + URL url = new URL("https://github.com/owncloud/android/raw/beta/apks/latest"); + BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); + + Integer latestVersion = Integer.parseInt(in.readLine()); + in.close(); + + return latestVersion; + + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return -1; + } + } }