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

Commit c3e148ab authored by Wysie's avatar Wysie
Browse files

Implemented code to hide status bar clock, as well as change battery...

Implemented code to hide status bar clock, as well as change battery percentage colour. Also, there are different alignments to fix issue 1208 for D/S and N1 devices. D/S one can be further improved according to PsychoI3oy, but I don't have a D/S to work on.
parent 7f6513bd
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1355,6 +1355,13 @@ public final class Settings {
         */
        public static final String RECENT_APPS_NUMBER = "recent_apps_number";
        
        /**
         * Wysie_Soh
         * Specifies whether to show or hide clock
         * @hide
         */
        public static final String SHOW_STATUS_CLOCK = "show_status_clock";
        
        /**
         * Wysie_Soh
         * Specifies the clock color
+50 −20
Original line number Diff line number Diff line
@@ -13,10 +13,12 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.util.DisplayMetrics;

class StatusBarIcon {
    // TODO: get this from a resource
@@ -32,9 +34,11 @@ class StatusBarIcon {
    private AnimatedImageView mImageView;
    private TextView mNumberView;
    private int clockColor = 0xff000000;
    private int currClockColor;
    private int batteryPercentColor = 0xffffffff;
    private Context mContext;

    public StatusBarIcon(Context context, IconData data, ViewGroup parent) {
        mContext = context;
        mData = data.clone();

        switch (data.type) {
@@ -46,13 +50,23 @@ class StatusBarIcon {
                        LinearLayout.LayoutParams.WRAP_CONTENT,
                        LinearLayout.LayoutParams.FILL_PARENT);
                t.setTextSize(16);
                updateColors(context);
                t.setTypeface(Typeface.DEFAULT_BOLD);
                t.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
                t.setPadding(6, 0, 0, 0);
                t.setLayoutParams(layoutParams);
                t.setText(data.text);
                this.view = t;
                
                clockColor = Settings.System.getInt(mContext.getContentResolver(), Settings.System.CLOCK_COLOR, clockColor);
                t.setTextColor(clockColor);
                
                if (getBoolean(Settings.System.SHOW_STATUS_CLOCK, true)) {
                    t.setVisibility(View.VISIBLE);
                }
                else {
                    t.setVisibility(View.GONE);
                }
                
                break;
            }

@@ -99,13 +113,33 @@ class StatusBarIcon {
                mNumberView = nv;
                
                //remove background, center, and change gravity of text                
                // attempt to correct position on both hdpi and mdpi
                DisplayMetrics dm = new DisplayMetrics();
                ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(dm);
        
                if (DisplayMetrics.DENSITY_HIGH == dm.densityDpi) {               
                    mNumberView.setLayoutParams(
                        new FrameLayout.LayoutParams(
                            FrameLayout.LayoutParams.WRAP_CONTENT,
                            FrameLayout.LayoutParams.WRAP_CONTENT,
                            Gravity.RIGHT | Gravity.CENTER_VERTICAL));
                mNumberView.setBackgroundDrawable(null);

                    mNumberView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
                }
                else {
                    mNumberView.setLayoutParams(
                        new FrameLayout.LayoutParams(
                            FrameLayout.LayoutParams.WRAP_CONTENT,
                            FrameLayout.LayoutParams.WRAP_CONTENT,
                            Gravity.CENTER | Gravity.CENTER_VERTICAL));

                    mNumberView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);                    
                }
                
                mNumberView.setBackgroundDrawable(null);                
                batteryPercentColor = Settings.System.getInt(mContext.getContentResolver(),
                                        Settings.System.BATTERY_PERCENTAGE_STATUS_COLOR, batteryPercentColor);
                mNumberView.setTextColor(batteryPercentColor);
                mNumberView.setTextSize(12);

                if (data.number > 0) {
@@ -208,12 +242,8 @@ class StatusBarIcon {
        return mData.number;
    }   

    private void updateColors(Context context) {
        clockColor = Settings.System.getInt(context.getContentResolver(), Settings.System.CLOCK_COLOR, clockColor);
        if (currClockColor != clockColor) {
            mTextView.setTextColor(clockColor);
            currClockColor = clockColor;
        }
    private boolean getBoolean(String systemSettingKey, boolean defaultValue) {
        return 1 == android.provider.Settings.System.getInt(mContext.getContentResolver(), systemSettingKey, defaultValue ? 1 : 0);
    }
}
+22 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import java.lang.reflect.Field;


/**
@@ -864,6 +865,27 @@ public class StatusBarService extends IStatusBar.Stub
            return null;
        }
        
        /* Lame attempt at trying to retrieve all TextViews, any more ideas? A good way will be
         * to use something like setForegroundColor on child, but no such method exists for Views.
         * The main reason for doing this is certain apps like Quick Setttings, and even the in-call
         * notification item does not get overwritten by this mod :(. - Wysie
         * Class cl = child.getClass();
         * Field[] fields = cl.getFields();
         * TextView temp = null;
         * int count = fields.length;
         *
         * for (int i = 0; i < count; i++) {
         *    try {
         *        Log.d("TITLE", "" + com.android.internal.R.id.title);
         *        temp = (TextView) child.findViewById(fields[i].getInt(child));
         *        temp.setTextColor(whiteColor);
         *    }
         *    catch (Exception e) {
         *        Log.d("WYSIE", e.toString());
         *    }
         * }
         */

        //Try-catch cause it does not work with QuickSettings, possibly other apps too :( (Won't work thru XML as well)
        try {
            TextView tv1 = (TextView) child.findViewById(com.android.internal.R.id.title);