import android.app.Activity;
import android.app.Application;
import android.content.Context;
+import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
+import android.os.Environment;
+import android.preference.PreferenceManager;
import com.owncloud.android.authentication.PassCodeManager;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
private static Context mContext;
+ private static String storagePath;
+
// TODO Enable when "On Device" is recovered?
// TODO better place
// private static boolean mOnlyOnDevice = false;
public void onCreate(){
super.onCreate();
MainApp.mContext = getApplicationContext();
-
+
+ SharedPreferences appPrefs =
+ PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ MainApp.storagePath = appPrefs.getString("storage_path", Environment.
+ getExternalStorageDirectory().getAbsolutePath());
+
boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
OwnCloudClientManagerFactory.setUserAgent(getUserAgent());
return MainApp.mContext;
}
+ public static String getStoragePath(){
+ return MainApp.storagePath;
+ }
+
+ public static void setStoragePath(String path){
+ MainApp.storagePath = path;
+ }
+
// Methods to obtain Strings referring app_name
// From AccountAuthenticator
// public static final String ACCOUNT_TYPE = "owncloud";
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.preference.CheckBoxPreference;
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;
protected FileDownloader.FileDownloaderBinder mDownloaderBinder = null;
protected FileUploader.FileUploaderBinder mUploaderBinder = null;
private ServiceConnection mDownloadServiceConnection, mUploadServiceConnection = null;
+ private PreferenceWithLongSummary mPrefStoragePath;
+ private String mStoragePath;
@SuppressWarnings("deprecation")
@Override
}
}
+ mPrefStoragePath = (PreferenceWithLongSummary)findPreference("storage_path");
+ if (mPrefStoragePath != null){
+
+ mPrefStoragePath.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ MainApp.setStoragePath((String) newValue);
+ return true;
+ }
+ });
+
+// mPrefStoragePath.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+// @Override
+// public boolean onPreferenceClick(Preference preference) {
+//
+//// if (!mUploadPath.endsWith(OCFile.PATH_SEPARATOR)) {
+//// mUploadPath += OCFile.PATH_SEPARATOR;
+//// }
+//// Intent intent = new Intent(Preferences.this, UploadPathActivity.class);
+//// intent.putExtra(UploadPathActivity.KEY_INSTANT_UPLOAD_PATH, mUploadPath);
+//// startActivityForResult(intent, ACTION_SELECT_UPLOAD_PATH);
+//// return true;
+// }
+// });
+ }
+
mPrefInstantUploadPath = findPreference("instant_upload_path");
if (mPrefInstantUploadPath != null){
}
loadInstantUploadPath();
+ loadStoragePath();
loadInstantUploadVideoPath();
/* ComponentsGetter */
}
/**
+ * 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() {
* 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());
}
/**