增加电量百分比功能

差分包:

--- a/idh.code/frameworks/base/core/java/android/provider/Settings.java
+++ b/idh.code/frameworks/base/core/java/android/provider/Settings.java
@@ -4519,6 +4519,10 @@ public final class Settings {
          */
         public static final String PAYMENT_SERVICE_SEARCH_URI = "payment_service_search_uri";

+        /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+       public static final String BATTERY_PERCENTAGE = "battery_percentage";
+        /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
+
         /**
          * This are the settings to be backed up.
          *
diff --git a/idh.code/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/idh.code/frameworks/base/packages/SettingsPro
index 506c0b1..b4c7d8b 100755
--- a/idh.code/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/idh.code/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -190,4 +190,6 @@
     <integer name="def_sms_validity">255</integer>
     <!--tangjc add-->
     <string name="time_12_24" translatable="false">24</string>
+    <!--Yang Liu add-->
+    <bool name="def_battery_percentage">false</bool>
 </resources>
diff --git a/idh.code/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/idh.code/frame
index 22351dc..35b0554 100755
--- a/idh.code/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/idh.code/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2148,6 +2148,10 @@ public class DatabaseHelper extends SQLiteOpenHelper {
                                   R.string.config_default_input_method);
             }
             /* @} */
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+            loadBooleanSetting(stmt, Settings.Secure.BATTERY_PERCENTAGE,
+                    R.bool.def_battery_percentage);
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
         } finally {
             if (stmt != null) stmt.close();
         }
diff --git a/idh.code/frameworks/base/packages/SystemUI/res/layout/status_bar.xml b/idh.code/frameworks/base/packages/SystemUI/res/layo
old mode 100644
new mode 100755
index 1b67e8a..794a0c6
--- a/idh.code/frameworks/base/packages/SystemUI/res/layout/status_bar.xml
+++ b/idh.code/frameworks/base/packages/SystemUI/res/layout/status_bar.xml
@@ -95,6 +95,15 @@
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     />
+                 <TextView
+                       android:id="@+id/percentage"
+                       android:layout_height="wrap_content"
+                       android:layout_width="wrap_content"
+                       android:visibility = "gone"
+                       android:paddingLeft="4dip"
+                       android:textSize="16sp"
+                       android:textColor="@android:color/holo_blue_light"
+                />
                 <!-- battery must be padded below by 2px to match assets -->
                 <com.android.systemui.BatteryMeterView
                     android:id="@+id/battery"
diff --git a/idh.code/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/idh.code/framewo
old mode 100644
new mode 100755
index ba5c2a9..67ed407
--- a/idh.code/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/idh.code/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -548,6 +548,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
         // Other icons
         mLocationController = new LocationController(mContext); // will post a notification
         mBatteryController = new BatteryController(mContext);
+       /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+       mBatteryController.addLabelView((TextView) mStatusBarWindow.findViewById(R.id.percentage));
+       /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
         mNetworkController = new NetworkController(mContext);
         mBluetoothController = new BluetoothController(mContext);
         mRotationLockController = new RotationLockController(mContext);
diff --git a/idh.code/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java b/idh.code/fra
old mode 100644
new mode 100755
index d098d3d..1c59ad1
--- a/idh.code/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
+++ b/idh.code/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
@@ -25,13 +25,23 @@ import android.graphics.drawable.Drawable;
 import android.os.BatteryManager;
 import android.util.Log;
 import android.widget.ImageView;
-
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+import android.widget.TextView;
+import android.view.View;
+import android.provider.Settings;
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
 import java.util.ArrayList;

 import com.android.systemui.R;

 public class BatteryController extends BroadcastReceiver {
     private static final String TAG = "StatusBar.BatteryController";
+    /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+    private boolean mShouldShowBatteryPercentage = false;
+    private String mBatteryPercentage = "100%";
+    private static final String ACTION_BATTERY_PERCENTAGE_SWITCH = "silence.intent.action.BATTERY_PERCENTAGE_SWITCH";
+    private ArrayList<TextView> mLabelViews = new ArrayList<TextView>();
+    /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
     /* SPRD: Modify 20140319 of bug 290550,rm systemui animation {@ */
     /*Context mContext;
     private ArrayList<ImageView> mIconViews = new ArrayList<ImageView>();
@@ -63,8 +73,11 @@ public class BatteryController extends BroadcastReceiver {

     public BatteryController(Context context) {
         //mContext = context;
+        mShouldShowBatteryPercentage = (Settings.Secure.getInt(context.getContentResolver(),
+                                               Settings.Secure.BATTERY_PERCENTAGE, 0) != 0);
         IntentFilter filter = new IntentFilter();
         filter.addAction(Intent.ACTION_BATTERY_CHANGED);
+       filter.addAction(ACTION_BATTERY_PERCENTAGE_SWITCH);
         context.registerReceiver(this, filter);
         /* SPRD: Modify 20140319 of bug 290550,rm systemui animation {@ */
         /*m_Anim_Charge_a = (AnimationDrawable) context.getResources().getDrawable(R.anim.stat_sys_battery_charge_anim_a);
@@ -76,7 +89,18 @@ public class BatteryController extends BroadcastReceiver {
         m_Anim_Charge_g = (AnimationDrawable) context.getResources().getDrawable(R.anim.stat_sys_battery_charge_anim_g);*/
         /* @} */
     }
