Added feature for remembering last upload location when sharing a file. Also added...
authorMagnus Sjoqvist <magnus.b.j.sjoqvist@gmail.com>
Wed, 8 Oct 2014 13:15:57 +0000 (15:15 +0200)
committerMagnus Sjoqvist <magnus.b.j.sjoqvist@gmail.com>
Tue, 14 Oct 2014 07:34:49 +0000 (09:34 +0200)
res/values-it/strings.xml
res/values-sv/strings.xml
res/values/strings.xml
res/xml/preferences.xml
src/com/owncloud/android/ui/activity/Preferences.java
src/com/owncloud/android/ui/activity/Uploader.java

index b21685e..bbd3c4f 100644 (file)
@@ -30,6 +30,8 @@
   <string name="prefs_recommend">Consiglia ad un amico</string>
   <string name="prefs_feedback">Segnalazioni</string>
   <string name="prefs_imprint">Imprint</string>
+  <string name="prefs_remember_last_upload_location_summary">Salvare l\'ultimo percorso usata per l\'upload</string>
+  <string name="prefs_remember_last_share_location">Salva la posizione</string>
   <string name="recommend_subject">Prova %1$s sul tuo smartphone!</string>
   <string name="recommend_text">\"Vorrei invitarti ad usare %1$s sul tuo smartphone!\nScaricalo qui: %2$s\"\n\t</string>
   <string name="auth_check_server">Verifica server</string>
index 8be33d9..10727c0 100644 (file)
@@ -30,6 +30,8 @@
   <string name="prefs_recommend">Rekommendera till en vän</string>
   <string name="prefs_feedback">Feedback</string>
   <string name="prefs_imprint">Imprint</string>
+  <string name="prefs_remember_last_share_location">Kom ihåg uppladdningsplats</string>
+  <string name="prefs_remember_last_upload_location_summary">Kom ihåg senaste uppladdningsplatsen för delning</string>
   <string name="recommend_subject">Försök %1$s på din smarttelefon!</string>
   <string name="recommend_text">\"Jag vill bjuda in dig att använda %1$s på din smartphone\nLadda ner här: %2$s\"\n\t</string>
   <string name="auth_check_server">Kontrollera Server</string>
index c1a1e2c..cf4dffb 100644 (file)
     <string name="prefs_recommend">Recommend to a friend</string>
     <string name="prefs_feedback">Feedback</string>
     <string name="prefs_imprint">Imprint</string>
-    
-       <string name="recommend_subject">"Try %1$s on your smartphone!"</string>
+    <string name="prefs_remember_last_share_location">Remember share location</string>
+    <string name="prefs_remember_last_upload_location_summary">Remember last share upload location</string>
+
+
+    <string name="recommend_subject">"Try %1$s on your smartphone!"</string>
        <string name="recommend_text">"I want to invite you to use %1$s on your smartphone!\nDownload here: %2$s"
        </string>
 
        <string name="network_error_socket_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
        <string name="network_error_connect_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
        <string name="network_host_not_available">The operation couldn\'t be completed, server is unavailable</string>
-       
 </resources>
index 69b4b28..8aa945c 100644 (file)
@@ -31,6 +31,9 @@
     <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_uploading" 
                         android:title="@string/prefs_instant_upload"  
                         android:summary="@string/prefs_instant_upload_summary"/>
+    <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="save_last_upload_location"
+        android:title="@string/prefs_remember_last_share_location"
+        android:summary="@string/prefs_remember_last_upload_location_summary"/>
     <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:dependency="instant_uploading" 
                                        android:disableDependentsState="true" 
                                        android:title="@string/instant_upload_on_wifi" 
index 1f18ca8..32bd11d 100644 (file)
@@ -38,6 +38,7 @@ import com.actionbarsherlock.view.MenuItem;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.db.DbHandler;
+import com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle;
 import com.owncloud.android.utils.DisplayUtils;
 import com.owncloud.android.utils.Log_OC;
 
@@ -53,6 +54,7 @@ public class Preferences extends SherlockPreferenceActivity {
     private static final String TAG = "OwnCloudPreferences";
     private DbHandler mDbHandler;
     private CheckBoxPreference pCode;
+    private CheckBoxPreference pSaveLocation;
     //private CheckBoxPreference pLogging;
     //private Preference pLoggingHistory;
     private Preference pAboutApp;
@@ -95,8 +97,26 @@ public class Preferences extends SherlockPreferenceActivity {
             });            
             
         }
-        
-        
+
+        pSaveLocation = (CheckBoxPreferenceWithLongTitle) findPreference("save_last_upload_location");
+        if(pSaveLocation != null){
+            pSaveLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+                @Override
+                public boolean onPreferenceChange(Preference preference, Object newValue) {
+                        if( newValue instanceof Boolean)
+                        {
+                           if(!(Boolean) newValue)
+                           {
+                               SharedPreferences.Editor appPrefs = PreferenceManager
+                                       .getDefaultSharedPreferences(getApplicationContext()).edit();
+                               appPrefs.remove("last_upload_path");
+                               appPrefs.commit();
+                           }
+                        }
+                        return true;
+                    }
+            });
+        }
 
         PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("more");
         
index 16b3267..9cf8256 100644 (file)
@@ -46,10 +46,12 @@ 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;
@@ -80,6 +82,7 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro
     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;
@@ -93,7 +96,32 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro
         super.onCreate(savedInstanceState);
         getWindow().requestFeature(Window.FEATURE_NO_TITLE);
         mParents = new Stack<String>();
-        mParents.add("");
+
+
+
+
+        SharedPreferences appPreferences = PreferenceManager
+                .getDefaultSharedPreferences(getApplicationContext());
+
+        mSaveUploadLocation = appPreferences.getBoolean("save_last_upload_location", false);
+
+        if(mSaveUploadLocation)
+        {
+            String last_path = appPreferences.getString("last_upload_path", "");
+
+            if(last_path.equals("/")) {
+                mParents.add("");
+            }
+            else{
+                String[] dir_names = last_path.split("/");
+                for (String dir : dir_names)
+                    mParents.add(dir);
+            }
+        }
+        else {
+            mParents.add("");
+        }
+
         if (prepareStreamsToUpload()) {
             mAccountManager = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE);
             Account[] accounts = mAccountManager.getAccountsByType(MainApp.getAccountType());
@@ -289,6 +317,7 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro
         setContentView(R.layout.uploader_layout);
 
         String full_path = "";
+
         for (String a : mParents)
             full_path += a + "/";
         
@@ -408,6 +437,14 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro
             intent.putExtra(FileUploader.KEY_REMOTE_FILE, remote.toArray(new String[remote.size()]));
             intent.putExtra(FileUploader.KEY_ACCOUNT, mAccount);
             startService(intent);
+
+            if(mSaveUploadLocation){
+                SharedPreferences.Editor appPrefs = PreferenceManager
+                        .getDefaultSharedPreferences(getApplicationContext()).edit();
+                appPrefs.putString("last_upload_path", mUploadPath);
+                appPrefs.commit();
+            }
+
             finish();
             }