From 78c1e583dec82a75ae5fdd9a82226c24695c43f5 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Mon, 14 Sep 2020 11:50:06 +0530 Subject: [PATCH 01/14] get Accent color from OS --- .../documentsui/files/LauncherActivity.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/com/android/documentsui/files/LauncherActivity.java b/src/com/android/documentsui/files/LauncherActivity.java index f14be5ae7..543fb072a 100644 --- a/src/com/android/documentsui/files/LauncherActivity.java +++ b/src/com/android/documentsui/files/LauncherActivity.java @@ -23,11 +23,14 @@ import android.app.ActivityManager; import android.app.ActivityManager.AppTask; import android.content.Context; import android.content.Intent; +import android.content.res.TypedArray; +import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Bundle; import android.provider.DocumentsContract; import android.support.annotation.Nullable; import android.util.Log; +import android.util.TypedValue; import com.android.documentsui.R; @@ -63,6 +66,9 @@ public class LauncherActivity extends Activity { launch(); finish(); + + fetchAccentColor(); + } private void launch() { @@ -165,4 +171,21 @@ public class LauncherActivity extends Activity { boolean result = uri != null && LAUNCH_CONTROL_AUTHORITY.equals(uri.getAuthority()); return result; } + + /* + * 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 + getSupportActionBar().setBackgroundDrawable( + new ColorDrawable(color)); + return color; + } + } -- GitLab From f210ddab807d64ebefe569679d512d202ed0e21d Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Mon, 14 Sep 2020 12:32:31 +0530 Subject: [PATCH 02/14] get Accent color impl on BaseActivity --- src/com/android/documentsui/BaseActivity.java | 24 ++++++++++++++++++- .../documentsui/files/LauncherActivity.java | 17 +------------ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java index a5784de27..9dab21c27 100644 --- a/src/com/android/documentsui/BaseActivity.java +++ b/src/com/android/documentsui/BaseActivity.java @@ -26,6 +26,8 @@ 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.drawable.ColorDrawable; import android.net.Uri; import android.os.Bundle; import android.os.MessageQueue.IdleHandler; @@ -35,6 +37,7 @@ 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.KeyEvent; import android.view.Menu; import android.view.MenuItem; @@ -101,6 +104,8 @@ public abstract class BaseActivity private long mStartTime; private PreferencesMonitor mPreferencesMonitor; + private Toolbar toolbar; + private int accentColor; public BaseActivity(@LayoutRes int layoutId, String tag) { mLayoutId = layoutId; @@ -140,7 +145,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 = @@ -200,6 +205,8 @@ public abstract class BaseActivity // Base classes must update result in their onCreate. setResult(Activity.RESULT_CANCELED); + + accentColor=fetchAccentColor(); } public void onPreferenceChanged(String pref) { @@ -675,4 +682,19 @@ 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); + return color; + } } diff --git a/src/com/android/documentsui/files/LauncherActivity.java b/src/com/android/documentsui/files/LauncherActivity.java index 543fb072a..db29254aa 100644 --- a/src/com/android/documentsui/files/LauncherActivity.java +++ b/src/com/android/documentsui/files/LauncherActivity.java @@ -67,7 +67,7 @@ public class LauncherActivity extends Activity { finish(); - fetchAccentColor(); + } @@ -172,20 +172,5 @@ public class LauncherActivity extends Activity { return result; } - /* - * 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 - getSupportActionBar().setBackgroundDrawable( - new ColorDrawable(color)); - return color; - } } -- GitLab From f12c294258dd1ae307f668b7212ce717479ec9e0 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Mon, 14 Sep 2020 18:07:03 +0530 Subject: [PATCH 03/14] implementation on Selected items, status bar, navigation Toolbar --- .../documentsui/ActionModeController.java | 1 + src/com/android/documentsui/BaseActivity.java | 21 +++++++++++++++++++ .../android/documentsui/DrawerController.java | 3 +++ .../dirlist/DirectoryItemAnimator.java | 5 ++++- .../documentsui/files/LauncherActivity.java | 17 +++++++++++++++ 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/com/android/documentsui/ActionModeController.java b/src/com/android/documentsui/ActionModeController.java index dc453b775..29d26abc6 100644 --- a/src/com/android/documentsui/ActionModeController.java +++ b/src/com/android/documentsui/ActionModeController.java @@ -91,6 +91,7 @@ public class ActionModeController extends SelectionObserver R.plurals.elements_selected, mSelected.size()); mActionMode.setTitle(title); mActivity.getWindow().setTitle(title); + } } diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java index 9dab21c27..57005e136 100644 --- a/src/com/android/documentsui/BaseActivity.java +++ b/src/com/android/documentsui/BaseActivity.java @@ -29,6 +29,7 @@ import android.content.pm.ProviderInfo; import android.content.res.TypedArray; import android.graphics.drawable.ColorDrawable; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.MessageQueue.IdleHandler; import android.preference.PreferenceManager; @@ -42,6 +43,8 @@ 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; @@ -74,6 +77,7 @@ import java.util.List; import javax.annotation.Nullable; + public abstract class BaseActivity extends Activity implements CommonAddons, NavigationViewManager.Environment { @@ -695,6 +699,23 @@ public abstract class BaseActivity 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); + } + } diff --git a/src/com/android/documentsui/DrawerController.java b/src/com/android/documentsui/DrawerController.java index 1a69363f1..b1608baf4 100644 --- a/src/com/android/documentsui/DrawerController.java +++ b/src/com/android/documentsui/DrawerController.java @@ -17,6 +17,7 @@ package com.android.documentsui; import static com.android.documentsui.base.SharedMinimal.DEBUG; +import static com.android.documentsui.files.LauncherActivity.ACCENT_COLOR; import android.annotation.IntDef; import android.app.Activity; @@ -61,6 +62,8 @@ public abstract class DrawerController implements DrawerListener { View drawer = activity.findViewById(R.id.drawer_roots); Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar); + toolbar.setBackgroundColor(ACCENT_COLOR); + drawer.getLayoutParams().width = calculateDrawerWidth(activity); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( diff --git a/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java b/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java index d769f7fda..fa07dc853 100644 --- a/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java +++ b/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java @@ -31,6 +31,8 @@ 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 * the way selection animations are normally performed - instead of cross fading the old Item with a @@ -46,7 +48,8 @@ class DirectoryItemAnimator extends DefaultItemAnimator { 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 = context.getResources().getColor(ACCENT_COLOR); } @Override diff --git a/src/com/android/documentsui/files/LauncherActivity.java b/src/com/android/documentsui/files/LauncherActivity.java index db29254aa..ef086eb74 100644 --- a/src/com/android/documentsui/files/LauncherActivity.java +++ b/src/com/android/documentsui/files/LauncherActivity.java @@ -58,11 +58,14 @@ public class LauncherActivity extends Activity { private static final String[] PERSISTENT_BOOLEAN_EXTRAS = { DocumentsContract.EXTRA_SHOW_ADVANCED }; + public static int ACCENT_COLOR; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + ACCENT_COLOR=fetchAccentColor(); + launch(); finish(); @@ -172,5 +175,19 @@ public class LauncherActivity extends Activity { return result; } + /* + * 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 + + return color; + } } -- GitLab From 302e2b3300abab53cbb51e37ceac43a47c0c6138 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Mon, 14 Sep 2020 21:08:20 +0530 Subject: [PATCH 04/14] update bug --- src/com/android/documentsui/dirlist/DirectoryItemAnimator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java b/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java index fa07dc853..a32f520c1 100644 --- a/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java +++ b/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java @@ -49,7 +49,7 @@ class DirectoryItemAnimator extends DefaultItemAnimator { 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(ACCENT_COLOR); + mSelectedColor = Integer.valueOf(ACCENT_COLOR); } @Override -- GitLab From 871423dc232c6fd50138ca84cc55806d167721e8 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Mon, 14 Sep 2020 22:16:48 +0530 Subject: [PATCH 05/14] Test toobar navigation drawer --- src/com/android/documentsui/DrawerController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/documentsui/DrawerController.java b/src/com/android/documentsui/DrawerController.java index b1608baf4..f2dcb46a2 100644 --- a/src/com/android/documentsui/DrawerController.java +++ b/src/com/android/documentsui/DrawerController.java @@ -62,7 +62,7 @@ public abstract class DrawerController implements DrawerListener { View drawer = activity.findViewById(R.id.drawer_roots); Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar); - toolbar.setBackgroundColor(ACCENT_COLOR); + toolbar.setBackgroundColor(activity.getResources().getColor(R.color.root_title_color)); drawer.getLayoutParams().width = calculateDrawerWidth(activity); -- GitLab From 27d021d6c61a50323fc9a9882d8bfdf5ee2f9eb4 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Tue, 15 Sep 2020 08:13:04 +0530 Subject: [PATCH 06/14] update for toolbar navigation drawer --- .../android/documentsui/DrawerController.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/com/android/documentsui/DrawerController.java b/src/com/android/documentsui/DrawerController.java index f2dcb46a2..9b89a5ddf 100644 --- a/src/com/android/documentsui/DrawerController.java +++ b/src/com/android/documentsui/DrawerController.java @@ -21,11 +21,13 @@ import static com.android.documentsui.files.LauncherActivity.ACCENT_COLOR; 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.View; import android.widget.Toolbar; @@ -42,6 +44,7 @@ import java.lang.annotation.RetentionPolicy; public abstract class DrawerController implements DrawerListener { public static final String TAG = "DrawerController"; + public abstract void update(); public abstract void setOpen(boolean open); public abstract boolean isPresent(); @@ -62,7 +65,10 @@ public abstract class DrawerController implements DrawerListener { View drawer = activity.findViewById(R.id.drawer_roots); Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar); - toolbar.setBackgroundColor(activity.getResources().getColor(R.color.root_title_color)); + int accentColor=fetchAccentColor(activity); + if(accentColor!=0){ + toolbar.setBackgroundColor(accentColor); + } drawer.getLayoutParams().width = calculateDrawerWidth(activity); @@ -76,6 +82,8 @@ public abstract class DrawerController implements DrawerListener { return new RuntimeDrawerController(layout, drawer, toggle, toolbar, activityConfig); } + + /** * Returns a controller suitable for {@code Layout}. */ @@ -250,4 +258,18 @@ 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; + } } -- GitLab From 477560f6b6a0f1f33cbe16ea85169c3281d29471 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Tue, 15 Sep 2020 11:32:57 +0530 Subject: [PATCH 07/14] update for Grid selected --- res/layout/item_dir_grid.xml | 1 + src/com/android/documentsui/BaseActivity.java | 2 +- .../android/documentsui/DrawerController.java | 15 +++++++++++---- .../documentsui/dirlist/GridDirectoryHolder.java | 16 +++++++++++++++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/res/layout/item_dir_grid.xml b/res/layout/item_dir_grid.xml index da923e94d..4de486a33 100644 --- a/res/layout/item_dir_grid.xml +++ b/res/layout/item_dir_grid.xml @@ -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. --> Date: Tue, 15 Sep 2020 12:15:31 +0530 Subject: [PATCH 08/14] update for Grid selected bug resolved --- src/com/android/documentsui/DrawerController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/android/documentsui/DrawerController.java b/src/com/android/documentsui/DrawerController.java index 1fc6389f1..56900883f 100644 --- a/src/com/android/documentsui/DrawerController.java +++ b/src/com/android/documentsui/DrawerController.java @@ -150,11 +150,13 @@ public abstract class DrawerController implements DrawerListener { // 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); } - v.setBackgroundColor(id); + } @Override -- GitLab From 19976714a3ebcf0f780bb17f15896ece814947a3 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Tue, 15 Sep 2020 13:16:03 +0530 Subject: [PATCH 09/14] update for Grid selected update CheckImage and TextTitle color --- src/com/android/documentsui/dirlist/GridDirectoryHolder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/com/android/documentsui/dirlist/GridDirectoryHolder.java b/src/com/android/documentsui/dirlist/GridDirectoryHolder.java index 6379e4a94..fa4aad328 100644 --- a/src/com/android/documentsui/dirlist/GridDirectoryHolder.java +++ b/src/com/android/documentsui/dirlist/GridDirectoryHolder.java @@ -66,6 +66,8 @@ final class GridDirectoryHolder extends DocumentHolder { if(selected){ mlayout_grid_item.setBackgroundColor(BaseActivity.accentColor); + mTitle.setTextColor(context.getResources().getColor(R.color.window_background)); + mIconCheck.setColorFilter(BaseActivity.accentColor, android.graphics.PorterDuff.Mode.SRC_IN); } else { mlayout_grid_item.setBackgroundColor(context.getResources().getColor(R.color.menu_search_background)); -- GitLab From f2a3c9ebfea605656a83bd6f04878b15a22084fa Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Tue, 15 Sep 2020 14:35:30 +0530 Subject: [PATCH 10/14] update for Grid selected update CheckImage and TextTitle color --- res/layout/item_doc_list.xml | 1 + .../documentsui/ActionModeController.java | 1 + .../documentsui/dirlist/GridDirectoryHolder.java | 4 +++- .../documentsui/dirlist/ListDocumentHolder.java | 16 +++++++++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/res/layout/item_doc_list.xml b/res/layout/item_doc_list.xml index 00b9aa22a..3d83473aa 100644 --- a/res/layout/item_doc_list.xml +++ b/res/layout/item_doc_list.xml @@ -24,6 +24,7 @@ mFileTypeLookup; // This is used in as a convenience in our bind method. private final DocumentInfo mDoc; + private final LinearLayout layout_list_item; + private final Context context; public ListDocumentHolder(Context context, ViewGroup parent, IconHelper iconHelper, Lookup fileTypeLookup) { super(context, parent, R.layout.item_doc_list); - + this.context=context; mIconLayout = itemView.findViewById(android.R.id.icon); mIconMime = (ImageView) itemView.findViewById(R.id.icon_mime); mIconThumb = (ImageView) itemView.findViewById(R.id.icon_thumb); @@ -69,6 +72,7 @@ final class ListDocumentHolder extends DocumentHolder { mType = (TextView) itemView.findViewById(R.id.file_type); // Warning: mDetails view doesn't exists in layout-sw720dp-land layout mDetails = (LinearLayout) itemView.findViewById(R.id.line2); + layout_list_item = (LinearLayout) itemView.findViewById(R.id.layout_list_item); mIconHelper = iconHelper; mFileTypeLookup = fileTypeLookup; @@ -101,6 +105,16 @@ final class ListDocumentHolder extends DocumentHolder { mIconMime.setAlpha(1f - checkAlpha); mIconThumb.setAlpha(1f - checkAlpha); } + + if(selected){ + layout_list_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 { + layout_list_item.setBackgroundColor(context.getResources().getColor(R.color.menu_search_background)); + mTitle.setTextColor(context.getResources().getColor(R.color.item_title)); + } } @Override -- GitLab From 2e98eb368a501a9af4404cc6b8cfa8831ca6456a Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Tue, 15 Sep 2020 14:41:08 +0530 Subject: [PATCH 11/14] update colors.xml in color accent --- res/values/colors.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index c5002615e..7fbec22b8 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -26,7 +26,9 @@ #ff254FAE @color/tool_bar_color - @color/tool_bar_color + + @*android:color/accent_device_default + @*android:color/accent_device_default @*android:color/accent_device_default_dark @*android:color/white -- GitLab From 0171c329e003b0ea6fa6991d66a396e74e19eb7f Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Fri, 18 Sep 2020 13:34:46 +0530 Subject: [PATCH 12/14] update Theme_DeviceDefault_Light --- src/com/android/documentsui/DrawerController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/android/documentsui/DrawerController.java b/src/com/android/documentsui/DrawerController.java index 56900883f..4e3f14ff1 100644 --- a/src/com/android/documentsui/DrawerController.java +++ b/src/com/android/documentsui/DrawerController.java @@ -28,6 +28,7 @@ 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; @@ -274,8 +275,11 @@ public abstract class DrawerController implements DrawerListener { 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); + + ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(activity, android.R.style.Theme_DeviceDefault_Light); + contextThemeWrapper.getTheme().resolveAttribute(android.R.attr.colorAccent, + typedValue, true); + int color = typedValue.data; a.recycle(); Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); //toolbar change color to accent color -- GitLab From d49230cd7bef457e354e8a4a7014e722cb8016bc Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Wed, 23 Sep 2020 09:31:16 +0530 Subject: [PATCH 13/14] update issue color is not changing according to Accent color --- src/com/android/documentsui/BaseActivity.java | 6 +++++- src/com/android/documentsui/DrawerController.java | 7 ++----- src/com/android/documentsui/files/LauncherActivity.java | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java index cb7450789..7a2a28ca0 100644 --- a/src/com/android/documentsui/BaseActivity.java +++ b/src/com/android/documentsui/BaseActivity.java @@ -39,6 +39,7 @@ 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; @@ -692,11 +693,14 @@ public abstract class BaseActivity * */ private int fetchAccentColor() { + TypedValue typedValue = new TypedValue(); - TypedArray a = this.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); + TypedArray a = 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 change color to accent color toolbar.setBackgroundColor(color); diff --git a/src/com/android/documentsui/DrawerController.java b/src/com/android/documentsui/DrawerController.java index 4e3f14ff1..eea3c9a2e 100644 --- a/src/com/android/documentsui/DrawerController.java +++ b/src/com/android/documentsui/DrawerController.java @@ -275,11 +275,8 @@ public abstract class DrawerController implements DrawerListener { 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; + 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 diff --git a/src/com/android/documentsui/files/LauncherActivity.java b/src/com/android/documentsui/files/LauncherActivity.java index ef086eb74..c6e5763f6 100644 --- a/src/com/android/documentsui/files/LauncherActivity.java +++ b/src/com/android/documentsui/files/LauncherActivity.java @@ -31,6 +31,7 @@ import android.provider.DocumentsContract; import android.support.annotation.Nullable; import android.util.Log; import android.util.TypedValue; +import android.view.ContextThemeWrapper; import com.android.documentsui.R; @@ -181,12 +182,11 @@ public class LauncherActivity extends Activity { private int fetchAccentColor() { TypedValue typedValue = new TypedValue(); - TypedArray a = this.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); + TypedArray a = 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; } -- GitLab From e1644e27f4a2e245d03dadfa564f07f714572a31 Mon Sep 17 00:00:00 2001 From: Narinder Rana Date: Wed, 23 Sep 2020 11:13:13 +0530 Subject: [PATCH 14/14] update issue color is not changing according to Accent color : imp using XML --- res/values/colors.xml | 4 ++-- src/com/android/documentsui/BaseActivity.java | 12 +++++------- src/com/android/documentsui/DrawerController.java | 6 ++++-- .../android/documentsui/files/LauncherActivity.java | 7 ++++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index 7fbec22b8..0ae5a0e24 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -26,9 +26,9 @@ #ff254FAE @color/tool_bar_color - + @*android:color/accent_device_default - @*android:color/accent_device_default + @*android:color/accent_device_default_dark @*android:color/white diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java index 7a2a28ca0..13e251233 100644 --- a/src/com/android/documentsui/BaseActivity.java +++ b/src/com/android/documentsui/BaseActivity.java @@ -693,15 +693,13 @@ public abstract class BaseActivity * */ private int fetchAccentColor() { - - TypedValue typedValue = new TypedValue(); - TypedArray a = obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); + int color=getResources().getColor(R.color.accent); + /* TypedValue typedValue = new TypedValue(); + TypedArray a = activity.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); - a.recycle(); + a.recycle();*/ Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); - //toolbar change color to accent color - - //toolbar change color to accent color + //toolbar change color to accent color toolbar.setBackgroundColor(color); //change status bar color diff --git a/src/com/android/documentsui/DrawerController.java b/src/com/android/documentsui/DrawerController.java index eea3c9a2e..51dbda611 100644 --- a/src/com/android/documentsui/DrawerController.java +++ b/src/com/android/documentsui/DrawerController.java @@ -274,10 +274,12 @@ public abstract class DrawerController implements DrawerListener { * */ private static int fetchAccentColor(Activity activity) { - TypedValue typedValue = new TypedValue(); + + int color=activity.getResources().getColor(R.color.accent); + /* TypedValue typedValue = new TypedValue(); TypedArray a = activity.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); - a.recycle(); + a.recycle();*/ Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); //toolbar change color to accent color return color; diff --git a/src/com/android/documentsui/files/LauncherActivity.java b/src/com/android/documentsui/files/LauncherActivity.java index c6e5763f6..59d5c8e85 100644 --- a/src/com/android/documentsui/files/LauncherActivity.java +++ b/src/com/android/documentsui/files/LauncherActivity.java @@ -181,10 +181,11 @@ public class LauncherActivity extends Activity { * */ private int fetchAccentColor() { - TypedValue typedValue = new TypedValue(); - TypedArray a = obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); + int color=getResources().getColor(R.color.accent); + /* TypedValue typedValue = new TypedValue(); + TypedArray a = activity.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); - a.recycle(); + a.recycle();*/ Log.e("TAG", "accent Colour #"+Integer.toHexString(color)); //toolbar change color to accent color return color; -- GitLab