From 29b98cab4063db079236d263a53388f5898ceaf9 Mon Sep 17 00:00:00 2001 From: Raj Yengisetty Date: Wed, 7 Jan 2015 15:15:41 -0800 Subject: CMFileManager: change breadcrumb views in dialogs for better visibility Change-Id: I0af7aef6d2605c1a2bf107ffce87236b01f11c42 --- res/drawable-hdpi/ic_material_dialog_fs_locked.png | Bin 0 -> 709 bytes .../ic_material_dialog_fs_unlocked.png | Bin 0 -> 703 bytes .../ic_material_dialog_fs_warning.png | Bin 0 -> 752 bytes res/drawable-mdpi/ic_material_dialog_fs_locked.png | Bin 0 -> 374 bytes .../ic_material_dialog_fs_unlocked.png | Bin 0 -> 376 bytes .../ic_material_dialog_fs_warning.png | Bin 0 -> 535 bytes .../ic_material_dialog_fs_locked.png | Bin 0 -> 890 bytes .../ic_material_dialog_fs_unlocked.png | Bin 0 -> 886 bytes .../ic_material_dialog_fs_warning.png | Bin 0 -> 1152 bytes .../ic_material_dialog_fs_locked.png | Bin 0 -> 1177 bytes .../ic_material_dialog_fs_unlocked.png | Bin 0 -> 1168 bytes .../ic_material_dialog_fs_warning.png | Bin 0 -> 1126 bytes res/layout/picker.xml | 2 +- res/values/theme.xml | 6 ++ .../filemanager/tasks/FilesystemAsyncTask.java | 34 ++++++++- .../filemanager/ui/widgets/BreadcrumbView.java | 8 +- .../ui/widgets/DialogBreadcrumbView.java | 83 +++++++++++++++++++++ 17 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 res/drawable-hdpi/ic_material_dialog_fs_locked.png create mode 100644 res/drawable-hdpi/ic_material_dialog_fs_unlocked.png create mode 100644 res/drawable-hdpi/ic_material_dialog_fs_warning.png create mode 100644 res/drawable-mdpi/ic_material_dialog_fs_locked.png create mode 100644 res/drawable-mdpi/ic_material_dialog_fs_unlocked.png create mode 100644 res/drawable-mdpi/ic_material_dialog_fs_warning.png create mode 100644 res/drawable-xhdpi/ic_material_dialog_fs_locked.png create mode 100644 res/drawable-xhdpi/ic_material_dialog_fs_unlocked.png create mode 100644 res/drawable-xhdpi/ic_material_dialog_fs_warning.png create mode 100644 res/drawable-xxhdpi/ic_material_dialog_fs_locked.png create mode 100644 res/drawable-xxhdpi/ic_material_dialog_fs_unlocked.png create mode 100644 res/drawable-xxhdpi/ic_material_dialog_fs_warning.png create mode 100644 src/com/cyanogenmod/filemanager/ui/widgets/DialogBreadcrumbView.java diff --git a/res/drawable-hdpi/ic_material_dialog_fs_locked.png b/res/drawable-hdpi/ic_material_dialog_fs_locked.png new file mode 100644 index 00000000..b61917a0 Binary files /dev/null and b/res/drawable-hdpi/ic_material_dialog_fs_locked.png differ diff --git a/res/drawable-hdpi/ic_material_dialog_fs_unlocked.png b/res/drawable-hdpi/ic_material_dialog_fs_unlocked.png new file mode 100644 index 00000000..bab5401f Binary files /dev/null and b/res/drawable-hdpi/ic_material_dialog_fs_unlocked.png differ diff --git a/res/drawable-hdpi/ic_material_dialog_fs_warning.png b/res/drawable-hdpi/ic_material_dialog_fs_warning.png new file mode 100644 index 00000000..929ab5eb Binary files /dev/null and b/res/drawable-hdpi/ic_material_dialog_fs_warning.png differ diff --git a/res/drawable-mdpi/ic_material_dialog_fs_locked.png b/res/drawable-mdpi/ic_material_dialog_fs_locked.png new file mode 100644 index 00000000..21b679c7 Binary files /dev/null and b/res/drawable-mdpi/ic_material_dialog_fs_locked.png differ diff --git a/res/drawable-mdpi/ic_material_dialog_fs_unlocked.png b/res/drawable-mdpi/ic_material_dialog_fs_unlocked.png new file mode 100644 index 00000000..e7ff986e Binary files /dev/null and b/res/drawable-mdpi/ic_material_dialog_fs_unlocked.png differ diff --git a/res/drawable-mdpi/ic_material_dialog_fs_warning.png b/res/drawable-mdpi/ic_material_dialog_fs_warning.png new file mode 100644 index 00000000..b787fabd Binary files /dev/null and b/res/drawable-mdpi/ic_material_dialog_fs_warning.png differ diff --git a/res/drawable-xhdpi/ic_material_dialog_fs_locked.png b/res/drawable-xhdpi/ic_material_dialog_fs_locked.png new file mode 100644 index 00000000..112a25cf Binary files /dev/null and b/res/drawable-xhdpi/ic_material_dialog_fs_locked.png differ diff --git a/res/drawable-xhdpi/ic_material_dialog_fs_unlocked.png b/res/drawable-xhdpi/ic_material_dialog_fs_unlocked.png new file mode 100644 index 00000000..7684ff8a Binary files /dev/null and b/res/drawable-xhdpi/ic_material_dialog_fs_unlocked.png differ diff --git a/res/drawable-xhdpi/ic_material_dialog_fs_warning.png b/res/drawable-xhdpi/ic_material_dialog_fs_warning.png new file mode 100644 index 00000000..3d9ebc71 Binary files /dev/null and b/res/drawable-xhdpi/ic_material_dialog_fs_warning.png differ diff --git a/res/drawable-xxhdpi/ic_material_dialog_fs_locked.png b/res/drawable-xxhdpi/ic_material_dialog_fs_locked.png new file mode 100644 index 00000000..7948955f Binary files /dev/null and b/res/drawable-xxhdpi/ic_material_dialog_fs_locked.png differ diff --git a/res/drawable-xxhdpi/ic_material_dialog_fs_unlocked.png b/res/drawable-xxhdpi/ic_material_dialog_fs_unlocked.png new file mode 100644 index 00000000..78c2bdb7 Binary files /dev/null and b/res/drawable-xxhdpi/ic_material_dialog_fs_unlocked.png differ diff --git a/res/drawable-xxhdpi/ic_material_dialog_fs_warning.png b/res/drawable-xxhdpi/ic_material_dialog_fs_warning.png new file mode 100644 index 00000000..4f8f354c Binary files /dev/null and b/res/drawable-xxhdpi/ic_material_dialog_fs_warning.png differ diff --git a/res/layout/picker.xml b/res/layout/picker.xml index 8baa52e0..3e6d56c5 100644 --- a/res/layout/picker.xml +++ b/res/layout/picker.xml @@ -23,7 +23,7 @@ android:orientation="vertical"> - @drawable/ic_material_light_fs_unlocked @drawable/ic_material_light_fs_warning + + @drawable/ic_material_dialog_fs_locked + + @drawable/ic_material_dialog_fs_unlocked + + @drawable/ic_material_dialog_fs_warning @drawable/ic_material_light_secure diff --git a/src/com/cyanogenmod/filemanager/tasks/FilesystemAsyncTask.java b/src/com/cyanogenmod/filemanager/tasks/FilesystemAsyncTask.java index dceeed5f..1f457d3d 100644 --- a/src/com/cyanogenmod/filemanager/tasks/FilesystemAsyncTask.java +++ b/src/com/cyanogenmod/filemanager/tasks/FilesystemAsyncTask.java @@ -55,6 +55,11 @@ public class FilesystemAsyncTask extends AsyncTask { final int mFreeDiskSpaceWarningLevel; private boolean mRunning; + /** + * @hide + */ + final boolean mIsDialog; + /** * @hide */ @@ -71,12 +76,29 @@ public class FilesystemAsyncTask extends AsyncTask { public FilesystemAsyncTask( Context context, ImageView mountPointInfo, ProgressBar diskUsageInfo, int freeDiskSpaceWarningLevel) { + this(context, mountPointInfo, diskUsageInfo, freeDiskSpaceWarningLevel, + false); + } + + /** + * Constructor of FilesystemAsyncTask. + * + * @param context The current context + * @param mountPointInfo The mount point info view + * @param diskUsageInfo The mount point info view + * @param freeDiskSpaceWarningLevel The free disk space warning level + * @param isDialog Whether or not to use dialog theme resources + */ + public FilesystemAsyncTask( + Context context, ImageView mountPointInfo, + ProgressBar diskUsageInfo, int freeDiskSpaceWarningLevel, boolean isDialog) { super(); this.mContext = context; this.mMountPointInfo = mountPointInfo; this.mDiskUsageInfo = diskUsageInfo; this.mFreeDiskSpaceWarningLevel = freeDiskSpaceWarningLevel; this.mRunning = false; + this.mIsDialog = isDialog; } /** @@ -116,7 +138,9 @@ public class FilesystemAsyncTask extends AsyncTask { theme.setImageDrawable( FilesystemAsyncTask.this.mContext, FilesystemAsyncTask.this.mMountPointInfo, - "filesystem_warning_drawable"); //$NON-NLS-1$ + FilesystemAsyncTask.this.mIsDialog ? + "filesystem_dialog_warning_drawable" //$NON-NLS-1$ + : "filesystem_warning_drawable"); //$NON-NLS-1$ FilesystemAsyncTask.this.mMountPointInfo.setTag(null); } }); @@ -130,8 +154,12 @@ public class FilesystemAsyncTask extends AsyncTask { public void run() { String resource = MountPointHelper.isReadOnly(mp) - ? "filesystem_locked_drawable" //$NON-NLS-1$ - : "filesystem_unlocked_drawable"; //$NON-NLS-1$ + ? FilesystemAsyncTask.this.mIsDialog ? + "filesystem_dialog_locked_drawable" //$NON-NLS-1$ + : "filesystem_locked_drawable" //$NON-NLS-1$ + : FilesystemAsyncTask.this.mIsDialog ? + "filesystem_dialog_unlocked_drawable" //$NON-NLS-1$ + : "filesystem_unlocked_drawable"; //$NON-NLS-1$ Theme theme = ThemeManager.getCurrentTheme(FilesystemAsyncTask.this.mContext); theme.setImageDrawable( FilesystemAsyncTask.this.mContext, diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/BreadcrumbView.java b/src/com/cyanogenmod/filemanager/ui/widgets/BreadcrumbView.java index baef88f6..fbe397ab 100644 --- a/src/com/cyanogenmod/filemanager/ui/widgets/BreadcrumbView.java +++ b/src/com/cyanogenmod/filemanager/ui/widgets/BreadcrumbView.java @@ -52,7 +52,7 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic * @hide */ HorizontalScrollView mScrollView; - private ViewGroup mBreadcrumbBar; + protected ViewGroup mBreadcrumbBar; /** * @hide */ @@ -65,13 +65,13 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic * @hide */ View mLoading; - private FilesystemAsyncTask mFilesystemAsyncTask; + protected FilesystemAsyncTask mFilesystemAsyncTask; - private int mFreeDiskSpaceWarningLevel = 95; + protected int mFreeDiskSpaceWarningLevel = 95; private List mBreadcrumbListeners; - private String mCurrentPath; + protected String mCurrentPath; /** * Constructor of BreadcrumbView. diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/DialogBreadcrumbView.java b/src/com/cyanogenmod/filemanager/ui/widgets/DialogBreadcrumbView.java new file mode 100644 index 00000000..1993af64 --- /dev/null +++ b/src/com/cyanogenmod/filemanager/ui/widgets/DialogBreadcrumbView.java @@ -0,0 +1,83 @@ +package com.cyanogenmod.filemanager.ui.widgets; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.View; +import android.widget.ImageView; +import android.widget.ProgressBar; +import com.cyanogenmod.filemanager.R; +import com.cyanogenmod.filemanager.model.MountPoint; +import com.cyanogenmod.filemanager.tasks.FilesystemAsyncTask; +import com.cyanogenmod.filemanager.ui.ThemeManager; +import com.cyanogenmod.filemanager.util.MountPointHelper; + +public class DialogBreadcrumbView extends BreadcrumbView { + public DialogBreadcrumbView(Context context) { + super(context); + } + + public DialogBreadcrumbView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public DialogBreadcrumbView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + public void applyTheme() { + ThemeManager.Theme theme = ThemeManager.getCurrentTheme(getContext()); + + //- Breadcrumb + if (this.mBreadcrumbBar != null) { + int cc = this.mBreadcrumbBar.getChildCount(); + for (int i = 0; i < cc; i++) { + // There are 2 types: Breadcrumb items and separators + View v = this.mBreadcrumbBar.getChildAt(i); + if (v instanceof BreadcrumbItem) { + // Breadcrumb item + theme.setTextColor( + getContext(), (BreadcrumbItem)v, "text_color"); //$NON-NLS-1$ + } else if (v instanceof ImageView) { + // Divider drawable + theme.setImageDrawable( + getContext(), + (ImageView)v, "breadcrumb_divider_drawable"); //$NON-NLS-1$ + } + } + } + if (this.mDiskUsageInfo != null) { + Drawable dw = theme.getDrawable(getContext(), "horizontal_progress_bar"); //$NON-NLS-1$ + this.mDiskUsageInfo.setProgressDrawable(dw); + } + final ImageView fsInfo = (ImageView)findViewById(R.id.ab_filesystem_info); + if (fsInfo != null) { + MountPoint mp = (MountPoint) fsInfo.getTag(); + if (mp == null) { + theme.setImageDrawable(getContext(), fsInfo, "filesystem_dialog_warning_drawable"); + } else { + String resource = + MountPointHelper.isReadOnly(mp) + ? "filesystem_dialog_locked_drawable" + : "filesystem_dialog_unlocked_drawable"; + theme.setImageDrawable(getContext(), fsInfo, resource); + } + } + } + + @Override + public synchronized void updateMountPointInfo() { + //Cancel the current execution (if any) and launch again + if (this.mFilesystemAsyncTask != null && this.mFilesystemAsyncTask.isRunning()) { + this.mFilesystemAsyncTask.cancel(true); + } + final ImageView filesystemInfo = (ImageView)findViewById(R.id.ab_filesystem_info); + final ProgressBar diskUsageInfo = (ProgressBar)findViewById(R.id.breadcrumb_diskusage); + this.mFilesystemAsyncTask = + new FilesystemAsyncTask( + getContext(), filesystemInfo, + diskUsageInfo, this.mFreeDiskSpaceWarningLevel, true); + this.mFilesystemAsyncTask.execute(this.mCurrentPath); + } +} -- cgit v1.2.3