From: David A. Velasco Date: Tue, 4 Feb 2014 13:43:36 +0000 (+0100) Subject: Merge branch 'develop' into share_link__new_share X-Git-Tag: oc-android-1.5.5~58^2~13 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/3eb043caf03305a7a4f4d8dc51d87a1e56b1c42a?hp=e2a4ad78de381058300972aa61072de086f3feeb Merge branch 'develop' into share_link__new_share --- diff --git a/SETUP.md b/SETUP.md index 1b5de18d..13c4f592 100644 --- a/SETUP.md +++ b/SETUP.md @@ -27,15 +27,17 @@ NOTE: You must have the Android SDK 'tools/', and 'platforms-tools/' folders in NOTE: You must have mvn (version >= 3.1.1) in your environment path. Current Android 'platforms-tools' need to be installed. -* Download/install Android plugin for Maven, then build ownCloud with mvn: -* "cd .." -* "git clone https://github.com/mosabua/maven-android-sdk-deployer.git" -* "cd maven-android-sdk-deployer" -* "mvn -pl com.simpligility.android.sdk-deployer:android-19 -am install" -* "cd ../android/oc_framework" -* "mvn install" -* "cd .." -* Now you can create ownCloud APK using "mvn package" +Download/install Android plugin for Maven, install oc_framework, then build ownCloud with mvn: + +* cd .. +* git clone https://github.com/mosabua/maven-android-sdk-deployer.git +* cd maven-android-sdk-deployer +* mvn -pl com.simpligility.android.sdk-deployer:android-19 -am install +* cd ../android/oc_framework +* mvn install +* cd .. + +Now you can create ownCloud APK using "mvn package" ### 4. Building with Eclipse: @@ -70,6 +72,16 @@ NOTE: You must sign the [Contributor Agreement][1] before your changes can be ac * Again, click "Edit" and set "compare:develop" * Enter description and send pull request. +### 6. Create another pull request: + +To make sure your new pull request does not contain commits which are already contained in previous PRs, create a new branch which is a clone of upstream/develop. + +* git fetch upstream +* git checkout -b my_new_develop_branch upstream/develop +* If you want to rename that branch later: "git checkout -b my_new_develop_branch_with_new_name" +* Push branch to server: "git push -u origin name_of_local_develop_branch" +* Use Github to issue PR + [0]: https://github.com/owncloud/android/blob/master/CONTRIBUTING.md [1]: http://owncloud.org/about/contributor-agreement/ diff --git a/res/values-es-rCL/strings.xml b/res/values-es-rCL/strings.xml index 6fc2efb7..a6b3cbb3 100644 --- a/res/values-es-rCL/strings.xml +++ b/res/values-es-rCL/strings.xml @@ -13,4 +13,20 @@ Subir No se encuentra la cuenta Subiendo + Seleccione un archivo para desplegar información adicional. + Tamaño: + Tipo: + Creado: + Modificado: + Descargar + Si + No + OK + Cancelar + Error + Nombre del directorio + Elija una cuenta + Por favor, ingreses su PIN de aplicación + Ingrese su PIN de aplicación + Por favor, reingrese su PIN de aplicación diff --git a/res/values-ja-rJP/strings.xml b/res/values-ja-rJP/strings.xml index 3870de62..d4e442e5 100644 --- a/res/values-ja-rJP/strings.xml +++ b/res/values-ja-rJP/strings.xml @@ -18,9 +18,9 @@ クライアントを保護する 自動アップロードを有効 カメラで撮影した画像を自動アップロード - 記録を有効化 - これは問題を記録するのにつかわれます。 - 記録している履歴 + ログを有効にする + これは問題をログに記録するのに使用します。 + ログ履歴 これは記録されたログを表示します 履歴を削除 ヘルプ @@ -98,7 +98,7 @@ フォルダ %1$s はもう存在しません 全て移動 全てのファイルは移動されました - いくつかのファイルは移動出来ませんでした + 一部のファイルは移動できませんでした ローカル: %1$s リモート: %1$s %1$s フォルダに選択されたファイルをコピーするのに十分なスペースがありません。コピーする代わりに、それらを移動させますか? @@ -123,7 +123,7 @@ メディアファイルが正確にエンコードされていません 再生中にタイムアウトが発生しました メディアファイルをストリーミングできません - メディアファイルをStock Media Playerでプレイ出来ません + メディアファイルをStock Media Playerで再生できません プレイに際してセキュリティエラー %1$s プレイに際して入力エラー %1$s プレイに際して予期しないエラー %1$s @@ -135,17 +135,17 @@ 暗号化通信が利用できません。 接続が確立しました 接続をテスト中... - サーバーの間違った設定 - 同じユーザとサーバのアカウントがデバイス上にすでに存在します - 入力されたユーザはこのアカウントのユーザと一致しません + サーバー設定が間違っています + 同じユーザーとサーバーのアカウントがデバイス上にすでに存在します + 入力されたユーザーはこのアカウントのユーザーと一致しません 不明なエラーに発生しました ホストが見つかりませんでした - のインスタンスが見つかりませんでした - サーバーからの反応がありません。 + サーバーのインスタンスが見つかりません + サーバーからの反応がありません 不明なURL形式 SSLの初期化に失敗しました - SSL サーバ識別子を確認できませんでした - 認識出来ないサーバのバージョンです + SSLサーバー識別子を確認できませんでした + 認識できないサーバーのバージョンです 接続を確立できませんでした 暗号化通信を確立しました 間違ったユーザー名もしくはパスワード @@ -155,8 +155,8 @@ 認証情報は有効期限切れです。再度認証を行ってください。 現在のパスワードを入力してください セッションの有効期限切れです。再度接続してください。 - 認証サーバに接続中 ... - サーバはこの認証方式をサポートしていません + 認証サーバーに接続中 ... + サーバーはこの認証方式をサポートしていません %1$s は複数アカウントをサポートしていません ファイルを最新に保つ 名前を変更 @@ -165,7 +165,7 @@ 本当に %1$s およびそのコンテンツを削除してもよろしいですか? ローカルのみ ローカルコンテンツのみ - サーバから削除 + サーバーから削除 リモートとローカルの両方 削除に成功しました 削除を完了できませんでした @@ -179,12 +179,12 @@ しばらくお待ちください 予期せぬ問題;他のアプリでファイルを選択してみてください。 ファイルは選択されていません - oAuth2 でログイン + oAuth2でログイン oAuth2サーバーに接続中... サイトの識別子を確認できませんでした - - サーバ証明書は信頼されていません - - サーバ証明書は有効期限切れです - - サーバ証明書は若すぎます + - サーバー証明書は信頼されていません + - サーバー証明書は有効期限切れです + - サーバー証明書の有効期限は未来のものです - URLは証明書内のホスト名と一致しません この証明書を信頼してもよろしいですか? 証明書は保存できませんでした @@ -211,14 +211,14 @@ 12:23:45 WiFi経由でのみ写真をアップロード /InstantUpload - 更新の競合 - リモートファイル %s はローカルファイルと同期していません。続行すると、サーバ上のファイルを置き換えます。 + 更新が競合 + リモートファイル %s はローカルファイルと同期していません。続行すると、サーバー上のファイルを置き換えます。 両方を保持 上書き アップロードしない イメージプレビュー この画像は表示できません - %1$s は %2$s ローカルディレクトリにコピー出来ませんでした + %1$s は %2$s ローカルディレクトリにコピーできませんでした インスタントアップロードに失敗 インスタントアップロードに失敗 全ての失敗したインスタントアップロードの要約 @@ -229,5 +229,5 @@ 更に画像を読み込む オンラインでなく、インスタントアップロードのために何もしません 失敗メッセージ: - サーバーの設定を確認してください。許容を超過している可能性があります。 + サーバー設定を確認してください。クォータサイズを超えている可能性があります。 diff --git a/res/values-ml/strings.xml b/res/values-ml/strings.xml new file mode 100644 index 00000000..c757504a --- /dev/null +++ b/res/values-ml/strings.xml @@ -0,0 +1,2 @@ + + diff --git a/res/values-nb-rNO/strings.xml b/res/values-nb-rNO/strings.xml index 48b731b7..471b4319 100644 --- a/res/values-nb-rNO/strings.xml +++ b/res/values-nb-rNO/strings.xml @@ -35,6 +35,7 @@ Avbryt Lagre og avslutt Feil + Ukjent feil Om Endre passord Slett konto diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 12390c3d..279229af 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -973,9 +973,8 @@ public class FileDataStorageManager { } public void saveShares(Collection shares) { + cleanShares(); if (shares != null) { - cleanShares(); - ArrayList operations = new ArrayList(shares.size()); // prepare operations to insert or update files to save in the given folder @@ -1012,32 +1011,33 @@ public class FileDataStorageManager { } // apply operations in batch - @SuppressWarnings("unused") - ContentProviderResult[] results = null; - Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider"); - try { - if (getContentResolver() != null) { - results = getContentResolver().applyBatch(MainApp.getAuthority(), operations); - - } else { - results = getContentProviderClient().applyBatch(operations); + if (operations.size() > 0) { + @SuppressWarnings("unused") + ContentProviderResult[] results = null; + Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider"); + try { + if (getContentResolver() != null) { + results = getContentResolver().applyBatch(MainApp.getAuthority(), operations); + + } else { + results = getContentProviderClient().applyBatch(operations); + } + + } catch (OperationApplicationException e) { + Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); + + } catch (RemoteException e) { + Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); } - - } catch (OperationApplicationException e) { - Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); - - } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); } - } } public void updateSharedFiles(Collection sharedFiles) { + cleanSharedFiles(); + if (sharedFiles != null) { - cleanSharedFiles(); - ArrayList operations = new ArrayList(sharedFiles.size()); // prepare operations to insert or update files to save in the given folder @@ -1078,57 +1078,52 @@ public class FileDataStorageManager { } // apply operations in batch - @SuppressWarnings("unused") - ContentProviderResult[] results = null; - Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider"); - try { - if (getContentResolver() != null) { - results = getContentResolver().applyBatch(MainApp.getAuthority(), operations); - - } else { - results = getContentProviderClient().applyBatch(operations); + if (operations.size() > 0) { + @SuppressWarnings("unused") + ContentProviderResult[] results = null; + Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider"); + try { + if (getContentResolver() != null) { + results = getContentResolver().applyBatch(MainApp.getAuthority(), operations); + + } else { + results = getContentProviderClient().applyBatch(operations); + } + + } catch (OperationApplicationException e) { + Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); + + } catch (RemoteException e) { + Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); } - - } catch (OperationApplicationException e) { - Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); - - } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); } - } } public void saveSharesDB(ArrayList shares) { - - if (shares.size() > 0) { - // Save share file - saveShares(shares); - - ArrayList sharedFiles = new ArrayList(); - - for (OCShare share : shares) { - // Get the path - String path = share.getPath(); - if (share.isDirectory()) { - path = path + FileUtils.PATH_SEPARATOR; - } - - // Update OCFile with data from share: ShareByLink ¿and publicLink? - OCFile file = getFileByPath(path); - if (file != null) { - if (share.getShareType().equals(ShareType.PUBLIC_LINK)) { - file.setShareByLink(true); - sharedFiles.add(file); - } - } - } - - if (sharedFiles.size() > 0) { - updateSharedFiles(sharedFiles); - } + saveShares(shares); + + ArrayList sharedFiles = new ArrayList(); + + for (OCShare share : shares) { + // Get the path + String path = share.getPath(); + if (share.isDirectory()) { + path = path + FileUtils.PATH_SEPARATOR; + } + + // Update OCFile with data from share: ShareByLink ¿and publicLink? + OCFile file = getFileByPath(path); + if (file != null) { + if (share.getShareType().equals(ShareType.PUBLIC_LINK)) { + file.setShareByLink(true); + sharedFiles.add(file); + } + } } + + updateSharedFiles(sharedFiles); } } diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index 852b2ca1..97c7a083 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -33,6 +33,7 @@ import org.apache.http.HttpStatus; import android.accounts.Account; import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; @@ -43,7 +44,7 @@ import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCo import com.owncloud.android.lib.operations.remote.ReadRemoteFileOperation; import com.owncloud.android.lib.operations.remote.ReadRemoteFolderOperation; import com.owncloud.android.lib.operations.common.RemoteFile; -import com.owncloud.android.syncadapter.FileSyncService; +import com.owncloud.android.syncadapter.FileSyncAdapter; import com.owncloud.android.utils.FileStorageUtils; import com.owncloud.android.utils.Log_OC; @@ -64,6 +65,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { private static final String TAG = SynchronizeFolderOperation.class.getSimpleName(); + public static final String EVENT_SINGLE_FOLDER_SYNCED = SynchronizeFolderOperation.class.getName() + ".EVENT_SINGLE_FOLDER_SYNCED"; /** Time stamp for the synchronization process in progress */ private long mCurrentSyncTime; @@ -172,7 +174,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { } if (!mSyncFullAccount) { - sendStickyBroadcast(false, mLocalFolder.getRemotePath(), result); + sendLocalBroadcast(mLocalFolder.getRemotePath(), result); } return result; @@ -476,17 +478,15 @@ public class SynchronizeFolderOperation extends RemoteOperation { * @param inProgress 'True' when the synchronization progress is not finished. * @param dirRemotePath Remote path of a folder that was just synchronized (with or without success) */ - private void sendStickyBroadcast(boolean inProgress, String dirRemotePath, RemoteOperationResult result) { - Intent i = new Intent(FileSyncService.getSyncMessage()); - i.putExtra(FileSyncService.IN_PROGRESS, inProgress); - i.putExtra(FileSyncService.ACCOUNT_NAME, mAccount.name); + private void sendLocalBroadcast(String dirRemotePath, RemoteOperationResult result) { + Intent intent = new Intent(EVENT_SINGLE_FOLDER_SYNCED); + intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, mAccount.name); if (dirRemotePath != null) { - i.putExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH, dirRemotePath); + intent.putExtra(FileSyncAdapter.EXTRA_FOLDER_PATH, dirRemotePath); } - if (result != null) { - i.putExtra(FileSyncService.SYNC_RESULT, result); - } - mContext.sendStickyBroadcast(i); + intent.putExtra(FileSyncAdapter.EXTRA_RESULT, result); + //mContext.sendStickyBroadcast(intent); + LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent); } diff --git a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java index c47a251f..7b628c61 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -51,6 +51,7 @@ import android.content.Context; import android.content.Intent; import android.content.SyncResult; import android.os.Bundle; +import android.support.v4.content.LocalBroadcastManager; /** * Implementation of {@link AbstractThreadedSyncAdapter} responsible for synchronizing @@ -69,6 +70,16 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { private static final int MAX_FAILED_RESULTS = 3; + public static final String EVENT_FULL_SYNC_START = FileSyncAdapter.class.getName() + ".EVENT_FULL_SYNC_START"; + public static final String EVENT_FULL_SYNC_END = FileSyncAdapter.class.getName() + ".EVENT_FULL_SYNC_END"; + public static final String EVENT_FOLDER_CONTENTS_SYNCED = FileSyncAdapter.class.getName() + ".EVENT_FOLDER_CONTENTS_SYNCED"; + public static final String EVENT_FOLDER_SIZE_SYNCED = FileSyncAdapter.class.getName() + ".EVENT_FOLDER_SIZE_SYNCED"; + + public static final String EXTRA_ACCOUNT_NAME = FileSyncAdapter.class.getName() + ".EXTRA_ACCOUNT_NAME"; + public static final String EXTRA_FOLDER_PATH = FileSyncAdapter.class.getName() + ".EXTRA_FOLDER_PATH"; + public static final String EXTRA_RESULT = FileSyncAdapter.class.getName() + ".EXTRA_RESULT"; + + /** Time stamp for the current synchronization process, used to distinguish fresh data */ private long mCurrentSyncTime; @@ -154,7 +165,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { } Log_OC.d(TAG, "Synchronization of ownCloud account " + account.name + " starting"); - sendStickyBroadcast(true, null, null); // message to signal the start of the synchronization to the UI + sendLocalBroadcast(EVENT_FULL_SYNC_START, null, null); // message to signal the start of the synchronization to the UI try { updateOCVersion(); @@ -184,7 +195,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { if (mForgottenLocalFiles.size() > 0) { notifyForgottenLocalFiles(); } - sendStickyBroadcast(false, null, mLastFailedResult); // message to signal the end to the UI + sendLocalBroadcast(EVENT_FULL_SYNC_END, null, mLastFailedResult); // message to signal the end to the UI } } @@ -258,7 +269,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { // synchronized folder -> notice to UI - ALWAYS, although !result.isSuccess - sendStickyBroadcast(true, folder.getRemotePath(), null); + sendLocalBroadcast(EVENT_FOLDER_CONTENTS_SYNCED, folder.getRemotePath(), result); // check the result of synchronizing the folder if (result.isSuccess() || result.getCode() == ResultCode.SYNC_CONFLICT) { @@ -332,9 +343,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { syncDown = (parentEtagChanged || etag == null || etag.length() == 0); if(syncDown) { */ synchronizeFolder(newFile); - // update the size of the parent folder again after recursive synchronization - //getStorageManager().updateFolderSize(parent.getFileId()); - sendStickyBroadcast(true, parent.getRemotePath(), null); // notify again to refresh size in UI + sendLocalBroadcast(EVENT_FOLDER_SIZE_SYNCED, parent.getRemotePath(), null); //} } } @@ -346,20 +355,21 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { /** * Sends a message to any application component interested in the progress of the synchronization. * - * @param inProgress 'True' when the synchronization progress is not finished. - * @param dirRemotePath Remote path of a folder that was just synchronized (with or without success) + * @param event Event in the process of synchronization to be notified. + * @param dirRemotePath Remote path of the folder target of the event occurred. + * @param result Result of an individual {@ SynchronizeFolderOperation}, if completed; may be null. */ - private void sendStickyBroadcast(boolean inProgress, String dirRemotePath, RemoteOperationResult result) { - Intent i = new Intent(FileSyncService.getSyncMessage()); - i.putExtra(FileSyncService.IN_PROGRESS, inProgress); - i.putExtra(FileSyncService.ACCOUNT_NAME, getAccount().name); + private void sendLocalBroadcast(String event, String dirRemotePath, RemoteOperationResult result) { + Intent intent = new Intent(event); + intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, getAccount().name); if (dirRemotePath != null) { - i.putExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH, dirRemotePath); + intent.putExtra(FileSyncAdapter.EXTRA_FOLDER_PATH, dirRemotePath); } if (result != null) { - i.putExtra(FileSyncService.SYNC_RESULT, result); + intent.putExtra(FileSyncAdapter.EXTRA_RESULT, result); } - getContext().sendStickyBroadcast(i); + //getContext().sendStickyBroadcast(i); + LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); } diff --git a/src/com/owncloud/android/syncadapter/FileSyncService.java b/src/com/owncloud/android/syncadapter/FileSyncService.java index 9ae051ca..5da8c24c 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncService.java +++ b/src/com/owncloud/android/syncadapter/FileSyncService.java @@ -31,20 +31,11 @@ import android.os.IBinder; */ public class FileSyncService extends Service { - private static final String SYNC_MESSAGE = "ACCOUNT_SYNC"; - public static final String SYNC_FOLDER_REMOTE_PATH = "SYNC_FOLDER_REMOTE_PATH"; - public static final String IN_PROGRESS = "SYNC_IN_PROGRESS"; - public static final String ACCOUNT_NAME = "ACCOUNT_NAME"; - public static final String SYNC_RESULT = "SYNC_RESULT"; - // Storage for an instance of the sync adapter private static FileSyncAdapter sSyncAdapter = null; // Object to use as a thread-safe lock private static final Object sSyncAdapterLock = new Object(); - public static String getSyncMessage(){ - return FileSyncService.class.getName().toString() + SYNC_MESSAGE; - } /* * {@inheritDoc} */ diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 692b5b03..f04760c9 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -77,7 +77,7 @@ import com.owncloud.android.operations.RenameFileOperation; import com.owncloud.android.operations.SynchronizeFileOperation; import com.owncloud.android.operations.SynchronizeFolderOperation; import com.owncloud.android.services.OperationsService; -import com.owncloud.android.syncadapter.FileSyncService; +import com.owncloud.android.syncadapter.FileSyncAdapter; import com.owncloud.android.ui.dialog.EditNameDialog; import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener; import com.owncloud.android.ui.dialog.LoadingDialog; @@ -195,7 +195,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa // Action bar setup mDirectories = new CustomArrayAdapter(this, R.layout.sherlock_spinner_dropdown_item); getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation - setSupportProgressBarIndeterminateVisibility(mSyncInProgress); // always AFTER setContentView(...) ; to work around bug in its implementation + setSupportProgressBarIndeterminateVisibility(mSyncInProgress || mRefreshSharesInProgress); // always AFTER setContentView(...) ; to work around bug in its implementation Log_OC.d(TAG, "onCreate() end"); } @@ -674,9 +674,14 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa Log_OC.e(TAG, "onResume() start"); // Listen for sync messages - IntentFilter syncIntentFilter = new IntentFilter(FileSyncService.getSyncMessage()); + IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START); + syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END); + syncIntentFilter.addAction(FileSyncAdapter.EVENT_FOLDER_SIZE_SYNCED); + syncIntentFilter.addAction(FileSyncAdapter.EVENT_FOLDER_CONTENTS_SYNCED); + syncIntentFilter.addAction(SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SYNCED); mSyncBroadcastReceiver = new SyncBroadcastReceiver(); - registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); + //registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); + LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); // Listen for upload messages IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage()); @@ -704,7 +709,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa super.onPause(); Log_OC.e(TAG, "onPause() start"); if (mSyncBroadcastReceiver != null) { - unregisterReceiver(mSyncBroadcastReceiver); + //unregisterReceiver(mSyncBroadcastReceiver); + LocalBroadcastManager.getInstance(this).unregisterReceiver(mSyncBroadcastReceiver); mSyncBroadcastReceiver = null; } if (mUploadFinishReceiver != null) { @@ -912,55 +918,60 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa */ @Override public void onReceive(Context context, Intent intent) { - boolean inProgress = intent.getBooleanExtra(FileSyncService.IN_PROGRESS, false); - String accountName = intent.getStringExtra(FileSyncService.ACCOUNT_NAME); - RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncService.SYNC_RESULT); + String event = intent.getAction(); + String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME); + String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); + RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncAdapter.EXTRA_RESULT); + boolean sameAccount = (getAccount() != null && accountName.equals(getAccount().name) && getStorageManager() != null); - if (getAccount() != null && accountName.equals(getAccount().name) - && getStorageManager() != null) { + if (sameAccount) { - String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH); - - OCFile currentFile = (getFile() == null) ? null : getStorageManager().getFileByPath(getFile().getRemotePath()); - OCFile currentDir = (getCurrentDir() == null) ? null : getStorageManager().getFileByPath(getCurrentDir().getRemotePath()); - - if (currentDir == null) { - // current folder was removed from the server - Toast.makeText( FileDisplayActivity.this, - String.format(getString(R.string.sync_current_folder_was_removed), mDirectories.getItem(0)), - Toast.LENGTH_LONG) - .show(); - browseToRoot(); + if (!FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) { + OCFile currentFile = (getFile() == null) ? null : getStorageManager().getFileByPath(getFile().getRemotePath()); + OCFile currentDir = (getCurrentDir() == null) ? null : getStorageManager().getFileByPath(getCurrentDir().getRemotePath()); + + if (currentDir == null) { + // current folder was removed from the server + Toast.makeText( FileDisplayActivity.this, + String.format(getString(R.string.sync_current_folder_was_removed), mDirectories.getItem(0)), + Toast.LENGTH_LONG) + .show(); + browseToRoot(); + + } else { + if (currentFile == null && !getFile().isFolder()) { + // currently selected file was removed in the server, and now we know it + cleanSecondFragment(); + currentFile = currentDir; + } - } else { - if (currentFile == null && !getFile().isFolder()) { - // currently selected file was removed in the server, and now we know it - cleanSecondFragment(); - currentFile = currentDir; - } - - if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) { - OCFileListFragment fileListFragment = getListOfFilesFragment(); - if (fileListFragment != null) { - fileListFragment.listDirectory(currentDir); + if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) { + OCFileListFragment fileListFragment = getListOfFilesFragment(); + if (fileListFragment != null) { + fileListFragment.listDirectory(currentDir); + } } + setFile(currentFile); } - setFile(currentFile); - } - - if (!mRefreshSharesInProgress) { - /// get the shared files - if (getFileOperationsHelper().isSharedSupported(FileDisplayActivity.this)) { + + mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) && + !SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SYNCED.equals(event) && + (synchResult == null || synchResult.isSuccess())) ; + + if (synchResult != null && + synchResult.isSuccess() && + (SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SYNCED.equals(event) || + FileSyncAdapter.EVENT_FOLDER_CONTENTS_SYNCED.equals(event) + ) && + !mRefreshSharesInProgress && + getFileOperationsHelper().isSharedSupported(FileDisplayActivity.this) + ) { startGetShares(); } - setSupportProgressBarIndeterminateVisibility(inProgress); - } else { - setSupportProgressBarIndeterminateVisibility(true); + } - - removeStickyBroadcast(intent); - mSyncInProgress = inProgress; - + //removeStickyBroadcast(intent); + setSupportProgressBarIndeterminateVisibility(mSyncInProgress || mRefreshSharesInProgress); } if (synchResult != null) { @@ -1557,8 +1568,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa startService(intent); mRefreshSharesInProgress = true; - setSupportProgressBarIndeterminateVisibility(true); - } } diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index b96a41bc..f31ca142 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -1,6 +1,6 @@ /* ownCloud Android client application * Copyright (C) 2011 Bartek Przybylski - * Copyright (C) 2012-2013 ownCloud Inc. + * Copyright (C) 2012-2014 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, diff --git a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java index 7cd2c2a4..5686874e 100644 --- a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java @@ -1,6 +1,6 @@ /* ownCloud Android client application * Copyright (C) 2011 Bartek Przybylski - * Copyright (C) 2012-2013 ownCloud Inc. + * Copyright (C) 2012-2014 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, @@ -135,6 +135,8 @@ public class LocalFileListAdapter extends BaseAdapter implements ListAdapter { view.findViewById(R.id.imageView2).setVisibility(View.INVISIBLE); // not GONE; the alignment changes; ugly way to keep it view.findViewById(R.id.imageView3).setVisibility(View.GONE); + + view.findViewById(R.id.shareIcon).setVisibility(View.GONE); } return view;