From: tobiasKaminsky Date: Sun, 23 Aug 2015 16:51:12 +0000 (+0200) Subject: Merge branch 'develop' of github.com:owncloud/android into switchListVsGrid X-Git-Tag: beta-20151122~25^2~7 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/7bd8443c183905a686b8e0c55258c97dcbbbd2fe Merge branch 'develop' of github.com:owncloud/android into switchListVsGrid icon is now always visible --- 7bd8443c183905a686b8e0c55258c97dcbbbd2fe diff --cc owncloud-android-library index dbc8c325,dbc8c325..c8f6e5ad --- a/owncloud-android-library +++ b/owncloud-android-library @@@ -1,1 -1,1 +1,1 @@@ --Subproject commit dbc8c325d74f3f7e8da8236c5abe77a141ae4019 ++Subproject commit c8f6e5ad57ee27fdac39c7b14eb6ab1942a92d49 diff --cc res/drawable-hdpi/ic_view_list.png index 00000000,00000000..64ad8e14 new file mode 100644 Binary files differ diff --cc res/drawable-hdpi/ic_view_module.png index 00000000,00000000..7982e383 new file mode 100644 Binary files differ diff --cc res/drawable-mdpi/ic_view_list.png index 00000000,00000000..4aca55c6 new file mode 100644 Binary files differ diff --cc res/drawable-mdpi/ic_view_module.png index 00000000,00000000..f308a32b new file mode 100644 Binary files differ diff --cc res/drawable-xhdpi/ic_view_list.png index 00000000,00000000..b81d9102 new file mode 100644 Binary files differ diff --cc res/drawable-xhdpi/ic_view_module.png index 00000000,00000000..b3548535 new file mode 100644 Binary files differ diff --cc res/menu/main_menu.xml index 8743512e,236bfd6e..b4316347 --- a/res/menu/main_menu.xml +++ b/res/menu/main_menu.xml @@@ -35,11 -35,6 +35,12 @@@ android:title="@string/actionbar_mkdir" android:contentDescription="@string/actionbar_mkdir"/> + 0 && imagesCount == filesCount) { + DisplayUtils.isGridView(mFile, mContainerActivity.getStorageManager())) { switchToGridView(); + registerLongClickListener(); } else { switchToListView(); } diff --cc src/com/owncloud/android/utils/DisplayUtils.java index 1662a726,3ae36e44..b835f8b6 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@@ -36,8 -35,9 +36,9 @@@ import java.util.Vector import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; -import android.graphics.Color; +import android.content.SharedPreferences; import android.graphics.Point; + import android.graphics.PorterDuff; import android.os.Build; import android.text.format.DateUtils; import android.view.Display; @@@ -377,64 -378,32 +380,93 @@@ public class DisplayUtils } /** + * Determines if user set folder to grid or list view. If folder is not set itself, + * it finds a parent that is set (at least root is set). + * @param file + * @param storageManager + * @return + */ + public static boolean isGridView(OCFile file, FileDataStorageManager storageManager){ + if (file != null) { + OCFile fileToTest = file; + OCFile parentDir = null; + String parentPath = null; + + SharedPreferences setting = MainApp.getAppContext().getSharedPreferences( + "viewMode", Context.MODE_PRIVATE); + + if (setting.contains(fileToTest.getRemoteId())) { + return setting.getBoolean(fileToTest.getRemoteId(), false); + } else { + do { + if (fileToTest.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) { + parentPath = new File(fileToTest.getRemotePath()).getParent(); + parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : + parentPath + OCFile.PATH_SEPARATOR; + parentDir = storageManager.getFileByPath(parentPath); + } else { + parentDir = storageManager.getFileByPath(OCFile.ROOT_PATH); + } + + while (parentDir == null) { + parentPath = new File(parentPath).getParent(); + parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : + parentPath + OCFile.PATH_SEPARATOR; + parentDir = storageManager.getFileByPath(parentPath); + } + fileToTest = parentDir; + } while (endWhile(parentDir, setting)); + return setting.getBoolean(fileToTest.getRemoteId(), false); + } + } else { + return false; + } + } + + private static boolean endWhile(OCFile parentDir, SharedPreferences setting) { + if (parentDir.getRemotePath().compareToIgnoreCase(OCFile.ROOT_PATH) == 0) { + return false; + } else { + return !setting.contains(parentDir.getRemoteId()); + } + } + + public static void setViewMode(OCFile file, boolean setGrid){ + SharedPreferences setting = MainApp.getAppContext().getSharedPreferences( + "viewMode", Context.MODE_PRIVATE); + + SharedPreferences.Editor editor = setting.edit(); + editor.putBoolean(file.getRemoteId(), setGrid); + editor.commit(); + } + ++ /** + * sets the coloring of the given progress bar to color_accent. + * + * @param progressBar the progress bar to be colored + */ + public static void colorPreLollipopHorizontalProgressBar(ProgressBar progressBar) { + if (progressBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + int color = progressBar.getResources().getColor(R.color.color_accent); + progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN); + progressBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN); + } + } + + /** + * sets the coloring of the given seek bar to color_accent. + * + * @param seekBar the seek bar to be colored + */ + public static void colorPreLollipopHorizontalSeekBar(SeekBar seekBar) { + if (seekBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + colorPreLollipopHorizontalProgressBar(seekBar); + + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + int color = seekBar.getResources().getColor(R.color.color_accent); + seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN); + seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN); + } + } + } }