From: Magnus Sjoqvist Date: Mon, 20 Oct 2014 12:38:13 +0000 (+0200) Subject: Merge with develop X-Git-Tag: oc-android-1.7.0_signed~119^2~2^2~6 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/844790057b6519bc6e90f49c139335a97aade4c8?hp=6ed394195d05b5b36c93ac8f112ff0dd50693af8 Merge with develop --- diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index d4507602..7423cbfe 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -30,6 +30,8 @@ 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 a usare %1$s sul tuo smartphone!\nScarica qui: %2$s Verifica server diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index be006747..7328f8ea 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -30,6 +30,8 @@ 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 skulle vilja bjuda in dig till att använda %1$s på din smartphone!\nLadda ner här: %2$s Kontrollera Server diff --git a/res/values/strings.xml b/res/values/strings.xml index b021ed7e..4332c19b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -31,7 +31,9 @@ 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" @@ -271,6 +273,7 @@ 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 @@ -305,5 +308,4 @@ Instant Uploads Security - diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 3b8b3e81..bda15014 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -29,6 +29,10 @@ / --> + + @@ -56,7 +60,6 @@ - diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index d078b1e2..8840eee9 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -51,6 +51,7 @@ import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.db.DbHandler; +import com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.LongClickableCheckBoxPreference; import com.owncloud.android.utils.DisplayUtils; @@ -68,6 +69,7 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa private DbHandler mDbHandler; private CheckBoxPreference pCode; + private CheckBoxPreference pSaveLocation; private Preference pAboutApp; private PreferenceCategory mAccountsPrefCategory = null; @@ -134,6 +136,24 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa } + 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.commit(); + } + return true; + } + }); + } + + PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("more"); boolean helpEnabled = getResources().getBoolean(R.bool.help_enabled); diff --git a/src/com/owncloud/android/ui/activity/Uploader.java b/src/com/owncloud/android/ui/activity/Uploader.java index 62ad44a4..d45ed4b0 100644 --- a/src/com/owncloud/android/ui/activity/Uploader.java +++ b/src/com/owncloud/android/ui/activity/Uploader.java @@ -39,22 +39,22 @@ 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,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. @@ -69,7 +88,7 @@ import android.widget.Toast; * @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; @@ -80,6 +99,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; @@ -91,9 +111,11 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro @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()); @@ -104,8 +126,37 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro 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 { @@ -288,12 +339,18 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro 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); @@ -317,6 +374,14 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro } } + 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(); @@ -408,6 +473,15 @@ 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 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(); }