Merge remote-tracking branch 'origin/bug_folder_size_delay' into bug_folder_size_delay
authorDavid A. Velasco <dvelasco@solidgear.es>
Tue, 9 Jul 2013 11:25:43 +0000 (13:25 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 9 Jul 2013 11:25:43 +0000 (13:25 +0200)
28 files changed:
AndroidManifest.xml
res/layout-land/account_setup.xml
res/layout/account_setup.xml
res/layout/video_layout.xml
res/menu/account_picker_long_click.xml
res/values-eu/strings.xml
res/values-pl/strings.xml
res/values-sl/strings.xml
res/values-sv/strings.xml
res/values-te/strings.xml
res/values/strings.xml
res/values/styles.xml
src/com/owncloud/android/authentication/AccountAuthenticator.java
src/com/owncloud/android/authentication/AuthenticatorActivity.java
src/com/owncloud/android/files/services/FileDownloader.java
src/com/owncloud/android/files/services/FileUploader.java
src/com/owncloud/android/syncadapter/FileSyncAdapter.java
src/com/owncloud/android/ui/activity/AccountSelectActivity.java
src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java
src/com/owncloud/android/ui/activity/FileActivity.java
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/activity/UploadFilesActivity.java
src/com/owncloud/android/ui/adapter/FileListListAdapter.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java
src/com/owncloud/android/ui/preview/PreviewImageActivity.java
src/com/owncloud/android/ui/preview/PreviewImagePagerAdapter.java
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java
src/com/owncloud/android/ui/preview/PreviewVideoActivity.java

index ad8488d..90de160 100644 (file)
@@ -95,7 +95,7 @@
                        
         <activity      android:name="com.owncloud.android.ui.preview.PreviewVideoActivity"
                                        android:label="@string/app_name"
-                                       android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
+                                       android:theme="@style/Theme.ownCloud.Fullscreen" >
                </activity>        
 
         <service
index dea86cd..d3622be 100644 (file)
                            android:orientation="vertical"\r
                            android:padding="8dp" >\r
                \r
-                               <EditText\r
-                                       android:id="@+id/hostUrlInput"\r
+                           <FrameLayout \r
                                        android:layout_width="match_parent"\r
                                        android:layout_height="wrap_content"\r
-                                       android:ems="10"\r
-                                       android:hint="@string/auth_host_url"\r
-                                       android:inputType="textUri"\r
-                                       android:drawablePadding="5dp"\r
-                                       >\r
-                                       <requestFocus />\r
-                               </EditText>\r
+                               >\r
+                                       <EditText\r
+                                               android:id="@+id/hostUrlInput"\r
+                                               android:layout_width="match_parent"\r
+                                               android:layout_height="wrap_content"\r
+                                               android:hint="@string/auth_host_url"\r
+                                               android:inputType="textUri"\r
+                                               android:drawablePadding="5dp"\r
+                                               android:paddingRight="55dp"\r
+                                               >\r
+                                               <requestFocus />\r
+                                       </EditText>\r
+                                       <ImageButton\r
+                                           android:id="@+id/refeshButton"\r
+                                           android:layout_width="48dp"\r
+                                           android:layout_height="48dp"\r
+                                           android:layout_gravity="center_vertical|right"\r
+                                           android:layout_marginRight="5dp"\r
+                                           android:padding="0dp"\r
+                                           android:scaleType="fitCenter"\r
+                                           android:src="@drawable/ic_action_refresh_black"\r
+                               android:onClick="onRefreshClick"\r
+                                           android:visibility="gone"\r
+                                               android:background="@android:color/transparent"\r
+                                           />\r
+                               </FrameLayout>\r
                \r
                                <TextView\r
                                        android:id="@+id/server_status_text"\r
index a218fa9..1c7921d 100644 (file)
             android:layout_marginTop="10dp"\r
             android:src="@drawable/logo" />\r
 \r
-               <EditText\r
-                       android:id="@+id/hostUrlInput"\r
+           <FrameLayout \r
                        android:layout_width="match_parent"\r
                        android:layout_height="wrap_content"\r
-                       android:ems="10"\r
-                       android:hint="@string/auth_host_url"\r
-                       android:inputType="textUri"\r
-                       android:drawablePadding="5dp"\r
-                       >\r
-                       <requestFocus />\r
-               </EditText>\r
-\r
-        <TextView\r
+               >\r
+                       <EditText\r
+                               android:id="@+id/hostUrlInput"\r
+                               android:layout_width="match_parent"\r
+                               android:layout_height="wrap_content"\r
+                               android:hint="@string/auth_host_url"\r
+                               android:inputType="textUri"\r
+                               android:drawablePadding="5dp"\r
+                               android:paddingRight="55dp"\r
+                               >\r
+                               <requestFocus />\r
+                       </EditText>\r
+                       <ImageButton\r
+                           android:id="@+id/refeshButton"\r
+                           android:layout_width="48dp"\r
+                           android:layout_height="48dp"\r
+                           android:layout_gravity="center_vertical|right"\r
+                           android:layout_marginRight="5dp"\r
+                           android:padding="0dp"\r
+                           android:scaleType="fitCenter"\r
+                           android:src="@drawable/ic_action_refresh_black"\r
+               android:onClick="onRefreshClick"\r
+                               android:visibility="gone"\r
+                               android:background="@android:color/transparent"\r
+                           />\r
+               </FrameLayout>\r
+\r
+               <TextView\r
             android:id="@+id/server_status_text"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
index 8781ad8..dfa29f7 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <FrameLayout   xmlns:android="http://schemas.android.com/apk/res/android"
-                               android:layout_width="fill_parent"
-                               android:layout_height="fill_parent" >
+                               android:layout_width="match_parent"
+                               android:layout_height="match_parent" >
 
        <VideoView  android:id="@+id/videoPlayer"
                                android:layout_width="wrap_content"
index a6ef11e..b7e2dd3 100644 (file)
@@ -18,7 +18,6 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 <menu xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item android:id="@+id/change_password" android:title="@string/change_password"></item>
     <item android:id="@+id/delete_account" android:title="@string/delete_account"></item>
-    
-
 </menu>
\ No newline at end of file
index d0b3cf0..9ba6f32 100644 (file)
   <string name="main_settings">Ezarpenak</string>
   <string name="main_tit_accsetup">Konfiguratu kontua</string>
   <string name="main_wrn_accsetup"> Ez dago ownCloud konturik zure gailuan. Programa hau erabiltzeko, kontu bat sortu behar duzu.</string>
+  <string name="about_android">%1$s Android Aplikazioa</string>
+  <string name="about_version">%1$s bertsioa</string>
+  <string name="actionbar_sync">Freskatu kontua</string>
   <string name="actionbar_upload">Igo fitxategia</string>
   <string name="actionbar_upload_from_apps">Beste app-en edukia</string>
   <string name="actionbar_upload_files">Fitxategiak</string>
+  <string name="actionbar_open_with">Ireki honekin</string>
   <string name="actionbar_mkdir">Sortu karpeta</string>
   <string name="actionbar_search">Bilatu</string>
   <string name="actionbar_settings">Ezarpenak</string>
   <string name="prefs_pincode_summary">Babestu zure ownCloud bezeroa</string>
   <string name="prefs_instant_upload">Gaitu berehalako igoera</string>
   <string name="prefs_instant_upload_summary">Igo berehala kamerak ateratako argazkiak</string>
+  <string name="prefs_log_title">Gaitu erregistroa</string>
+  <string name="prefs_log_summary">Arazoen erregistroa gordetzeko erabiltzen da</string>
+  <string name="prefs_log_title_history">Erregistro historia</string>
+  <string name="prefs_log_summary_history">Honek gordetako erregistroak bistaratzen ditu.</string>
+  <string name="prefs_log_delete_history_button">Ezabatu historia</string>
   <string name="auth_host_url">Zerbitzariaren helbidea</string>
   <string name="auth_username">Erabiltzaile izena</string>
   <string name="auth_password">Pasahitza</string>
@@ -68,6 +77,7 @@
   <string name="filedetails_created">Sortuta:</string>
   <string name="filedetails_modified">Aldatuta:</string>
   <string name="filedetails_download">Deskargatu</string>
+  <string name="filedetails_sync_file">Freskatu fitxaegia</string>
   <string name="filedetails_redownload">Birdeskargatzen</string>
   <string name="filedetails_renamed_in_upload_msg">Fitxategiaren izena %1$sra aldatu da igotzean</string>
   <string name="common_yes">Bai</string>
   <string name="media_err_malformed">Euskarri fitxategia ezin da kodetu</string>
   <string name="media_err_timeout">Denbora gehiegi erreproduzitzen saiatzen</string>
   <string name="media_err_invalid_progressive_playback">Euskarri fitxategia ezin da jariotu</string>
+  <string name="media_err_security_ex">Segurtasun errorea %1$s erreproduzitzen saiatzean</string>
+  <string name="media_err_io_ex">Sarrera errorea %1$s erreproduzitzen saiatzean</string>
+  <string name="media_err_unexpected">Ezusteko errorea %1$s erreproduzitzen saiatzean</string>
+  <string name="media_previous_description">Aurreko pista botoia</string>
+  <string name="media_rewind_description">Atzeratu botoia</string>
+  <string name="media_play_pause_description">Erreproduzitu edo pausatu botoia</string>
+  <string name="media_forward_description">Azkar aurreratu botoia</string>
+  <string name="media_next_description">Hurrengo pista botoia</string>
   <string-array name="prefs_trackmydevice_intervall_keys">
     <item>15 Minutu</item>
     <item>30 Minutu</item>
     <item>30</item>
     <item>60</item>
   </string-array>
+  <string name="auth_trying_to_login">Saioa hasten saiatzen...</string>
   <string name="auth_no_net_conn_title">Ez dago sare konexiorik</string>
   <string name="auth_no_net_conn_message">Ez da sare konexiorik antzeman, egiaztatu zure interneteko konexioa eta saiatu berriz.</string>
   <string name="auth_connect_anyway">Konektatu hala ere</string>
   <string name="auth_nossl_plain_ok_title">Konexio segurua ez dago eskuragarri</string>
   <string name="auth_nossl_plain_ok_message">Aplikazioak ezin izan du zerbitzariarekin konexio seguru bat ezarri. Hala ere konexio ez segurua egin daiteke. Jarraitu edo ezeztatu dezakezu.</string>
   <string name="auth_connection_established">Konexioa ezarri da</string>
+  <string name="auth_testing_connection">Konexioa frogatzen...</string>
   <string name="auth_not_configured_title">gaizki egindako ownCloud konfigurazioa</string>
   <string name="auth_not_configured_message">Badirudi zure ownCloud instantzia ez dagoela ongi konfiguratuta. Jarri zure harremanetan administradorearkin informazio gehiago izateko.</string>
   <string name="auth_unknown_error_title">Errore ezezagun bat gertatu da</string>
   <string name="ssl_validator_label_signature">Sinadura:</string>
   <string name="ssl_validator_label_signature_algorithm">Algoritmoa:</string>
   <string name="placeholder_sentence">Hau leku-marka da</string>
+  <string name="placeholder_filetype">PNG Irudia</string>
+  <string name="placeholder_filesize">389 KB</string>
+  <string name="placeholder_timestamp">2012/05/18 12:23 PM</string>
+  <string name="placeholder_media_time">12:23:45</string>
   <string name="instant_upload_on_wifi">Igo irudiak bakarrik WIFIren bidez</string>
   <string name="instant_upload_path">/BerehalakoIgoerak</string>
   <string name="conflict_title">Igoera konfliktoa</string>
   <string name="conflict_keep_both">Mantendu biak</string>
   <string name="conflict_overwrite">Gainidatzi</string>
   <string name="conflict_dont_upload">Ez igo</string>
+  <string name="preview_image_description">Irudi aurreikuspena</string>
+  <string name="preview_image_error_unknown_format">Ezin da irudi hau erakutsi</string>
+  <string name="preview_image_error_out_of_memory">\"Ez dago orrialde hau erakusteko memoria aski</string>
   <!--we need to improve the communication of errors to the user-->
   <string name="error__upload__local_file_not_copied">%1$s ezin da %2$s bertako karpetara kopiatu</string>
+  <string name="actionbar_failed_instant_upload">UnekoIgoerak huts egin du\"</string>
+  <string name="failed_upload_headline_text">Uneko igoerek huts egin dute</string>
+  <string name="failed_upload_headline_hint">Huts egindako igoeren laburpena</string>
+  <string name="failed_upload_all_cb">Hautatu dena</string>
+  <string name="failed_upload_headline_retryall_btn">Berriz saiatu hautatutakoak</string>
+  <string name="failed_upload_headline_delete_all_btn">kendu hautatutakoak igoera-ilaratik</string>
+  <string name="failed_upload_retry_text">Berriz saiatu irudia igotzen:</string>
+  <string name="failed_upload_load_more_images">Kargatu irudi gehiago</string>
+  <string name="failed_upload_failure_text">Hutsegite mezua:</string>
+  <string name="failed_upload_quota_exceeded_text">Egiaztatu zure konfigurazioa, agian zure kuota muga gainditu  duzu.</string>
 </resources>
index c9adcaf..4e95d6a 100644 (file)
   <string name="auth_oauth_error_access_denied">Dostęp zabroniony przez serwer autoryzacji</string>
   <string name="auth_not_found">Wprowadzono nieprawidłową ścieżkę</string>
   <string name="auth_internal">Wewnętrzny błąd serwera, kod %1$d</string>
+  <string name="auth_wtf_reenter_URL">Nieoczekiwany stan; Proszę wpisz adres URL serwera ponownie</string>
+  <string name="auth_expired_oauth_token_toast">Twoja sesja wygasła.\nProszę zaloguj się ponownie</string>
+  <string name="auth_expired_basic_auth_toast">Zapisane dane logowania są nieprawidłowe.\nWprowadź nowe dane logowania.</string>
   <string name="crashlog_message">Aplikacja została nieoczekiwanie zakończona. Czy chcesz przesłać raport awarii?</string>
   <string name="crashlog_send_report">Wyślij raport</string>
   <string name="crashlog_dont_send_report">Nie wysyłaj raportu</string>
   <string name="oauth_host_url">oAuth2 URL</string>
   <string name="oauth_check_onoff">Loguj przez oAuth2</string>
   <string name="oauth_login_connection">Łączenie z serwerem oAuth2...</string>
+  <string name="oauth_code_validation_message">Proszę Otwórz przeglądarkę internetową i przejdź do:\n%1$s.\nSprawdź ten kod tam:\n%2$s</string>
+  <string name="oauth_connection_url_unavailable">Połączenie do tego adresu URL jest niedostępne.</string>
   <string name="ssl_validator_title">Uwaga</string>
   <string name="ssl_validator_header">Nie można zweryfikować tożsamości strony</string>
   <string name="ssl_validator_reason_cert_not_trusted">- Certyfikat serwera jest niezaufany</string>
index c1ab57c..730eaf2 100644 (file)
@@ -16,6 +16,7 @@
   <string name="actionbar_upload">Pošlji datoteko</string>
   <string name="actionbar_upload_from_apps">Vsebina iz drugih programov</string>
   <string name="actionbar_upload_files">Datoteke</string>
+  <string name="actionbar_open_with">Odpri z:</string>
   <string name="actionbar_mkdir">Ustvari mapo</string>
   <string name="actionbar_search">Poišči</string>
   <string name="actionbar_settings">Nastavitve</string>
@@ -36,6 +37,9 @@
   <string name="prefs_pincode_summary">Zaščitite odjemalec ownCloud</string>
   <string name="prefs_instant_upload">Omogoči takojšnje pošiljanje</string>
   <string name="prefs_instant_upload_summary">Takojšnje pošiljanje posnetih fotografij</string>
+  <string name="prefs_log_title">Omogoči zapisovanje v dnevnik</string>
+  <string name="prefs_log_title_history">Zgodovina</string>
+  <string name="prefs_log_delete_history_button">Izbriši zgodovino</string>
   <string name="auth_host_url">Naslov strežnika</string>
   <string name="auth_username">Uporabniško ime</string>
   <string name="auth_password">Geslo</string>
@@ -51,6 +55,7 @@
   <string name="setup_title">Poveži se z oblakom ownCloud</string>
   <string name="setup_btn_connect">Poveži</string>
   <string name="uploader_btn_upload_text">Pošlji</string>
+  <string name="uploader_top_message">Izberite mapo, v katero boste prenesli dokumente:</string>
   <string name="uploader_wrn_no_account_title">Uporabniškega računa ni mogoče najti</string>
   <string name="uploader_wrn_no_account_text">Na napravi ni računov ownCloud. Nastaviti je treba vsaj en račun.</string>
   <string name="uploader_wrn_no_account_setup_btn_text">Nastavi</string>
@@ -78,6 +83,7 @@
   <string name="common_save_exit">Shrani in končaj</string>
   <string name="common_exit">Zapusti ownCloud</string>
   <string name="common_error">Napaka</string>
+  <string name="common_loading">Nalaganje...</string>
   <string name="common_error_unknown">Neznana napaka</string>
   <string name="about_title">O oblaku ownCloud</string>
   <string name="delete_account">Izbriši račun</string>
   <string name="downloader_download_succeeded_content">%1$s je uspešno prejet</string>
   <string name="downloader_download_failed_ticker">Prejemanje je spodletelo</string>
   <string name="downloader_download_failed_content">Prejemanja %1$s ni mogoče dokončati</string>
+  <string name="downloader_not_downloaded_yet">Prenos še ni zaključen</string>
   <string name="common_choose_account">Izbor računa</string>
   <string name="sync_string_contacts">Stiki</string>
   <string name="sync_fail_ticker">Usklajevanje je spodletelo</string>
   <string name="pincode_wrong">Nepravilen kodo PIN programa ownCloud</string>
   <string name="pincode_removed">Koda PIN programa ownCloud je odstranjena</string>
   <string name="pincode_stored">Koda PIN programa ownCloud je shranjena</string>
+  <string name="media_state_playing">%1$s (predvajanja)</string>
+  <string name="media_state_loading">%1$s (nalaganja)</string>
+  <string name="media_err_nothing_to_play">Medijskih datotek ni bilo mogoče najti</string>
+  <string name="media_err_no_account">Niste navedli uporabniškega računa</string>
+  <string name="media_err_not_in_owncloud">Dokument ni shranjen pod veljaven račun.</string>
+  <string name="media_err_unsupported">Medijski kodek ni podprt</string>
+  <string name="media_err_io">Medijske datoteke ni bilo mogoče prebrati.</string>
+  <string name="media_err_malformed">Medijska datoteka ni pravilno kodirana.</string>
+  <string name="media_err_invalid_progressive_playback">Medijske datoteke ni mogoče predvajati</string>
+  <string name="media_err_unknown">Medijske datoteke ni mogoče predvajati s predvajalnikom Stock media player</string>
   <string-array name="prefs_trackmydevice_intervall_keys">
     <item>15 minut</item>
     <item>30 minut</item>
   <string name="ssl_validator_label_signature">Podpis:</string>
   <string name="ssl_validator_label_signature_algorithm">Algoritem:</string>
   <string name="placeholder_sentence">To je vsebnik predmetov.</string>
+  <string name="placeholder_filesize">389 KB</string>
+  <string name="placeholder_timestamp">2012/05/18 12:23 PM</string>
+  <string name="placeholder_media_time">12:23:45</string>
   <string name="instant_upload_on_wifi">Pošiljaj slike le preko povezav Wi-Fi</string>
   <string name="instant_upload_path">/NeposrednoNalaganje</string>
   <string name="conflict_title">Posodobi podatke spora</string>
   <string name="conflict_keep_both">Ohrani obe</string>
   <string name="conflict_overwrite">Prepiši</string>
   <string name="conflict_dont_upload">Ne pošlji</string>
+  <string name="preview_image_description">Predogled slike</string>
+  <string name="preview_image_error_unknown_format">Te slike ni mogoče prikazati</string>
   <!--we need to improve the communication of errors to the user-->
   <string name="error__upload__local_file_not_copied">Datoteke %1$s ni mogoče kopirati v krajevno mapo %2$s.</string>
+  <string name="failed_upload_all_cb">izberi vse</string>
+  <string name="failed_upload_load_more_images">Naloži več slik</string>
+  <string name="failed_upload_failure_text">Sporočilo o napaki:</string>
 </resources>
index ac844e0..c91cb8d 100644 (file)
   <string name="prefs_instant_upload">Aktivera direktuppladdning</string>
   <string name="prefs_instant_upload_summary">Direktuppladdning av kamerabilder</string>
   <string name="prefs_log_title">Aktivera loggning</string>
+  <string name="prefs_log_summary">Används för att logga problem</string>
+  <string name="prefs_log_title_history">Logghistorik</string>
+  <string name="prefs_log_summary_history">Visar sparade loggar</string>
+  <string name="prefs_log_delete_history_button">Radera historik</string>
   <string name="auth_host_url">Serveradress</string>
   <string name="auth_username">Användare</string>
   <string name="auth_password">Lösenord</string>
@@ -73,6 +77,7 @@
   <string name="filedetails_created">Skapad:</string>
   <string name="filedetails_modified">Ändrad:</string>
   <string name="filedetails_download">Ladda ner</string>
+  <string name="filedetails_sync_file">Ladda om fil</string>
   <string name="filedetails_redownload">Ladda ner igen</string>
   <string name="filedetails_renamed_in_upload_msg">Filen bytte namn till %1$s under uppladdningen</string>
   <string name="common_yes">Ja</string>
@@ -94,7 +99,7 @@
   <string name="uploader_upload_in_progress_ticker">Laddar upp ...</string>
   <string name="uploader_upload_in_progress_content">%1$d%% Laddar upp %2$s</string>
   <string name="uploader_upload_succeeded_ticker">Uppladdning klar</string>
-  <string name="uploader_upload_succeeded_content_single">%1$s var uppladdade</string>
+  <string name="uploader_upload_succeeded_content_single">%1$s laddades upp</string>
   <string name="uploader_upload_succeeded_content_multiple">%1$d filer uppladdade</string>
   <string name="uploader_upload_failed_ticker">Misslyckad uppladdning</string>
   <string name="uploader_upload_failed_content_single">Uppladdning av %1$s kunde inte slutföras</string>
   <string name="sync_string_contacts">Kontakter</string>
   <string name="sync_fail_ticker">Synkroniseringen misslyckades</string>
   <string name="sync_fail_content">Synkronisering av %1$s kunde inte slutföras</string>
+  <string name="sync_fail_content_unauthorized">Ogiltiga inloggningsuppgifter för %1$s</string>
   <string name="sync_conflicts_in_favourites_ticker">Konflikter uppstod</string>
   <string name="sync_conflicts_in_favourites_content">%1$d Flaggad som Håll-filen-uppdaterad kan inte synkas</string>
   <string name="sync_fail_in_favourites_ticker">Filer flaggade som Håll-filen-uppdaterad misslyckades</string>
     <item>30</item>
     <item>60</item>
   </string-array>
+  <string name="auth_trying_to_login">Försöker logga in...</string>
   <string name="auth_no_net_conn_title">Ingen anslutning till nätverket</string>
   <string name="auth_no_net_conn_message">Ingen nätverksanslutning har upptäckts, kontrollera din Internet-anslutning och försök igen.</string>
   <string name="auth_connect_anyway">Anslut ändå</string>
   <string name="auth_nossl_plain_ok_title">Säker anslutning inte tillgänglig.</string>
   <string name="auth_nossl_plain_ok_message">Applikationen kunde inte etablera en krypterad anslutning till servern. Okrypterad anslutning kan finnas tillgänglig. Du kan fortsätta eller avbryta.</string>
   <string name="auth_connection_established">Anslutning etablerad</string>
+  <string name="auth_testing_connection">Testar anslutning...</string>
   <string name="auth_not_configured_title">Felaktig konfiguration</string>
   <string name="auth_not_configured_message">Det verkar som om din version av ownCloud inte är korrekt konfigurerad. Kontakta din administratör för mer information.</string>
   <string name="auth_unknown_error_title">Okänt fel uppstod</string>
   <string name="auth_bad_oc_version_title">Okänd ownCloud serverversion</string>
   <string name="auth_wrong_connection_title">Kunde inte etablera anslutning</string>
   <string name="auth_secure_connection">Säker anslutning etablerad</string>
+  <string name="auth_unauthorized">Ogiltiga inloggningsuppgifter</string>
+  <string name="auth_oauth_error">Behörighet saknas</string>
+  <string name="auth_oauth_error_access_denied">Nekad åtkomst av server</string>
   <string name="auth_not_found">Felaktig  sökväg angavs</string>
   <string name="auth_internal">Internt serverfel, kod %1$d</string>
+  <string name="auth_wtf_reenter_URL">Oväntat tillstånd; Ange serverns URL igen</string>
+  <string name="auth_expired_oauth_token_toast">Din inloggning har gått ut.\nVar god, logga in igen</string>
+  <string name="auth_expired_basic_auth_toast">Dina sparade uppgifter är felaktiga.\nVar god ange aktuella uppgifter</string>
   <string name="crashlog_message">Applikationen avslutades oväntat. Vill du skicka en felrapport?</string>
   <string name="crashlog_send_report">Skicka rapport</string>
   <string name="crashlog_dont_send_report">Skicka inte rapport</string>
   <string name="wait_a_moment">Var god vänta</string>
   <string name="filedisplay_unexpected_bad_get_content">Oväntat problem; prova annat program för aktuell fil</string>
   <string name="filedisplay_no_file_selected">Ingen fil vald</string>
+  <string name="oauth_host_url">oAuth2 URL</string>
+  <string name="oauth_check_onoff">Logga in med oAuth2.</string>
+  <string name="oauth_login_connection">Ansluter till oAuth2 servern…</string>
+  <string name="oauth_code_validation_message">Öppna en webbläsare och gå till:\n%1$s.\nAnge denna kod för validering:\n%2$s</string>
+  <string name="oauth_connection_url_unavailable">Anslutning till denna URL är inte tillgänglig.</string>
   <string name="ssl_validator_title">Varning</string>
   <string name="ssl_validator_header">Webbplatsens identitet kunde inte verifieras</string>
   <string name="ssl_validator_reason_cert_not_trusted">- Servercertifikatet är inte tillförlitligt</string>
index f439af4..876c8b6 100644 (file)
@@ -4,6 +4,7 @@
   <string name="main_music">సంగీతం</string>
   <string name="main_settings">అమరికలు</string>
   <string name="actionbar_settings">అమరికలు</string>
+  <string name="auth_host_url">సేవకి చిరునామా</string>
   <string name="auth_username">వాడుకరి పేరు</string>
   <string name="auth_password">సంకేతపదం</string>
   <string name="setup_hint_username">వాడుకరి పేరు</string>
index 4ea3157..7e4ec93 100644 (file)
@@ -51,7 +51,7 @@
     <string name="auth_host_url">Server address</string>
     <string name="auth_username">Username</string>
     <string name="auth_password">Password</string>
-    <string name="auth_register">I am new to %1$s</string>
+    <string name="auth_register">New to %1$s?</string>
     <string name="new_session_uri_error">Incorrect address given</string>
     <string name="new_session_session_name_error">Incorrect session name</string>
     <string name="sync_string_files">Files</string>
@@ -95,6 +95,7 @@
     <string name="common_loading">Loading &#8230;</string>
     <string name="common_error_unknown">Unknown error</string>
     <string name="about_title">About</string>
+    <string name="change_password">Change password</string>
     <string name="delete_account">Delete account</string>
     <string name="create_account">Create account</string>
     <string name="upload_chooser_title">Upload from &#8230;</string>
     <string name="sync_string_contacts">Contacts</string>
     <string name="sync_fail_ticker">Synchronization failed</string>
     <string name="sync_fail_content">Synchronization of %1$s could not be completed</string>
-    <string name="sync_fail_content_unauthorized">Invalid credentials for %1$s</string>
+    <string name="sync_fail_content_unauthorized">Invalid password for %1$s</string>
        <string name="sync_conflicts_in_favourites_ticker">Conflicts found</string>
        <string name="sync_conflicts_in_favourites_content">%1$d kept-in-sync files could not be sync\'ed</string>
     <string name="sync_fail_in_favourites_ticker">Kept-in-sync files failed</string>
         <item>60</item>
     </string-array>
 
-    <string name="auth_trying_to_login">Trying to login...</string>
+    <string name="auth_trying_to_login">Trying to login&#8230;</string>
     <string name="auth_no_net_conn_title">No network connection</string>
     <string name="auth_no_net_conn_message">No network connection has been detected, check your Internet connection and try again.</string>
     <string name="auth_connect_anyway">Connect anyway</string>
     <string name="auth_nossl_plain_ok_title">Secure connection unavailable.</string>
     <string name="auth_nossl_plain_ok_message">The Application cannot establish a secure connection to the server. A non secure connection is available. You may continue or cancel.</string>
     <string name="auth_connection_established">Connection established</string>
-    <string name="auth_testing_connection">Testing connection...</string>
+    <string name="auth_testing_connection">Testing connection&#8230;</string>
     <string name="auth_not_configured_title">Malformed server configuration</string>
     <string name="auth_not_configured_message">It seems that your server instance is not correctly configured. Contact your administrator for more details.</string>
     <string name="auth_unknown_error_title">Unknown error occurred!</string>
     <string name="auth_bad_oc_version_title">Unrecognized server version</string>
     <string name="auth_wrong_connection_title">Couldn\'t establish connection</string>
     <string name="auth_secure_connection">Secure connection established</string>
-    <string name="auth_unauthorized">Invalid credentials</string>
+    <string name="auth_unauthorized">Wrong username or password</string>
        <string name="auth_oauth_error">Unsuccessful authorization</string>
        <string name="auth_oauth_error_access_denied">Access denied by authorization server</string>
     <string name="auth_not_found">Wrong path given</string>
     <string name="auth_internal">Internal server error, code %1$d</string>
     <string name="auth_wtf_reenter_URL">Unexpected state; please, enter the server URL again</string>
     <string name="auth_expired_oauth_token_toast">Your authorization expired.\nPlease, authorize again</string>
-    <string name="auth_expired_basic_auth_toast">Your saved credentials are invalid.\nPlease, enter the current credentials</string>
+    <string name="auth_expired_basic_auth_toast">Please, enter the current password</string>
     
     <string name="crashlog_message">Application terminated unexpectedly. Would you like to submit a crash report?</string>
     <string name="crashlog_send_report">Send report</string>
index 161f5d3..13d0ed2 100644 (file)
@@ -17,7 +17,7 @@
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
-<resources>
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
        <style name="Animations" />
 
        <!-- Default ownCloud app style -->
        <style name="Theme.ownCloud.noActionBar" parent="style/Theme.Sherlock.Light.NoActionBar">
       <item name="android:actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
       <item name="actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
-  </style>
+    </style>
+       
+       <style name="Theme.ownCloud.Fullscreen" parent="style/Theme.Sherlock.NoActionBar">
+      <item name="android:actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
+      <item name="actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
+      <item name="android:windowFullscreen">true</item>
+    </style>
+       
        
-
        <style name="Theme.ownCloud.Widget.ActionBar" parent="style/Widget.Sherlock.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/main_header_bg</item>
        <item name="background">@drawable/main_header_bg</item>
index aa12993..30eda59 100644 (file)
@@ -190,6 +190,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
         intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType);
         intent.putExtra(KEY_LOGIN_OPTIONS, options);
         intent.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);
