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 res/values/colors.xml +5 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,9 @@ <color name="app_icon_background">#ff4688f2</color> <color name="shortcut_foreground">#ff3367d6</color> <color name="shortcut_background">#fff5f5f5</color> <color name="window_background">#fff1f1f1</color> <color name="item_doc_background_selected">#4d3367d6</color> <color name="item_title">#ff333333</color> </resources> src/com/android/documentsui/BaseActivity.java +45 −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,15 @@ import android.preference.PreferenceManager; import android.provider.DocumentsContract; import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.ContextThemeWrapper; 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 +121,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 +166,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 +284,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 +896,38 @@ public abstract class BaseActivity */ void onDirectoryLoaded(@Nullable Uri uri); } /* * get Accent color from OS * */ private int fetchAccentColor() { TypedValue typedValue = new TypedValue(); ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(this, android.R.style.Theme_DeviceDefault_Light); contextThemeWrapper.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true); int color = typedValue.data; 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 +36 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,10 @@ 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.ContextThemeWrapper; import android.view.View; import androidx.annotation.ColorRes; Loading @@ -43,12 +46,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 +61,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 +139,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 +258,21 @@ 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(); ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(activity, android.R.style.Theme_DeviceDefault_Light); contextThemeWrapper.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true); int color = typedValue.data; Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); //toolbar change color to accent color return color; } } 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
res/values/colors.xml +5 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,9 @@ <color name="app_icon_background">#ff4688f2</color> <color name="shortcut_foreground">#ff3367d6</color> <color name="shortcut_background">#fff5f5f5</color> <color name="window_background">#fff1f1f1</color> <color name="item_doc_background_selected">#4d3367d6</color> <color name="item_title">#ff333333</color> </resources>
src/com/android/documentsui/BaseActivity.java +45 −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,15 @@ import android.preference.PreferenceManager; import android.provider.DocumentsContract; import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.ContextThemeWrapper; 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 +121,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 +166,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 +284,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 +896,38 @@ public abstract class BaseActivity */ void onDirectoryLoaded(@Nullable Uri uri); } /* * get Accent color from OS * */ private int fetchAccentColor() { TypedValue typedValue = new TypedValue(); ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(this, android.R.style.Theme_DeviceDefault_Light); contextThemeWrapper.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true); int color = typedValue.data; 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 +36 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,10 @@ 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.ContextThemeWrapper; import android.view.View; import androidx.annotation.ColorRes; Loading @@ -43,12 +46,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 +61,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 +139,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 +258,21 @@ 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(); ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(activity, android.R.style.Theme_DeviceDefault_Light); contextThemeWrapper.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true); int color = typedValue.data; Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); //toolbar change color to accent color return color; } }