</declare-styleable>
<string-array name="pref_behaviour_entries">
- <item>@string/pref_behaviour_entries_do_nothing</item>
- <item>@string/pref_behaviour_entries_copy</item>
+ <item>@string/pref_behaviour_entries_keep_file</item>
<item>@string/pref_behaviour_entries_move</item>
- <item>@string/pref_behaviour_entries_delete</item>
</string-array>
<string-array name="pref_behaviour_entryValues">
<item>NOTHING</item>
- <item>COPY</item>
<item>MOVE</item>
- <item>DELETE</item>
</string-array>
</resources>
\ No newline at end of file
<string name="pref_cache_size">Cache size</string>
<string name="prefs_instant_behaviour_dialogTitle">Upload file to server and ...</string>
<string name="prefs_instant_behaviour_title">Behaviour</string>
+ <string name="prefs_instant_behaviour_dialogTitle">Original file will be...</string>
+ <string name="prefs_instant_behaviour_title">Original file will be...</string>
<string name="upload_copy_files">Copy file</string>
<string name="upload_move_files">Move file</string>
<string name="prefs_storage_path">Storage path</string>
<string name="stream_expose_password">Do you want to stream this file with an external app?\n\nCAUTION: This may expose your password!</string>
<string name="set_picture_as">Set picture as</string>
<string name="set_as">Set As</string>
+ <string name="pref_behaviour_entries_keep_file">kept in original folder</string>
+ <string name="pref_behaviour_entries_move">moved to ownCloud folder</string>
<string name="share_dialog_title">Sharing</string>
<string name="share_with_user_section_title">Share with users and groups</string>
</PreferenceCategory>
<PreferenceCategory android:title="@string/prefs_category_instant_uploading" android:key="instant_uploading_category">
- <com.owncloud.android.ui.dialog.OwnCloudListPreference android:key="prefs_instant_behaviour"
- android:dialogTitle="@string/prefs_instant_behaviour_dialogTitle"
- android:title="@string/prefs_instant_behaviour_title"
- android:entries="@array/pref_behaviour_entries"
- android:entryValues="@array/pref_behaviour_entryValues"
- android:defaultValue="NOTHING"
- android:summary="%s"
- />
-
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_uploading"
android:title="@string/prefs_instant_upload"
android:summary="@string/prefs_instant_upload_summary"/>
android:disableDependentsState="true"
android:title="@string/instant_video_upload_on_charging"
android:key="instant_video_upload_on_charging"/>
+ <com.owncloud.android.ui.dialog.OwnCloudListPreference android:key="prefs_instant_behaviour"
+ android:dialogTitle="@string/prefs_instant_behaviour_dialogTitle"
+ android:title="@string/prefs_instant_behaviour_title"
+ android:entries="@array/pref_behaviour_entries"
+ android:entryValues="@array/pref_behaviour_entryValues"
+ android:defaultValue="NOTHING"
+ android:summary="%s"
+ />
</PreferenceCategory>
<PreferenceCategory android:title="@string/common_category" android:key="common_category">
if (behaviour.equalsIgnoreCase("NOTHING")) {
Log_OC.d(TAG, "upload file and do nothing");
i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_FORGET);
- } else if (behaviour.equalsIgnoreCase("COPY")) {
- i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_COPY);
- Log_OC.d(TAG, "upload file and copy file to oc folder");
} else if (behaviour.equalsIgnoreCase("MOVE")) {
i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
Log_OC.d(TAG, "upload file and move file to oc folder");
- } else if (behaviour.equalsIgnoreCase("DELETE")){
- i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_REMOVE);
- Log_OC.d(TAG, "upload file and delete file in original place");
}
-
return i;
}
Pair<String, String> putResult = mPendingDownloads.putIfAbsent(
account, file.getRemotePath(), newDownload
);
- String downloadKey = putResult.first;
- requestedDownloads.add(downloadKey);
-
- sendBroadcastNewDownload(newDownload, putResult.second);
+ if (putResult != null) {
+ String downloadKey = putResult.first;
+ requestedDownloads.add(downloadKey);
+ sendBroadcastNewDownload(newDownload, putResult.second);
+ } // else, file already in the queue of downloads; don't repeat the request
} catch (IllegalArgumentException e) {
Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage());
public static final int LOCAL_BEHAVIOUR_COPY = 0;
public static final int LOCAL_BEHAVIOUR_MOVE = 1;
public static final int LOCAL_BEHAVIOUR_FORGET = 2;
- public static final int LOCAL_BEHAVIOUR_REMOVE = 3;
public static final int UPLOAD_SINGLE_FILE = 0;
public static final int UPLOAD_MULTIPLE_FILES = 1;
boolean forceOverwrite = intent.getBooleanExtra(KEY_FORCE_OVERWRITE, false);
boolean isInstant = intent.getBooleanExtra(KEY_INSTANT_UPLOAD, false);
- int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_COPY);
+ int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_FORGET);
if (intent.hasExtra(KEY_FILE) && files == null) {
Log_OC.e(TAG, "Incorrect array for OCFiles provided in upload intent");
Pair<String, String> putResult = mPendingUploads.putIfAbsent(
account, files[i].getRemotePath(), newUpload
);
- uploadKey = putResult.first;
- requestedUploads.add(uploadKey);
+ if (putResult != null) {
+ uploadKey = putResult.first;
+ requestedUploads.add(uploadKey);
+ } // else, file already in the queue of uploads; don't repeat the request
}
} catch (IllegalArgumentException e) {
public /* synchronized */ Pair<String, String> putIfAbsent(Account account, String remotePath, V value) {
String targetKey = buildKey(account, remotePath);
Node<V> valuedNode = new Node(targetKey, value);
- mMap.putIfAbsent(
- targetKey,
- valuedNode
+ Node<V> previousValue = mMap.putIfAbsent(
+ targetKey,
+ valuedNode
);
+ if (previousValue != null) {
+ // remotePath already known; not replaced
+ return null;
- String currentPath = remotePath, parentPath = null, parentKey = null;
- Node<V> currentNode = valuedNode, parentNode = null;
- boolean linked = false;
- while (!OCFile.ROOT_PATH.equals(currentPath) && !linked) {
- parentPath = new File(currentPath).getParent();
- if (!parentPath.endsWith(OCFile.PATH_SEPARATOR)) {
- parentPath += OCFile.PATH_SEPARATOR;
+ } else {
+ // value really added
+ String currentPath = remotePath, parentPath = null, parentKey = null;
+ Node<V> currentNode = valuedNode, parentNode = null;
+ boolean linked = false;
+ while (!OCFile.ROOT_PATH.equals(currentPath) && !linked) {
+ parentPath = new File(currentPath).getParent();
+ if (!parentPath.endsWith(OCFile.PATH_SEPARATOR)) {
+ parentPath += OCFile.PATH_SEPARATOR;
+ }
+ parentKey = buildKey(account, parentPath);
+ parentNode = mMap.get(parentKey);
+ if (parentNode == null) {
+ parentNode = new Node(parentKey, null);
+ parentNode.addChild(currentNode);
+ mMap.put(parentKey, parentNode);
+ } else {
+ parentNode.addChild(currentNode);
+ linked = true;
+ }
+ currentPath = parentPath;
+ currentNode = parentNode;
}
- parentKey = buildKey(account, parentPath);
- parentNode = mMap.get(parentKey);
- if (parentNode == null) {
- parentNode = new Node(parentKey, null);
- parentNode.addChild(currentNode);
- mMap.put(parentKey, parentNode);
- } else {
- parentNode.addChild(currentNode);
- linked = true;
+
+ String linkedTo = OCFile.ROOT_PATH;
+ if (linked) {
+ linkedTo = parentNode.getKey().substring(account.name.length());
}
- currentPath = parentPath;
- currentNode = parentNode;
- }
- String linkedTo = OCFile.ROOT_PATH;
- if (linked) {
- linkedTo = parentNode.getKey().substring(account.name.length());
+ return new Pair<String, String>(targetKey, linkedTo);
}
- return new Pair<String, String>(targetKey, linkedTo);
};
// location in the ownCloud local folder
if (result.isSuccess()) {
if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_FORGET) {
- mFile.setStoragePath(null);
- } else if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_REMOVE){
- mFile.setStoragePath(null);
- originalFile.delete();
+ mFile.setStoragePath("");
} else {
mFile.setStoragePath(expectedPath);
File fileToMove = null;
public void add(Account account, String remotePath,
SynchronizeFolderOperation syncFolderOperation){
- mPendingOperations.putIfAbsent(account, remotePath, syncFolderOperation);
- sendBroadcastNewSyncFolder(account, remotePath); // TODO upgrade!
+ Pair<String, String> putResult =
+ mPendingOperations.putIfAbsent(account, remotePath, syncFolderOperation);
+ if (putResult != null) {
+ sendBroadcastNewSyncFolder(account, remotePath); // TODO upgrade!
+ }
}
@Override
public void onReceive(Context context, Intent intent) {
try {
- String uploadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
+ String uploadedRemotePath = intent.getStringExtra(FileUploader.EXTRA_REMOTE_PATH);
String accountName = intent.getStringExtra(FileUploader.ACCOUNT_NAME);
boolean sameAccount = getAccount() != null && accountName.equals(getAccount().name);
OCFile currentDir = getCurrentDir();
if (sameAccount && isDescendant) {
String linkedToRemotePath =
- intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH);
+ intent.getStringExtra(FileUploader.EXTRA_LINKED_TO_PATH);
if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) {
refreshListOfFilesFragment();
}
private String mUploadPath;
private PreferenceCategory mPrefInstantUploadCategory;
private Preference mPrefInstantUpload;
+ private Preference mPrefInstantUploadBehaviour;
private Preference mPrefInstantUploadPath;
private Preference mPrefInstantUploadPathWiFi;
private Preference mPrefInstantVideoUpload;
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
toggleInstantPictureOptions((Boolean) newValue);
+ toggleInstantUploadBehaviour(
+ ((CheckBoxPreference)mPrefInstantVideoUpload).isChecked(),
+ (Boolean) newValue);
return true;
}
});
toggleInstantVideoOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked());
mPrefInstantVideoUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
-
+
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
toggleInstantVideoOptions((Boolean) newValue);
+ toggleInstantUploadBehaviour(
+ (Boolean) newValue,
+ ((CheckBoxPreference) mPrefInstantUpload).isChecked());
return true;
}
});
-
+
+ mPrefInstantUploadBehaviour = findPreference("prefs_instant_behaviour");
+ toggleInstantUploadBehaviour(
+ ((CheckBoxPreference)mPrefInstantVideoUpload).isChecked(),
+ ((CheckBoxPreference)mPrefInstantUpload).isChecked());
+
/* About App */
pAboutApp = findPreference("about_app");
if (pAboutApp != null) {
}
}
+ private void toggleInstantUploadBehaviour(Boolean video, Boolean picture){
+ if (picture || video){
+ mPrefInstantUploadCategory.addPreference(mPrefInstantUploadBehaviour);
+ } else {
+ mPrefInstantUploadCategory.removePreference(mPrefInstantUploadBehaviour);
+ }
+ }
+
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-22
+target=android-23