From: tobiasKaminsky Date: Fri, 20 Nov 2015 17:32:55 +0000 (+0100) Subject: Merge remote-tracking branch 'remotes/upstream/externalSD2' into beta X-Git-Tag: beta-20151122~9 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/e35e32ad52f3964a44f0f404adf699e0d18502de?ds=inline;hp=--cc Merge remote-tracking branch 'remotes/upstream/externalSD2' into beta --- e35e32ad52f3964a44f0f404adf699e0d18502de diff --cc AndroidManifest.xml index ad5dcfd5,ac57163c..12bd3f18 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@@ -58,9 -59,9 +58,11 @@@ + + - + diff --cc owncloud-android-library index 2e0f2a79,b09969d0..4f9a7528 --- a/owncloud-android-library +++ b/owncloud-android-library @@@ -1,1 -1,1 +1,1 @@@ - Subproject commit 2e0f2a79224383145d61cc15ca42c6bcc59902d5 -Subproject commit b09969d078b3a790b01c8d61a7298a37439a9f24 ++Subproject commit 4f9a7528cab0563cb234a8b817e8ee371dd6cc25 diff --cc res/values/strings.xml index 4e8f1800,4be03c1b..3750f610 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@@ -370,29 -385,9 +387,31 @@@ %1$d files %1$d files, 1 folder %1$d files, %2$d folders + Switch to grid view + Switch to list view + Common + Cache size + Upload file to server and ... + Behaviour + Copy file + Move file + Storage path + Common + do nothing + copy file to OC folder + move file to OC folder + delete origin file + Do you really want to remove selected items? + Do you really want to remove a folder and its content? + selected items + Exit + Send Log + Error Log + Stream file with external player + Do you want to stream this file with an external app?\n\nCAUTION: This may expose your password! + Set picture as + Sharing Share with Users and Groups No data shared with users yet diff --cc res/xml/preferences.xml index b4f46f98,e5908cf3..3972e9e3 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@@ -18,13 -18,16 +18,16 @@@ along with this program. If not, see . --> - + + + + - + - + diff --cc src/com/owncloud/android/MainApp.java index 6bf385ce,1cac7e53..401f6075 --- a/src/com/owncloud/android/MainApp.java +++ b/src/com/owncloud/android/MainApp.java @@@ -23,7 -23,7 +23,8 @@@ package com.owncloud.android import android.app.Activity; import android.app.Application; import android.content.Context; +import android.content.Intent; + import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Build; @@@ -56,16 -57,22 +59,24 @@@ public class MainApp extends Applicatio private static Context mContext; + private static String storagePath; + - // TODO Enable when "On Device" is recovered? - // TODO better place - // private static boolean mOnlyOnDevice = false; + private static boolean mOnlyOnDevice = false; public void onCreate(){ super.onCreate(); MainApp.mContext = getApplicationContext(); + // Setup handler for uncaught exceptions. + Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); + ++ + SharedPreferences appPrefs = + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + MainApp.storagePath = appPrefs.getString("storage_path", Environment. + getExternalStorageDirectory().getAbsolutePath()); + boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso)); OwnCloudClientManagerFactory.setUserAgent(getUserAgent()); diff --cc src/com/owncloud/android/datamodel/FileDataStorageManager.java index 1ba669ee,dc24f343..cef10bc7 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@@ -717,40 -713,71 +710,72 @@@ public class FileDataStorageManager } } - private boolean copyFile(File src, File target) { - boolean ret = true; + public void migrateStoredFiles(String srcPath, String dstPath) throws Exception { + Cursor c = null; + if (getContentResolver() != null) { + c = getContentResolver().query(ProviderTableMeta.CONTENT_URI_FILE, + null, + ProviderTableMeta.FILE_STORAGE_PATH + " IS NOT NULL", + null, + null); + + } else { + try { + c = getContentProviderClient().query(ProviderTableMeta.CONTENT_URI_FILE, + new String[]{ProviderTableMeta._ID, ProviderTableMeta.FILE_STORAGE_PATH}, + ProviderTableMeta.FILE_STORAGE_PATH + " IS NOT NULL", + null, + null); + } catch (RemoteException e) { + Log_OC.e(TAG, e.getMessage()); + throw e; + } + } + + ArrayList operations = + new ArrayList(c.getCount()); + if (c.moveToFirst()) { + do { + ContentValues cv = new ContentValues(); + long fileId = c.getLong(c.getColumnIndex(ProviderTableMeta._ID)); + String oldFileStoragePath = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)); + + if (oldFileStoragePath.startsWith(srcPath)) { + + cv.put( + ProviderTableMeta.FILE_STORAGE_PATH, + oldFileStoragePath.replaceFirst(srcPath, dstPath)); + + operations.add( + ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI). + withValues(cv). + withSelection( + ProviderTableMeta._ID + "=?", + new String[]{String.valueOf(fileId)} + ) + .build()); + } - InputStream in = null; - OutputStream out = null; + } while (c.moveToNext()); + } + c.close(); + /// 3. apply updates in batch try { - in = new FileInputStream(src); - out = new FileOutputStream(target); - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - } catch (IOException ex) { - ret = false; - } finally { - if (in != null) try { - in.close(); - } catch (IOException e) { - e.printStackTrace(System.err); - } - if (out != null) try { - out.close(); - } catch (IOException e) { - e.printStackTrace(System.err); + if (getContentResolver() != null) { + getContentResolver().applyBatch(MainApp.getAuthority(), operations); + + } else { + getContentProviderClient().applyBatch(operations); } - } - return ret; + } catch (Exception e) { + throw e; + } } - private Vector getFolderContent(long parentId/*, boolean onlyOnDevice*/) { + + private Vector getFolderContent(long parentId, boolean onlyOnDevice) { Vector ret = new Vector(); diff --cc src/com/owncloud/android/ui/activity/Preferences.java index 3f242c2d,3d5d8ab9..6d677cd3 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@@ -34,8 -34,8 +34,9 @@@ import android.content.pm.PackageInfo import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.net.Uri; +import android.os.AsyncTask; import android.os.Bundle; + import android.os.Environment; import android.os.Handler; import android.os.IBinder; import android.preference.CheckBoxPreference; @@@ -82,12 -81,7 +84,13 @@@ import com.owncloud.android.ui.Preferen import com.owncloud.android.ui.RadioButtonPreference; import com.owncloud.android.utils.DisplayUtils; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.concurrent.ExecutionException; + import java.io.File; /** @@@ -460,17 -460,10 +490,17 @@@ public class Preferences extends Prefer }); /* About App */ - pAboutApp = (Preference) findPreference("about_app"); + pAboutApp = findPreference("about_app"); if (pAboutApp != null) { - pAboutApp.setTitle(String.format(getString(R.string.about_android), getString(R.string.app_name))); - pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion)); + pAboutApp.setTitle(String.format(getString(R.string.about_android), + getString(R.string.app_name))); + try { + Integer currentVersion = getPackageManager().getPackageInfo + (getPackageName(), 0).versionCode; + pAboutApp.setSummary(String.format(getString(R.string.about_version), + currentVersion)); + } catch (NameNotFoundException e) { + } } loadInstantUploadPath(); diff --cc src/com/owncloud/android/utils/FileStorageUtils.java index 47a46d2c,e93ead0d..e300a5e2 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@@ -21,11 -21,13 +21,16 @@@ package com.owncloud.android.utils; import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; + import java.io.FileInputStream; + import java.io.FileOutputStream; + import java.io.IOException; + import java.io.InputStream; + import java.io.OutputStream; import java.util.Collections; import java.util.Comparator; +import java.util.List; import java.util.Vector; import third_parties.daveKoeller.AlphanumComparator;