+        intent.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
         intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
         
 
index 6eae48f..dabe98e 100644 (file)
@@ -60,6 +60,7 @@ import android.view.inputmethod.EditorInfo;
 import android.widget.CheckBox;\r
 import android.widget.EditText;\r
 import android.widget.Button;\r
+import android.widget.ImageButton;\r
 import android.widget.TextView;\r
 import android.widget.Toast;\r
 import android.widget.TextView.OnEditorActionListener;\r
@@ -83,6 +84,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     public static final String EXTRA_USER_NAME = "USER_NAME";\r
     public static final String EXTRA_HOST_NAME = "HOST_NAME";\r
     public static final String EXTRA_ACTION = "ACTION";\r
+    public static final String EXTRA_ENFORCED_UPDATE = "ENFORCE_UPDATE";\r
 \r
     private static final String KEY_HOST_URL_TEXT = "HOST_URL_TEXT";\r
     private static final String KEY_OC_VERSION = "OC_VERSION";\r
@@ -109,7 +111,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
     public static final byte ACTION_CREATE = 0;\r
     public static final byte ACTION_UPDATE_TOKEN = 1;\r
-    \r
+\r
     private String mHostBaseUrl;\r
     private OwnCloudVersion mDiscoveredVersion;\r
 \r
@@ -131,6 +133,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private Account mAccount;\r
 \r
     private EditText mHostUrlInput;\r