-
+
+     /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+     public void addLabelView(TextView v) {
+        mLabelViews.add(v);
+    }
+    private  String getBatteryPercentage(Intent batteryChangedIntent) {
+        int level = batteryChangedIntent.getIntExtra("level", 0);
+        int scale = batteryChangedIntent.getIntExtra("scale", 100);
+        return String.valueOf(level * 100 / scale) + "%";
+    }
+     /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
+
     public void addStateChangedCallback(BatteryStateChangeCallback cb) {
         mChangeCallbacks.add(cb);
     }
@@ -189,7 +213,34 @@ public class BatteryController extends BroadcastReceiver {
                 }
             }*/
             /* @} */
+
+           /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+           mBatteryPercentage = getBatteryPercentage(intent);
+            Log.d(TAG,"mBatteryPercentage is " + mBatteryPercentage + " mShouldShowBatteryPercentage is "
+                    + mShouldShowBatteryPercentage + " mLabelViews.size() " + mLabelViews.size());
+            TextView v = mLabelViews.get(0);
+            if (mShouldShowBatteryPercentage) {
+                v.setText(mBatteryPercentage);
+                v.setVisibility(View.VISIBLE);
+            } else {
+                v.setVisibility(View.GONE);
+            }
+           /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
+        }
+           /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+       else if (action.equals(ACTION_BATTERY_PERCENTAGE_SWITCH)) {
+            mShouldShowBatteryPercentage = (intent.getIntExtra("state",0) == 1);
+            Log.d(TAG, " OnReceive from mediatek.intent.ACTION_BATTERY_PERCENTAGE_SWITCH  mShouldShowBatteryPercentage" +
+                    " is " + mShouldShowBatteryPercentage);
+            TextView v = mLabelViews.get(0);
+            if (mShouldShowBatteryPercentage) {
+                v.setText(mBatteryPercentage);
+                v.setVisibility(View.VISIBLE);
+            } else {
+                v.setVisibility(View.GONE);
+            }
         }
+       /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
     }

     // SPRD: Modify 20140319 of bug 290550,rm systemui animation
diff --git a/idh.code/packages/apps/Settings/res/values-id/strings.xml b/idh.code/packages/apps/Settings/res/values-id/strings.xml
old mode 100644
new mode 100755
index a7d5455..f024973
--- a/idh.code/packages/apps/Settings/res/values-id/strings.xml
+++ b/idh.code/packages/apps/Settings/res/values-id/strings.xml
@@ -1562,4 +1562,5 @@
   <string name="master_clear_level">"Kapasitas kurang dari 30%, apakah melanjutkan operasi ulang telepon?"</string>
   <string name="factory_dialog_title">"Minta"</string>
   <string name="wep_password_tip_text">Silakan masukan 5,13,29 karakter ASCII atau 10,26,58 karakter lain untuk otentikasi WEP.</strin
+  <string name="battery_percent">baterai Persentase</string>
 </resources>
\ No newline at end of file
diff --git a/idh.code/packages/apps/Settings/res/values-zh-rCN/strings_ex.xml b/idh.code/packages/apps/Settings/res/values-zh-rCN/strin
old mode 100644
new mode 100755
index 0de2451..deaae77
--- a/idh.code/packages/apps/Settings/res/values-zh-rCN/strings_ex.xml
+++ b/idh.code/packages/apps/Settings/res/values-zh-rCN/strings_ex.xml
@@ -60,4 +60,5 @@
   <string name="close">关闭</string>

     <string name="apn_settings_ex">SIM<xliff:g id="SIM">%s</xliff:g> 接入点名称</string>
+  <string name="battery_percent">电量百分比</string>
 </resources>
\ No newline at end of file
diff --git a/idh.code/packages/apps/Settings/res/values-zh-rTW/strings_ex.xml b/idh.code/packages/apps/Settings/res/values-zh-rTW/strin
old mode 100644
new mode 100755
index fc853f9..60e43c5
--- a/idh.code/packages/apps/Settings/res/values-zh-rTW/strings_ex.xml
+++ b/idh.code/packages/apps/Settings/res/values-zh-rTW/strings_ex.xml
@@ -60,4 +60,5 @@
   <string name="close">關閉</string>

     <string name="apn_settings_ex">SIM<xliff:g id="SIM">%s</xliff:g> 存取點名稱</string>
