Loading res/layout/item_dir_grid.xml +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ <!-- The height is 48px. paddingTop (9dp) + @dimen/check_icon_size (30dp) + paddingBottom (9dp) --> <LinearLayout android:id="@+id/layout_grid_item" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" Loading res/layout/item_doc_list.xml +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ <LinearLayout android:id="@+id/layout_list_item" android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="false" Loading src/com/android/documentsui/BaseActivity.java +40 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; import android.content.res.TypedArray; import android.graphics.Color; import android.net.Uri; import android.os.Build; Loading @@ -33,11 +34,14 @@ import android.preference.PreferenceManager; import android.provider.DocumentsContract; import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.Checkable; import android.widget.TextView; Loading Loading @@ -116,6 +120,10 @@ public abstract class BaseActivity private PreferencesMonitor mPreferencesMonitor; private Toolbar toolbar; public static int accentColor; public BaseActivity(@LayoutRes int layoutId, String tag) { mLayoutId = layoutId; mTag = tag; Loading Loading @@ -157,7 +165,7 @@ public abstract class BaseActivity mProviders = DocumentsApplication.getProvidersCache(this); mDocs = DocumentsAccess.create(this); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Breadcrumb breadcrumb = Loading Loading @@ -275,6 +283,7 @@ public abstract class BaseActivity // Base classes must update result in their onCreate. setResult(AppCompatActivity.RESULT_CANCELED); accentColor=fetchAccentColor(); } public void onPreferenceChanged(String pref) { Loading Loading @@ -886,4 +895,34 @@ public abstract class BaseActivity */ void onDirectoryLoaded(@Nullable Uri uri); } /* * get Accent color from OS * */ private int fetchAccentColor() { TypedValue typedValue = new TypedValue(); TypedArray a = this.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); a.recycle(); Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); //toolbar change color to accent color toolbar.setBackgroundColor(color); //change status bar color if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(darkenColor(color)); } return color; } int darkenColor(int color) { float[] hsv = new float[3]; android.graphics.Color.colorToHSV(color, hsv); hsv[2] *= 0.8f; return android.graphics.Color.HSVToColor(hsv); } } src/com/android/documentsui/DrawerController.java +33 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,9 @@ package com.android.documentsui; import static com.android.documentsui.base.SharedMinimal.DEBUG; import android.app.Activity; import android.content.res.TypedArray; import android.util.Log; import android.util.TypedValue; import android.view.View; import androidx.annotation.ColorRes; Loading @@ -43,12 +45,13 @@ public abstract class DrawerController implements DrawerListener { public abstract boolean isPresent(); public abstract boolean isOpen(); abstract void setTitle(String title); private static int accentColor; /** * Returns a controller suitable for {@code Layout}. */ public static DrawerController create(Activity activity, ActivityConfig activityConfig) { accentColor=fetchAccentColor(activity); DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); if (layout == null) { Loading @@ -57,6 +60,11 @@ public abstract class DrawerController implements DrawerListener { View drawer = activity.findViewById(R.id.drawer_roots); Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar); if(accentColor!=0){ toolbar.setBackgroundColor(accentColor); } drawer.getLayoutParams().width = calculateDrawerWidth(activity); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( Loading Loading @@ -130,11 +138,17 @@ public abstract class DrawerController implements DrawerListener { public void setDropTargetHighlight(View v, boolean highlight) { assert (v.getId() == R.id.drawer_edge); @ColorRes int id = highlight ? R.color.secondary : android.R.color.transparent; if(accentColor!=0){ @ColorRes int id = highlight ? accentColor : android.R.color.transparent; v.setBackgroundColor(id); } else { @ColorRes int id = highlight ? R.color.item_doc_background_selected : android.R.color.transparent; v.setBackgroundColor(id); } } @Override public void onDragEntered(View v) { // do nothing; let drawer only open for onViewHovered Loading Loading @@ -243,4 +257,19 @@ public abstract class DrawerController implements DrawerListener { @Override public void onDrawerStateChanged(int newState) {} } /* * get Accent color from OS * */ private static int fetchAccentColor(Activity activity) { TypedValue typedValue = new TypedValue(); TypedArray a = activity.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); a.recycle(); Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); //toolbar change color to accent color return color; } } src/com/android/documentsui/dirlist/GridDirectoryHolder.java +21 −1 Original line number Diff line number Diff line Loading @@ -26,8 +26,10 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.android.documentsui.BaseActivity; import com.android.documentsui.IconUtils; import com.android.documentsui.R; import com.android.documentsui.base.State; Loading @@ -40,14 +42,18 @@ final class GridDirectoryHolder extends DocumentHolder { private final ImageView mIconCheck; private final ImageView mIconMime; private final View mIconLayout; private final LinearLayout mlayout_grid_item; private final Context context; public GridDirectoryHolder(Context context, ViewGroup parent) { super(context, parent, R.layout.item_dir_grid); this.context=context; mIconLayout = itemView.findViewById(R.id.icon); mTitle = (TextView) itemView.findViewById(android.R.id.title); mIconMime = (ImageView) itemView.findViewById(R.id.icon_mime_sm); mIconCheck = (ImageView) itemView.findViewById(R.id.icon_check); mlayout_grid_item=(LinearLayout)itemView.findViewById(R.id.layout_grid_item); mIconMime.setImageDrawable( IconUtils.loadMimeIcon(context, DocumentsContract.Document.MIME_TYPE_DIR)); } Loading @@ -64,6 +70,20 @@ final class GridDirectoryHolder extends DocumentHolder { mIconCheck.setAlpha(checkAlpha); mIconMime.setAlpha(1f - checkAlpha); } if(selected){ mlayout_grid_item.setBackgroundColor(BaseActivity.accentColor); mTitle.setTextColor(context.getResources().getColor(R.color.window_background)); mIconCheck.setColorFilter(context.getResources().getColor(R.color.window_background), android.graphics.PorterDuff.Mode.SRC_IN); } else { mlayout_grid_item.setBackgroundColor(context.getResources().getColor(R.color.menu_search_background)); mTitle.setTextColor(context.getResources().getColor(R.color.item_title)); } } @Override Loading Loading
res/layout/item_dir_grid.xml +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ <!-- The height is 48px. paddingTop (9dp) + @dimen/check_icon_size (30dp) + paddingBottom (9dp) --> <LinearLayout android:id="@+id/layout_grid_item" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" Loading
res/layout/item_doc_list.xml +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ <LinearLayout android:id="@+id/layout_list_item" android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="false" Loading
src/com/android/documentsui/BaseActivity.java +40 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; import android.content.res.TypedArray; import android.graphics.Color; import android.net.Uri; import android.os.Build; Loading @@ -33,11 +34,14 @@ import android.preference.PreferenceManager; import android.provider.DocumentsContract; import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.Checkable; import android.widget.TextView; Loading Loading @@ -116,6 +120,10 @@ public abstract class BaseActivity private PreferencesMonitor mPreferencesMonitor; private Toolbar toolbar; public static int accentColor; public BaseActivity(@LayoutRes int layoutId, String tag) { mLayoutId = layoutId; mTag = tag; Loading Loading @@ -157,7 +165,7 @@ public abstract class BaseActivity mProviders = DocumentsApplication.getProvidersCache(this); mDocs = DocumentsAccess.create(this); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Breadcrumb breadcrumb = Loading Loading @@ -275,6 +283,7 @@ public abstract class BaseActivity // Base classes must update result in their onCreate. setResult(AppCompatActivity.RESULT_CANCELED); accentColor=fetchAccentColor(); } public void onPreferenceChanged(String pref) { Loading Loading @@ -886,4 +895,34 @@ public abstract class BaseActivity */ void onDirectoryLoaded(@Nullable Uri uri); } /* * get Accent color from OS * */ private int fetchAccentColor() { TypedValue typedValue = new TypedValue(); TypedArray a = this.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); a.recycle(); Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); //toolbar change color to accent color toolbar.setBackgroundColor(color); //change status bar color if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(darkenColor(color)); } return color; } int darkenColor(int color) { float[] hsv = new float[3]; android.graphics.Color.colorToHSV(color, hsv); hsv[2] *= 0.8f; return android.graphics.Color.HSVToColor(hsv); } }
src/com/android/documentsui/DrawerController.java +33 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,9 @@ package com.android.documentsui; import static com.android.documentsui.base.SharedMinimal.DEBUG; import android.app.Activity; import android.content.res.TypedArray; import android.util.Log; import android.util.TypedValue; import android.view.View; import androidx.annotation.ColorRes; Loading @@ -43,12 +45,13 @@ public abstract class DrawerController implements DrawerListener { public abstract boolean isPresent(); public abstract boolean isOpen(); abstract void setTitle(String title); private static int accentColor; /** * Returns a controller suitable for {@code Layout}. */ public static DrawerController create(Activity activity, ActivityConfig activityConfig) { accentColor=fetchAccentColor(activity); DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); if (layout == null) { Loading @@ -57,6 +60,11 @@ public abstract class DrawerController implements DrawerListener { View drawer = activity.findViewById(R.id.drawer_roots); Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar); if(accentColor!=0){ toolbar.setBackgroundColor(accentColor); } drawer.getLayoutParams().width = calculateDrawerWidth(activity); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( Loading Loading @@ -130,11 +138,17 @@ public abstract class DrawerController implements DrawerListener { public void setDropTargetHighlight(View v, boolean highlight) { assert (v.getId() == R.id.drawer_edge); @ColorRes int id = highlight ? R.color.secondary : android.R.color.transparent; if(accentColor!=0){ @ColorRes int id = highlight ? accentColor : android.R.color.transparent; v.setBackgroundColor(id); } else { @ColorRes int id = highlight ? R.color.item_doc_background_selected : android.R.color.transparent; v.setBackgroundColor(id); } } @Override public void onDragEntered(View v) { // do nothing; let drawer only open for onViewHovered Loading Loading @@ -243,4 +257,19 @@ public abstract class DrawerController implements DrawerListener { @Override public void onDrawerStateChanged(int newState) {} } /* * get Accent color from OS * */ private static int fetchAccentColor(Activity activity) { TypedValue typedValue = new TypedValue(); TypedArray a = activity.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); a.recycle(); Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); //toolbar change color to accent color return color; } }
src/com/android/documentsui/dirlist/GridDirectoryHolder.java +21 −1 Original line number Diff line number Diff line Loading @@ -26,8 +26,10 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.android.documentsui.BaseActivity; import com.android.documentsui.IconUtils; import com.android.documentsui.R; import com.android.documentsui.base.State; Loading @@ -40,14 +42,18 @@ final class GridDirectoryHolder extends DocumentHolder { private final ImageView mIconCheck; private final ImageView mIconMime; private final View mIconLayout; private final LinearLayout mlayout_grid_item; private final Context context; public GridDirectoryHolder(Context context, ViewGroup parent) { super(context, parent, R.layout.item_dir_grid); this.context=context; mIconLayout = itemView.findViewById(R.id.icon); mTitle = (TextView) itemView.findViewById(android.R.id.title); mIconMime = (ImageView) itemView.findViewById(R.id.icon_mime_sm); mIconCheck = (ImageView) itemView.findViewById(R.id.icon_check); mlayout_grid_item=(LinearLayout)itemView.findViewById(R.id.layout_grid_item); mIconMime.setImageDrawable( IconUtils.loadMimeIcon(context, DocumentsContract.Document.MIME_TYPE_DIR)); } Loading @@ -64,6 +70,20 @@ final class GridDirectoryHolder extends DocumentHolder { mIconCheck.setAlpha(checkAlpha); mIconMime.setAlpha(1f - checkAlpha); } if(selected){ mlayout_grid_item.setBackgroundColor(BaseActivity.accentColor); mTitle.setTextColor(context.getResources().getColor(R.color.window_background)); mIconCheck.setColorFilter(context.getResources().getColor(R.color.window_background), android.graphics.PorterDuff.Mode.SRC_IN); } else { mlayout_grid_item.setBackgroundColor(context.getResources().getColor(R.color.menu_search_background)); mTitle.setTextColor(context.getResources().getColor(R.color.item_title)); } } @Override Loading