Android13---下拉状态栏添加阅读模式(MTK平台)

问题

客户需求,阅读模式开关要加到状态栏里面。

代码位置

alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_qs_reader_off.xml [new file with mode: 0755] patch | blob
alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_qs_reader_on.xml [new file with mode: 0755] patch | blob
alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-zh-rCN/xw_strings.xml [new file with mode: 0755] patch | blob
alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml [changed mode: 0644->0755] patch | blob | history
alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/xw_strings.xml [new file with mode: 0755] patch | blob
alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java [changed mode: 0644->0755] patch | blob | history
alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tiles/XwReaderTile.java [new file with mode: 0755] patch | blob

具体代码

diff --git a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_qs_reader_off.xml b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_qs_reader_off.xml
new file mode 100755 (executable)
index 0000000..082c75c
--- /dev/null
+++ b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_qs_reader_off.xml
@@ -0,0 +1,7 @@
+\r
+\r
+    \r
+        \r
+    \r
+
\ No newline at end of file
diff --git a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_qs_reader_on.xml b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_qs_reader_on.xml
new file mode 100755 (executable)
index 0000000..41a7c30
--- /dev/null
+++ b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_qs_reader_on.xml
@@ -0,0 +1,7 @@
+\r
+\r
+    \r
+        \r
+    \r
+
\ No newline at end of file
diff --git a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-zh-rCN/xw_strings.xml b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-zh-rCN/xw_strings.xml
new file mode 100755 (executable)
index 0000000..d38a881
--- /dev/null
+++ b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-zh-rCN/xw_strings.xml
@@ -0,0 +1,25 @@
+
+
+
+
+    "实时网速"
+    "阅读模式"
+
+
+
diff --git a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml
old mode 100644 (file)
new mode 100755 (executable)
index 1a89f12..d590517
--- a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml
+++ b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml
@@ -74,7 +74,7 @@
 
     
     
-        internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle
+        internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,xwreader
     
 
     
@@ -87,7 +87,7 @@
 
     
     
-        internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction
+        internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,xwreader
     
 
     
diff --git a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/xw_strings.xml b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/xw_strings.xml
new file mode 100755 (executable)
index 0000000..7381dd3
--- /dev/null
+++ b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/xw_strings.xml
@@ -0,0 +1,209 @@
+
+
+
+
+    Charger Is Connected.
+    Charger Has Pulled Up.
+    
+    "Used"
+    "Free"
+    "Total"
+    "Memory optimization to optimal state"
+    "Clean" 
+    
+    B
+    
+    K
+    
+    M
+    
+    G
+    
+    T
+    
+    P
+
+    Sound
+    Vibrate
+    Silent
+    Mobile data
+    Screen Recorder
+
+
+    %s/s
+    %1$s"\n"%2$s  
+    
+    Network Speed
+    Reader-M
+
+    Low Battery, Flashlight not available!
+    
+    ScreenShot  
+    
+    battery full 
+
+   
+    
+    System
+    
+    Recovery
+    
+    Bootloader
+    
+    Download
+    
+    Fastbootd
+
+    
+    Restarting\u2026
+    
+    Restarting to recovery mode\u2026
+    
+    Restarting to bootloader mode\u2026
+    
+    Restarting to download mode\u2026
+    
+    Restarting to fastbootd mode\u2026
+
+    
+    Current
+
+    
+    Cursor left
+    Cursor right
+
+    
+    
+    ADB over network
+    no network
+
+    
+    Ambient display
+    Ambient display off.
+    Ambient display on.
+    Ambient display turned off.
+    Ambient display turned on.
+
+    
+    Caffeine
+    Caffeine off.
+    Caffeine on.
+
+    
+    Heads up
+    Heads up off.
+    Heads up on.
+    Heads up turned off.
+    Heads up turned on.
+
+    
+    Reading mode
+    Reading mode on.
+    Reading mode off.
+    Reading mode turned on.
+    Reading mode turned off.
+
+    
+    Sync
+    Sync off.
+    Sync on.
+    Sync turned off.
+    Sync turned on.
+
+    
+    System profiles
+    Profiles off.
+    Profile: %s.
+    Profiles turned off.
+    Profile changed to %s.
+
+    
+    USB tethering
+
+    
+    Volume panel
+
+    
+    VPN
+    Connect to\u2026
+    Please enter your credentials for connecting to %s
+    Username
+    Password
+    Connect
+
+    
+    Location reporting: battery saving mode.
+    
+    Location reporting: sensors only mode.
+    
+    Location reporting: high accuracy mode.
+
+    
+    Battery saving
+    Battery\nsaving
+    
+    Device only
+    Device\nonly
+    
+    High accuracy
+    High\naccuracy
+
+    
+    Location
+    
+    Select mode:
+    
+    High accuracy
+    
+    Battery saving
+    
+    Device only
+    
+    Use GPS, Wi\u2011Fi, Bluetooth, or cellular networks to determine location
+    
+    Use Wi\u2011Fi, Bluetooth, or cellular networks to determine location
+    
+    Use GPS to determine location
+
+    
+    Battery
+
+    Settings
+Media
+
+    Devices
+    
+
+    
+    AOD
+    AOD off\nBattery saver    
+    
+    
+    "CMCC"
+    "CUCC"
+    "CTCC"
+
+    "Power off"
+    "Restart"
+    "Emergent mode"
+    "Tap again to turn off your phone"
+    "Tap again to restart your phone"    
+
+
+
diff --git a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
old mode 100644 (file)
new mode 100755 (executable)
index c987283..d7841a3
--- a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
+++ b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
@@ -71,6 +71,7 @@ import javax.inject.Inject;
 import javax.inject.Provider;
 
 import dagger.Lazy;
