|
@@ -35,6 +35,7 @@ import android.os.Environment;
|
|
import android.os.Handler;
|
|
import android.os.Handler;
|
|
import android.os.IBinder;
|
|
import android.os.IBinder;
|
|
import android.preference.CheckBoxPreference;
|
|
import android.preference.CheckBoxPreference;
|
|
|
|
+import android.preference.ListPreference;
|
|
import android.preference.Preference;
|
|
import android.preference.Preference;
|
|
import android.preference.Preference.OnPreferenceChangeListener;
|
|
import android.preference.Preference.OnPreferenceChangeListener;
|
|
import android.preference.Preference.OnPreferenceClickListener;
|
|
import android.preference.Preference.OnPreferenceClickListener;
|
|
@@ -64,12 +65,11 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
|
import com.owncloud.android.services.OperationsService;
|
|
import com.owncloud.android.services.OperationsService;
|
|
import com.owncloud.android.ui.PreferenceWithLongSummary;
|
|
import com.owncloud.android.ui.PreferenceWithLongSummary;
|
|
import com.owncloud.android.ui.RadioButtonPreference;
|
|
import com.owncloud.android.ui.RadioButtonPreference;
|
|
|
|
+import com.owncloud.android.utils.DataStorageUtils;
|
|
import com.owncloud.android.utils.DisplayUtils;
|
|
import com.owncloud.android.utils.DisplayUtils;
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* An Activity that allows the user to change the application's settings.
|
|
* An Activity that allows the user to change the application's settings.
|
|
*
|
|
*
|
|
@@ -118,6 +118,10 @@ public class Preferences extends PreferenceActivity {
|
|
private PreferenceWithLongSummary mPrefStoragePath;
|
|
private PreferenceWithLongSummary mPrefStoragePath;
|
|
private String mStoragePath;
|
|
private String mStoragePath;
|
|
|
|
|
|
|
|
+ public static class Keys {
|
|
|
|
+ public static final String STORAGE_PATH = "storage_path";
|
|
|
|
+ }
|
|
|
|
+
|
|
@SuppressWarnings("deprecation")
|
|
@SuppressWarnings("deprecation")
|
|
@Override
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
@@ -140,7 +144,6 @@ public class Preferences extends PreferenceActivity {
|
|
getWindow().getDecorView().findViewById(actionBarTitleId).
|
|
getWindow().getDecorView().findViewById(actionBarTitleId).
|
|
setContentDescription(getString(R.string.actionbar_settings));
|
|
setContentDescription(getString(R.string.actionbar_settings));
|
|
}
|
|
}
|
|
-
|
|
|
|
// Load package info
|
|
// Load package info
|
|
String temp;
|
|
String temp;
|
|
try {
|
|
try {
|
|
@@ -149,9 +152,9 @@ public class Preferences extends PreferenceActivity {
|
|
} catch (NameNotFoundException e) {
|
|
} catch (NameNotFoundException e) {
|
|
temp = "";
|
|
temp = "";
|
|
Log_OC.e(TAG, "Error while showing about dialog", e);
|
|
Log_OC.e(TAG, "Error while showing about dialog", e);
|
|
- }
|
|
|
|
|
|
+ }
|
|
final String appVersion = temp;
|
|
final String appVersion = temp;
|
|
-
|
|
|
|
|
|
+
|
|
// Register context menu for list of preferences.
|
|
// Register context menu for list of preferences.
|
|
registerForContextMenu(getListView());
|
|
registerForContextMenu(getListView());
|
|
|
|
|
|
@@ -237,7 +240,7 @@ public class Preferences extends PreferenceActivity {
|
|
preferenceCategory.removePreference(pHelp);
|
|
preferenceCategory.removePreference(pHelp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
boolean recommendEnabled = getResources().getBoolean(R.bool.recommend_enabled);
|
|
boolean recommendEnabled = getResources().getBoolean(R.bool.recommend_enabled);
|
|
Preference pRecommend = findPreference("recommend");
|
|
Preference pRecommend = findPreference("recommend");
|
|
if (pRecommend != null){
|
|
if (pRecommend != null){
|
|
@@ -246,11 +249,11 @@ public class Preferences extends PreferenceActivity {
|
|
@Override
|
|
@Override
|
|
public boolean onPreferenceClick(Preference preference) {
|
|
public boolean onPreferenceClick(Preference preference) {
|
|
|
|
|
|
- Intent intent = new Intent(Intent.ACTION_SENDTO);
|
|
|
|
|
|
+ Intent intent = new Intent(Intent.ACTION_SENDTO);
|
|
intent.setType("text/plain");
|
|
intent.setType("text/plain");
|
|
- intent.setData(Uri.parse(getString(R.string.mail_recommend)));
|
|
|
|
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
-
|
|
|
|
|
|
+ intent.setData(Uri.parse(getString(R.string.mail_recommend)));
|
|
|
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
+
|
|
String appName = getString(R.string.app_name);
|
|
String appName = getString(R.string.app_name);
|
|
String downloadUrl = getString(R.string.url_app_download);
|
|
String downloadUrl = getString(R.string.url_app_download);
|
|
|
|
|
|
@@ -259,7 +262,7 @@ public class Preferences extends PreferenceActivity {
|
|
appName);
|
|
appName);
|
|
String recommendText = String.format(getString(R.string.recommend_text),
|
|
String recommendText = String.format(getString(R.string.recommend_text),
|
|
appName, downloadUrl);
|
|
appName, downloadUrl);
|
|
-
|
|
|
|
|
|
+
|
|
intent.putExtra(Intent.EXTRA_SUBJECT, recommendSubject);
|
|
intent.putExtra(Intent.EXTRA_SUBJECT, recommendSubject);
|
|
intent.putExtra(Intent.EXTRA_TEXT, recommendText);
|
|
intent.putExtra(Intent.EXTRA_TEXT, recommendText);
|
|
startActivity(intent);
|
|
startActivity(intent);
|
|
@@ -272,7 +275,7 @@ public class Preferences extends PreferenceActivity {
|
|
preferenceCategory.removePreference(pRecommend);
|
|
preferenceCategory.removePreference(pRecommend);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
boolean feedbackEnabled = getResources().getBoolean(R.bool.feedback_enabled);
|
|
boolean feedbackEnabled = getResources().getBoolean(R.bool.feedback_enabled);
|
|
Preference pFeedback = findPreference("feedback");
|
|
Preference pFeedback = findPreference("feedback");
|
|
if (pFeedback != null){
|
|
if (pFeedback != null){
|
|
@@ -286,11 +289,11 @@ public class Preferences extends PreferenceActivity {
|
|
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
|
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
|
intent.setType("text/plain");
|
|
intent.setType("text/plain");
|
|
intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
|
|
intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
|
|
-
|
|
|
|
- intent.setData(Uri.parse(feedbackMail));
|
|
|
|
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
|
+
|
|
|
|
+ intent.setData(Uri.parse(feedbackMail));
|
|
|
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
startActivity(intent);
|
|
startActivity(intent);
|
|
-
|
|
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -339,26 +342,35 @@ public class Preferences extends PreferenceActivity {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- mPrefStoragePath = (PreferenceWithLongSummary)findPreference("storage_path");
|
|
|
|
|
|
+ mPrefStoragePath = (ListPreference) findPreference(Keys.STORAGE_PATH);
|
|
if (mPrefStoragePath != null) {
|
|
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;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ DataStorageUtils.Storage[] storageOptions = DataStorageUtils.getAvailableStoragePoints(getApplicationContext());
|
|
|
|
+ String[] entries = new String[storageOptions.length];
|
|
|
|
+ String[] values = new String[storageOptions.length];
|
|
|
|
+ for (int i = 0; i < storageOptions.length; ++i) {
|
|
|
|
+ entries[i] = storageOptions[i].getDescription();
|
|
|
|
+ values[i] = storageOptions[i].getPath();
|
|
|
|
+ }
|
|
|
|
+ mPrefStoragePath.setEntries(entries);
|
|
|
|
+ mPrefStoragePath.setEntryValues(values);
|
|
|
|
|
|
mPrefStoragePath.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
|
mPrefStoragePath.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
|
@Override
|
|
@Override
|
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
- MainApp.setStoragePath((String) newValue);
|
|
|
|
|
|
+ String newPath = (String)newValue;
|
|
|
|
+ if (mStoragePath.equals(newPath))
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ StorageMigration storageMigration = new StorageMigration(Preferences.this, mStoragePath, newPath);
|
|
|
|
+
|
|
|
|
+ storageMigration.setStorageMigrationProgressListener(Preferences.this);
|
|
|
|
+
|
|
|
|
+ storageMigration.migrate();
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
mPrefInstantUploadPath = (PreferenceWithLongSummary)findPreference("instant_upload_path");
|
|
mPrefInstantUploadPath = (PreferenceWithLongSummary)findPreference("instant_upload_path");
|
|
@@ -377,7 +389,7 @@ public class Preferences extends PreferenceActivity {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
mPrefInstantUploadCategory =
|
|
mPrefInstantUploadCategory =
|
|
(PreferenceCategory) findPreference("instant_uploading_category");
|
|
(PreferenceCategory) findPreference("instant_uploading_category");
|
|
|
|
|
|
@@ -385,11 +397,11 @@ public class Preferences extends PreferenceActivity {
|
|
mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi");
|
|
mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi");
|
|
mPrefInstantPictureUploadOnlyOnCharging = findPreference("instant_upload_on_charging");
|
|
mPrefInstantPictureUploadOnlyOnCharging = findPreference("instant_upload_on_charging");
|
|
mPrefInstantUpload = findPreference("instant_uploading");
|
|
mPrefInstantUpload = findPreference("instant_uploading");
|
|
-
|
|
|
|
|
|
+
|
|
toggleInstantPictureOptions(((CheckBoxPreference) mPrefInstantUpload).isChecked());
|
|
toggleInstantPictureOptions(((CheckBoxPreference) mPrefInstantUpload).isChecked());
|
|
-
|
|
|
|
|
|
+
|
|
mPrefInstantUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
|
mPrefInstantUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
toggleInstantPictureOptions((Boolean) newValue);
|
|
toggleInstantPictureOptions((Boolean) newValue);
|
|
@@ -399,7 +411,7 @@ public class Preferences extends PreferenceActivity {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
mPrefInstantVideoUploadPath = findPreference("instant_video_upload_path");
|
|
mPrefInstantVideoUploadPath = findPreference("instant_video_upload_path");
|
|
if (mPrefInstantVideoUploadPath != null){
|
|
if (mPrefInstantVideoUploadPath != null){
|
|
|
|
|
|
@@ -423,7 +435,7 @@ public class Preferences extends PreferenceActivity {
|
|
mPrefInstantVideoUpload = findPreference("instant_video_uploading");
|
|
mPrefInstantVideoUpload = findPreference("instant_video_uploading");
|
|
mPrefInstantVideoUploadOnlyOnCharging = findPreference("instant_video_upload_on_charging");
|
|
mPrefInstantVideoUploadOnlyOnCharging = findPreference("instant_video_upload_on_charging");
|
|
toggleInstantVideoOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked());
|
|
toggleInstantVideoOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked());
|
|
-
|
|
|
|
|
|
+
|
|
mPrefInstantVideoUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
|
mPrefInstantVideoUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -523,7 +535,7 @@ public class Preferences extends PreferenceActivity {
|
|
mPrefInstantUploadCategory.removePreference(mPrefInstantPictureUploadOnlyOnCharging);
|
|
mPrefInstantUploadCategory.removePreference(mPrefInstantPictureUploadOnlyOnCharging);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
private void toggleInstantVideoOptions(Boolean value){
|
|
private void toggleInstantVideoOptions(Boolean value){
|
|
if (value){
|
|
if (value){
|
|
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi);
|
|
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi);
|
|
@@ -747,9 +759,10 @@ public class Preferences extends PreferenceActivity {
|
|
mStoragePath = newStoragePath;
|
|
mStoragePath = newStoragePath;
|
|
MainApp.setStoragePath(mStoragePath);
|
|
MainApp.setStoragePath(mStoragePath);
|
|
SharedPreferences.Editor editor = appPrefs.edit();
|
|
SharedPreferences.Editor editor = appPrefs.edit();
|
|
- editor.putString("storage_path", mStoragePath);
|
|
|
|
|
|
+ editor.putString(Keys.STORAGE_PATH, mStoragePath);
|
|
editor.commit();
|
|
editor.commit();
|
|
- mPrefStoragePath.setSummary(mStoragePath);
|
|
|
|
|
|
+ String storageDescription = DataStorageUtils.getStorageDescriptionByPath(mStoragePath, this);
|
|
|
|
+ mPrefStoragePath.setSummary(storageDescription);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -758,9 +771,10 @@ public class Preferences extends PreferenceActivity {
|
|
private void loadStoragePath() {
|
|
private void loadStoragePath() {
|
|
SharedPreferences appPrefs =
|
|
SharedPreferences appPrefs =
|
|
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
|
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
|
- mStoragePath = appPrefs.getString("storage_path", Environment.getExternalStorageDirectory()
|
|
|
|
|
|
+ mStoragePath = appPrefs.getString(Keys.STORAGE_PATH, Environment.getExternalStorageDirectory()
|
|
.getAbsolutePath());
|
|
.getAbsolutePath());
|
|
- mPrefStoragePath.setSummary(mStoragePath);
|
|
|
|
|
|
+ String storageDescription = DataStorageUtils.getStorageDescriptionByPath(mStoragePath, getApplicationContext());
|
|
|
|
+ mPrefStoragePath.setSummary(storageDescription);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -791,4 +805,16 @@ public class Preferences extends PreferenceActivity {
|
|
editor.putString("instant_video_upload_path", mUploadVideoPath);
|
|
editor.putString("instant_video_upload_path", mUploadVideoPath);
|
|
editor.commit();
|
|
editor.commit();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onStorageMigrationFinished(String storagePath, boolean succeed) {
|
|
|
|
+ if (succeed) {
|
|
|
|
+ saveStoragePath(storagePath);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onCancelMigration() {
|
|
|
|
+ // Migration was canceled so we don't do anything
|
|
|
|
+ }
|
|
}
|
|
}
|