+    private ImageButton mRefreshButton;\r
     private EditText mUsernameInput;\r
     private EditText mPasswordInput;\r
     private CheckBox mOAuth2Check;\r
@@ -157,6 +160,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         /// set view and get references to view elements\r
         setContentView(R.layout.account_setup);\r
         mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput);\r
+        mRefreshButton = (ImageButton) findViewById(R.id.refeshButton);\r
         mUsernameInput = (EditText) findViewById(R.id.account_username);\r
         mPasswordInput = (EditText) findViewById(R.id.account_password);\r
         mOAuthAuthEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_1);\r
@@ -177,6 +181,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE); \r
         mAccount = null;\r
         mHostBaseUrl = "";\r
+        boolean refreshButtonEnabled = false;\r
 \r
         if (savedInstanceState == null) {\r
             /// connection state and info\r
@@ -204,7 +209,11 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             }\r
             mOAuth2Check.setChecked(oAuthRequired);\r
             changeViewByOAuth2Check(oAuthRequired);\r
-\r
+            mJustCreated = true;\r
+            \r
+            if (mAction == ACTION_UPDATE_TOKEN) {\r
+                checkOcServer(); \r
+            }\r
 \r
         } else {\r
             /// connection state and info\r
@@ -235,43 +244,35 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             }            \r
             \r
             // refresh button enabled\r
