Loading res/layout/item_dir_grid.xml +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ when touch mode is not enable. So, if you, heroic engineer of the future, decide to rip these out, please be sure to check out focus and keyboards. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_grid_item" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/grid_item_margin" Loading res/layout/item_doc_list.xml +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,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 +43 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,9 @@ 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.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.MessageQueue.IdleHandler; import android.preference.PreferenceManager; Loading @@ -35,10 +37,14 @@ import android.support.annotation.CallSuper; import android.support.annotation.LayoutRes; import android.support.annotation.VisibleForTesting; 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.Window; import android.view.WindowManager; import android.widget.Toolbar; import com.android.documentsui.AbstractActionHandler.CommonAddons; Loading Loading @@ -101,7 +107,8 @@ public abstract class BaseActivity private long mStartTime; private PreferencesMonitor mPreferencesMonitor; private Toolbar toolbar; public static int accentColor; public BaseActivity(@LayoutRes int layoutId, String tag) { mLayoutId = layoutId; mTag = tag; Loading Loading @@ -140,7 +147,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); setActionBar(toolbar); Breadcrumb breadcrumb = Loading Loading @@ -200,6 +207,7 @@ public abstract class BaseActivity // Base classes must update result in their onCreate. setResult(Activity.RESULT_CANCELED); accentColor=fetchAccentColor(); } public void onPreferenceChanged(String pref) { Loading Loading @@ -677,4 +685,37 @@ 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 +40 −4 Original line number Diff line number Diff line Loading @@ -16,15 +16,19 @@ package com.android.documentsui; import static com.android.documentsui.base.Shared.DEBUG; import android.annotation.IntDef; import android.app.Activity; import android.content.res.TypedArray; import android.support.annotation.ColorRes; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout.DrawerListener; import android.util.Log; import android.util.TypedValue; import android.view.ContextThemeWrapper; import android.view.View; import android.widget.Toolbar; Loading @@ -40,7 +44,7 @@ import java.lang.annotation.RetentionPolicy; */ public abstract class DrawerController implements DrawerListener { public static final String TAG = "DrawerController"; private static int accentColor; public abstract void update(); public abstract void setOpen(boolean open); public abstract boolean isPresent(); Loading @@ -52,6 +56,7 @@ public abstract class DrawerController implements DrawerListener { */ public static DrawerController create(Activity activity, ActivityConfig activityConfig) { accentColor=fetchAccentColor(activity); DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); if (layout == null) { Loading @@ -61,6 +66,10 @@ 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 @@ -134,11 +143,21 @@ 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.item_doc_background_selected : android.R.color.transparent; // @ColorRes int id = highlight ? R.color.item_doc_background_selected : // 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 @@ -247,4 +266,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; } } src/com/android/documentsui/dirlist/DirectoryItemAnimator.java +3 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.documentsui.R; import java.util.ArrayList; import java.util.List; import java.util.Map; import static com.android.documentsui.files.LauncherActivity.ACCENT_COLOR; /** * Performs change animations on Items in DirectoryFragment's RecyclerView. This class overrides Loading @@ -43,10 +44,10 @@ class DirectoryItemAnimator extends DefaultItemAnimator { new ArrayMap<>(); private final Integer mDefaultColor; private final Integer mSelectedColor; public DirectoryItemAnimator(Context context) { mDefaultColor = context.getResources().getColor(R.color.item_doc_background); mSelectedColor = context.getResources().getColor(R.color.item_doc_background_selected); //mSelectedColor = context.getResources().getColor(R.color.item_doc_background_selected); mSelectedColor = Integer.valueOf(ACCENT_COLOR); } @Override Loading Loading
res/layout/item_dir_grid.xml +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ when touch mode is not enable. So, if you, heroic engineer of the future, decide to rip these out, please be sure to check out focus and keyboards. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_grid_item" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/grid_item_margin" Loading
res/layout/item_doc_list.xml +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,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 +43 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,9 @@ 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.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.MessageQueue.IdleHandler; import android.preference.PreferenceManager; Loading @@ -35,10 +37,14 @@ import android.support.annotation.CallSuper; import android.support.annotation.LayoutRes; import android.support.annotation.VisibleForTesting; 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.Window; import android.view.WindowManager; import android.widget.Toolbar; import com.android.documentsui.AbstractActionHandler.CommonAddons; Loading Loading @@ -101,7 +107,8 @@ public abstract class BaseActivity private long mStartTime; private PreferencesMonitor mPreferencesMonitor; private Toolbar toolbar; public static int accentColor; public BaseActivity(@LayoutRes int layoutId, String tag) { mLayoutId = layoutId; mTag = tag; Loading Loading @@ -140,7 +147,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); setActionBar(toolbar); Breadcrumb breadcrumb = Loading Loading @@ -200,6 +207,7 @@ public abstract class BaseActivity // Base classes must update result in their onCreate. setResult(Activity.RESULT_CANCELED); accentColor=fetchAccentColor(); } public void onPreferenceChanged(String pref) { Loading Loading @@ -677,4 +685,37 @@ 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 +40 −4 Original line number Diff line number Diff line Loading @@ -16,15 +16,19 @@ package com.android.documentsui; import static com.android.documentsui.base.Shared.DEBUG; import android.annotation.IntDef; import android.app.Activity; import android.content.res.TypedArray; import android.support.annotation.ColorRes; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout.DrawerListener; import android.util.Log; import android.util.TypedValue; import android.view.ContextThemeWrapper; import android.view.View; import android.widget.Toolbar; Loading @@ -40,7 +44,7 @@ import java.lang.annotation.RetentionPolicy; */ public abstract class DrawerController implements DrawerListener { public static final String TAG = "DrawerController"; private static int accentColor; public abstract void update(); public abstract void setOpen(boolean open); public abstract boolean isPresent(); Loading @@ -52,6 +56,7 @@ public abstract class DrawerController implements DrawerListener { */ public static DrawerController create(Activity activity, ActivityConfig activityConfig) { accentColor=fetchAccentColor(activity); DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); if (layout == null) { Loading @@ -61,6 +66,10 @@ 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 @@ -134,11 +143,21 @@ 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.item_doc_background_selected : android.R.color.transparent; // @ColorRes int id = highlight ? R.color.item_doc_background_selected : // 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 @@ -247,4 +266,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; } }
src/com/android/documentsui/dirlist/DirectoryItemAnimator.java +3 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.documentsui.R; import java.util.ArrayList; import java.util.List; import java.util.Map; import static com.android.documentsui.files.LauncherActivity.ACCENT_COLOR; /** * Performs change animations on Items in DirectoryFragment's RecyclerView. This class overrides Loading @@ -43,10 +44,10 @@ class DirectoryItemAnimator extends DefaultItemAnimator { new ArrayMap<>(); private final Integer mDefaultColor; private final Integer mSelectedColor; public DirectoryItemAnimator(Context context) { mDefaultColor = context.getResources().getColor(R.color.item_doc_background); mSelectedColor = context.getResources().getColor(R.color.item_doc_background_selected); //mSelectedColor = context.getResources().getColor(R.color.item_doc_background_selected); mSelectedColor = Integer.valueOf(ACCENT_COLOR); } @Override Loading