From: David A. Velasco Date: Thu, 4 Apr 2013 14:49:04 +0000 (+0200) Subject: Merge branch 'bug_hunting' into feature_previews X-Git-Tag: oc-android-1.4.3~39^2~5 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/053aad5ae17a1ad7a15218c220810e6b369fea4c?ds=sidebyside;hp=-c Merge branch 'bug_hunting' into feature_previews Conflicts: src/com/owncloud/android/ui/activity/FileDisplayActivity.java --- 053aad5ae17a1ad7a15218c220810e6b369fea4c diff --combined AndroidManifest.xml index 42c51748,341cbc5e..5262d68a --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@@ -19,8 -19,8 +19,8 @@@ along with this program. If not, see . --> + android:versionCode="103022" + android:versionName="1.3.22" xmlns:android="http://schemas.android.com/apk/res/android"> @@@ -35,8 -35,7 +35,8 @@@ - + + @@@ -59,9 -58,6 +59,9 @@@ + + + @@@ -90,13 -86,6 +90,13 @@@ + + + + + - - + + + - + - + - + - - - - - + + + @@@ -168,7 -158,7 +168,7 @@@ - + - + diff --combined res/values-de-rDE/strings.xml index 9f20caeb,a5f8c76a..77a5a82e --- a/res/values-de-rDE/strings.xml +++ b/res/values-de-rDE/strings.xml @@@ -53,6 -53,7 +53,7 @@@ Mit Ihrer %1$s verbinden Verbinden Hochladen + Wähle Zielverzeichnis: Kein Konto gefunden Es sind keine %1$s-Konten auf Ihrem Gerät eingerichtet. Bitte richten Sie zuerst ein Konto ein. Einrichten @@@ -82,8 -83,6 +83,8 @@@ Speichern & Schließen %1$s verlassen Fehler + Wird geladen … + Unbekannter Fehler Über Account löschen Account erstellen @@@ -103,7 -102,6 +104,7 @@@ %1$s wurde erfolgreich heruntergeladen Herunterladen fehlgeschlagen Herunterladen von %1$s konnte nicht abgeschlossen werden + Noch nicht heruntergeladen Konto auswählen Kontakte Synchronisation fehlgeschlagen @@@ -124,26 -122,6 +125,26 @@@ Falsche App-PIN Die App-PIN wurde entfernt Die App-PIN wurde gespeichert + "%1$s Musik Player" + "%1$s (wird abgespielt)" + "%1$s (wird geladen)" + "%1$s Wiedergabe beendet" + Keine Media-Datei gefunden + Ungültiger Account + Datei ist nicht in einem gültigen Account + Nicht unterstützter Medien-Codec + Media-Datei konnte nicht gelesen werden + Die Media-Datei ist noch nicht kodiert + Zeitüberschreitung ist beim Abspielen aufgetreten + Media-Datei konnte nicht gestreamt werden + Media-Datei kann nicht vom Standard Player wiedergegeben werden + Sicherheits-Fehler ist beim Abspielen aufgetreten %1$s + Eingabe-Fehler ist beim Abspielen aufgetreten %1$s + Unerwarteter Fehler bei der Wiedergabe %1$s + Zurückspulen + Wiedergabe oder Pause + Vorspulen + 15 Minuten 30 Minuten @@@ -187,7 -165,7 +188,7 @@@ Erweiterung verfügbar! Scheinbar unterstützt Ihr Server weitere Erweiterungen. Möchten Sie die verfügbaren Erweiterungen für Android sehen? Datei aktuell halten - Freigeben + Teilen Umbenennen Löschen Möchten Sie %1$s wirklich löschen? @@@ -239,17 -217,4 +240,17 @@@ Beide behalten Überschreiben Nicht hochladen + Bildvorschau + Das Bild kann nicht angezeigt werden + "Nicht genug Speicherplatz um das Bild anzuzeigen + + Fehlgeschlagene Sofortuploads + Fehlgeschlagene Sofortuploads + Auflistung aller fehlgeschlagenen Softuploads + Alle auswählen + Ausgewählte wiederholen + Ausgewählte löschen + Versuche ausgewählte erneut hochzuladen + Load more Picrures + do nothing you are not online for instant upload diff --combined res/values-de/strings.xml index 98f042f5,814f125e..8013575d --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@@ -53,6 -53,7 +53,7 @@@ Mit Deiner %1$s verbinden Verbinden Hochladen + Wähle Zielverzeichnis: Kein Account gefunden Es sind keine %1$s-Accounts auf Deinem Gerät eingerichtet. Bitte richte zuerst ein Konto ein. Einrichten @@@ -106,8 -107,8 +107,8 @@@ Synchronisation fehlgeschlagen Bei der Synchronisation konnte %1$s nicht übertragen werden Konflikte gefunden - %1$d synchrongehaltene Dateien konnte nicht synchronisiert werden. - Synchronhalten schlug fehl. + %1$d synchron zu haltende Dateien konnte nicht synchronisiert werden. + Synchron halten schlug fehl. Inhalte von %1$d konnte nicht synchronisiert werden (%2$d Konflikte) Sichere Verbindung benutzen %1$s kann Dein Gerät nicht verfolgen. Bitte überprüfe Deine Standorteinstellungen @@@ -181,7 -182,7 +182,7 @@@ Die entfernte Datei konnte nicht überprüft werden Dateiinhalte bereits synchronisiert Das Verzeichnis konnte nicht erstellt werden. - Bitte warten Sie einen Moment. + Bitte warte einen Moment. Ein unerwartetes Problem ist aufgetreten. Bitte versuche, die Datei in einer anderen App zu öffnen Es wurde keine Datei ausgewählt. Warnung @@@ -216,16 -217,4 +217,16 @@@ Beide behalten Überschreiben Nicht hochladen + + Fehlgeschlagene Sofortuploads + Fehlgeschlagene Sofortuploads + Auflistung aller fehlgeschlagenen Softuploads + Alle auswählen + Ausgewählte wiederholen + Ausgewählte löschen + Versuche ausgewählte erneut hochzuladen + Weitere Bilder laden + Upload nicht gestarted, Sie sind nicht online für ein Softupload + Fehlermeldung: + Bitte überprüfen sie ihre Serverkonfiguration, möglicherweise ist ihre Upload Limit überschritten diff --combined res/values/strings.xml index 9abfa798,3803e22d..f54a5d56 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@@ -1,8 -1,6 +1,7 @@@ + ownCloud - What\'s new Password: Username: Login @@@ -15,7 -13,9 +14,7 @@@ Settings Setup Account There is no account set up on your device. In order to use this App, you need to create one. - %1$s Android App\n\nversion: %2$s - Refresh Upload Content from other apps @@@ -23,10 -23,8 +22,9 @@@ Create directory Search Settings + Details General - Device tracking Add new session Create image thumbnails Select an account @@@ -42,6 -40,7 +40,6 @@@ Protect your client Enable instant uploads Instantly upload photos taken by camera - URL Username Password @@@ -57,16 -56,17 +55,17 @@@ Connect to your %1$s Connect Upload + Choose upload directory: No account found There are no %1$s accounts on your device. Please setup an account first. Setup Quit - No content to upload - No content was received. Nothing to upload. + No content to upload + No content was received. Nothing to upload. %1$s is not allowed to access the shared content Uploading Create directory for upload - There are no files in this folder.\nNew files can be added with the \"Upload\" menu option. + There are no files in this folder.\nNew files can be added with the \"Upload\" menu option. Tap on a file to display additional information. Size: Type: @@@ -74,7 -74,7 +73,7 @@@ Modified: Download Refresh - Redownload + Redownload Open File was renamed to %1$s during upload Yes @@@ -82,20 -82,20 +81,20 @@@ OK Cancel download Cancel upload - Cancel + Cancel Save & Exit Leave %1$s Error + Loading … + Unknown error About - Delete account Create account - Upload from … Directory name - Uploading … - %1$d%% Uploading %2$s - Upload succeeded + Uploading … + %1$d%% Uploading %2$s + Upload succeeded %1$s was successfully uploaded %1$d files were successfully uploaded Upload failed @@@ -107,69 -107,51 +106,69 @@@ %1$s was successfully downloaded Download failed Download of %1$s could not be completed + Not downloaded yet Choose account Contacts - Synchronization failed + Synchronization failed Synchronization of %1$s could not be completed - Conflicts found - %1$d kept-in-sync files could not be sync\'ed + Conflicts found + %1$d kept-in-sync files could not be sync\'ed Kept-in-sync files failed - Contents of %1$d files could not be sync\'ed (%2$d conflicts) - Some local files were forgotten - %1$d files out of the %2$s directory could not be copied into - "As of version 1.3.16, files uploaded from this device are copied into the local %1$s folder to prevent data loss when a single file is synced with multiple accounts.\n\nDue to this change, all files uploaded in previous versions of this app were copied into the %2$s folder. However, an error prevented the completion of this operation during account synchronization. You may either leave the file(s) as is and remove the link to %3$s, or move the file(s) into the %1$s directory and retain the link to %4$s.\n\nListed below are the local file(s), and the the remote file(s) in %5$s they were linked to. - + Contents of %1$d files could not be sync\'ed (%2$d conflicts) + Some local files were forgotten + %1$d files out of the %2$s directory could not be copied into + "As of version 1.3.16, files uploaded from this device are copied into the local %1$s folder to prevent data loss when a single file is synced with multiple accounts.\n\nDue to this change, all files uploaded in previous versions of this app were copied into the %2$s folder. However, an error prevented the completion of this operation during account synchronization. You may either leave the file(s) as is and remove the link to %3$s, or move the file(s) into the %1$s directory and retain the link to %4$s.\n\nListed below are the local file(s), and the the remote file(s) in %5$s they were linked to. "Move all" "All files were moved" "Some files could not be moved" "Local: %1$s" - "Remote: %1$s" - - There is not space enough to copy the selected files into the %1$s folder. Would like to move them into instead? - - Use Secure Connection + "Remote: %1$s" + There is not space enough to copy the selected files into the %1$s folder. Would like to move them into instead? + Use Secure Connection %1$s cannot track your device. Please check your location settings - Please, insert your App PIN Please, insert your new App PIN Enter your App PIN - The PIN will be requested every time the app is started + The PIN will be requested every time the app is started Please, reenter your App PIN Remove your App PIN - The App PINs are not the same + The App PINs are not the same Incorrect App PIN App PIN removed App PIN stored + "%1$s music player" + "%1$s (playing)" + "%1$s (loading)" + "%1$s playback finished" + No media file found + No account provided + File not in a valid account + Unsupported media codec + Media file could not be read + Media file not correctly encoded + Too much time trying to play + Media file cannot be streamed + Media file cannot be played with the stock media player + Security error trying to play %1$s + Input error trying to play %1$s + Unexpected error trying to play %1$s + Previous track button + Rewind button + Play or pause button + Fast forward button + Next track button - 15 Minutes - 30 Minutes - 60 Minutes - - + 15 Minutes + 30 Minutes + 60 Minutes + - 15 - 30 - 60 - + 15 + 30 + 60 + + Trying to login… No network connection No network connection has been detected, check your Internet connection and try again. @@@ -188,41 -170,51 +187,41 @@@ Application couldn\'t find a server instance at the given path. Please check your path and try again. The server took too long to respond Malformed URL - SSL initialization failed - Unverified SSL server\'s identity - Unrecognized server version - Couldn\'t establish connection - Secure connection established + SSL initialization failed + Unverified SSL server\'s identity + Unrecognized server version + Couldn\'t establish connection + Secure connection established Login details Invalid login / password Wrong path given Internal server error, code %1$d - Application terminated unexpectedly. Would you like to submit a crash report? Send report Don\'t send report - Extensions available! Looks like your server instance is supporting advanced extensions. Would you like to see extensions available for android ? Keep file up to date Share Rename Remove - - "Do you really want to remove %1$s ?" - "Do you really want to remove %1$s and its contents ?" - Local only - Local contents only - Remove from server - Remote and local - + "Do you really want to remove %1$s ?" + "Do you really want to remove %1$s and its contents ?" + Local only + Local contents only + Remove from server + Remote and local "Removal succeeded" "Removal failed" - Enter a new name "Local copy could not be renamed; try a different name" "Rename could not be completed" - - Remote file could not be checked - File contents already synchronized - + Remote file could not be checked + File contents already synchronized Directory could not be created - Wait a moment - "Unexpected problem ; please select the file from a different app" No file was selected - Warning The identity of the site could not be verified - The server certificate is not trusted @@@ -238,46 -230,28 +237,46 @@@ Issued by: Common name: Organization: - Organizational unit: - Country: - State: - Location: + Organizational unit: + Country: + State: + Location: Validity: From: To: Signature: Algorithm: - This is a placeholder + This is a placeholder + placeholder.txt + PNG Image + 389 KB + 2012/05/18 12:23 PM + 12:23:45 Upload pictures via WiFi only - /InstantUpload - + /InstantUpload Update conflict Remote file %s is not synchronized with local file. Continuing will replace content of file on server. Keep both Overwrite Don\'t upload + Image preview + This image can not be shown + "Not enough memory to show this image + %1$s could not be copied to %2$s local directory - + Failed InstantUpload" + Failed instant uploads + Summary of all failed instant uploads + select all + retry all selected + delete all selected from uploadqueue + retry to upload the image: + Load more Picrures + do nothing you are not online for instant upload + Failure Message: + Please check your server configuration,maybe your quota is exceeded. diff --combined src/com/owncloud/android/ui/activity/FileDisplayActivity.java index ca0ff010,7df1ecbb..17504a8f --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@@ -4,7 -4,7 +4,7 @@@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@@ -49,7 -49,6 +49,7 @@@ import android.os.Handler import android.os.IBinder; import android.preference.PreferenceManager; import android.provider.MediaStore; +import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.util.Log; import android.view.View; @@@ -86,14 -85,12 +86,16 @@@ import com.owncloud.android.operations. import com.owncloud.android.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.syncadapter.FileSyncService; import com.owncloud.android.ui.dialog.ChangelogDialog; + import com.owncloud.android.ui.dialog.EditNameDialog; import com.owncloud.android.ui.dialog.SslValidatorDialog; + import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener; import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener; import com.owncloud.android.ui.fragment.FileDetailFragment; +import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.ui.fragment.OCFileListFragment; +import com.owncloud.android.ui.preview.PreviewImageActivity; +import com.owncloud.android.ui.preview.PreviewImageFragment; +import com.owncloud.android.ui.preview.PreviewMediaFragment; import com.owncloud.android.R; import eu.alefzero.webdav.WebdavClient; @@@ -102,11 -99,11 +104,11 @@@ * Displays, what files the user has available in his ownCloud. * * @author Bartek Przybylski - * + * @author David A. Velasco */ public class FileDisplayActivity extends SherlockFragmentActivity implements - OCFileListFragment.ContainerActivity, FileFragment.ContainerActivity, OnNavigationListener, OnSslValidatorListener, OnRemoteOperationListener { + OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNavigationListener, OnSslValidatorListener, OnRemoteOperationListener, EditNameDialogListener { private ArrayAdapter mDirectories; private OCFile mCurrentDir = null; @@@ -140,11 -137,7 +142,11 @@@ private static final String TAG = "FileDisplayActivity"; - private static int[] mMenuIdentifiersToPatch = {R.id.about_app}; + private static int[] mMenuIdentifiersToPatch = {R.id.action_about_app}; + + private OCFile mWaitingToPreview; + private Handler mHandler; + @Override public void onCreate(Bundle savedInstanceState) { @@@ -152,19 -145,15 +154,19 @@@ super.onCreate(savedInstanceState); /// Load of parameters from received intent - mCurrentDir = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE); // no check necessary, mCurrenDir == null if the parameter is not in the intent Account account = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT); - if (account != null) - AccountUtils.setCurrentOwnCloudAccount(this, account.name); + if (account != null && AccountUtils.setCurrentOwnCloudAccount(this, account.name)) { + mCurrentDir = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE); + } /// Load of saved instance state: keep this always before initDataFromCurrentAccount() if(savedInstanceState != null) { // TODO - test if savedInstanceState should take precedence over file in the intent ALWAYS (now), NEVER, or SOME TIMES mCurrentDir = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE); + mWaitingToPreview = (OCFile) savedInstanceState.getParcelable(FileDetailActivity.KEY_WAITING_TO_PREVIEW); + + } else { + mWaitingToPreview = null; } if (!AccountUtils.accountsAreSetup(this)) { @@@ -200,7 -189,7 +202,7 @@@ // Drop-down navigation mDirectories = new CustomArrayAdapter(this, R.layout.sherlock_spinner_dropdown_item); OCFile currFile = mCurrentDir; - while(currFile != null && currFile.getFileName() != OCFile.PATH_SEPARATOR) { + while(mStorageManager != null && currFile != null && currFile.getFileName() != OCFile.PATH_SEPARATOR) { mDirectories.add(currFile.getFileName()); currFile = mStorageManager.getFileById(currFile.getParentId()); } @@@ -212,19 -201,6 +214,19 @@@ mDualPane = (findViewById(R.id.file_details_container) != null); if (mDualPane) { initFileDetailsInDualPane(); + } else { + // quick patchES to fix problem in turn from landscape to portrait, when a file is selected in the right pane + // TODO serious refactorization in activities and fragments providing file browsing and handling + if (mCurrentFile != null) { + onFileClick(mCurrentFile); + mCurrentFile = null; + } + Fragment rightPanel = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + if (rightPanel != null) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.remove(rightPanel); + transaction.commit(); + } } // Action bar setup @@@ -238,7 -214,7 +240,7 @@@ // show changelog, if needed - showChangeLog(); + //showChangeLog(); Log.d(getClass().toString(), "onCreate() end"); } @@@ -279,7 -255,7 +281,7 @@@ startActivity(intent); // the new activity won't be created until this.onStart() and this.onResume() are finished; } - + /** * Load of state dependent of the existence of an ownCloud account */ @@@ -316,18 -292,8 +318,18 @@@ if (mDualPane && getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG) == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (mCurrentFile != null) { - transaction.replace(R.id.file_details_container, new FileDetailFragment(mCurrentFile, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); // empty FileDetailFragment + if (PreviewMediaFragment.canBePreviewed(mCurrentFile)) { + if (mCurrentFile.isDown()) { + transaction.replace(R.id.file_details_container, new PreviewMediaFragment(mCurrentFile, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); + } else { + transaction.replace(R.id.file_details_container, new FileDetailFragment(mCurrentFile, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); + mWaitingToPreview = mCurrentFile; + } + } else { + transaction.replace(R.id.file_details_container, new FileDetailFragment(mCurrentFile, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); + } mCurrentFile = null; + } else { transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null), FileDetailFragment.FTAG); // empty FileDetailFragment } @@@ -349,7 -315,7 +351,7 @@@ @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getSherlock().getMenuInflater(); - inflater.inflate(R.menu.menu, menu); + inflater.inflate(R.menu.main_menu, menu); patchHiddenAccents(menu); @@@ -380,11 -346,12 +382,12 @@@ public boolean onOptionsItemSelected(MenuItem item) { boolean retval = true; switch (item.getItemId()) { - case R.id.createDirectoryItem: { - //showDialog(DIALOG_CREATE_DIR); + case R.id.action_create_dir: { - showDialog(DIALOG_CREATE_DIR); + EditNameDialog dialog = EditNameDialog.newInstance(getString(R.string.uploader_info_dirname), "", this); + dialog.show(getSupportFragmentManager(), "createdirdialog"); + break; } - case R.id.startSync: { + case R.id.action_sync_account: { startSynchronization(); break; } @@@ -397,7 -364,7 +400,7 @@@ startActivity(settingsIntent); break; } - case R.id.about_app : { + case R.id.action_about_app: { showDialog(DIALOG_ABOUT_APP); break; } @@@ -541,10 -508,11 +544,10 @@@ if (mDualPane) { // Resets the FileDetailsFragment on Tablets so that it always displays - FileDetailFragment fileDetails = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); - if (fileDetails != null && !fileDetails.isEmpty()) { + Fragment fileFragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + if (fileFragment != null && (fileFragment instanceof PreviewMediaFragment || !((FileDetailFragment) fileFragment).isEmpty())) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - transaction.remove(fileDetails); - transaction.add(R.id.file_details_container, new FileDetailFragment(null, null), FileDetailFragment.FTAG); + transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null), FileDetailFragment.FTAG); // empty FileDetailFragment transaction.commit(); } } @@@ -562,20 -530,19 +565,20 @@@ super.onSaveInstanceState(outState); outState.putParcelable(FileDetailFragment.EXTRA_FILE, mCurrentDir); if (mDualPane) { - FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + FileFragment fragment = (FileFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); if (fragment != null) { - OCFile file = fragment.getDisplayedFile(); + OCFile file = fragment.getFile(); if (file != null) { outState.putParcelable(FileDetailFragment.EXTRA_FILE, file); } } } + outState.putParcelable(FileDetailActivity.KEY_WAITING_TO_PREVIEW, mWaitingToPreview); Log.d(getClass().toString(), "onSaveInstanceState() end"); } @Override - protected void onResume() { + public void onResume() { Log.d(getClass().toString(), "onResume() start"); super.onResume(); @@@ -600,8 -567,7 +603,8 @@@ registerReceiver(mUploadFinishReceiver, uploadIntentFilter); // Listen for download messages - IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.DOWNLOAD_FINISH_MESSAGE); + IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.DOWNLOAD_ADDED_MESSAGE); + downloadIntentFilter.addAction(FileDownloader.DOWNLOAD_FINISH_MESSAGE); mDownloadFinishReceiver = new DownloadFinishReceiver(); registerReceiver(mDownloadFinishReceiver, downloadIntentFilter); @@@ -619,7 -585,7 +622,7 @@@ @Override - protected void onPause() { + public void onPause() { Log.d(getClass().toString(), "onPause() start"); super.onPause(); if (mSyncBroadcastReceiver != null) { @@@ -750,33 -716,27 +753,33 @@@ break; } case DIALOG_CHOOSE_UPLOAD_SOURCE: { - final String [] items = { getString(R.string.actionbar_upload_files), - getString(R.string.actionbar_upload_from_apps) }; + final String[] items = { getString(R.string.actionbar_upload_files), + getString(R.string.actionbar_upload_from_apps), + getString(R.string.actionbar_failed_instant_upload) }; builder = new AlertDialog.Builder(this); builder.setTitle(R.string.actionbar_upload); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { - //if (!mDualPane) { - Intent action = new Intent(FileDisplayActivity.this, UploadFilesActivity.class); - action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(FileDisplayActivity.this)); - startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); - //} else { - // TODO create and handle new fragment LocalFileListFragment - //} + // if (!mDualPane) { + Intent action = new Intent(FileDisplayActivity.this, UploadFilesActivity.class); + action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, + AccountUtils.getCurrentOwnCloudAccount(FileDisplayActivity.this)); + startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); + // } else { + // TODO create and handle new fragment + // LocalFileListFragment + // } } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); - action = action.setType("*/*") - .addCategory(Intent.CATEGORY_OPENABLE); - startActivityForResult( - Intent.createChooser(action, getString(R.string.upload_chooser_title)), + action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); + startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)), ACTION_SELECT_CONTENT_FROM_APPS); + } else if (item == 2) { + Account account = AccountUtils.getCurrentOwnCloudAccount(FileDisplayActivity.this); + Intent action = new Intent(FileDisplayActivity.this, InstantUploadActivity.class); + action.putExtra(FileUploader.KEY_ACCOUNT, account); + startActivity(action); } } }); @@@ -1002,78 -962,27 +1005,78 @@@ /** - * Once the file download has finished -> update view + * Class waiting for broadcast events from the {@link FielDownloader} service. + * + * Updates the UI when a download is started or finished, provided that it is relevant for the + * current folder. */ private class DownloadFinishReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + boolean sameAccount = isSameAccount(context, intent); String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH); - String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME); - boolean sameAccount = accountName.equals(AccountUtils.getCurrentOwnCloudAccount(context).name); - boolean isDescendant = (mCurrentDir != null) && (downloadedRemotePath != null) && (downloadedRemotePath.startsWith(mCurrentDir.getRemotePath())); + boolean isDescendant = isDescendant(downloadedRemotePath); + if (sameAccount && isDescendant) { - OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList); - if (fileListFragment != null) { - fileListFragment.listDirectory(); + updateLeftPanel(); + if (mDualPane) { + updateRightPanel(intent.getAction(), downloadedRemotePath, intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false)); } } + + removeStickyBroadcast(intent); + } + + private boolean isDescendant(String downloadedRemotePath) { + return (mCurrentDir != null && downloadedRemotePath != null && downloadedRemotePath.startsWith(mCurrentDir.getRemotePath())); + } + + private boolean isSameAccount(Context context, Intent intent) { + String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME); + return (accountName != null && accountName.equals(AccountUtils.getCurrentOwnCloudAccount(context).name)); } } - - + protected void updateLeftPanel() { + OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList); + if (fileListFragment != null) { + fileListFragment.listDirectory(); + } + } + + protected void updateRightPanel(String downloadEvent, String downloadedRemotePath, boolean success) { + Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + boolean waitedPreview = (mWaitingToPreview != null && mWaitingToPreview.getRemotePath().equals(downloadedRemotePath)); + if (fragment != null && fragment instanceof FileDetailFragment) { + FileDetailFragment detailsFragment = (FileDetailFragment) fragment; + OCFile fileInFragment = detailsFragment.getFile(); + if (fileInFragment != null && !downloadedRemotePath.equals(fileInFragment.getRemotePath())) { + // the user browsed to other file ; forget the automatic preview + mWaitingToPreview = null; + + } else if (downloadEvent.equals(FileDownloader.DOWNLOAD_ADDED_MESSAGE)) { + // grant that the right panel updates the progress bar + detailsFragment.listenForTransferProgress(); + detailsFragment.updateFileDetails(true, false); + + } else if (downloadEvent.equals(FileDownloader.DOWNLOAD_FINISH_MESSAGE)) { + // update the right panel + if (success && waitedPreview) { + mWaitingToPreview = mStorageManager.getFileById(mWaitingToPreview.getFileId()); // update the file from database, for the local storage path + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.file_details_container, new PreviewMediaFragment(mWaitingToPreview, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); + transaction.commit(); + mWaitingToPreview = null; + + } else { + detailsFragment.updateFileDetails(false, (success)); + } + } + } + } + + /** * {@inheritDoc} */ @@@ -1082,7 -991,7 +1085,7 @@@ return mStorageManager; } - + /** * {@inheritDoc} */ @@@ -1094,10 -1003,11 +1097,10 @@@ if (mDualPane) { // Resets the FileDetailsFragment on Tablets so that it always displays - FileDetailFragment fileDetails = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); - if (fileDetails != null && !fileDetails.isEmpty()) { + Fragment fileFragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + if (fileFragment != null && (fileFragment instanceof PreviewMediaFragment || !((FileDetailFragment) fileFragment).isEmpty())) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - transaction.remove(fileDetails); - transaction.add(R.id.file_details_container, new FileDetailFragment(null, null), FileDetailFragment.FTAG); + transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null), FileDetailFragment.FTAG); // empty FileDetailFragment transaction.commit(); } } @@@ -1109,40 -1019,16 +1112,40 @@@ */ @Override public void onFileClick(OCFile file) { - - // If we are on a large device -> update fragment + if (file != null && PreviewImageFragment.canBePreviewed(file)) { + // preview image - it handles the download, if needed + startPreviewImage(file); + + } else if (file != null && PreviewMediaFragment.canBePreviewed(file)) { + if (file.isDown()) { + // general preview + startMediaPreview(file); + + } else { + // automatic download, preview on finish + startDownloadForPreview(file); + + } + } else { + // details view + startDetails(file); + } + } + + private void startPreviewImage(OCFile file) { + Intent showDetailsIntent = new Intent(this, PreviewImageActivity.class); + showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file); + showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this)); + startActivity(showDetailsIntent); + } + + private void startMediaPreview(OCFile file) { if (mDualPane) { - // buttons in the details view are problematic when trying to reuse an existing fragment; create always a new one solves some of them, BUT no all; downloads are 'dangerous' FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - transaction.replace(R.id.file_details_container, new FileDetailFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); - transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); + transaction.replace(R.id.file_details_container, new PreviewMediaFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); transaction.commit(); - } else { // small or medium screen device -> new Activity + } else { Intent showDetailsIntent = new Intent(this, FileDetailActivity.class); showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file); showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this)); @@@ -1150,37 -1036,7 +1153,37 @@@ } } + private void startDownloadForPreview(OCFile file) { + if (mDualPane) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.file_details_container, new FileDetailFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); + transaction.commit(); + mWaitingToPreview = file; + requestForDownload(); + + } else { + Intent showDetailsIntent = new Intent(this, FileDetailActivity.class); + showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file); + showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this)); + startActivity(showDetailsIntent); + } + } + + private void startDetails(OCFile file) { + if (mDualPane && !file.isImage()) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.file_details_container, new FileDetailFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); + transaction.commit(); + } else { + Intent showDetailsIntent = new Intent(this, FileDetailActivity.class); + showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file); + showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this)); + startActivity(showDetailsIntent); + } + } + + /** * {@inheritDoc} */ @@@ -1228,10 -1084,6 +1231,10 @@@ if (component.equals(new ComponentName(FileDisplayActivity.this, FileDownloader.class))) { Log.d(TAG, "Download service connected"); mDownloaderBinder = (FileDownloaderBinder) service; + if (mWaitingToPreview != null) { + requestForDownload(); + } + } else if (component.equals(new ComponentName(FileDisplayActivity.this, FileUploader.class))) { Log.d(TAG, "Upload service connected"); mUploaderBinder = (FileUploaderBinder) service; @@@ -1242,12 -1094,9 +1245,12 @@@ if (mFileList != null) mFileList.listDirectory(); if (mDualPane) { - FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); - if (fragment != null) - fragment.updateFileDetails(false); + Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + if (fragment != null && fragment instanceof FileDetailFragment) { + FileDetailFragment detailFragment = (FileDetailFragment)fragment; + detailFragment.listenForTransferProgress(); + detailFragment.updateFileDetails(false, false); + } } } @@@ -1327,8 -1176,8 +1330,8 @@@ msg.show(); OCFile removedFile = operation.getFile(); if (mDualPane) { - FileDetailFragment details = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); - if (details != null && removedFile.equals(details.getDisplayedFile()) ) { + FileFragment details = (FileFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + if (details != null && removedFile.equals(details.getFile())) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null)); // empty FileDetailFragment transaction.commit(); @@@ -1360,9 -1209,9 +1363,9 @@@ OCFile renamedFile = operation.getFile(); if (result.isSuccess()) { if (mDualPane) { - FileDetailFragment details = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); - if (details != null && renamedFile.equals(details.getDisplayedFile()) ) { - details.updateFileDetails(renamedFile, AccountUtils.getCurrentOwnCloudAccount(this)); + FileFragment details = (FileFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + if (details != null && details instanceof FileDetailFragment && renamedFile.equals(details.getFile()) ) { + ((FileDetailFragment) details).updateFileDetails(renamedFile, AccountUtils.getCurrentOwnCloudAccount(this)); } } if (mStorageManager.getFileById(renamedFile.getParentId()).equals(mCurrentDir)) { @@@ -1424,12 -1273,12 +1427,12 @@@ fileListFragment.listDirectory(); }*/ if (mDualPane) { - FileDetailFragment details = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); - if (details != null && file.equals(details.getDisplayedFile()) ) { + FileFragment details = (FileFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + if (details != null && details instanceof FileDetailFragment && file.equals(details.getFile()) ) { if (downloading || uploading) { - details.updateFileDetails(file, AccountUtils.getCurrentOwnCloudAccount(this)); + ((FileDetailFragment)details).updateFileDetails(file, AccountUtils.getCurrentOwnCloudAccount(this)); } else { - details.updateFileDetails(downloading || uploading); + ((FileDetailFragment)details).updateFileDetails(false, true); } } } @@@ -1437,32 -1286,31 +1440,58 @@@ @Override + public void showFragmentWithDetails(OCFile file) { + if (mDualPane) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.file_details_container, new FileDetailFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); + transaction.commit(); + + } else { + Intent showDetailsIntent = new Intent(this, FileDetailActivity.class); + showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file); + showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this)); + showDetailsIntent.putExtra(FileDetailActivity.EXTRA_MODE, FileDetailActivity.MODE_DETAILS); + startActivity(showDetailsIntent); + } + } + + public void onDismiss(EditNameDialog dialog) { + //dialog.dismiss(); + if (dialog.getResult()) { + String newDirectoryName = dialog.getNewFilename().trim(); + Log.d(TAG, "'create directory' dialog dismissed with new name " + newDirectoryName); + if (newDirectoryName.length() > 0) { + String path; + if (mCurrentDir == null) { + // this is just a patch; we should ensure that mCurrentDir never is null + if (!mStorageManager.fileExists(OCFile.PATH_SEPARATOR)) { + OCFile file = new OCFile(OCFile.PATH_SEPARATOR); + mStorageManager.saveFile(file); + } + mCurrentDir = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR); + } + path = FileDisplayActivity.this.mCurrentDir.getRemotePath(); + + // Create directory + path += newDirectoryName + OCFile.PATH_SEPARATOR; + Thread thread = new Thread(new DirectoryCreator(path, AccountUtils.getCurrentOwnCloudAccount(FileDisplayActivity.this), new Handler())); + thread.start(); + + showDialog(DIALOG_SHORT_WAIT); + } + } + } + private void requestForDownload() { + Account account = AccountUtils.getCurrentOwnCloudAccount(this); + if (!mDownloaderBinder.isDownloading(account, mWaitingToPreview)) { + Intent i = new Intent(this, FileDownloader.class); + i.putExtra(FileDownloader.EXTRA_ACCOUNT, account); + i.putExtra(FileDownloader.EXTRA_FILE, mWaitingToPreview); + startService(i); + } + } + + } +