</intent-filter>
</activity>
<activity android:name=".ui.activity.UploadFilesActivity" />
+ <activity android:name=".ui.activity.LocalDirectorySelectorActivity" />
<activity android:name=".ui.activity.Uploader" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
- <PreferenceCategory android:title="@string/prefs_common">
- <EditTextPreference
+ <PreferenceCategory android:title="@string/prefs_category_general">
+ <Preference
android:title="@string/prefs_storage_path"
android:key="storage_path" />
</PreferenceCategory>
// Set folder for store logs
Log_OC.setLogDataFolder(dataFolder);
- Log_OC.startLogging();
+ Log_OC.startLogging(MainApp.storagePath);
Log_OC.d("Debug", "start logging");
}
--- /dev/null
+/**
+ * ownCloud Android client application
+ *
+ * @author Bartosz Przybylski
+ * Copyright (C) 2015 ownCloud Inc.
+ * Copyright (C) 2015 Bartosz Przybylski
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package com.owncloud.android.ui.activity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+
+import com.owncloud.android.R;
+
+/**
+ * Created by Bartosz Przybylski on 07.11.2015.
+ */
+public class LocalDirectorySelectorActivity extends UploadFilesActivity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mUploadBtn.setText(R.string.folder_picker_choose_button_text);
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.upload_files_btn_cancel) {
+ setResult(RESULT_CANCELED);
+ finish();
+
+ } else if (v.getId() == R.id.upload_files_btn_upload) {
+ Intent resultIntent = new Intent();
+ resultIntent.putExtra(EXTRA_CHOSEN_FILES, getInitialDirectory().getAbsolutePath());
+ setResult(RESULT_OK, resultIntent);
+ finish();
+ }
+ }
+}
import com.owncloud.android.ui.RadioButtonPreference;
import com.owncloud.android.utils.DisplayUtils;
+import java.io.File;
+
/**
* An Activity that allows the user to change the application's settings.
private static final int ACTION_SELECT_UPLOAD_PATH = 1;
private static final int ACTION_SELECT_UPLOAD_VIDEO_PATH = 2;
+ private static final int ACTION_SELECT_STORAGE_PATH = 3;
+ private static final int ACTION_PERFORM_MIGRATION = 4;
private DbHandler mDbHandler;
private CheckBoxPreference pCode;
}
}
- mPrefStoragePath = (PreferenceWithLongSummary)findPreference("storage_path");
- if (mPrefStoragePath != null){
+ mPrefStoragePath = findPreference("storage_path");
+ if (mPrefStoragePath != null) {
- mPrefStoragePath.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ 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;
}
});
-
-// 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");
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);
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,
+ currentStorageDir.getAbsolutePath());
+ startActivityForResult(migrationIntent, ACTION_PERFORM_MIGRATION);
+ }
+ } else if (requestCode == ACTION_PERFORM_MIGRATION && resultCode == RESULT_OK) {
+ String resultStorageDir = data.getStringExtra(StorageMigrationActivity.KEY_MIGRATION_TARGET_DIR);
+ mStoragePath = resultStorageDir;
+ mPrefStoragePath.setSummary(mStoragePath);
}
}
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
mStoragePath = appPrefs.getString("storage_path", Environment.getExternalStorageDirectory()
.getAbsolutePath());
- mPrefStoragePath.setSummary(mStoragePath);
+ mPrefStoragePath.setSummary(mStoragePath + File.separator + MainApp.getDataFolder());
}
/**
--- /dev/null
+/**
+ * ownCloud Android client application
+ *
+ * @author Bartosz Przybylski
+ * Copyright (C) 2015 ownCloud Inc.
+ * Copyright (C) 2015 Bartosz Przybylski
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package com.owncloud.android.ui.activity;
+
+import android.support.v7.app.AppCompatActivity;
+
+/**
+ * Created by Bartosz Przybylski on 07.11.2015.
+ */
+public class StorageMigrationActivity extends AppCompatActivity {
+ public static final String KEY_MIGRATION_TARGET_DIR = "MIGRATION_TARGET";
+ public static final String KEY_MIGRATION_SOURCE_DIR = "MIGRATION_SOURCE";
+}
private ArrayAdapter<String> mDirectories;
private File mCurrentDir = null;
- private LocalFileListFragment mFileListFragment;
- private Button mCancelBtn;
- private Button mUploadBtn;
- private Account mAccountOnCreation;
- private DialogFragment mCurrentDialog;
+ protected LocalFileListFragment mFileListFragment;
+ protected Button mCancelBtn;
+ protected Button mUploadBtn;
+ protected Account mAccountOnCreation;
+ protected DialogFragment mCurrentDialog;
public static final String EXTRA_CHOSEN_FILES =
UploadFilesActivity.class.getCanonicalName() + ".EXTRA_CHOSEN_FILES";
public static final int RESULT_OK_AND_MOVE = RESULT_FIRST_USER;
- private static final String KEY_DIRECTORY_PATH =
+ public static final String KEY_DIRECTORY_PATH =
UploadFilesActivity.class.getCanonicalName() + ".KEY_DIRECTORY_PATH";
private static final String TAG = "UploadFilesActivity";
private static final String WAIT_DIALOG_TAG = "WAIT";
super.onCreate(savedInstanceState);
if(savedInstanceState != null) {
- mCurrentDir = new File(savedInstanceState.getString(
- UploadFilesActivity.KEY_DIRECTORY_PATH));
+ mCurrentDir = new File(savedInstanceState.getString(KEY_DIRECTORY_PATH));
+ } else if (getIntent() != null && getIntent().hasExtra(KEY_DIRECTORY_PATH)) {
+ mCurrentDir = new File(getIntent().getStringExtra(KEY_DIRECTORY_PATH));
} else {
mCurrentDir = Environment.getExternalStorageDirectory();
}
public static final String getSavePath(String accountName) {
// File sdCard = Environment.getExternalStorageDirectory();
- return MainApp.getStoragePath() + "/" + MainApp.getDataFolder() + "/" + Uri.encode(accountName, "@");
+ return MainApp.getStoragePath() + File.separator + MainApp.getDataFolder() + File.separator + Uri.encode(accountName, "@");
// URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B
}
}
public static final String getTemporalPath(String accountName) {
- File sdCard = Environment.getExternalStorageDirectory();
- return sdCard.getAbsolutePath() + "/" + MainApp.getDataFolder() + "/tmp/" + Uri.encode(accountName, "@");
+ return MainApp.getStoragePath() + File.separator + MainApp.getDataFolder() + File.separator + "tmp" + File.separator + Uri.encode(accountName, "@");
// URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B
}
@SuppressLint("NewApi")
public static final long getUsableSpace(String accountName) {
- File savePath = Environment.getExternalStorageDirectory();
+ File savePath = new File(MainApp.getStoragePath());
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
return savePath.getUsableSpace();
}
public static final String getLogPath() {
- return Environment.getExternalStorageDirectory() + File.separator + MainApp.getDataFolder() + File.separator + "log";
+ return MainApp.getStoragePath() + File.separator + MainApp.getDataFolder() + File.separator + "log";
}
public static String getInstantUploadFilePath(Context context, String fileName) {