+  <string name="battery_percent">電量百分比</string>
 </resources>
diff --git a/idh.code/packages/apps/Settings/res/values/strings.xml b/idh.code/packages/apps/Settings/res/values/strings.xml
old mode 100644
new mode 100755
index b2cf46f..7f6af10
--- a/idh.code/packages/apps/Settings/res/values/strings.xml
+++ b/idh.code/packages/apps/Settings/res/values/strings.xml
@@ -5206,4 +5206,7 @@
     <!-- SPRD: Bug #313604 UMS Settings modify sprd USB [email protected]{ -->
     <string name="move_app_to_internal_sdcard" product="default" msgid="1143379049903056407">"Move to internal SD card"</string>
     <!-- @} -->
+    <!-- SPRD: battery percentage yang [email protected]{ -->
+    <string name="battery_percent">Battery Percentage</string>
+     <!-- @} -->
 </resources>
diff --git a/idh.code/packages/apps/Settings/res/xml/power_usage_summary.xml b/idh.code/packages/apps/Settings/res/xml/power_usage_summ
old mode 100644
new mode 100755
diff --git a/idh.code/packages/apps/Settings/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/idh.code/packages/apps/Setting
old mode 100644
new mode 100755
index fc65a8c..c362b3a
--- a/idh.code/packages/apps/Settings/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/idh.code/packages/apps/Settings/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -43,12 +43,20 @@ import com.android.settings.R;

 import java.util.List;
 import com.android.internal.os.PowerProfile;
