From: Magnus Sjoqvist Date: Fri, 17 Oct 2014 09:06:30 +0000 (+0200) Subject: Merge with develop X-Git-Tag: oc-android-1.7.0_signed~119^2~2^2~7 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/b6c7719415ce87d905996a4def50066415786c3e?hp=-c Merge with develop --- b6c7719415ce87d905996a4def50066415786c3e diff --combined res/values-it/strings.xml index bbd3c4f1,d4507602..7423cbfe --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@@ -30,10 -30,8 +30,10 @@@ Consiglia ad un amico Segnalazioni Imprint + Salvare l\'ultimo percorso usata per l\'upload + Salva la posizione Prova %1$s sul tuo smartphone! - \"Vorrei invitarti ad usare %1$s sul tuo smartphone!\nScaricalo qui: %2$s\"\n\t + Vorrei invitarti a usare %1$s sul tuo smartphone!\nScarica qui: %2$s Verifica server Indirizzo server https://... Nome utente @@@ -51,7 -49,9 +51,9 @@@ Non è stato ricevuto alcun contenuto. Niente da caricare. %1$s non è abilitato ad accedere al contenuto condiviso Caricamento in corso - Non ci sono file in questa cartella.\nNuovi file possono essere aggiunti con l\'opzione di menu \"Carica\". + Non c\'è niente qui. Carica qualcosa! + Caricamento in corso... + Non ci sono file in questa cartella. Tocca un file per visualizzare informazioni aggiuntive. Dimensione: Tipo: @@@ -104,7 -104,7 +106,7 @@@ I contenuti di %1$d file non possono essere sincronizzati (%2$d conflitti) Alcuni file locali sono stati trascurati %1$d file della cartella %2$s non possono essere copiati - Nella versione 1.3.16, i file caricati da questo dispositivo vengono copiati nella cartella locale %1$s per evitare la perdita dei dati quando un singolo file è sincronizzato con diversi account.\n\nA causa di questo cambiamento, tutti i file caricati nelle versioni precedenti di questa applicazione sono stati copiati nella cartella %2$s. Tuttavia, un errore non ha permesso il completamento di questa operazione durante la sincronizzazione dell\'account. Puoi, dunque, sia lasciare i file come sono e rimuovere il collegamento a %3$s, o spostare i file nella cartella %1$s e mantenere il collegamento a %4$s.\n\nIn basso sono elencati i file locali e i file remoti in %5$s ai quali sono collegati. + Dalla versione 1.3.16, i file caricati da questo dispositivo sono copiati nella cartella locale %1$s per evitare perdite di dati in caso di sincronizzazione di un singolo file con più account.\n\nA causa di questa modifica, tutti i file caricati nelle versioni precedenti di questa applicazione sono copiati nella cartella %2$s. In ogni caso, un errore ha impedito il completamento di questa operazione durante la sincronizzazione dell\'account. Puoi mantenere i file intatti e rimuovere il collegamento a %3$s o spostare i file nella cartella %1$s e mantenere il collegamento a %4$s.\n\nQui sotto sono elencati i file locali e i file remoti in %5$s ai quali sono collegati. La cartella %1$s non esiste più Sposta tutto Tutti i file sono stati spostati @@@ -169,7 -169,8 +171,8 @@@ Connessione al server di autenticazione in corso... Il server non supporta questo metodo di autenticazione %1$s non supporta account multipli - Il tuo server non ha restituito un id utente corretto, contatta un amministratore\n\t + Il tuo server non ha restituito un id utente corretto, contatta un amministratore + Impossibile eseguire l\'autenticazione su questo server Tieni aggiornato il file Rinomina @@@ -237,21 -238,11 +240,11 @@@ Anteprima dell\'immagine Questa immagine non può essere mostrata %1$s non può essere copiato nella cartella locale %2$s - Caricamento istantaneo non riuscito - Caricamenti istantanei non riusciti - Riepilogo dei caricamenti istantanei non riusciti - seleziona tutto - riprova tutti i selezionati - elimina tutti i selezionati dalla coda di caricamento - riprova a caricare l\'immagine: - Carica altre immagini - non fare niente, non sei collegato per i caricamenti istantanei - Messaggio d\'errore: - Controlla la configurazione del server, forse hai superato la tua quota. - Spiacenti, la condivisione non è abilitata sul tuo server. Contatta il tuo\n\t\tamministratore. - Impossibile condividere il file o la cartella. Assicurati che esista. + Spiacenti, la condivisione non è abilitata sul tuo server. Contatta il tuo + amministratore. + Impossibile condividere. Assicurati che il file esista Si è verificato un errore durante il tentativo di condivisione del file o della cartella - Impossibile rimuovere dalla condivisione il file o la cartella. Non esiste. + Impossibile rimuovere dalla condivisione. Assicurati che il file esista Si è verificato un errore durante il tentativo di rimuovere la condivisione del file o della cartella Invia Copia collegamento @@@ -261,4 -252,30 +254,30 @@@ Si è verificato un errore in attesa della risposta del server, l\'operazione non è stata completata Si è verificato un errore in attesa della risposta del server, l\'operazione non è stata completata L\'operazione non è stata completata, il server non è disponibile + + Non hai i permessi %s + per rinominare questo file + per eliminare questo file + per condividere questo file + per rimuovere la condivisione di questo file + per creare il file + per caricare in questa cartella + Il file non è più disponibile sul server + Account + Aggiungi account + La connessione sicura è rediretta attraverso un percorso non sicuro. + Registri + Invia cronologia + Registri applicazione ownCloud Android + Caricamento dati... + Autenticazione richiesta + Password errata + Sposta + Qui non c\'è niente. Puoi aggiungere una cartella. + Scegli + Impossibile spostare. Assicurati che il file esista + Impossibile spostare una cartella in una cartella inferiore + Il file esiste già nella cartella di destinazione + Si è verificato un errore durante il tentativo di spostare il file o la cartella + per spostare questo file diff --combined res/values-sv/strings.xml index 10727c06,be006747..7328f8ea --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@@ -30,10 -30,8 +30,10 @@@ Rekommendera till en vän Feedback Imprint + Kom ihåg uppladdningsplats + Kom ihåg senaste uppladdningsplatsen för delning Försök %1$s på din smarttelefon! - \"Jag vill bjuda in dig att använda %1$s på din smartphone\nLadda ner här: %2$s\"\n\t + Jag skulle vilja bjuda in dig till att använda %1$s på din smartphone!\nLadda ner här: %2$s Kontrollera Server Serveradress https://... Användarnamn @@@ -51,7 -49,9 +51,9 @@@ Inget innehåll mottaget. Inget att ladda upp. %1$s har inte rättighet till det delade innehållet Laddar upp - Det finns inga filer i denna mapp.\nNya filer kan läggas till med \"Ladda upp\" i menyn. + Ingenting här. Ladda upp något! + Laddar... + Det finns inga filer i den här mappen. Peka på en fil för att visa mer information. Storlek: Typ: @@@ -95,6 -95,7 +97,7 @@@ Nerladda misslyckades, måste du logga in igen Välj konto Synkroniseringen misslyckades + Synkroniseringen misslyckades, du måste logga in på nytt. Synkronisering av %1$s kunde inte slutföras Felaktigt lösenord för %1$s Konflikter uppstod @@@ -103,7 -104,6 +106,6 @@@ Innehållet i %1$d filer kunde inte synkas (%2$d konflikter) Vissa lokala filer glömdes %1$d filer från %2$s mappar kunde inte kopieras till - Från och med version 1.3.16, kopieras uppladdade filer från den här enheten till den lokala %1$s mappen för att förhindra förlust av data när en enda fil synkroniseras med flera konton.\n\nPå grund av denna förändring har alla filer som laddats upp i tidigare versioner av denna app kopierats till %2$s mappen. Men ett fel förhindrade slutförande av denna operation under synkronisering. Du kan antingen lämna fil(er) som det är och ta bort länken till %3$s, eller flytta fil(er) till %1$s mappen och behålla länken till %4$s.\n\nNedan listas dom lokala fil(er) och fjärrfil(er) i %5$s dom var länkade till. Mappen %1$s existerar inte längre Flytta allt Alla filer flyttades @@@ -168,7 -168,8 +170,8 @@@ Ansluter till autentiseringsservern... Servern har inte stöd för denna autentiseringsmetod %1$s har inte stöd för multipla konton - Din server returnerar inte ett korrekt användare id, vänligen kontakta en administratör\n\t + Din server returnerar inte ett korrekt användare id, vänligen kontakta en administratör + Kan inte autentisera mot servern Håll filen uppdaterad Byt namn @@@ -236,21 -237,9 +239,9 @@@ Förhandsvisa bild Denna bild kan inte visas %1$s kunde inte kopieras till %2$s lokal mapp - Fel vid direktuppladdning\" - Misslyckades vid direktuppladdning - Sammanfattning av alla misslyckade uppladdningar - välj alla - försökt igen med alla valda - radera alla valda från uppladdningskön - försök igen att ladda upp bilden: - Ladda fler bilder - Du är inte ansluten, direktuppladdning ej möjligt - Felmeddelande: - Vänligen kontrollera dina serverkonfiguration. Din kvot kan ha överskridits. - Ledsen, delning är inte aktiverat på din server. Vänligen kontakta din\n\t\tadministratör. - Kan inte dela denna fil eller mapp. Se till att den existerar + Ledsen, delning är inte aktiverat på din server. Vänligen kontakta din + administratör. Ett fel uppstod vid försök att dela denna fil eller mapp - Kan inte ta bort delningen för denna fil eller mapp. Den existerar inte. Ett fel uppstod vid försök att sluta dela denna fil eller mapp Skicka Kopiera länk @@@ -260,4 -249,23 +251,23 @@@ Ett fel uppstod i väntan på servern, operationen kunde inte ha gjorts Ett fel uppstod i väntan på servern, operationen kunde inte ha gjorts Åtgärden kunte inte slutföras, servern är ej tillgänglig + + Du har inga rättigheter %s + att döpa om denna fil + att radera denna fil + att dela denna fil + att avbryta delningen utav denna fil + att skapa filen + att ladda upp i den här mappen + Filen är inte längre tillgänglig på servern + Konton + Lägg till konto + Laddar data... + Autentisering krävs + Fel lösenord + Flytta + Ingenting här. Du kan skapa en mapp! + Välj + Gick inte att flytta. Vänligen kontrollera att filen existerar + att flytta den här filen diff --combined res/values/strings.xml index cf4dffbd,4c7cf34d..30c9557b --- a/res/values/strings.xml +++ b/res/values/strings.xml @@@ -31,13 -31,9 +31,11 @@@ Recommend to a friend Feedback Imprint - + Remember share location + Remember last share upload location + - - "Try %1$s on your smartphone!" - "I want to invite you to use %1$s on your smartphone!\nDownload here: %2$s" - + "Try %1$s on your smartphone!" + "I want to invite you to use %1$s on your smartphone!\nDownload here: %2$s" Check Server Server address https://… @@@ -56,7 -52,9 +54,9 @@@ No content was received. Nothing to upload. %1$s is not allowed to access the shared content Uploading - There are no files in this folder.\nNew files can be added with the \"Upload\" menu option. + Nothing in here. Upload something! + Loading... + There are no files in this folder. Tap on a file to display additional information. Size: Type: @@@ -256,9 -254,9 +256,9 @@@ Sorry, sharing is not enabled on your server. Please contact your administrator. - Unable to share this file or folder. Please, make sure it exists + Unable to share. Please check whether the file exists An error occurred while trying to share this file or folder - Unable to unshare this file or folder. It does not exist. + Unable to unshare. Please check whether the file exists An error occurred while trying to unshare this file or folder Send @@@ -272,4 -270,36 +272,36 @@@ An error occurred while waiting for the server, the operation couldn\'t have been done An error occurred while waiting for the server, the operation couldn\'t have been done The operation couldn\'t be completed, server is unavailable ++ + + + You do not have permission %s + to rename this file + to delete this file + to share this file + to unshare this file + to create the file + to upload in this folder + The file is no longer available on the server + + Accounts + Add account + Secure connection is redirected through an unsecured route. + + Logs + Send History + ownCloud Android app logs + Loading data... + + Authentication required + Wrong password + Move + Nothing in here. You can add a folder! + Choose + + Unable to move. Please check whether the file exists + It is not possible to move a folder into a descendant + The file exists already in the destination folder + An error occurred while trying to move this file or folder + to move this file - diff --combined res/xml/preferences.xml index 8aa945cf,945e853c..77ef6ed1 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@@ -18,22 -18,20 +18,23 @@@ along with this program. If not, see . --> - + + + - + { private static final String TAG = "OwnCloudPreferences"; + private DbHandler mDbHandler; private CheckBoxPreference pCode; + private CheckBoxPreference pSaveLocation; - //private CheckBoxPreference pLogging; - //private Preference pLoggingHistory; private Preference pAboutApp; + private PreferenceCategory mAccountsPrefCategory = null; + private final Handler mHandler = new Handler(); + private String mAccountName; + private boolean mShowContextMenu = false; + @SuppressWarnings("deprecation") @Override @@@ -66,22 -82,39 +84,39 @@@ super.onCreate(savedInstanceState); mDbHandler = new DbHandler(getBaseContext()); addPreferencesFromResource(R.xml.preferences); - //populateAccountList(); + ActionBar actionBar = getSherlock().getActionBar(); actionBar.setIcon(DisplayUtils.getSeasonalIconId()); actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setTitle(R.string.actionbar_settings); - Preference p = findPreference("manage_account"); - if (p != null) - p.setOnPreferenceClickListener(new OnPreferenceClickListener() { + // Load the accounts category for adding the list of accounts + mAccountsPrefCategory = (PreferenceCategory) findPreference("accounts_category"); + + ListView listView = getListView(); + listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override - public boolean onPreferenceClick(Preference preference) { - Intent i = new Intent(getApplicationContext(), AccountSelectActivity.class); - startActivity(i); - return true; + public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { + ListView listView = (ListView) parent; + ListAdapter listAdapter = listView.getAdapter(); + Object obj = listAdapter.getItem(position); + + if (obj != null && obj instanceof LongClickableCheckBoxPreference) { + mShowContextMenu = true; + mAccountName = obj.toString(); + + Preferences.this.openContextMenu(listView); + + View.OnLongClickListener longListener = (View.OnLongClickListener) obj; + return longListener.onLongClick(view); + } + return false; } }); - + + // Register context menu for list of preferences. + registerForContextMenu(getListView()); + pCode = (CheckBoxPreference) findPreference("set_pincode"); if (pCode != null){ pCode.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @@@ -98,23 -131,6 +133,24 @@@ } + pSaveLocation = (CheckBoxPreferenceWithLongTitle) findPreference("save_last_upload_location"); + if(pSaveLocation != null){ + pSaveLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + //The saved path is removed when the preference is turned off + if( newValue instanceof Boolean && !(Boolean) newValue) { + SharedPreferences.Editor appPrefs = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()).edit(); + appPrefs.remove("last_upload_path"); - appPrefs.apply(); ++ appPrefs.commit(); + } + return true; + } + }); + } + ++ PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("more"); boolean helpEnabled = getResources().getBoolean(R.bool.help_enabled); @@@ -236,44 -252,66 +272,66 @@@ Log_OC.e(TAG, "Error while showing about dialog", e); } } - - /* DISABLED FOR RELEASE UNTIL FIXED - pLogging = (CheckBoxPreference) findPreference("log_to_file"); - if (pLogging != null) { - pLogging.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - - String logpath = Environment.getExternalStorageDirectory()+File.separator+"owncloud"+File.separator+"log"; - - if(!pLogging.isChecked()) { - Log_OC.d("Debug", "start logging"); - Log_OC.v("PATH", logpath); - Log_OC.startLogging(logpath); - } - else { - Log_OC.d("Debug", "stop logging"); - Log_OC.stopLogging(); - } - return true; - } - }); - } - - pLoggingHistory = (Preference) findPreference("log_history"); - if (pLoggingHistory != null) { - pLoggingHistory.setOnPreferenceClickListener(new OnPreferenceClickListener() { - - @Override - public boolean onPreferenceClick(Preference preference) { - Intent intent = new Intent(getApplicationContext(),LogHistoryActivity.class); - startActivity(intent); - return true; + } + + @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { + + // Filter for only showing contextual menu when long press on the + // accounts + if (mShowContextMenu) { + getMenuInflater().inflate(R.menu.account_picker_long_click, menu); + mShowContextMenu = false; + } + super.onCreateContextMenu(menu, v, menuInfo); + } + + /** + * 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} + */ + @Override + public boolean onContextItemSelected(android.view.MenuItem item) { + AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE); + Account accounts[] = am.getAccountsByType(MainApp.getAccountType()); + for (Account a : accounts) { + if (a.name.equals(mAccountName)) { + if (item.getItemId() == R.id.change_password) { + + // Change account 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) { + + // Remove account + am.removeAccount(a, this, mHandler); + } } - }); - } - */ - + } + + return true; + } + + @Override + public void run(AccountManagerFuture future) { + if (future.isDone()) { + Account a = AccountUtils.getCurrentOwnCloudAccount(this); + String accountName = ""; + if (a == null) { + Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType()); + if (accounts.length != 0) + accountName = accounts[0].name; + AccountUtils.setCurrentOwnCloudAccount(this, accountName); + } + addAccountsCheckboxPreferences(); + } } @Override @@@ -282,6 -320,9 +340,9 @@@ SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); boolean state = appPrefs.getBoolean("set_pincode", false); pCode.setChecked(state); + + // Populate the accounts category with the list of accounts + addAccountsCheckboxPreferences(); } @Override @@@ -318,5 -359,107 +379,107 @@@ mDbHandler.close(); super.onDestroy(); } - + + /** + * Create the list of accounts that has been added into the app + */ + @SuppressWarnings("deprecation") + private void addAccountsCheckboxPreferences() { + + // Remove accounts in case list is refreshing for avoiding to have + // duplicate items + if (mAccountsPrefCategory.getPreferenceCount() > 0) { + mAccountsPrefCategory.removeAll(); + } + + AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE); + Account accounts[] = am.getAccountsByType(MainApp.getAccountType()); + Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()); + + if (am.getAccountsByType(MainApp.getAccountType()).length == 0) { + // Show create account screen if there isn't any account + am.addAccount(MainApp.getAccountType(), null, null, null, this, + null, + null); + } + else { + + for (Account a : accounts) { + LongClickableCheckBoxPreference accountPreference = new LongClickableCheckBoxPreference(this); + accountPreference.setKey(a.name); + accountPreference.setTitle(a.name); + mAccountsPrefCategory.addPreference(accountPreference); + + // Check the current account that is being used + if (a.name.equals(currentAccount.name)) { + accountPreference.setChecked(true); + } else { + accountPreference.setChecked(false); + } + + accountPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + String key = preference.getKey(); + AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE); + Account accounts[] = am.getAccountsByType(MainApp.getAccountType()); + for (Account a : accounts) { + CheckBoxPreference p = (CheckBoxPreference) findPreference(a.name); + if (key.equals(a.name)) { + boolean accountChanged = !p.isChecked(); + p.setChecked(true); + AccountUtils.setCurrentOwnCloudAccount( + getApplicationContext(), + a.name + ); + if (accountChanged) { + // restart the main activity + Intent i = new Intent( + Preferences.this, + FileDisplayActivity.class + ); + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(i); + } else { + finish(); + } + } else { + p.setChecked(false); + } + } + return (Boolean) newValue; + } + }); + + } + + // Add Create Account preference at the end of account list if + // Multiaccount is enabled + if (getResources().getBoolean(R.bool.multiaccount_support)) { + createAddAccountPreference(); + } + + } + } + + /** + * Create the preference for allow adding new accounts + */ + private void createAddAccountPreference() { + Preference addAccountPref = new Preference(this); + addAccountPref.setKey("add_account"); + addAccountPref.setTitle(getString(R.string.prefs_add_account)); + mAccountsPrefCategory.addPreference(addAccountPref); + + addAccountPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + AccountManager am = AccountManager.get(getApplicationContext()); + am.addAccount(MainApp.getAccountType(), null, null, null, Preferences.this, null, null); + return true; + } + }); + + } + } diff --combined src/com/owncloud/android/ui/activity/Uploader.java index cfc07431,62ad44a4..d45ed4b0 --- a/src/com/owncloud/android/ui/activity/Uploader.java +++ b/src/com/owncloud/android/ui/activity/Uploader.java @@@ -32,29 -32,29 +32,29 @@@ import com.owncloud.android.authenticat import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileUploader; - import com.owncloud.android.utils.Log_OC; + import com.owncloud.android.lib.common.utils.Log_OC; import android.accounts.Account; import android.accounts.AccountManager; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Dialog; -import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.DialogInterface.OnClickListener; import android.content.Intent; +import android.content.SharedPreferences; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.os.Parcelable; +import android.preference.PreferenceManager; import android.provider.MediaStore.Audio; import android.provider.MediaStore.Images; import android.provider.MediaStore.Video; import android.view.View; -import android.view.Window; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.Button; @@@ -62,25 -62,6 +62,25 @@@ import android.widget.EditText import android.widget.SimpleAdapter; import android.widget.Toast; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockListActivity; +import com.owncloud.android.MainApp; +import com.owncloud.android.R; +import com.owncloud.android.authentication.AccountAuthenticator; +import com.owncloud.android.datamodel.FileDataStorageManager; +import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.files.services.FileUploader; +import com.owncloud.android.utils.DisplayUtils; +import com.owncloud.android.utils.Log_OC; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Stack; +import java.util.Vector; + /** * This can be used to upload things to an ownCloud instance. @@@ -88,7 -69,7 +88,7 @@@ * @author Bartek Przybylski * */ -public class Uploader extends ListActivity implements OnItemClickListener, android.view.View.OnClickListener { +public class Uploader extends SherlockListActivity implements OnItemClickListener, android.view.View.OnClickListener { private static final String TAG = "ownCloudUploader"; private Account mAccount; @@@ -99,7 -80,6 +99,7 @@@ private String mUploadPath; private FileDataStorageManager mStorageManager; private OCFile mFile; + private boolean mSaveUploadLocation; private final static int DIALOG_NO_ACCOUNT = 0; private final static int DIALOG_WAITING = 1; @@@ -111,11 -91,9 +111,11 @@@ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - getWindow().requestFeature(Window.FEATURE_NO_TITLE); mParents = new Stack(); - mParents.add(""); + + ActionBar actionBar = getSherlock().getActionBar(); + actionBar.setIcon(DisplayUtils.getSeasonalIconId()); + if (prepareStreamsToUpload()) { mAccountManager = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); Account[] accounts = mAccountManager.getAccountsByType(MainApp.getAccountType()); @@@ -126,37 -104,8 +126,37 @@@ Log_OC.i(TAG, "More then one ownCloud is available"); showDialog(DIALOG_MULTIPLE_ACCOUNT); } else { + mAccount = accounts[0]; mStorageManager = new FileDataStorageManager(mAccount, getContentResolver()); + + SharedPreferences appPreferences = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()); + + mSaveUploadLocation = appPreferences.getBoolean("save_last_upload_location", false); + + //If the users has enabled last upload path saving then populate mParents with the previous path + if(mSaveUploadLocation) + { + String last_path = appPreferences.getString("last_upload_path", ""); + // "/" equals root-directory + if(last_path.equals("/")) { + mParents.add(""); + } + else{ + String[] dir_names = last_path.split("/"); + for (String dir : dir_names) + mParents.add(dir); + } + //Make sure that path still exists, if it doesn't pop the stack and try the previous path + while(!mStorageManager.fileExists(generatePath(mParents))){ + mParents.pop(); + } + } + else { + mParents.add(""); + } + populateDirectoryList(); } } else { @@@ -339,18 -288,12 +339,18 @@@ private void populateDirectoryList() { setContentView(R.layout.uploader_layout); - String full_path = ""; - for (String a : mParents) - full_path += a + "/"; + String current_dir = mParents.peek(); + if(current_dir.equals("")){ + getActionBar().setTitle(getString(R.string.default_display_name_for_root_folder)); + } + else{ + getActionBar().setTitle(current_dir); + } + + String full_path = generatePath(mParents); Log_OC.d(TAG, "Populating view with content of : " + full_path); - + mFile = mStorageManager.getFileByPath(full_path); if (mFile != null) { Vector files = mStorageManager.getFolderContent(mFile); @@@ -374,14 -317,6 +374,14 @@@ } } + private String generatePath(Stack dirs) { + String full_path = ""; + + for (String a : dirs) + full_path += a + "/"; + return full_path; + } + private boolean prepareStreamsToUpload() { if (getIntent().getAction().equals(Intent.ACTION_SEND)) { mStreamsToUpload = new ArrayList(); @@@ -473,15 -408,6 +473,15 @@@ intent.putExtra(FileUploader.KEY_REMOTE_FILE, remote.toArray(new String[remote.size()])); intent.putExtra(FileUploader.KEY_ACCOUNT, mAccount); startService(intent); + + //If the user has enabled last upload path then save the path to shared preferences + if(mSaveUploadLocation){ + SharedPreferences.Editor appPrefs = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()).edit(); + appPrefs.putString("last_upload_path", mUploadPath); + appPrefs.apply(); + } + finish(); }