欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Android9.0 SystemUI 快速设置栏增加自定义字体大小栏

程序员文章站 2022-05-06 14:18:00
diff --git a/frameworks/base/proto/src/metrics_constants.proto b/frameworks/base/proto/src/metrics_constants.protoindex 806ea3bde7801d57873c794321cf32047b592bcc..b13fee674717f1fdcef565152375209a03552566 100644--- a/frameworks/base/proto/src/metrics_cons....
diff --git a/frameworks/base/proto/src/metrics_constants.proto b/frameworks/base/proto/src/metrics_constants.proto
index 806ea3bde7801d57873c794321cf32047b592bcc..b13fee674717f1fdcef565152375209a03552566 100644
--- a/frameworks/base/proto/src/metrics_constants.proto
+++ b/frameworks/base/proto/src/metrics_constants.proto
@@ -6120,6 +6120,8 @@ message MetricsEvent {
     // CATEGORY: QUICK_SETTINGS
     // OS: 6.0
     QS_FONTSIZE = 1457;
+	//for  QS dispaly size settings os android9.0
+    QS_DISPLAYSIZE = 1458;
 
 
     // ---- End P Constants, all P constants go above this line ----
diff --git a/vendor/mediatek/proprietary/packages/apps/MtkSettings/AndroidManifest.xml b/vendor/mediatek/proprietary/packages/apps/MtkSettings/AndroidManifest.xml
index f784ca75e7ae268d37c4399e24ed2b2caf7ba97a..2b887543706574d8fc227524bcadaef3c25fd607 100644
--- a/vendor/mediatek/proprietary/packages/apps/MtkSettings/AndroidManifest.xml
+++ b/vendor/mediatek/proprietary/packages/apps/MtkSettings/AndroidManifest.xml
@@ -1607,6 +1607,9 @@
         </activity>
 	<activity android:name=".accessibility.QSFontSizeActivity">
          </activity>
+	 
+	<activity android:name=".display.QSDisplaySizeActivity">
+         </activity>
 	
 
         <activity
diff --git a/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/layout/qs_display_size.xml b/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/layout/qs_display_size.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c9bc3b05a2b49dbca1f118d52744a8cf64aef1ce
--- /dev/null
+++ b/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/layout/qs_display_size.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:tools="http://schemas.android.com/tools"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      tools:context="com.android.settings.display.QSDisplaySizeActivity" >
+
+ <LinearLayout
+          android:id="@+id/fragment_displaysize"
+         android:layout_width="match_parent"
+         android:layout_height="match_parent" />
+</LinearLayout>
diff --git a/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/display/QSDisplaySizeActivity.java b/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/display/QSDisplaySizeActivity.java
new file mode 100755
index 0000000000000000000000000000000000000000..059ce253cae322f6bf439dee8ccd0c2931b9f4bc
--- /dev/null
+++ b/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/display/QSDisplaySizeActivity.java
@@ -0,0 +1,26 @@
+
+package com.android.settings.display;
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.os.Bundle;
+import com.android.settings.R;
+public class QSDisplaySizeActivity extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.qs_display_size);
+        FragmentManager fragmentManager = getFragmentManager();
+        FragmentTransaction transaction = fragmentManager.beginTransaction();
+        ScreenZoomSettings mscreenZoomSettings= new ScreenZoomSettings();
+
+       transaction.replace(R.id.fragment_displaysize, mscreenZoomSettings);
+        transaction.commit();
+
+
+
+    }
+
+}
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml
index 150a1f48384a77ceed80ce6e2c3f807a3044a376..2ddcf8e41e4aaf815e2859d4c589f053132aeb0a 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml
@@ -119,12 +119,12 @@
     <!-- The default tiles to display in QuickSettings -->
 <!--  wifi,bt,dnd,flashlight,rotation,battery,cell,airplane,cast-->
     <string name="quick_settings_tiles_default" translatable="false">
-        wifi,bt,location,fontsize
+        wifi,bt,location,fontsize,displaysize
     </string>
 
     <!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
     <string name="quick_settings_tiles_stock" translatable="false">
-        wifi,bt,location,fontsize,cell,battery,dnd,flashlight,airplane,hotspot,inversion,saver,work,cast,night
+        wifi,bt,location,fontsize,displaysize,cell,battery,dnd,flashlight,airplane,hotspot,inversion,saver,work,cast,night
     </string>
 
     <!-- The tiles to display in QuickSettings -->
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/strings.xml b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/strings.xml
index 8eca14cebaae7b551a646c45fee4f07efe85b9b4..956ce5d4dac6acb685b8602cf55866862b8dcd36 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/strings.xml
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/strings.xml
@@ -2246,6 +2246,7 @@
 
     <!-- Name for quick setting tile, font size setting -->
     <string name="quick_settings_fontsize">瀛椾綋澶у皬</string>