+
+import android.preference.CheckBoxPreference;
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+import android.provider.Settings;
+import android.util.Log;
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
 /**
  * Displays a list of apps and subsystems that consume power, ordered by how much power was
  * consumed since the last time it was unplugged.
  */
 public class PowerUsageSummary extends PreferenceFragment {
-
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+    private static final String ACTION_BATTERY_PERCENTAGE_SWITCH = "silence.intent.action.BATTERY_PERCENTAGE_SWITCH";
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
     private static final boolean DEBUG = false;

     private static final String TAG = "PowerUsageSummary";
@@ -133,7 +141,21 @@ public class PowerUsageSummary extends PreferenceFragment {

     @Override
     public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
-        if (preference instanceof BatteryHistoryPreference) {
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+       if (preference instanceof CheckBoxPreference) {
+            Log.d(TAG, "click battery percentage checkbox");
+            CheckBoxPreference prf = (CheckBoxPreference) preference;
+            int state = prf.isChecked() ? 1 : 0;
+            Log.d(TAG, "state: " + state);
+            Settings.Secure.putInt(getActivity().getContentResolver(), Settings.Secure.BATTERY_PERCENTAGE, state);
+            Intent intent = new Intent(ACTION_BATTERY_PERCENTAGE_SWITCH);
+            intent.putExtra("state", state);
+            Log.d(TAG, "sendBroadcast battery percentage switch");
+            getActivity().sendBroadcast(intent);
+            return super.onPreferenceTreeClick(preferenceScreen, preference);
+        }
+/*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
+       if (preference instanceof BatteryHistoryPreference) {
             Parcel hist = Parcel.obtain();
             mStatsHelper.getStats().writeToParcelWithoutUids(hist, 0);
             byte[] histData = hist.marshall();
@@ -202,7 +224,19 @@ public class PowerUsageSummary extends PreferenceFragment {
     private void refreshStats() {
         mAppListGroup.removeAll();
         mAppListGroup.setOrderingAsAdded(false);
-
+
+        /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> start*/
+        CheckBoxPreference batterrPercentPrf = new CheckBoxPreference(getActivity());
+        batterrPercentPrf.setTitle(getString(R.string.battery_percent));
+        batterrPercentPrf.setOrder(-3);
+
+        final boolean enable = Settings.Secure.getInt(getActivity().getContentResolver(),
+                Settings.Secure.BATTERY_PERCENTAGE, 0) != 0;
+
+        batterrPercentPrf.setChecked(enable);
+        mAppListGroup.addPreference(batterrPercentPrf);
+       /*Yang Liu for <B5><E7><C1><BF><B0>???<A6><C4><DC> end*/
+
         mBatteryStatusPref.setOrder(-2);
         mAppListGroup.addPreference(mBatteryStatusPref);
         BatteryHistoryPreference hist = new BatteryHistoryPreference(
时间: 2024-10-11 21:22:44

增加电量百分比功能的相关文章

卓流应用网新功能推广——ECMALL商城增加微信商城功能

微信商城是基于当前很受欢迎的微信的这种传媒方式中的一种商业运用,微信的当前的火热是一个商机,基于微信的传播速度,及其简便等优点,为商家提供一个平台,在这个更简便的.方便的平台里进行更为现代的电子商务.同时在利用微信的这个平台也可以为商家提供更有效的宣传方式,更有利于商品的推广. 同时尽快实现商业价值是重要的阶段目标,通过微信平台实现在线销售便是一个方向.于是诞生了微信商城这个平台! 微网站一种跨移动平台的营销型网站.它源于WebApp和网站的融合创新,兼容iOS.android.WP等各大操作系

seci-log 1.11 发布,日志分析软件增加 ftpserver 等功能

日志分析软件 seci-log 1.11发布,增加了增加了ftpserver,远程ftp,sftp采集简化配置等功能. 配置文件application.properties做了简化操作. 1.对系统用到的端口采用了默认处理,这样可以不需要在配置端口了. 2.本机ip如果不配置,则获取本机第一块网卡的ip地址. 3.增加了server=syslog|remote|file|ftpserver|snmp的配置,通过减少里面的内容可以启动部分内容,也可以拆分出来进行多进程启动. 取消了file.pro

.Net Web产品中增加自己的功能和代码?

背景: 最近有一个项目,一个朋友找了一个网上比较成熟的CMS系统(动易),让我给他增加一些功能,这个产品功能挺多,但是没有源代码.按照以前的做法,就是直接反编译他的dll,生成源代码,然后在源代码的基础上修改和完善自己的功能.但是研究了一下这个产品,bin下面的DLL非常多,有主要的,还有辅助的.如果每个dll都反编译,简直不现实. ? 用发编译工具?ILSpy打开里面几个主要的dll,发现还加壳混淆了,用De4Dot反混淆出来.里面的代码还是非常清晰,但是如果每个dll都这样搞,岂不累死. ?

.NET跨平台之旅:增加文件日志功能遇到的挫折

在将我们的ASP.NET 5示例站点(about.cnblogs.com)升级至ASP.NET 5 RC1的时候,我们增加了控制台日志功能. 在ASP.NET 5添加日志功能很简单,只需在project.json中添加Microsoft.Extensions.Logging.Console的引用: "dependencies":{ "Microsoft.Extensions.Logging.Console": "1.0.0-*" } 并且在 St

给文件右击菜单增加7-ZIP浏览功能(用注册表设置Shell调用预览命令)

疯狂delphi delphiXE7.XE8.XE10公开课A 群号:58592705 QQ:513187410 朱建强 BAT-给文件右击菜单增加7-ZIP浏览功能 Reg给文件右击菜单增加7-ZIP浏览功能 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\用7-ZIP浏览(ZJQ)]"icon"="d:\\7ZIP.ico" [HKEY_CLASSES_ROOT\*\shell\用7

discuz3.2x增加邮箱验证功能

为防止垃圾用户多次注册,为disczu增加邮箱验证功能. 大致分为二步: 1.申请邮箱,这里推荐使用腾讯免费企业邮箱:https://exmail.qq.com/portal/introducefree (对普通开发者来说50个名额已足够,只要买个域名就能申请到企业邮箱还是很划算的),如果有其他更好的,欢迎推荐下 2.在discuz中进行设置. 1的具体步骤: 进入注册页面注册成功,登录企业邮箱,首页显示,如图: 在成员与群组中增加一个部门,并且在部门下增加一个用户(用来收发邮件的用户): 在我

php版给UEditor的图片在线管理栏目增加图片删除功能

1.找到uedior/dialogs/image/image.js文件,Add为修改部分的代码: /** * tab点击处理事件 * @param tabHeads * @param tabBodys * @param obj */ function clickHandler(tabHeads, tabBodys, obj) { //head样式更改 for (var k = 0, len = tabHeads.length; k < len; k++) { tabHeads[k].classN

从头认识Spring-3.8 简单的AOP日志实现(注解版)-扩展增加检查订单功能,以便记录并检测输入的参数

这一章节我们讨论一下扩展增加检查订单功能,以便记录并检测输入的参数. 1.domain 蛋糕类: package com.raylee.my_new_spring.my_new_spring.ch03.topic_1_8; public class Cake { private String name = ""; public String getName() { return name; } public void setName(String name) { this.name =

[Android]AndroidBucket增加碎片SubLayout功能及AISubLayout的注解支持

以下内容为原创,转载请注明: 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3709957.html 之前写过一篇博客,是使用Fragment来实现TabHost的效果,并且模拟TabHost的切换各个fragment生命周期的调用,见http://www.cnblogs.com/tiantianbyconan/p/3360938.html 但是如果要实现的效果是两级的Tab,比如在第一级tab中又有三个子Tab切换不同的布局, 相当于在Frag