Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d2971dd authored by narinder Rana's avatar narinder Rana Committed by Romain Hunault
Browse files

Use accent color in UI

parent 9f8c0408
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -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;
    }



}
+8 −2
Original line number Diff line number Diff line
@@ -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),
                    imageView.setColorFilter(mActivity.getResources().getColor(ACCENT_COLOR),
                            PorterDuff.Mode.SRC_ATOP);
            textView.setTextColor(ACCENT_COLOR);
        } else {
            imageView.clearColorFilter();
        }

    }

    private void notifyChangeAndRebuildList() {
+5 −2
Original line number Diff line number Diff line
@@ -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;
        }