Intent i = new Intent(context, FileUploader.class);
i.putExtra(FileUploader.KEY_ACCOUNT, account);
i.putExtra(FileUploader.KEY_LOCAL_FILE, file_path);
- i.putExtra(FileUploader.KEY_REMOTE_FILE, FileStorageUtils.getInstantUploadFilePath(context, file_name));
+ i.putExtra(FileUploader.KEY_REMOTE_FILE, FileStorageUtils.getInstantVideoUploadFilePath(context, file_name));
i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
i.putExtra(FileUploader.KEY_MIME_TYPE, mime_type);
i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true);
private static final String TAG = "OwnCloudPreferences";
private static final int ACTION_SELECT_UPLOAD_PATH = 1;
+ private static final int ACTION_SELECT_UPLOAD_VIDEO_PATH = 2;
+
private DbHandler mDbHandler;
private CheckBoxPreference pCode;
private boolean mShowContextMenu = false;
private String mUploadPath;
private Preference mPrefInstantUploadPath;
+ private Preference mPrefInstantVideoUploadPath;
+ private String mUploadVideoPath;
@SuppressWarnings("deprecation")
}
});
}
+
+ mPrefInstantVideoUploadPath = findPreference("instant_video_upload_path");
+ if (mPrefInstantVideoUploadPath != null){
+
+ mPrefInstantVideoUploadPath.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ Intent intent = new Intent(Preferences.this, UploadPathActivity.class);
+ intent.putExtra(UploadPathActivity.KEY_INSTANT_UPLOAD_PATH, mUploadVideoPath);
+ startActivityForResult(intent, ACTION_SELECT_UPLOAD_VIDEO_PATH);
+ return true;
+ }
+ });
+ }
/* About App */
pAboutApp = (Preference) findPreference("about_app");
}
loadInstantUploadPath();
+ loadInstantUploadVideoPath();
}
@Override
protected void onPause() {
- saveInstantUploadPathOnPreferences();
super.onPause();
}
if (requestCode == ACTION_SELECT_UPLOAD_PATH && (resultCode == RESULT_OK ||
resultCode == UploadPathActivity.RESULT_OK_SET_UPLOAD_PATH)){
- OCFile folderToMoveAt = (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_CURRENT_FOLDER);
+ OCFile folderToUpload = (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_CURRENT_FOLDER);
- mUploadPath = folderToMoveAt.getRemotePath();
+ mUploadPath = folderToUpload.getRemotePath();
saveInstantUploadPathOnPreferences();
+ } else if (requestCode == ACTION_SELECT_UPLOAD_VIDEO_PATH && (resultCode == RESULT_OK ||
+ resultCode == UploadPathActivity.RESULT_OK_SET_UPLOAD_PATH)){
+
+ OCFile folderToUploadVideo = (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_CURRENT_FOLDER);
+
+ mUploadVideoPath = folderToUploadVideo.getRemotePath();
+
+ saveInstantUploadVideoPathOnPreferences();
}
}
editor.putString("instant_upload_path", mUploadPath);
editor.commit();
}
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Save the "Instant Video Upload Path" on preferences
+ */
+ private void saveInstantUploadVideoPathOnPreferences() {
+ mPrefInstantVideoUploadPath.setSummary(mUploadVideoPath);
+ SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences.Editor editor = appPrefs.edit();
+ editor.putString("instant_video_upload_path", mUploadVideoPath);
+ editor.commit();
+ }
}
String value = uploadPath + OCFile.PATH_SEPARATOR + (fileName == null ? "" : fileName);
return value;
}
+
+ /**
+ * Gets the composed path when video is or must be stored
+ * @param context
+ * @param fileName: video file name
+ * @return String: video file path composed
+ */
+ public static String getInstantVideoUploadFilePath(Context context, String fileName) {
+ SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
+ String uploadVideoPathdef = context.getString(R.string.instant_upload_path);
+ String uploadVideoPath = pref.getString("instant_video_upload_path", uploadVideoPathdef);
+ String value = uploadVideoPath + OCFile.PATH_SEPARATOR + (fileName == null ? "" : fileName);
+ return value;
+ }
public static String getParentPath(String remotePath) {
String parentPath = new File(remotePath).getParent();