在Android系统中,移除Settings应用中的顶部标题和搜索框通常涉及对应用界面布局的修改,这可以通过编辑XML布局文件和Java/Kotlin代码文件来实现。以下是一个基于Android系统一般开发实践的步骤概览,适用于不同版本的Android系统(如Android 11、12、13等),但请注意,具体实现可能会因Android版本和定制厂商的不同而有所差异。以Android13为例
1.Settings移除顶部标题和搜索框
--- a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/layout/settings_homepage_container.xml
+++ b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/layout/settings_homepage_container.xml
@@ -56,7 +56,7 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>
- <com.google.android.material.appbar.AppBarLayout
+<!-- <com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -78,5 +78,5 @@
layout="@layout/settings_homepage_app_bar_two_pane_layout"
android:visibility="gone"/>
</LinearLayout>
- </com.google.android.material.appbar.AppBarLayout>
+ </com.google.android.material.appbar.AppBarLayout> -->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/homepage/SettingsHomepageActivity.java b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settin
gs/homepage/SettingsHomepageActivity.java
old mode 100644
new mode 100755
index a23b743..196897b
--- a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -97,7 +97,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
private TopLevelSettings mMainFragment;
private View mHomepageView;
- private View mSuggestionView;
+ //private View mSuggestionView;
private View mTwoPaneSuggestionView;
private CategoryMixin mCategoryMixin;
private Set<HomepageLoadedListener> mLoadedListeners;
@@ -147,7 +147,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
}
Log.i(TAG, "showHomepageWithSuggestion: " + showSuggestion);
final View homepageView = mHomepageView;
- mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
+ //mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
mTwoPaneSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
mHomepageView = null;
@@ -362,7 +362,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
return;
}
- mSuggestionView = findViewById(R.id.suggestion_content);
+ //mSuggestionView = findViewById(R.id.suggestion_content);
mTwoPaneSuggestionView = findViewById(R.id.two_pane_suggestion_content);
mHomepageView = findViewById(R.id.settings_homepage_container);
// Hide the homepage for preparing the suggestion. If scrolling is needed, the list views
@@ -594,15 +594,15 @@ public class SettingsHomepageActivity extends FragmentActivity implements
return;
}
updateAppBarMinHeight();
- if (mIsTwoPane) {
+/* if (mIsTwoPane) {
findViewById(R.id.homepage_app_bar_regular_phone_view).setVisibility(View.GONE);
- findViewById(R.id.homepage_app_bar_two_pane_view).setVisibility(View.VISIBLE);
- findViewById(R.id.suggestion_container_two_pane).setVisibility(View.VISIBLE);
+ findViewById(R.id.homepage_app_bar_two_pane_view).setVisibility(View.GONE);
+ findViewById(R.id.suggestion_container_two_pane).setVisibility(View.GONE);
} else {
- findViewById(R.id.homepage_app_bar_regular_phone_view).setVisibility(View.VISIBLE);
+ findViewById(R.id.homepage_app_bar_regular_phone_view).setVisibility(View.GONE);
findViewById(R.id.homepage_app_bar_two_pane_view).setVisibility(View.GONE);
findViewById(R.id.suggestion_container_two_pane).setVisibility(View.GONE);
- }
+ } */
}
private void updateHomepagePaddings() {
@@ -625,7 +625,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
mIsEmbeddingActivityEnabled && mIsTwoPane
? R.dimen.homepage_app_bar_padding_two_pane
: R.dimen.search_bar_margin);
- findViewById(R.id.app_bar_container).setMinimumHeight(searchBarHeight + margin * 2);
+ //findViewById(R.id.app_bar_container).setMinimumHeight(searchBarHeight + margin * 2);
}
private static class SuggestionFragCreator implements FragmentCreator {
2.Settings一级菜单的字体调整
--- a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/layout/homepage_preference.xml
+++ b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/layout/homepage_preference.xml
@@ -63,6 +63,7 @@
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceListItem"
android:hyphenationFrequency="normalFast"
+ android:textSize="16dp"
android:ellipsize="marquee"/>
<TextView
@@ -73,6 +74,7 @@
android:layout_alignStart="@android:id/title"
android:layout_gravity="start"
android:textAlignment="viewStart"
+ android:textSize="12dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="4"
3.Settings一级菜单图标颜色修改
diff --git a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/top_level_settings.xml b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/top_level_settings.xml
index 9216eff..2784156 100755
--- a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/top_level_settings.xml
+++ b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/top_level_settings.xml
@@ -197,11 +197,13 @@
settings:highlightableMenuKey="@string/menu_key_accounts"
settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/> -->
<com.android.settings.widget.HomepagePreference
+ android:key="auto_shutdown"
android:fragment="com.android.settings.shutdown.AutoShutdownFragment"
android:icon="@drawable/ic_auto_shutdown"
android:order="5"
android:title="@string/auto_shutdown_title"/>
<com.android.settings.widget.HomepagePreference
+ android:key="schpwronoff"
android:icon="@drawable/ic_schedule_power_on_off"
android:order="7"
android:title="@string/schedule_shutdown_title">
diff --git a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/homepage/TopLevelSettings.java b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/homepage/TopLevelSettings.java
old mode 100644
new mode 100755
index 70530fc..ac22cea
--- a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/homepage/TopLevelSettings.java
@@ -50,7 +50,7 @@ import com.android.settings.widget.HomepagePreferenceLayoutHelper.HomepagePrefer
import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.search.SearchIndexable;
-
+import android.graphics.Color;
@SearchIndexable(forTarget = MOBILE)
public class TopLevelSettings extends DashboardFragment implements SplitLayoutListener,
PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
@@ -189,7 +189,65 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi
iteratePreferences(preference -> {
Drawable icon = preference.getIcon();
if (icon != null) {
- icon.setTint(tintColor);
+ android.util.Log.d("hqb","preference.getKey()"+preference.getKey());
+ if(null!=preference.getKey()){
+ switch (preference.getKey()) {
+ case "main_toggle_wifi":
+ icon.setTint(Color.parseColor("#3878FF"));
+ break;
+ case "bluetooth_switchbar_screen":
+ icon.setTint(Color.parseColor("#66ccff"));
+ break;
+ case "memory":
+ icon.setTint(Color.parseColor("#CDB38B"));
+ break;
+ case "top_level_apps":
+ icon.setTint(Color.parseColor("#FF8C69"));
+ break;
+ case "top_level_battery":
+ icon.setTint(Color.parseColor("#FF6A6A"));
+ break;
+ case "top_level_storage":
+ icon.setTint(Color.parseColor("#EE82EE"));
+ break;
+ case "top_level_sound":
+ icon.setTint(Color.parseColor("#DAA520"));
+ break;
+ case "top_level_safety_center":
+ icon.setTint(Color.parseColor("#CD6889"));
+ break;
+ case "top_level_display":
+ icon.setTint(Color.parseColor("#DDA0DD"));
+ break;
+ case "top_level_security":
+ icon.setTint(Color.parseColor("#B22222"));
+ break;
+ case "top_level_google":
+ icon.setTint(Color.parseColor("#8470FF"));
+ break;
+ case "top_level_system":
+ icon.setTint(Color.parseColor("#FF6699"));
+ break;
+ case "top_level_about_device":
+ icon.setTint(Color.parseColor("#9E9E9E"));
+ break;
+ case "top_level_support":
+ icon.setTint(Color.parseColor("#B03060"));
+ break;
+ case "auto_shutdown":
+ icon.setTint(Color.parseColor("#FF3333"));
+ break;
+ case "schpwronoff":
+ icon.setTint(Color.parseColor("#CC6666"));
+ break;
+ default:
+ icon.setTint(tintColor);
+ break;
+ }
+ }else{
+ icon.setTint(tintColor);
+ }
+ //icon.setTint(tintColor);
}
});
}
4.Settings搜索框过滤某些关键字
--- a/alps-mp-u0/packages/apps/SettingsIntelligence/src/com/android/settings/intelligence/search/SearchResultsAdapter.java
+++ b/alps-mp-u0/packages/apps/SettingsIntelligence/src/com/android/settings/intelligence/search/SearchResultsAdapter.java
@@ -17,6 +17,7 @@
package com.android.settings.intelligence.search;
+import android.text.TextUtils;
import android.content.Context;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.RecyclerView;
@@ -105,7 +106,50 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder>
public void postSearchResults(List<? extends SearchResult> newSearchResults) {
final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(
new SearchResultDiffCallback(mSearchResults, newSearchResults));
+ //hqingbin 2023.7.18 settings Filters the keyword in the search box begin
mSearchResults.clear();
+ notifyDataSetChanged();
+ int index = -1;
+ if(newSearchResults.size()>0){
+ for (int i= 0; i < newSearchResults.size(); i++) {
+ SearchResult sr = newSearchResults.get(i);
+ String title ="";
+ String summary="";
+ String dataKey="";
+ if(!TextUtils.isEmpty(sr.title)){
+ title = sr.title.toString();}
+ if(!TextUtils.isEmpty(sr.summary)){
+ summary=sr.summary.toString();}
+ if(!TextUtils.isEmpty(sr.dataKey)){
+ dataKey=sr.dataKey.toString();}
+ android.util.Log.d("hqb","dataKey="+dataKey+" title="+title+" summary="+summary);
+ if(dataKey.contains("sim")|| dataKey.contains("preferred_network_mode_key")|| dataKey.contains("com.google.android.syncadapters.contacts")
+ || dataKey.contains("mobile_network")|| dataKey.contains("com.android.calllogbackup")|| dataKey.contains("wifi_calling_key")
+ || dataKey.contains("wifi_data_usage")
+ || title.contains("数据")
+ || title.contains("网络")
+ || dataKey.contains("phone")
+ || dataKey.contains("mobile")
+ || dataKey.contains("data")
+ || dataKey.contains("sim")
+ || dataKey.contains("internet_settings")
+ || dataKey.contains("vibration")
+ || dataKey.contains("tether_settings")
+ || dataKey.contains("usb_tether_settings")
+ || dataKey.contains("enable_bluetooth_tethering")
+ || dataKey.contains("wifi_tether")
+ || dataKey.contains("tether")
+ || dataKey.contains("NearbySharingSettings")
+ || dataKey.contains("SMS")
+ || dataKey.contains("location")){
+ index = i;
+ newSearchResults.remove(index);
+ notifyDataSetChanged();
+ i--;
+ }
+ }
+ }
+ //hqingbin 2023.7.18 settings Filters the keyword in the search box begin
mSearchResults.addAll(newSearchResults);
diffResult.dispatchUpdatesTo(this);
mFragment.onSearchResultsDisplayed(mSearchResults.size());
[3]+ Stopped git show 2b5d979
5.Settings运行内存移到一级界面
diff --git a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/drawable/ic_settings_memory.xml b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/drawable/ic_settings_memory.xml
old mode 100644
new mode 100755
index 78a6b8d..56ef283
--- a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/drawable/ic_settings_memory.xml
+++ b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/drawable/ic_settings_memory.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="32dp"
- android:height="32dp"
+ android:width="24.0dp"
+ android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
diff --git a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/top_level_settings.xml b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/top_level_settings.xml
index 4590b07..c2ea7bc 100755
--- a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/top_level_settings.xml
+++ b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/top_level_settings.xml
@@ -30,27 +30,28 @@
settings:highlightableMenuKey="@string/menu_key_network"
settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/> -->
-<Preference
+<com.android.settings.widget.HomepagePreference
android:fragment="com.android.settings.wifi.WifiSettings"
android:key="main_toggle_wifi"
android:title="@string/wifi_settings"
- android:summary="@string/summary_placeholder"
android:icon="@drawable/ic_settings_wireless"
android:order="-150"
- settings:allowDividerAbove="true">
- <intent
- android:action="android.settings.WIFI_SETTINGS"
- android:targetClass="Settings$WifiSettingsActivity" />
- </Preference>
+ settings:allowDividerAbove="true"
+ />
- <Preference
+ <com.android.settings.widget.HomepagePreference
android:fragment="com.android.settings.connecteddevice.BluetoothDashboardFragment"
android:key="bluetooth_switchbar_screen"
android:order="-140"
android:title="@string/bluetooth_settings_title"
android:icon="@*android:drawable/ic_settings_bluetooth"
/>
-
+<com.android.settings.widget.HomepagePreference
+ android:order="-135"
+ android:key="memory"
+ android:icon="@drawable/ic_settings_memory"
+ android:title="@string/memory_settings_title"
+ android:fragment="com.android.settings.applications.ProcessStatsSummary"/>
<!-- <com.android.settings.widget.HomepagePreference
android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
android:icon="@drawable/ic_devices_other"
diff --git a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/applications/ProcStatsData.java b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/appl
ications/ProcStatsData.java
old mode 100644
new mode 100755
index 7742e98..9c69f22
--- a/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/applications/ProcStatsData.java
+++ b/alps-mp-t0/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/applications/ProcStatsData.java
@@ -421,7 +421,8 @@ public class ProcStatsData {
long memTotalTime) {
MemInfoReader memReader = new MemInfoReader();
memReader.readMemInfo();
- realTotalRam = memReader.getTotalSize();
+ //realTotalRam = memReader.getTotalSize();
+ realTotalRam = 3f*1000*1000*1000;//hqingbin totalram change
freeWeight = totalMem.sysMemFreeWeight + totalMem.sysMemCachedWeight;
usedWeight = totalMem.sysMemKernelWeight + totalMem.sysMemNativeWeight;
if (!totalMem.hasSwappedOutPss) {