diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java index 9e94ff1bc78aef7029883412e41797d2f3e7fc84..28c3ec5c4231eb9285afc6361a3930d16e4f0671 100644 --- a/src/com/android/contacts/activities/PeopleActivity.java +++ b/src/com/android/contacts/activities/PeopleActivity.java @@ -28,8 +28,11 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SyncStatusObserver; import android.content.res.Configuration; +import android.content.res.TypedArray; import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.provider.ContactsContract; @@ -47,11 +50,14 @@ import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; +import android.util.TypedValue; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.widget.ImageButton; @@ -111,6 +117,7 @@ public class PeopleActivity extends AppCompatContactsActivity implements DrawerFragmentListener, SelectAccountDialogFragment.Listener { + public static int ACCENT_COLOR = 0; /** Possible views of Contacts app. */ public enum ContactsView { NONE, @@ -413,6 +420,8 @@ public class PeopleActivity extends AppCompatContactsActivity implements Log.d(Constants.PERFORMANCE_TAG, "PeopleActivity.onCreate finish"); } getWindow().setBackgroundDrawable(null); + + ACCENT_COLOR=fetchAccentColor(); } @Override @@ -1292,4 +1301,30 @@ public class PeopleActivity extends AppCompatContactsActivity implements } + /* + * 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)); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + Window window = getWindow(); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(color); + } + + getSupportActionBar().setBackgroundDrawable( + new ColorDrawable(color)); + return color; + } + + + } diff --git a/src/com/android/contacts/drawer/DrawerAdapter.java b/src/com/android/contacts/drawer/DrawerAdapter.java index ba45163538cd3e074ccc8ef20c506fd9321eb6b9..b62054be6237261b4b9883eeabd1622a90e429ac 100644 --- a/src/com/android/contacts/drawer/DrawerAdapter.java +++ b/src/com/android/contacts/drawer/DrawerAdapter.java @@ -44,6 +44,8 @@ import com.android.contactsbind.ObjectFactory; import java.util.ArrayList; import java.util.List; +import static com.android.contacts.activities.PeopleActivity.ACCENT_COLOR; + public class DrawerAdapter extends BaseAdapter { private static final int VIEW_TYPE_PRIMARY_ITEM = 0; @@ -267,6 +269,7 @@ public class DrawerAdapter extends BaseAdapter { titleView.setText(item.text); final ImageView iconView = (ImageView) result.findViewById(R.id.icon); iconView.setImageResource(item.icon); + iconView.setColorFilter(ACCENT_COLOR, android.graphics.PorterDuff.Mode.MULTIPLY); final TextView newBadge = (TextView) result.findViewById(R.id.assistant_new_badge); final boolean showWelcomeBadge = !SharedPreferenceUtil.isWelcomeCardDismissed(mActivity); newBadge.setVisibility(item.contactsView == ContactsView.ASSISTANT && showWelcomeBadge @@ -404,12 +407,15 @@ public class DrawerAdapter extends BaseAdapter { private void updateSelectedStatus(TextView textView, ImageView imageView, boolean activated) { textView.setTextAppearance(mActivity, activated ? TYPEFACE_STYLE_ACTIVATE : TYPEFACE_STYLE_INACTIVE); + if (activated) { - imageView.setColorFilter(mActivity.getResources().getColor(R.color.primary_color), - PorterDuff.Mode.SRC_ATOP); + imageView.setColorFilter(mActivity.getResources().getColor(ACCENT_COLOR), + PorterDuff.Mode.SRC_ATOP); + textView.setTextColor(ACCENT_COLOR); } else { imageView.clearColorFilter(); } + } private void notifyChangeAndRebuildList() { diff --git a/src/com/android/contacts/list/CustomContactListFilterActivity.java b/src/com/android/contacts/list/CustomContactListFilterActivity.java index 92087b3a4c189af6be919a54b8c6d2f9f3d35185..ad621b16f38c406948250a1361ddc62162e2f3e9 100644 --- a/src/com/android/contacts/list/CustomContactListFilterActivity.java +++ b/src/com/android/contacts/list/CustomContactListFilterActivity.java @@ -57,6 +57,7 @@ import android.widget.ExpandableListView.ExpandableListContextMenuInfo; import android.widget.TextView; import com.android.contacts.R; +import com.android.contacts.activities.PeopleActivity; import com.android.contacts.model.AccountTypeManager; import com.android.contacts.model.ValuesDelta; import com.android.contacts.model.account.AccountInfo; @@ -593,8 +594,10 @@ public class CustomContactListFilterActivity extends Activity implements final int textColor = mContext.getResources().getColor(isExpanded ? R.color.dialtacts_theme_color : R.color.account_filter_text_color); - text1.setTextColor(textColor); - text2.setTextColor(textColor); + // text1.setTextColor(textColor); + // text2.setTextColor(textColor); + text1.setTextColor(PeopleActivity.ACCENT_COLOR); + text2.setTextColor(PeopleActivity.ACCENT_COLOR); return convertView; }