-            mRefreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);\r
+            refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);\r
+            \r
 \r
         }\r
 \r
         showServerStatus();\r
         showAuthStatus();\r
-        if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton();\r
-        mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
-\r
-        if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) {\r
-            mOAuth2Check.setVisibility(View.GONE);\r
-        }\r
 \r
         if (mAction == ACTION_UPDATE_TOKEN) {\r
             /// lock things that should not change\r
             mHostUrlInput.setEnabled(false);\r
+            mHostUrlInput.setFocusable(false);\r
             mUsernameInput.setEnabled(false);\r
+            mUsernameInput.setFocusable(false);\r
+            mOAuth2Check.setVisibility(View.GONE);\r
+        }\r
+        \r
+        //if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton();\r
+        if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton();\r
+        mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
+\r
+        if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) {\r
             mOAuth2Check.setVisibility(View.GONE);\r
-            if (!mServerIsValid && mOcServerChkOperation == null) {\r
-                checkOcServer(); \r
-            }\r
         }\r
 \r
         mPasswordInput.setText("");     // clean password to avoid social hacking (disadvantage: password in removed if the device is turned aside)\r
-        mJustCreated = true;\r
 \r
         /// bind view elements to listeners\r
         mHostUrlInput.setOnFocusChangeListener(this);\r
-        mHostUrlInput.setOnTouchListener(new RightDrawableOnTouchListener() {\r
-            @Override\r
-            public boolean onDrawableTouch(final MotionEvent event) {\r
-                if (event.getAction() == MotionEvent.ACTION_UP) {\r
-                    AuthenticatorActivity.this.onRefreshClick();\r
-                }\r
-                return true;\r
-            }\r
-        });\r
         mHostUrlInput.addTextChangedListener(new TextWatcher() {\r
 \r
             @Override\r
@@ -337,7 +338,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         }\r
         \r
         // refresh button enabled\r
-        outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled);\r
+        //outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled);\r
+        outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE));\r
 \r
     }\r
 \r
@@ -368,7 +370,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         super.onResume();\r
         // the state of mOAuth2Check is automatically recovered between configuration changes, but not before onCreate() finishes; so keep the next lines here\r
         changeViewByOAuth2Check(mOAuth2Check.isChecked());  \r
-        if (mAction == ACTION_UPDATE_TOKEN && mJustCreated) {\r
+        if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) {\r
             if (mOAuth2Check.isChecked())\r
                 Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();\r
             else\r
@@ -1193,13 +1195,15 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
 \r
     private void showRefreshButton() {\r
-        mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
-        mRefreshButtonEnabled = true;\r
+        /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
+        mRefreshButtonEnabled = true;*/\r
+        mRefreshButton.setVisibility(View.VISIBLE);\r
     }\r
 \r
     private void hideRefreshButton() {\r
-        mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
-        mRefreshButtonEnabled = false;\r
+        /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
+        mRefreshButtonEnabled = false;*/\r
+        mRefreshButton.setVisibility(View.GONE);\r
     }\r
 \r
     /**\r
@@ -1209,7 +1213,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      * \r
      * @param view      Refresh 'button'\r
      */\r
-    public void onRefreshClick() {\r
+    public void onRefreshClick(View view) {\r
         checkOcServer();\r
     }\r
     \r
index 1ec5591..02a8a45 100644 (file)
@@ -468,6 +468,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
                 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, download.getAccount());
+                updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
                 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
index 2f66e30..e9f445a 100644 (file)
@@ -795,6 +795,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
                 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount());
+                updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
                 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
index b7d3bcc..44fe401 100644 (file)
@@ -309,6 +309,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             // let the user update credentials with one click
             Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);
             updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount());
+            updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
             updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
             updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
index 7428f50..1a1cd51 100644 (file)
@@ -48,6 +48,7 @@ import com.actionbarsherlock.view.Menu;
 import com.actionbarsherlock.view.MenuInflater;
 import com.actionbarsherlock.view.MenuItem;
 import com.owncloud.android.authentication.AccountAuthenticator;
+import com.owncloud.android.authentication.AuthenticatorActivity;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.Log_OC;
 
@@ -142,11 +143,17 @@ public class AccountSelectActivity extends SherlockListActivity implements
         return false;
     }
 
+    /**
+     * Called when the user clicked on an item into the context menu created at 
+     * {@link #onCreateContextMenu(ContextMenu, View, ContextMenuInfo)} for every
+     * ownCloud {@link Account} , containing 'secondary actions' for them.
+     * 
+     * {@inheritDoc}}
+     */
     @SuppressWarnings("unchecked")
     @Override
     public boolean onContextItemSelected(android.view.MenuItem item) {
-        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
-                .getMenuInfo();
+        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
         int index = info.position;
         HashMap<String, String> map = null;
         try {
@@ -158,11 +165,18 @@ public class AccountSelectActivity extends SherlockListActivity implements
         
         String accountName = map.get("NAME");
         AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);
-        Account accounts[] = am
-                .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);
+        Account accounts[] = am.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);
         for (Account a : accounts) {
             if (a.name.equals(accountName)) {
-                am.removeAccount(a, this, mHandler);
+                if (item.getItemId() == R.id.change_password) {
+                    Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
+                    updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, a);
+                    updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
+                    startActivity(updateAccountCredentials);
+                    
+                } else if (item.getItemId() == R.id.delete_account) {
+                    am.removeAccount(a, this, mHandler);
+                }
             }
         }
 
index 62c5f46..61ac8f5 100644 (file)
 
 package com.owncloud.android.ui.activity;
 
-import com.actionbarsherlock.app.SherlockFragmentActivity;
 import com.owncloud.android.Log_OC;
+import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.ui.dialog.ConflictsResolveDialog;
 import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Decision;
 import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionMadeListener;
 
-import android.accounts.Account;
 import android.content.Intent;
 import android.os.Bundle;
 
@@ -35,32 +35,15 @@ import android.os.Bundle;
  * application. 
  * 
  * @author Bartek Przybylski
- *
+ * @author David A. Velasco
  */
-public class ConflictsResolveActivity extends SherlockFragmentActivity implements OnConflictDecisionMadeListener {
-
-    public static final String EXTRA_FILE = "FILE";
-    public static final String EXTRA_ACCOUNT = "ACCOUNT";
+public class ConflictsResolveActivity extends FileActivity implements OnConflictDecisionMadeListener {
 
     private String TAG = ConflictsResolveActivity.class.getSimpleName();
     
-    //private String mRemotePath;
-    
-    //private String mLocalPath;
-    
-    private OCFile mFile;
-    private Account mOCAccount;
-    
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        
-        //mRemotePath = getIntent().getStringExtra("remotepath");
-        //mLocalPath = getIntent().getStringExtra("localpath");
-        mFile = getIntent().getParcelableExtra(EXTRA_FILE);
-        mOCAccount = getIntent().getParcelableExtra(EXTRA_ACCOUNT);
-        ConflictsResolveDialog d = ConflictsResolveDialog.newInstance(mFile.getRemotePath(), this);
-        d.showDialog(this);
     }
 
     @Override
@@ -81,11 +64,40 @@ public class ConflictsResolveActivity extends SherlockFragmentActivity implement
                 Log_OC.wtf(TAG, "Unhandled conflict decision " + decision);
                 return;
         }
-        i.putExtra(FileUploader.KEY_ACCOUNT, mOCAccount);
-        i.putExtra(FileUploader.KEY_FILE, mFile);
+        i.putExtra(FileUploader.KEY_ACCOUNT, getAccount());
+        i.putExtra(FileUploader.KEY_FILE, getFile());
         i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
         
         startService(i);
         finish();
     }
+
+    @Override
+    protected void onAccountSet(boolean stateWasRecovered) {
+        if (getAccount() != null) {
+            OCFile file = getFile();
+            if (getFile() == null) {
+                Log_OC.e(TAG, "No conflictive file received");
+                finish();
+            } else {
+                /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
+                DataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver());
+                file = storageManager.getFileByPath(file.getRemotePath());   // file = null if not in the current Account
+                if (file != null) {
+                    setFile(file);
+                    ConflictsResolveDialog d = ConflictsResolveDialog.newInstance(file.getRemotePath(), this);
+                    d.showDialog(this);
+                    
+                } else {
+                    // account was changed to a different one - just finish
+                    finish();
+                }
+            }
+            
+        } else {
+            Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+            finish();
+        }
+        
+    }
 }
index cfada45..a23b3be 100644 (file)
@@ -60,9 +60,15 @@ public abstract class FileActivity extends SherlockFragmentActivity {
     /** Flag to signal that the activity will is finishing to enforce the creation of an ownCloud {@link Account} */
     private boolean mRedirectingToSetupAccount = false;
     
+    /** Flag to signal when the value of mAccount was set */ 
+    private boolean mAccountWasSet;
+    
+    /** Flag to signal when the value of mAccount was restored from a saved state */ 
+    private boolean mAccountWasRestored;
 
+    
     /**
-     * Loads the cownCloud {@link Account} and main {@link OCFile} to be handled by the instance of 
+     * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of 
      * the {@link FileActivity}.
      * 
      * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user 
@@ -72,18 +78,16 @@ public abstract class FileActivity extends SherlockFragmentActivity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        Account account;
         if(savedInstanceState != null) {
+            account = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
             mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
-            mAccount = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
         } else {
-            mAccount = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
+            account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
             mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
         }
 
-        grantValidAccount();
-        if (mAccount != null) {
-            onAccountSet(savedInstanceState != null);
-        }
+        setAccount(account, savedInstanceState != null);
     }
 
     
@@ -95,37 +99,75 @@ public abstract class FileActivity extends SherlockFragmentActivity {
     @Override
     protected void onRestart() {
         super.onRestart();
+        boolean validAccount = (mAccount != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), mAccount.name));
+        if (!validAccount) {
+            swapToDefaultAccount();
+        }
         
-        Account oldAccount = mAccount;
-        grantValidAccount();
-        if (mAccount != null && !mAccount.equals(oldAccount)) {
-            onAccountSet(false);
+    }
+
+    
+    @Override 
+    protected void onStart() {
+        super.onStart();
+        if (mAccountWasSet) {
+            onAccountSet(mAccountWasRestored);
         }
     }
     
-        
+    
     /**
-     *  Validates the ownCloud {@link Account} associated to the Activity any time it is restarted.
+     *  Sets and validates the ownCloud {@link Account} associated to the Activity. 
      * 
      *  If not valid, tries to swap it for other valid and existing ownCloud {@link Account}.
+     *  
+     *  POSTCONDITION: updates {@link #mAccountWasSet} and {@link #mAccountWasRestored}. 
      * 
-     *  If no valid ownCloud {@link Account} exists, mAccount is set to NULL and the user is requested 
-     *  to create a new ownCloud {@link Account}.
+     *  @param account          New {@link Account} to set.
+     *  @param savedAccount     When 'true', account was retrieved from a saved instance state.
      */
-    private void grantValidAccount() {
-        boolean validAccount = (mAccount != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), mAccount.name));
-        if (!validAccount) {
-            // get most recently used account as default account
-            mAccount = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
-            if (mAccount == null) {
-                /// no account available: force account creation
-                createFirstAccount();
-                mRedirectingToSetupAccount = true;
-            }
+    private void setAccount(Account account, boolean savedAccount) {
+        Account oldAccount = mAccount;
+        boolean validAccount = (account != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), account.name));
+        if (validAccount) {
+            mAccount = account;
+            mAccountWasSet = true;
+            mAccountWasRestored = (savedAccount || mAccount.equals(oldAccount));
+            
+        } else {
+            swapToDefaultAccount();
         }
     }