+     <string name="quick_settings_displaysize">鏄剧ず澶у皬</string>
 
 
 </resources>
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
index 287735c43e71c290da45631e73ebeedf5af274c5..6b0bc371e5e09648c260886e5d47063c0ba50105 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
@@ -42,6 +42,7 @@ import com.android.systemui.qs.tiles.UserTile;
 import com.android.systemui.qs.tiles.WifiTile;
 import com.android.systemui.qs.tiles.WorkModeTile;
 import com.android.systemui.qs.tiles.FontSizeTile;
+import com.android.systemui.qs.tiles.DisplaySizeTile;
 import com.android.systemui.qs.QSTileHost;
 import com.android.systemui.util.leak.GarbageMonitor;
 
@@ -119,6 +120,10 @@ public class QSFactoryImpl implements QSFactory {
                 return new NfcTile(mHost);
             case "fontsize":
                 return new FontSizeTile(mHost);
+	  case "displaysize":
+                return new DisplaySizeTile(mHost);
+			
+	
 
         }
 
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tiles/DisplaySizeTile.java b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tiles/DisplaySizeTile.java
new file mode 100644
index 0000000000000000000000000000000000000000..c3113f8c6fce50ee0ddc1cc6624af5d61d3fb47b
--- /dev/null
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tiles/DisplaySizeTile.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.qs.tiles;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ComponentName;
+import android.net.ConnectivityManager;
+import android.os.SystemProperties;
+import android.os.UserManager;
+import android.provider.Settings;
+import android.provider.Settings.Global;
+import android.service.quicksettings.Tile;
+import android.util.Log;
+import android.widget.Switch;
+import android.preference.PreferenceActivity;
+
+import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.telephony.TelephonyIntents;
+import com.android.internal.telephony.TelephonyProperties;
+import com.android.systemui.Dependency;
+import com.android.systemui.R;
+import com.android.systemui.plugins.ActivityStarter;
+import com.android.systemui.plugins.qs.QSTile.BooleanState;
+import com.android.systemui.qs.GlobalSetting;
+import com.android.systemui.qs.QSHost;
+import com.android.systemui.qs.tileimpl.QSTileImpl;
+
+/** Quick settings tile: Font size setting **/
+public class DisplaySizeTile extends QSTileImpl<BooleanState> {
+    private final Icon mIcon =
+            ResourceIcon.get(R.drawable.ic_signal_airplane);
+
+    public DisplaySizeTile(QSHost host) {
+        super(host);
+    }
+    
+    @Override
+    public BooleanState newTileState() {
+        return new BooleanState();
+    }
+
+    @Override
+    public void handleSetListening(boolean listening) {
+	
+    }
+
+    @Override
+    public void handleClick() {
+	Log.i(TAG, "DisplaySizeTile click event");
+	ComponentName cn = new ComponentName("com.android.settings","com.android.settings.display.QSDisplaySizeActivity");
+	Intent intent = new Intent();
+	intent.setComponent(cn);
+	intent.setAction(Intent.ACTION_MAIN);
+	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+	//intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, "com.android.settings.accessibility.ToggleFontSizePreferenceFragment");
+	//intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS,true);
+	//intent.setClassName("com.android.settings","com.android.settings.accessibility.ToggleFontSizePreferenceFragment");
+	mContext.startActivity(intent);
+    }
+
+    private void setEnabled(boolean enabled) {
+	Log.i(TAG, "FontSizeTile setEnabled event");
+    }
+
+    @Override
+    public Intent getLongClickIntent() {
+    /*
+	Intent intent = new Intent();
+	intent.setAction(Intent.ACTION_MAIN);
+
+	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+	intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, "com.android.settings.accessibility.QSFontSizeActivity");
+	intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS,true);
+	intent.setClassName("com.android.settings","com.android.settings.SubSettings");
+*/
+	ComponentName cn = new ComponentName("com.android.settings","com.android.settings.display.QSDisplaySizeActivity");
+	Intent intent = new Intent();
+	intent.setComponent(cn);
+	intent.setAction(Intent.ACTION_MAIN);
+	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        return intent;
+    }
+
+    @Override
+    public CharSequence getTileLabel() {
+        return mContext.getString(R.string.quick_settings_displaysize);
+    }
+
+    @Override
+    protected void handleUpdateState(BooleanState state, Object arg) {
+        state.label = mContext.getString(R.string.quick_settings_displaysize);
+        state.icon = mIcon;
+        state.value = false;
+        state.state = Tile.STATE_ACTIVE;
+        state.contentDescription = state.label;
+        state.expandedAccessibilityClassName = Switch.class.getName();
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.QS_DISPLAYSIZE;
+    }
+
+}

 

本文地址:https://blog.csdn.net/qwertyuiop159158/article/details/112533305