+import com.android.systemui.qs.tiles.XwReaderTile;
 
 @SysUISingleton
 public class QSFactoryImpl implements QSFactory {
@@ -109,6 +110,8 @@ public class QSFactoryImpl implements QSFactory {
 
     private final Lazy mQsHostLazy;
     private final Provider mCustomTileBuilderProvider;
+       
+       private final Provider mXwReaderTileProvider; //lyz add Reading mode
 
     @Inject
     public QSFactoryImpl(
@@ -142,7 +145,8 @@ public class QSFactoryImpl implements QSFactory {
             Provider quickAccessWalletTileProvider,
             Provider qrCodeScannerTileProvider,
             Provider oneHandedModeTileProvider,
-            Provider colorCorrectionTileProvider) {
+            Provider colorCorrectionTileProvider,
+                       Provider xwReaderTileProvider) {
         mQsHostLazy = qsHostLazy;
         mCustomTileBuilderProvider = customTileBuilderProvider;
 
@@ -175,6 +179,7 @@ public class QSFactoryImpl implements QSFactory {
         mQRCodeScannerTileProvider = qrCodeScannerTileProvider;
         mOneHandedModeTileProvider = oneHandedModeTileProvider;
         mColorCorrectionTileProvider = colorCorrectionTileProvider;
+               mXwReaderTileProvider = xwReaderTileProvider;
     }
 
     /** Creates a tile with a type based on {@code tileSpec} */
@@ -260,6 +265,9 @@ public class QSFactoryImpl implements QSFactory {
                 return mOneHandedModeTileProvider.get();
             case "color_correction":
                 return mColorCorrectionTileProvider.get();
+                               //lyz add Reading mode
+                       case "xwreader":
+                return mXwReaderTileProvider.get();    
         }
 
         // Custom tiles
diff --git a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tiles/XwReaderTile.java b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tiles/XwReaderTile.java
new file mode 100755 (executable)
index 0000000..1d8608e
--- /dev/null
+++ b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tiles/XwReaderTile.java
@@ -0,0 +1,118 @@
+package com.android.systemui.qs.tiles;\r
+\r
+\r
+import android.content.Intent;\r
+import android.database.ContentObserver;\r
+import android.os.Handler;\r
+import android.provider.Settings;\r
+import android.service.quicksettings.Tile;\r
+\r
+import com.android.internal.logging.nano.MetricsProto;\r
+import com.android.systemui.R;\r
+import com.android.systemui.plugins.qs.QSTile;\r
+import com.android.systemui.qs.QSHost;\r
+import com.android.systemui.qs.tileimpl.QSTileImpl;\r
+\r
+\r
+\r
+import android.view.View;\r
+import androidx.annotation.Nullable;\r
+import android.os.Handler;\r
+\r
+import android.content.BroadcastReceiver;\r
+import com.android.systemui.qs.logging.QSLogger;\r
+import android.os.Looper;\r
+\r
+import com.android.systemui.plugins.ActivityStarter;\r
+import com.android.systemui.plugins.FalsingManager;\r
+import com.android.internal.logging.MetricsLogger;\r
+import com.android.systemui.plugins.statusbar.StatusBarStateController;\r
+import com.android.systemui.broadcast.BroadcastDispatcher;\r
+import com.android.systemui.dagger.qualifiers.Background;\r
+import com.android.systemui.dagger.qualifiers.Main;\r
+\r
+import dagger.Lazy;\r
+import android.net.ConnectivityManager;\r
+import javax.inject.Inject;\r
+import android.util.Log;\r
+\r
+\r
+public class XwReaderTile extends QSTileImpl {\r
+    private static final String TAG = "XwReaderTile";\r
+    private static final String NETWORK_SPEED = "xw_show_network_speed";\r
+    static final int SETTING_VALUE_OFF = 0;\r
+    static final int SETTING_VALUE_ON = 1;\r
+       \r
+       @Inject\r
+    public XwReaderTile(QSHost host,\r
+            @Background Looper backgroundLooper,\r
+            @Main Handler mainHandler,\r
+            FalsingManager falsingManager,\r
+            MetricsLogger metricsLogger,\r
+            StatusBarStateController statusBarStateController,\r
+            ActivityStarter activityStarter,\r
+            QSLogger qsLogger,\r
+            BroadcastDispatcher broadcastDispatcher,\r
+            Lazy lazyConnectivityManager) {\r
+        super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,\r
+                statusBarStateController, activityStarter, qsLogger);\r
+    }\r
+\r
+    @Override\r
+    public Intent getLongClickIntent() {\r
+        return new Intent();\r
+    }\r
+\r
+    @Override\r
+    public BooleanState newTileState() {\r
+        return new BooleanState();\r
+    }\r
+\r
+    @Override\r
+    public void handleSetListening(boolean listening) {\r
+        refreshState();\r
+    }\r
+\r
+    @Override\r
+    public CharSequence getTileLabel() {\r
+        return mContext.getString(R.string.xw_reader);\r
+    }\r
+\r
+    @Override\r
+    protected void handleClick(@Nullable View view) {\r
+        boolean isOn = Settings.Secure.getInt(\r
+                mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, SETTING_VALUE_OFF)\r
+                != SETTING_VALUE_OFF;\r
+        if (!isOn) {\r
+            Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,\r
+                    SETTING_VALUE_ON);\r
+            Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, 0);\r
+        } else {\r
+            Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,\r
+                    SETTING_VALUE_OFF);\r
+        }\r
+        refreshState();\r
+    }\r
+\r
+    @Override\r
+    protected void handleUpdateState(BooleanState state, Object arg) {\r
+\r
+        boolean isOn = Settings.Secure.getInt(\r
+                mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, SETTING_VALUE_OFF)\r
+                != SETTING_VALUE_OFF;\r
+        state.value = isOn ? true : false;\r
+        state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;\r
+        if(isOn) {\r
+            state.icon = ResourceIcon.get(R.drawable.ic_qs_reader_on);\r
+        } else {\r
+            state.icon = ResourceIcon.get(R.drawable.ic_qs_reader_off);\r
+        }\r
+        state.label = mContext.getString(R.string.xw_reader);\r
+    }\r
+\r
+    @Override\r
+    public int getMetricsCategory() {\r
+        return MetricsProto.MetricsEvent.QS_PANEL;\r
+    }\r
+\r
+}\r

代码分析

添加步骤就是客户提供drawable跟strings,我们在​QSFactoryImpl.java​中写好接口,在tiles/XXXXXXXXTile.java中实现具体的功能。

你可能感兴趣的:(Android13,android,java,开发语言,gitee)