+
     
-    
+    /**
+     *  Tries to swap the current ownCloud {@link Account} for other valid and existing. 
+     * 
+     *  If no valid ownCloud {@link Account} exists, the the user is requested 
+     *  to create a new ownCloud {@link Account}.
+     *  
+     *  POSTCONDITION: updates {@link #mAccountWasSet} and {@link #mAccountWasRestored}.
+     *   
+     *  @return     'True' if the checked {@link Account} was valid.
+     */
+    private void swapToDefaultAccount() {
+        // default to the most recently used account
+        Account newAccount  = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
+        if (newAccount == null) {
+            /// no account available: force account creation
+            createFirstAccount();
+            mRedirectingToSetupAccount = true;
+            mAccountWasSet = false;
+            mAccountWasRestored = false;
+            
+        } else {
+            mAccountWasSet = true;
+            mAccountWasRestored = (newAccount.equals(mAccount));
+            mAccount = newAccount;
+        }
+    }
+
+
     /**
      * Launches the account creation activity. To use when no ownCloud account is available
      */
@@ -203,6 +245,7 @@ public abstract class FileActivity extends SherlockFragmentActivity {
         @Override
         public void run(AccountManagerFuture<Bundle> future) {
             FileActivity.this.mRedirectingToSetupAccount = false;
+            boolean accountWasSet = false;
             if (future != null) {
                 try {
                     Bundle result;
@@ -210,11 +253,11 @@ public abstract class FileActivity extends SherlockFragmentActivity {
                     String name = result.getString(AccountManager.KEY_ACCOUNT_NAME);
                     String type = result.getString(AccountManager.KEY_ACCOUNT_TYPE);
                     if (AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), name)) {
-                        FileActivity.this.mAccount = new Account(name, type);
-                        FileActivity.this.onAccountSet(false);
+                        setAccount(new Account(name, type), false);
+                        accountWasSet = true;
                     }
                 } catch (OperationCanceledException e) {
-                    Log_OC.e(TAG, "Account creation canceled");
+                    Log_OC.d(TAG, "Account creation canceled");
                     
                 } catch (Exception e) {
                     Log_OC.e(TAG, "Account creation finished in exception: ", e);
@@ -223,8 +266,8 @@ public abstract class FileActivity extends SherlockFragmentActivity {
             } else {
                 Log_OC.e(TAG, "Account creation callback with null bundle");
             }
-            if (mAccount == null) {
-                finish();
+            if (!accountWasSet) {
+                moveTaskToBack(true);
             }
         }
         
index 125fd9e..0ce6cce 100644 (file)
@@ -176,27 +176,13 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
         mRightFragmentContainer = findViewById(R.id.right_fragment_container);
         if (savedInstanceState == null) {
             createMinFragments();
-            if (!isRedirectingToSetupAccount()) {
-                initFragmentsWithFile();
-            }
         }
 
         // Action bar setup
         mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
-        OCFile currFile = getFile();
-        if (mStorageManager != null) {
-            while(currFile != null && currFile.getFileName() != OCFile.PATH_SEPARATOR) {
-                if (currFile.isDirectory()) {
-                    mDirectories.add(currFile.getFileName());
-                }
-                currFile = mStorageManager.getFileById(currFile.getParentId());
-            }
-        }
-        mDirectories.add(OCFile.PATH_SEPARATOR);
-        ActionBar actionBar = getSupportActionBar();
-        actionBar.setHomeButtonEnabled(true);   // mandatory since Android ICS, according to the official documentation
-        setSupportProgressBarIndeterminateVisibility(false);        // always AFTER setContentView(...) ; to workaround bug in its implementation
-
+        getSupportActionBar().setHomeButtonEnabled(true);       // mandatory since Android ICS, according to the official documentation
+        setSupportProgressBarIndeterminateVisibility(false);    // always AFTER setContentView(...) ; to work around bug in its implementation
+        
         Log_OC.d(TAG, "onCreate() end");
     }
 
@@ -233,17 +219,28 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
             }
             if (file == null) {
                 // fall back to root folder
-                file = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);  // never should return null
+                file = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);  // never returns null
             }
             setFile(file);
-
-            if (findViewById(android.R.id.content) != null && !stateWasRecovered) {
+            mDirectories.clear();
+            OCFile fileIt = file;
+            while(fileIt != null && fileIt.getFileName() != OCFile.PATH_SEPARATOR) {
+                if (fileIt.isDirectory()) {
+                    mDirectories.add(fileIt.getFileName());
+                }
+                fileIt = mStorageManager.getFileById(fileIt.getParentId());
+            }
+            mDirectories.add(OCFile.PATH_SEPARATOR);
+            if (!stateWasRecovered) {
                 Log_OC.e(TAG, "Initializing Fragments in onAccountChanged..");
                 initFragmentsWithFile();
+                
             } else {
-                Log_OC.e(TAG, "Fragment initializacion ignored in onAccountChanged due to lack of CONTENT VIEW");
+                updateFragmentsVisibility(!file.isDirectory());
+                updateNavigationElementsInActionBar(file.isDirectory() ? null : file);
             }
-
+            
+            
         } else {
             Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
         }
@@ -259,11 +256,24 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
 
     private void initFragmentsWithFile() {
         if (getAccount() != null && getFile() != null) {
+            /// First fragment
+            OCFileListFragment listOfFiles = getListOfFilesFragment(); 
+            if (listOfFiles != null) {
+                listOfFiles.listDirectory(getCurrentDir());   
+            } else {
+                Log.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
+            }
+            
             /// Second fragment
             OCFile file = getFile(); 
             Fragment secondFragment = chooseInitialSecondFragment(file);
             if (secondFragment != null) {
                 setSecondFragment(secondFragment);
+                updateFragmentsVisibility(true);
+                updateNavigationElementsInActionBar(file);
+                
+            } else {
+                cleanSecondFragment();
             }
 
         } else {
@@ -361,8 +371,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
             FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
             tr.remove(second);
             tr.commit();
-            updateFragmentsVisibility(false);
         }
+        updateFragmentsVisibility(false);
+        updateNavigationElementsInActionBar(null);
     }
 
     protected void refeshListOfFilesFragment() {
@@ -587,7 +598,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
             setFile(listOfFiles.getCurrentFile());
         }
         cleanSecondFragment();
-        updateNavigationElementsInActionBar(null);
     }
 
     @Override
@@ -600,14 +610,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
     }
 
     @Override
-    protected void onStart() {
-        super.onStart();
-        FileFragment second = getSecondFragment();
-        updateFragmentsVisibility(second != null);
-        updateNavigationElementsInActionBar((second == null) ? null : second.getFile());
-    }
-
-    @Override
     protected void onResume() {
         super.onResume();
         Log_OC.e(TAG, "onResume() start");
@@ -627,13 +629,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
         downloadIntentFilter.addAction(FileDownloader.DOWNLOAD_FINISH_MESSAGE);
         mDownloadFinishReceiver = new DownloadFinishReceiver();
         registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
-
-        // List current directory
-        OCFileListFragment listOfFiles = getListOfFilesFragment(); 
-        if (listOfFiles != null) {
-            listOfFiles.listDirectory(getCurrentDir());   // TODO we should find the way to avoid the need of this (maybe it's not necessary yet; to check)
-        }
-
+    
         Log_OC.d(TAG, "onResume() end");
     }
 
@@ -844,19 +840,14 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
                         || fillBlankRoot ) {
                     if (!fillBlankRoot) 
                         currentDir = getStorageManager().getFileByPath(synchFolderRemotePath);
-//                    OCFileListFragment fileListFragment = getListOfFilesFragment();
-//                    if (fileListFragment != null) {
-//                        fileListFragment.listDirectory(currentDir);
-//                    }
-                }
-
-                OCFileListFragment fileListFragment = getListOfFilesFragment();
-                if (fileListFragment != null) {
-                    fileListFragment.listDirectory(currentDir);
+                    OCFileListFragment fileListFragment = getListOfFilesFragment();
+                    if (fileListFragment != null) {
+                        fileListFragment.listDirectory(currentDir);
+                    }
+                    if (getSecondFragment() == null)
+                        setFile(currentDir);
                 }
-
-                setFile(currentDir);
-
+                
                 setSupportProgressBarIndeterminateVisibility(inProgress);
                 removeStickyBroadcast(intent);
 
@@ -945,7 +936,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
     public void onBrowsedDownTo(OCFile directory) {
         pushDirname(directory);
         cleanSecondFragment();
-        updateNavigationElementsInActionBar(null);
     }
 
     /**
@@ -1015,9 +1005,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
     /**
      * TODO
      */
