Android7.0 为亮度条添加百分比(MTK)

直接贴修改记录
diff --git a/frameworks/base/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml b/frameworks/base/packages/SystemUI/res/layo
index 5cbe635..9460edea 100644
--- a/frameworks/base/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml
+++ b/frameworks/base/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml
@@ -15,8 +15,6 @@
 -->
       xmlns:systemui="http://schemas.android.com/apk/res-auto"
-    android:layout_height="48dp"
-    android:layout_width="match_parent"
     android:paddingLeft="16dp"
     android:paddingRight="16dp"
     style="@style/BrightnessDialogContainer">
@@ -30,6 +28,14 @@
         android:src="@drawable/ic_qs_brightness_auto_off"
         android:contentDescription="@null"
         android:visibility="gone" />
+        
+     +        android:id="@+id/bringhtness_percent"
+        android:gravity="center"
+        android:layout_gravity="center_vertical"
+        android:layout_width="48dp"
+        android:layout_height="wrap_content" 
+        android:textSize="18dp"/>
 
               android:id="@+id/brightness_slider"
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/frameworks/base/packages/SystemUI/src/com/android
index 67be5e3..d702406 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -27,6 +27,7 @@ import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.ImageView;
+import android.widget.TextView;
 import android.widget.LinearLayout;
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
@@ -107,6 +108,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
 
         mBrightnessController = new BrightnessController(getContext(),
                 (ImageView) findViewById(R.id.brightness_icon),
+                (TextView) findViewById(R.id.bringhtness_percent),
                 (ToggleSlider) findViewById(R.id.brightness_slider));
 
     }
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java b/frameworks/base/packages/Syste
index d5131be..647cb0b 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
@@ -34,6 +34,7 @@ import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 
 import java.util.ArrayList;
+import android.widget.TextView;
 
 public class BrightnessController implements ToggleSlider.Listener {
     private static final String TAG = "StatusBar.BrightnessController";
@@ -50,6 +51,7 @@ public class BrightnessController implements ToggleSlider.Listener {
 
     private final Context mContext;
     private final ImageView mIcon;
+    private final TextView mTextView;
     private final ToggleSlider mControl;
     private final boolean mAutomaticAvailable;
     private final IPowerManager mPower;
@@ -132,9 +134,10 @@ public class BrightnessController implements ToggleSlider.Listener {
 
     }
 
-    public BrightnessController(Context context, ImageView icon, ToggleSlider control) {
+    public BrightnessController(Context context, ImageView icon, TextView testview, ToggleSlider control) {
         mContext = context;
         mIcon = icon;
+        mTextView = testview;
         mControl = control;
         mHandler = new Handler();
         mUserTracker = new CurrentUserTracker(mContext) {
@@ -209,6 +212,8 @@ public class BrightnessController implements ToggleSlider.Listener {
                 MetricsLogger.action(mContext, MetricsEvent.ACTION_BRIGHTNESS, val);
             }
             setBrightness(val);
+            int npercent = (value*100)/(mMaximumBacklight-mMinimumBacklight);
+            mTextView.setText(npercent + "%");
             if (!tracking) {
                 AsyncTask.execute(new Runnable() {
                         public void run() {
@@ -299,6 +304,8 @@ public class BrightnessController implements ToggleSlider.Listener {
                     UserHandle.USER_CURRENT);
             mControl.setMax(mMaximumBacklight - mMinimumBacklight);
             mControl.setValue(value - mMinimumBacklight);
+            int npercent = ((value-mMinimumBacklight)*100)/(mMaximumBacklight-mMinimumBacklight);
+            mTextView.setText(npercent + "%");
         }
     }
 
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java b/frameworks/base/packages/SystemUI/
index 4952234..4bae301 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java
@@ -23,7 +23,7 @@ import android.view.KeyEvent;
 import android.view.Window;
 import android.view.WindowManager;
 import android.widget.ImageView;
-
+import android.widget.TextView;
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.systemui.R;
@@ -46,8 +46,9 @@ public class BrightnessDialog extends Activity {
         setContentView(R.layout.quick_settings_brightness_dialog);
 
         final ImageView icon = (ImageView) findViewById(R.id.brightness_icon);
+        final TextView mTextView = (TextView) findViewById(R.id.bringhtness_percent);
         final ToggleSlider slider = (ToggleSlider) findViewById(R.id.brightness_slider);
-        mBrightnessController = new BrightnessController(this, icon, slider);
+        mBrightnessController = new BrightnessController(this, icon, mTextView, slider);
     }
 
     @Override
 

你可能感兴趣的:(mtk_android)