-    private void updateNavigationElementsInActionBar(OCFile currentFile) {
+    private void updateNavigationElementsInActionBar(OCFile chosenFile) {
         ActionBar actionBar = getSupportActionBar(); 
-        if (currentFile == null || mDualPane) {
+        if (chosenFile == null || mDualPane) {
             // only list of files - set for browsing through folders
             OCFile currentDir = getCurrentDir();
             actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0);
@@ -1028,7 +1018,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
         } else {
             actionBar.setDisplayHomeAsUpEnabled(true);
             actionBar.setDisplayShowTitleEnabled(true);
-            actionBar.setTitle(currentFile.getFileName());
+            actionBar.setTitle(chosenFile.getFileName());
             actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
         }
     }
@@ -1038,15 +1028,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
      * {@inheritDoc}
      */
     @Override
-    public OCFile getInitialDirectory() {
-        return getCurrentDir();
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public void onFileStateChanged() {
         refeshListOfFilesFragment();
         updateNavigationElementsInActionBar(getSecondFragment().getFile());
@@ -1345,12 +1326,11 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
         if (file != null) {
             if (file.isDirectory()) {
                 return file;
-            } else {
+            } else if (mStorageManager != null) {
                 return mStorageManager.getFileById(file.getParentId());
             }
-        } else {
-            return null;
         }
+        return null;
     }
 
 }
index 16e05f8..a6031cd 100644 (file)
@@ -34,7 +34,6 @@ import android.widget.TextView;
 
 import com.actionbarsherlock.app.ActionBar;
 import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
 import com.actionbarsherlock.view.MenuItem;
 import com.owncloud.android.ui.dialog.IndeterminateProgressDialog;
 import com.owncloud.android.ui.fragment.ConfirmationDialogFragment;
@@ -53,7 +52,7 @@ import com.owncloud.android.R;
  * 
  */
 
-public class UploadFilesActivity extends SherlockFragmentActivity implements
+public class UploadFilesActivity extends FileActivity implements
     LocalFileListFragment.ContainerActivity, OnNavigationListener, OnClickListener, ConfirmationDialogFragmentListener {
     
     private ArrayAdapter<String> mDirectories;
@@ -61,10 +60,9 @@ public class UploadFilesActivity extends SherlockFragmentActivity implements
     private LocalFileListFragment mFileListFragment;
     private Button mCancelBtn;
     private Button mUploadBtn;
-    private Account mAccount;
+    private Account mAccountOnCreation;
     private DialogFragment mCurrentDialog;
     
-    public static final String EXTRA_ACCOUNT = UploadFilesActivity.class.getCanonicalName() + ".EXTRA_ACCOUNT";
     public static final String EXTRA_CHOSEN_FILES = UploadFilesActivity.class.getCanonicalName() + ".EXTRA_CHOSEN_FILES";
 
     public static final int RESULT_OK_AND_MOVE = RESULT_FIRST_USER; 
@@ -86,7 +84,7 @@ public class UploadFilesActivity extends SherlockFragmentActivity implements
             mCurrentDir = Environment.getExternalStorageDirectory();
         }
         
-        mAccount = getIntent().getParcelableExtra(EXTRA_ACCOUNT);
+        mAccountOnCreation = getAccount();
                 
         /// USER INTERFACE
             
@@ -318,7 +316,7 @@ public class UploadFilesActivity extends SherlockFragmentActivity implements
                 File localFile = new File(localPath);
                 total += localFile.length();
             }
-            return (FileStorageUtils.getUsableSpace(mAccount.name) >= total);
+            return (FileStorageUtils.getUsableSpace(mAccountOnCreation.name) >= total);
         }
 
         /**
@@ -374,6 +372,22 @@ public class UploadFilesActivity extends SherlockFragmentActivity implements
     public void onCancel(String callerTag) {
         /// nothing to do; don't finish, let the user change the selection
         Log_OC.d(TAG, "Negative button in dialog was clicked; dialog tag is " + callerTag);
+    }
+
+
+    @Override
+    protected void onAccountSet(boolean stateWasRecovered) {
+        if (getAccount() != null) {
+            if (!mAccountOnCreation.equals(getAccount())) {
+                setResult(RESULT_CANCELED);
+                finish();
+            }
+            
+        } else {
+            Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+            setResult(RESULT_CANCELED);
+            finish();
+        }
     }    
 
     
index 69ff49d..3e8eecd 100644 (file)
-
-/* ownCloud Android client application
- *   Copyright (C) 2011  Bartek Przybylski
- *   Copyright (C) 2012-2013 ownCloud Inc.
- *
- *   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
- *   (at your option) any later version.
- *
- *   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.adapter;
-
-import java.util.Vector;
-
-import android.accounts.Account;
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import com.owncloud.android.DisplayUtils;
-import com.owncloud.android.R;
-import com.owncloud.android.authentication.AccountUtils;
-import com.owncloud.android.datamodel.DataStorageManager;
-import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
-import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
-import com.owncloud.android.ui.activity.TransferServiceGetter;
-
-/**
- * This Adapter populates a ListView with all files and folders in an ownCloud
- * instance.
- * 
- * @author Bartek Przybylski
- * 
- */
-public class FileListListAdapter extends BaseAdapter implements ListAdapter {
-    private Context mContext;
-    private OCFile mFile = null;
-    private Vector<OCFile> mFiles = null;
-    private DataStorageManager mStorageManager;
-    private Account mAccount;
-    private TransferServiceGetter mTransferServiceGetter;
-
-    public FileListListAdapter(OCFile file, DataStorageManager storage_man,
-            Context context, TransferServiceGetter transferServiceGetter) {
-        mStorageManager = storage_man;
-        mContext = context;
-        mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
-        mTransferServiceGetter = transferServiceGetter;
-        swapDirectory(file, mStorageManager);
-        /*mFile = file;
-        mFiles = mStorageManager.getDirectoryContent(mFile);*/
-    }
-
-    @Override
-    public boolean areAllItemsEnabled() {
-        return true;
-    }
-
-    @Override
-    public boolean isEnabled(int position) {
-        return true;
-    }
-
-    @Override
-    public int getCount() {
-        return mFiles != null ? mFiles.size() : 0;
-    }
-
-    @Override
-    public Object getItem(int position) {
-        if (mFiles == null || mFiles.size() <= position)
-            return null;
-        return mFiles.get(position);
-    }
-
-    @Override
-    public long getItemId(int position) {
-        if (mFiles == null || mFiles.size() <= position)
-            return 0;
-        return mFiles.get(position).getFileId();
-    }
-
-    @Override
-    public int getItemViewType(int position) {
-        return 0;
-    }
-
-    @Override
-    public View getView(int position, View convertView, ViewGroup parent) {
-        View view = convertView;
-        if (view == null) {
-            LayoutInflater inflator = (LayoutInflater) mContext
-                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-            view = inflator.inflate(R.layout.list_item, null);
-        }
-        if (mFiles != null && mFiles.size() > position) {
-            OCFile file = mFiles.get(position);
-            TextView fileName = (TextView) view.findViewById(R.id.Filename);
-            String name = file.getFileName();
-
-            fileName.setText(name);
-            ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);
-            fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));
-            ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);
-            FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();
-            FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
-            if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {
-                localStateView.setImageResource(R.drawable.downloading_file_indicator);
-                localStateView.setVisibility(View.VISIBLE);
-            } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
-                localStateView.setImageResource(R.drawable.uploading_file_indicator);
-                localStateView.setVisibility(View.VISIBLE);
-            } else if (file.isDown()) {
-                localStateView.setImageResource(R.drawable.local_file_indicator);
-                localStateView.setVisibility(View.VISIBLE);
-            } else {
-                localStateView.setVisibility(View.INVISIBLE);
-            }
-
-
-            TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
-            TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
-            ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
-
-            if (!file.isDirectory()) {
-                fileSizeV.setVisibility(View.VISIBLE);
-                fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
-                lastModV.setVisibility(View.VISIBLE);
-                lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
-                // this if-else is needed even thoe fav icon is visible by default
-                // because android reuses views in listview
-                if (!file.keepInSync()) {
-                    view.findViewById(R.id.imageView3).setVisibility(View.GONE);
-                } else {
-                    view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);
-                }
-
-                ListView parentList = (ListView)parent;
-                if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) { 
-                    checkBoxV.setVisibility(View.GONE);
-                } else {
-                    if (parentList.isItemChecked(position)) {
-                        checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
-                    } else {
-                        checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
-                    }
-                    checkBoxV.setVisibility(View.VISIBLE);
-                }
-
-            } 
-            else {
-
-                fileSizeV.setVisibility(View.VISIBLE);
-                fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
-                lastModV.setVisibility(View.VISIBLE);
-                lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
-
-                checkBoxV.setVisibility(View.GONE);
-                view.findViewById(R.id.imageView3).setVisibility(View.GONE);
-            }
-        }
-
-        return view;
-    }
-
-
-    @Override
-    public int getViewTypeCount() {
-        return 1;
-    }
-
-    @Override
-    public boolean hasStableIds() {
-        return true;
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return (mFiles == null || mFiles.isEmpty());
-    }
-
-    /**
-     * Change the adapted directory for a new one
-     * @param directory                 New file to adapt. Can be NULL, meaning "no content to adapt".
-     * @param updatedStorageManager     Optional updated storage manager; used to replace mStorageManager if is different (and not NULL)
-     */
-    public void swapDirectory(OCFile directory, DataStorageManager updatedStorageManager) {
-        mFile = directory;
-        if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {
-            mStorageManager = updatedStorageManager;
-            mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
-        }
-        if (mStorageManager != null) {
-            mFiles = mStorageManager.getDirectoryContent(mFile);
-        } else {
-            mFiles = null;
-        }
-        notifyDataSetChanged();
-    }
-
-}
\ No newline at end of file
+/* ownCloud Android client application\r
+ *   Copyright (C) 2011  Bartek Przybylski\r
+ *   Copyright (C) 2012-2013 ownCloud Inc.\r
+ *\r
+ *   This program is free software: you can redistribute it and/or modify\r
+ *   it under the terms of the GNU General Public License version 2,\r
+ *   as published by the Free Software Foundation.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU General Public License\r
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+ *\r
+ */\r
+package com.owncloud.android.ui.adapter;\r
+\r
+import android.accounts.Account;\r
+import android.content.Context;\r
+import android.view.LayoutInflater;\r
+import android.view.View;\r
+import android.view.ViewGroup;\r
+import android.widget.BaseAdapter;\r
+import android.widget.ImageView;\r
+import android.widget.ListAdapter;\r
+import android.widget.ListView;\r
+import android.widget.TextView;\r
+\r
+import com.owncloud.android.DisplayUtils;\r
+import com.owncloud.android.R;\r
+import com.owncloud.android.authentication.AccountUtils;\r
+import com.owncloud.android.datamodel.DataStorageManager;\r
+import com.owncloud.android.datamodel.OCFile;\r
+import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;\r
+import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
+import com.owncloud.android.ui.activity.TransferServiceGetter;\r
+\r
+import java.util.Vector;\r
+\r
+\r
+/**\r
+ * This Adapter populates a ListView with all files and folders in an ownCloud\r
+ * instance.\r
+ * \r
+ * @author Bartek Przybylski\r
+ * \r
+ */\r
+public class FileListListAdapter extends BaseAdapter implements ListAdapter {\r
+    private Context mContext;\r
+    private OCFile mFile = null;\r
+    private Vector<OCFile> mFiles = null;\r
+    private DataStorageManager mStorageManager;\r
+    private Account mAccount;\r
+    private TransferServiceGetter mTransferServiceGetter;\r
+    //total size of a directory (recursive)\r
+    private Long totalSizeOfDirectoriesRecursive = null;\r
+    private Long lastModifiedOfAllSubdirectories = null;\r
+    \r
+    public FileListListAdapter(Context context, TransferServiceGetter transferServiceGetter) {\r
+        mContext = context;\r
+        mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
+        mTransferServiceGetter = transferServiceGetter;\r
+    }\r
+\r
+    @Override\r
+    public boolean areAllItemsEnabled() {\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public boolean isEnabled(int position) {\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public int getCount() {\r
+        return mFiles != null ? mFiles.size() : 0;\r
+    }\r
+\r
+    @Override\r
+    public Object getItem(int position) {\r
+        if (mFiles == null || mFiles.size() <= position)\r
+            return null;\r
+        return mFiles.get(position);\r
+    }\r
+\r
+    @Override\r
+    public long getItemId(int position) {\r
+        if (mFiles == null || mFiles.size() <= position)\r
+            return 0;\r
+        return mFiles.get(position).getFileId();\r
+    }\r
+\r
+    @Override\r
+    public int getItemViewType(int position) {\r
+        return 0;\r
+    }\r
+\r
+    @Override\r
+    public View getView(int position, View convertView, ViewGroup parent) {\r
+        View view = convertView;\r
+        if (view == null) {\r
+            LayoutInflater inflator = (LayoutInflater) mContext\r
+                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);\r
+            view = inflator.inflate(R.layout.list_item, null);\r
+        }\r
+    \r
+        if (mFiles != null && mFiles.size() > position) {\r
+            OCFile file = mFiles.get(position);\r
+            TextView fileName = (TextView) view.findViewById(R.id.Filename);\r
+            String name = file.getFileName();\r
+\r
+            fileName.setText(name);\r
+            ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);\r
+            fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));\r
+            ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);\r
+            FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();\r
+            FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();\r
+            if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {\r
+                localStateView.setImageResource(R.drawable.downloading_file_indicator);\r
+                localStateView.setVisibility(View.VISIBLE);\r
+            } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {\r
+                localStateView.setImageResource(R.drawable.uploading_file_indicator);\r
+                localStateView.setVisibility(View.VISIBLE);\r
+            } else if (file.isDown()) {\r
+                localStateView.setImageResource(R.drawable.local_file_indicator);\r
+                localStateView.setVisibility(View.VISIBLE);\r
+            } else {\r
+                localStateView.setVisibility(View.INVISIBLE);\r
+            }\r
+            \r
+            TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);\r
+            TextView lastModV = (TextView) view.findViewById(R.id.last_mod);\r
+            ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);\r
+            \r
+            if (!file.isDirectory()) {\r
+                fileSizeV.setVisibility(View.VISIBLE);\r
+                fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));\r
+                lastModV.setVisibility(View.VISIBLE);\r
+                lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));\r
+                // this if-else is needed even thoe fav icon is visible by default\r
+                // because android reuses views in listview\r
+                if (!file.keepInSync()) {\r
+                    view.findViewById(R.id.imageView3).setVisibility(View.GONE);\r
+                } else {\r
+                    view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);\r
+                }\r
+                \r
+                ListView parentList = (ListView)parent;\r
+                if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) { \r
+                    checkBoxV.setVisibility(View.GONE);\r
+                } else {\r
+                    if (parentList.isItemChecked(position)) {\r
+                        checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);\r
+                    } else {\r
+                        checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);\r
+                    }\r
+                    checkBoxV.setVisibility(View.VISIBLE);\r
+                }\r
+                \r
+            } \r
+            else {\r
+                \r
+                fileSizeV.setVisibility(View.VISIBLE);\r
+                fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));\r
+                lastModV.setVisibility(View.VISIBLE);\r
+                lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));\r
+               checkBoxV.setVisibility(View.GONE);\r
+               view.findViewById(R.id.imageView3).setVisibility(View.GONE);\r
+            }\r
+        }\r
+\r
+        return view;\r
+    }\r
+\r
+    @Override\r
+    public int getViewTypeCount() {\r
+        return 1;\r
+    }\r
+\r
+    @Override\r
+    public boolean hasStableIds() {\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public boolean isEmpty() {\r
+        return (mFiles == null || mFiles.isEmpty());\r
+    }\r
+\r
+    /**\r
+     * Change the adapted directory for a new one\r
+     * @param directory                 New file to adapt. Can be NULL, meaning "no content to adapt".\r
+     * @param updatedStorageManager     Optional updated storage manager; used to replace mStorageManager if is different (and not NULL)\r
+     */\r
+    public void swapDirectory(OCFile directory, DataStorageManager updatedStorageManager) {\r
+        mFile = directory;\r
+        if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {\r
+            mStorageManager = updatedStorageManager;\r
+            mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
+        }\r
+        if (mStorageManager != null) {\r
+            mFiles = mStorageManager.getDirectoryContent(mFile);\r
+        } else {\r
+            mFiles = null;\r
+        }\r
+        notifyDataSetChanged();\r
+    }\r
+    \r
+}\r
index 0634965..c674442 100644 (file)
@@ -63,6 +63,9 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
 public class OCFileListFragment extends ExtendedListFragment implements EditNameDialogListener, ConfirmationDialogFragmentListener {
     
     private static final String TAG = OCFileListFragment.class.getSimpleName();
+
+    private static final String MY_PACKAGE = OCFileListFragment.class.getPackage() != null ? OCFileListFragment.class.getPackage().getName() : "com.owncloud.android.ui.fragment";
+    private static final String EXTRA_FILE = MY_PACKAGE + ".extra.FILE";
     
     private OCFileListFragment.ContainerActivity mContainerActivity;
     
@@ -94,7 +97,10 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         Log_OC.e(TAG, "onActivityCreated() start");
-        mAdapter = new FileListListAdapter(mContainerActivity.getInitialDirectory(), mContainerActivity.getStorageManager(), getActivity(), mContainerActivity);
+        mAdapter = new FileListListAdapter(getActivity(), mContainerActivity);
+        if (savedInstanceState != null) {
+            mFile = savedInstanceState.getParcelable(EXTRA_FILE);
+        }
         setListAdapter(mAdapter);
         
         registerForContextMenu(getListView());
@@ -103,6 +109,15 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
         mHandler = new Handler();
 
     }
+    
+    /**
+     * Saves the current listed folder.
+     */
+    @Override
+    public void onSaveInstanceState (Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putParcelable(EXTRA_FILE, mFile);
+    }
 
 
     /**
@@ -125,7 +140,6 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
         if (file != null) {
             if (file.isDirectory()) { 
                 // update state and view of this fragment
-                mFile = file;
                 listDirectory(file);
                 // then, notify parent activity to let it update its state and view, and other fragments
                 mContainerActivity.onBrowsedDownTo(file);
@@ -390,14 +404,6 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
         
         
         /**
-         * Callback method invoked when the parent activity is fully created to get the directory to list firstly.
-         * 
-         * @return  Directory to list firstly. Can be NULL.
-         */
-        public OCFile getInitialDirectory();
-        
-        
-        /**
          * Callback method invoked when a the 'transfer state' of a file changes.
          * 
          * This happens when a download or upload is started or ended for a file.
index 1c1e0f6..0a60305 100644 (file)
@@ -16,7 +16,6 @@
  */
 package com.owncloud.android.ui.preview;
 
-import android.accounts.Account;
 import android.app.Dialog;
 import android.app.ProgressDialog;
 import android.content.BroadcastReceiver;
@@ -33,7 +32,6 @@ import android.view.View;
 import android.view.View.OnTouchListener;
 
 import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
 import com.actionbarsherlock.view.MenuItem;
 import com.actionbarsherlock.view.Window;
 import com.owncloud.android.authentication.AccountUtils;
@@ -52,7 +50,7 @@ import com.owncloud.android.Log_OC;
 import com.owncloud.android.R;
 
 /**
- *  Used as an utility to preview image files contained in an ownCloud account.
+ *  Holds a swiping galley where image files contained in an ownCloud directory are shown
  *  
  *  @author David A. Velasco
  */
@@ -65,9 +63,6 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
     public static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW";
     private static final String KEY_WAITING_FOR_BINDER = "WAITING_FOR_BINDER";
     
-    private OCFile mFile;
-    private OCFile mParentFolder;  
-    private Account mAccount;
     private DataStorageManager mStorageManager;
     
     private ViewPager mViewPager; 
@@ -88,53 +83,35 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
-        mAccount = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
-        if (mFile == null) {
-            throw new IllegalStateException("Instanced with a NULL OCFile");
-        }
-        if (mAccount == null) {
-            throw new IllegalStateException("Instanced with a NULL ownCloud Account");
-        }
-        if (!mFile.isImage()) {
-            throw new IllegalArgumentException("Non-image file passed as argument");
-        }
         requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
         setContentView(R.layout.preview_image_activity);
-    
+        
         ActionBar actionBar = getSupportActionBar();
         actionBar.setDisplayHomeAsUpEnabled(true);
-        actionBar.setTitle(mFile.getFileName());
         actionBar.hide();
         
         mFullScreen = true;
-        
-        mStorageManager = new FileDataStorageManager(mAccount, getContentResolver());
-        mParentFolder = mStorageManager.getFileById(mFile.getParentId());
-        if (mParentFolder == null) {
-            // should not be necessary
-            mParentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
-        }
-
         if (savedInstanceState != null) {
             mRequestWaitingForBinder = savedInstanceState.getBoolean(KEY_WAITING_FOR_BINDER);
         } else {
             mRequestWaitingForBinder = false;
         }
-        
-        createViewPager();
-
     }
 
-    private void createViewPager() {
-        mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), mParentFolder, mAccount, mStorageManager);
+    private void initViewPager() {
+        OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId());
+        if (parentFolder == null) {
+            // should not be necessary
+            parentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
+        }
+        mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, getAccount(), mStorageManager);
         mViewPager = (ViewPager) findViewById(R.id.fragmentPager);
-        int position = mPreviewImagePagerAdapter.getFilePosition(mFile);
+        int position = mPreviewImagePagerAdapter.getFilePosition(getFile());
         position = (position >= 0) ? position : 0;
         mViewPager.setAdapter(mPreviewImagePagerAdapter); 
         mViewPager.setOnPageChangeListener(this);
         mViewPager.setCurrentItem(position);
-        if (position == 0 && !mFile.isDown()) {
+        if (position == 0 && !getFile().isDown()) {
             // this is necessary because mViewPager.setCurrentItem(0) just after setting the adapter does not result in a call to #onPageSelected(0) 
             mRequestWaitingForBinder = true;
         }
@@ -320,9 +297,9 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
         if (mDownloaderBinder == null) {
             Log_OC.d(TAG, "requestForDownload called without binder to download service");
             
-        } else if (!mDownloaderBinder.isDownloading(mAccount, file)) {
+        } else if (!mDownloaderBinder.isDownloading(getAccount(), file)) {
             Intent i = new Intent(this, FileDownloader.class);
-            i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
+            i.putExtra(FileDownloader.EXTRA_ACCOUNT, getAccount());
             i.putExtra(FileDownloader.EXTRA_FILE, file);
             startService(i);
         }
@@ -385,7 +362,7 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
         public void onReceive(Context context, Intent intent) {
             String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME);
             String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
-            if (mAccount.name.equals(accountName) && 
+            if (getAccount().name.equals(accountName) && 
                     downloadedRemotePath != null) {
 
                 OCFile file = mStorageManager.getFileByPath(downloadedRemotePath);
@@ -436,7 +413,33 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
 
     @Override
     protected void onAccountSet(boolean stateWasRecovered) {
-        // TODO
+        if (getAccount() != null) {
+            OCFile file = getFile();
+            /// Validate handled file  (first image to preview)
+            if (file == null) {
+                throw new IllegalStateException("Instanced with a NULL OCFile");
+            }
+            if (!file.isImage()) {
+                throw new IllegalArgumentException("Non-image file passed as argument");
+            }
+            mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
+            file = mStorageManager.getFileById(file.getFileId()); 
+            if (file != null) {
+                /// Refresh the activity according to the Account and OCFile set
+                setFile(file);  // reset after getting it fresh from mStorageManager
+                getSupportActionBar().setTitle(getFile().getFileName());
+                //if (!stateWasRecovered) {
+                    initViewPager();
+                //}
+
+            } else {
+                // handled file not in the current Account
+                finish();
+            }
+            
+        } else {
+            Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+        }
     }
     
     
index a253624..3db62e9 100644 (file)
@@ -40,8 +40,6 @@ import com.owncloud.android.ui.fragment.FileFragment;
 //public class PreviewImagePagerAdapter extends PagerAdapter {
 public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
     
-    private static final String TAG = PreviewImagePagerAdapter.class.getSimpleName();
-            
     private Vector<OCFile> mImageFiles;
     private Account mAccount;
     private Set<Object> mObsoleteFragments;
@@ -51,14 +49,6 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
     
     private Map<Integer, FileFragment> mCachedFragments;
 
-    /*
-    private final FragmentManager mFragmentManager;
-    private FragmentTransaction mCurTransaction = null;
-    private ArrayList<Fragment.SavedState> mSavedState = new ArrayList<Fragment.SavedState>();
-    private ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
-    private Fragment mCurrentPrimaryItem = null;
-    */
-
     /**
      * Constructor.
      * 
@@ -188,8 +178,6 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
         return mDownloadErrors.contains(Integer.valueOf(position));
     }
 
-
-    
     /* -*
      * Called when a change in the shown pages is going to start being made.
      * 
index 7ea9f52..366dd9f 100644 (file)
@@ -61,6 +61,7 @@ import com.owncloud.android.operations.OnRemoteOperationListener;
 import com.owncloud.android.operations.RemoteOperation;
 import com.owncloud.android.operations.RemoteOperationResult;
 import com.owncloud.android.operations.RemoveFileOperation;
+import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.fragment.ConfirmationDialogFragment;
 import com.owncloud.android.ui.fragment.FileFragment;
@@ -477,8 +478,8 @@ public class PreviewMediaFragment extends FileFragment implements
     
     private void startFullScreenVideo() {
         Intent i = new Intent(getActivity(), PreviewVideoActivity.class);
-        i.putExtra(PreviewVideoActivity.EXTRA_ACCOUNT, mAccount);
-        i.putExtra(PreviewVideoActivity.EXTRA_FILE, getFile());
+        i.putExtra(FileActivity.EXTRA_ACCOUNT, mAccount);
+        i.putExtra(FileActivity.EXTRA_FILE, getFile());
         i.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, mVideoPreview.isPlaying());
         mVideoPreview.pause();
         i.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, mVideoPreview.getCurrentPosition());
@@ -661,7 +662,6 @@ public class PreviewMediaFragment extends FileFragment implements
                                                             mStorageManager);
             mLastRemoteOperation.execute(mAccount, getSherlockActivity(), this, mHandler, getSherlockActivity());
             
-            boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
             getActivity().showDialog(FileDisplayActivity.DIALOG_SHORT_WAIT);
         }
     }
@@ -716,7 +716,6 @@ public class PreviewMediaFragment extends FileFragment implements
     }
     
     private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) {
-        boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
         getActivity().dismissDialog(FileDisplayActivity.DIALOG_SHORT_WAIT);
         
         if (result.isSuccess()) {
index c4b6dce..0cab2e2 100644 (file)
@@ -18,7 +18,6 @@
 package com.owncloud.android.ui.preview;
 
 import android.accounts.Account;
-import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.DialogInterface;
 import android.content.Intent;
@@ -28,16 +27,18 @@ import android.media.MediaPlayer.OnErrorListener;
 import android.media.MediaPlayer.OnPreparedListener;
 import android.net.Uri;
 import android.os.Bundle;
-import android.view.MotionEvent;
 import android.widget.MediaController;
 import android.widget.VideoView;
 
 import com.owncloud.android.Log_OC;
 import com.owncloud.android.R;
+import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.media.MediaService;
+import com.owncloud.android.ui.activity.FileActivity;
 
 /**
  *  Activity implementing a basic video player.
@@ -49,14 +50,8 @@ import com.owncloud.android.media.MediaService;
  *  
  *  @author David A. Velasco
  */
-public class PreviewVideoActivity extends Activity implements OnCompletionListener, OnPreparedListener, OnErrorListener {
+public class PreviewVideoActivity extends FileActivity implements OnCompletionListener, OnPreparedListener, OnErrorListener {
 
-    /** Key to receive an {@link OCFile} to play as an extra value in an {@link Intent} */
-    public static final String EXTRA_FILE = "FILE";
-    
-    /** Key to receive the ownCloud {@link Account} where the file to play is saved as an extra value in an {@link Intent} */
-    public static final String EXTRA_ACCOUNT = "ACCOUNT";
-    
     /** Key to receive a flag signaling if the video should be started immediately */
     public static final String EXTRA_AUTOPLAY = "AUTOPLAY";
     
@@ -65,8 +60,8 @@ public class PreviewVideoActivity extends Activity implements OnCompletionListen
     
     private static final String TAG = PreviewVideoActivity.class.getSimpleName();
 
-    private OCFile mFile;                       // video file to play
-    private Account mAccount;                   // ownCloud account holding mFile
+    private DataStorageManager mStorageManager;
+    
     private int mSavedPlaybackPosition;         // in the unit time handled by MediaPlayer.getCurrentPosition()
     private boolean mAutoplay;                  // when 'true', the playback starts immediately with the activity
     private VideoView mVideoPlayer;             // view to play the file; both performs and show the playback
@@ -91,14 +86,10 @@ public class PreviewVideoActivity extends Activity implements OnCompletionListen
     
         if (savedInstanceState == null) {
             Bundle extras = getIntent().getExtras();
-            mFile = extras.getParcelable(EXTRA_FILE);
-            mAccount = extras.getParcelable(EXTRA_ACCOUNT);
             mSavedPlaybackPosition = extras.getInt(EXTRA_START_POSITION);
             mAutoplay = extras.getBoolean(EXTRA_AUTOPLAY);
             
         } else {
-            mFile = savedInstanceState.getParcelable(EXTRA_FILE);
-            mAccount = savedInstanceState.getParcelable(EXTRA_ACCOUNT);
             mSavedPlaybackPosition = savedInstanceState.getInt(EXTRA_START_POSITION);
             mAutoplay = savedInstanceState.getBoolean(EXTRA_AUTOPLAY);
         }
@@ -112,34 +103,6 @@ public class PreviewVideoActivity extends Activity implements OnCompletionListen
           
         // keep the screen on while the playback is performed (prevents screen off by battery save)
         mVideoPlayer.setKeepScreenOn(true);
-        
-        if (mFile != null) {
-            if (mFile.isDown()) {
-                mVideoPlayer.setVideoPath(mFile.getStoragePath());
-                
-            } else if (mAccount != null) {
-                // not working yet
-                String url;
-                try {
-                    url = AccountUtils.constructFullURLForAccount(this, mAccount) + mFile.getRemotePath();
-                    mVideoPlayer.setVideoURI(Uri.parse(url));
-                } catch (AccountNotFoundException e) {
-                    onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
-                }
-                
-            } else {
-                onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
-            }
-            
-            // create and prepare control panel for the user
-            mMediaController = new MediaController(this);
-            mMediaController.setMediaPlayer(mVideoPlayer);
-            mMediaController.setAnchorView(mVideoPlayer);
-            mVideoPlayer.setMediaController(mMediaController);
-            
-        } else {
-            onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_nothing_to_play);
-        }
     }    
     
     
@@ -150,8 +113,6 @@ public class PreviewVideoActivity extends Activity implements OnCompletionListen
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
         Log_OC.e(TAG, "ACTIVITY\t\tonSaveInstanceState");
-        outState.putParcelable(PreviewVideoActivity.EXTRA_FILE, mFile);
-        outState.putParcelable(PreviewVideoActivity.EXTRA_ACCOUNT, mAccount);
         outState.putInt(PreviewVideoActivity.EXTRA_START_POSITION, mVideoPlayer.getCurrentPosition());
         outState.putBoolean(PreviewVideoActivity.EXTRA_AUTOPLAY , mVideoPlayer.isPlaying());
     }
@@ -168,39 +129,6 @@ public class PreviewVideoActivity extends Activity implements OnCompletionListen
     }
 
     
-    @Override
-    public void onResume() {
-        super.onResume();
-        Log_OC.e(TAG, "ACTIVTIY\t\tonResume");
-    }
-
-    
-    @Override
-    public void onStart() {
-        super.onStart();
-        Log_OC.e(TAG, "ACTIVTIY\t\tonStart");
-    }
-    
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        Log_OC.e(TAG, "ACTIVITY\t\tonDestroy");
-    }
-    
-    @Override
-    public void onStop() {
-        super.onStop();
-        Log_OC.e(TAG, "ACTIVTIY\t\tonStop");
-    }
-    
-    
-    @Override
-    public void onPause() {
-        super.onPause();
-        Log_OC.e(TAG, "ACTIVTIY\t\tonPause");
-    }
-    
-    
     /** 
      * Called when the file is ready to be played.
      * 
@@ -264,25 +192,48 @@ public class PreviewVideoActivity extends Activity implements OnCompletionListen
     }
     
     
-    /**  
-     * Screen touches trigger the appearance of the control panel for a limited time.
-     *
-     * {@inheritDoc}
-     */
     @Override
-    public boolean onTouchEvent (MotionEvent ev){ 
-        /*if (ev.getAction() == MotionEvent.ACTION_DOWN) {
-            if (mMediaController.isShowing()) {
-                mMediaController.hide();
+    protected void onAccountSet(boolean stateWasRecovered) {
+        if (getAccount() != null) {
+            OCFile file = getFile();
+            /// Validate handled file  (first image to preview)
+            if (file == null) {
+                throw new IllegalStateException("Instanced with a NULL OCFile");
+            }
+            if (!file.isVideo()) {
+                throw new IllegalArgumentException("Non-video file passed as argument");
+            }
+            mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
+            file = mStorageManager.getFileById(file.getFileId()); 
+            if (file != null) {
+                if (file.isDown()) {
+                    mVideoPlayer.setVideoPath(file.getStoragePath());
+                    
+                } else {
+                    // not working yet
+                    String url;
+                    try {
+                        url = AccountUtils.constructFullURLForAccount(this, getAccount()) + file.getRemotePath();
+                        mVideoPlayer.setVideoURI(Uri.parse(url));
+                    } catch (AccountNotFoundException e) {
+                        onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
+                    }
+                }
+                
+                // create and prepare control panel for the user
+                mMediaController = new MediaController(this);
+                mMediaController.setMediaPlayer(mVideoPlayer);
+                mMediaController.setAnchorView(mVideoPlayer);
+                mVideoPlayer.setMediaController(mMediaController);
+                
             } else {
-                mMediaController.show(MediaService.MEDIA_CONTROL_SHORT_LIFE);
+                finish();
             }
-            return true;        
         } else {
-            return false;
-        }*/
-        return false;
-    }
+            Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+            finish();
+        }
+   }
 
 
 }
\ No newline at end of file