目录
一、Settings应用的作用和重要性
二、Settings应用的架构和组件
三、Settings应用的定制和扩展
四、总结
一、Settings应用的作用和重要性
Settings应用的作用和重要性如以下表格所示:
作用 | 重要性 |
---|---|
提供系统设置选项 | Settings应用是用户在Android设备上访问和更改系统设置的主要入口。它提供了各种设置选项,包括网络、声音、显示、账户、安全性等。 |
系统功能的配置和管理 | Settings应用允许用户对系统的各种功能进行配置和管理。用户可以通过Settings应用设置设备的默认应用程序、权限管理、语言和输入设置等。 |
调试和故障排除 | Settings应用中还包含一些高级选项,用于开发者进行调试和故障排除。例如,开发者选项允许开发者启用USB调试、查看应用程序的日志信息等。 |
设备信息查看 | 用户可以通过Settings应用查看设备的详细信息,包括设备型号、Android版本、内存使用情况、存储空间、电池状态等。这些信息对用户和开发者都很有用。 |
Settings应用在Android设备中起着重要的作用,允许用户配置和管理各种系统设置,同时也提供了一些调试和故障排除的功能。
二、Settings应用的架构和组件
Settings应用的架构和组件如以下表格所示:
架构和组件 | 说明 |
---|---|
Activity | Settings应用主要由多个Activity组成,每个Activity负责展示和处理不同的设置选项。 |
Fragment | 在Settings应用的各个Activity中,使用Fragment来管理和展示具体的设置内容。 |
Preference | Settings应用使用Preference来展示和管理设置选项,包括单选项、复选项、开关、输入框等。 |
Content Provider | 为了访问和修改系统设置数据,Settings应用使用Content Provider来提供对这些数据的统一访问接口。 |
Intent | Settings应用使用Intent来启动其他应用程序或组件,例如打开应用程序详细信息、启动应用程序的权限管理界面等。 |
Service | Settings应用中的一些功能可能需要在后台运行,因此可能会使用Service来处理这些后台任务,例如同步设置数据到云端。 |
Settings应用采用了Activity和Fragment来组织界面,使用Preference来展示和管理设置选项,通过Content Provider提供对设置数据的访问,使用Intent启动其他组件,以及可能使用Service来处理后台任务。这些组件共同构成了Settings应用的架构。
三、Settings应用的定制和扩展
- 去掉设置中的备份和硬件反馈
- 移除“用作额外的手机存储空间” 菜单和设置中的部分选项
- 修改输入法无法按键更改的问题
- 隐藏语言和输入法选项下无用选项
- 去掉移动套餐选项
解决方案:
1.在settings应用的AndroidManifest中将category项给注释掉即可:
<!--<meta-data android:name="com.android.settings.category"android:value="com.android.settings.category.ia.system" />-->
2. 在storage_wizard_init.xml中设置gone属性将其隐藏,和设置Preference为不可见:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 The Android Open Source ProjectLicensed 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 athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
--><com.google.android.setupdesign.GlifLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/setup_wizard_layout"android:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutstyle="@style/SudContentFrame"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="@dimen/sud_description_margin_top"android:orientation="horizontal"android:gravity="center_vertical"><ImageViewandroid:layout_width="144dp"android:layout_height="144dp"android:scaleType="centerInside"android:visibility="gone"android:src="@drawable/ic_storage_wizard_internal" /><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:layout_marginStart="@dimen/sud_glif_margin_sides"android:orientation="vertical"><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:visibility="gone"android:layout_marginBottom="@dimen/sud_description_margin_bottom"android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"android:text="@string/storage_wizard_init_v2_internal_title" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:visibility="gone"android:layout_marginBottom="@dimen/sud_description_margin_bottom"android:textColor="?android:attr/textColorSecondary"android:text="@string/storage_wizard_init_v2_internal_summary" /><Buttonandroid:id="@+id/storage_wizard_init_internal"style="@style/SudGlifButton.Primary"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/storage_wizard_init_v2_internal_action"android:onClick="onNavigateInternal" /></LinearLayout></LinearLayout><!--<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="@dimen/sud_description_margin_top"android:orientation="horizontal"android:gravity="center_vertical"><Viewandroid:layout_width="0dp"android:layout_height="1dp"android:layout_weight="1"android:background="@android:color/black"android:backgroundTint="?android:attr/textColorTertiary" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginStart="8dp"android:layout_marginEnd="8dp"android:text="@string/storage_wizard_init_v2_or"android:textColor="?android:attr/textColorTertiary"android:textAllCaps="true" /><Viewandroid:layout_width="0dp"android:layout_height="1dp"android:layout_weight="1"android:background="@android:color/black"android:backgroundTint="?android:attr/textColorTertiary" /></LinearLayout>--><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="@dimen/sud_description_margin_top"android:orientation="horizontal"android:gravity="center_vertical"><ImageViewandroid:layout_width="144dp"android:layout_height="144dp"android:scaleType="centerInside"android:src="@drawable/ic_storage_wizard_external" /><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:layout_marginStart="@dimen/sud_glif_margin_sides"android:orientation="vertical"><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginBottom="@dimen/sud_description_margin_bottom"android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"android:text="@string/storage_wizard_init_v2_external_title" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginBottom="@dimen/sud_description_margin_bottom"android:textColor="?android:attr/textColorSecondary"android:text="@string/storage_wizard_init_v2_external_summary" /><Buttonandroid:id="@+id/storage_wizard_init_external"style="@style/SudGlifButton.Primary"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/storage_wizard_init_v2_external_action"android:onClick="onNavigateExternal" /></LinearLayout></LinearLayout></LinearLayout></com.google.android.setupdesign.GlifLayout>
private Preference mFormatPrivate;if (mIsPermittedToAdopt) {mFormatPrivate = buildAction(R.string.storage_menu_format_private);//add beginmFormatPrivate.setVisible(false);}
3. 在LocaleDragAndDragAdapter.java中添加输入法可以通过按键更改的代码:
private int mSourcePosition;public CustomViewHolder(LocaleDragCell view) {super(view);mLocaleDragCell = view;mLocaleDragCell.getDragHandle().setOnTouchListener(this);//add beginmLocaleDragCell.getDragHandle().setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mSourcePosition = getPosition();onItemMove(mSourcePosition,0);doTheUpdate();}});}@Overridepublic void onBindViewHolder(final CustomViewHolder holder, int i) {final LocaleStore.LocaleInfo feedItem = mFeedItemList.get(i);final LocaleDragCell dragCell = holder.getLocaleDragCell();final String label = feedItem.getFullNameNative();final String description = feedItem.getFullNameInUiLanguage();dragCell.setLabelAndDescription(label, description);dragCell.setLocalized(feedItem.isTranslated());dragCell.setMiniLabel(mNumberFormatter.format(i + 1));dragCell.setShowCheckbox(mRemoveMode);dragCell.setShowMiniLabel(!mRemoveMode);dragCell.setShowHandle(!mRemoveMode && mDragEnabled);dragCell.setTag(feedItem);CheckBox checkbox = dragCell.getCheckbox();// clear listener before setChecked() in case another item already bind to// current ViewHolder and checked event is triggered on stale listener mistakenly.checkbox.setOnCheckedChangeListener(null);checkbox.setChecked(mRemoveMode ? feedItem.getChecked() : false);checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {LocaleStore.LocaleInfo feedItem =(LocaleStore.LocaleInfo) dragCell.getTag();feedItem.setChecked(isChecked);}});//add beginif (i == mSourcePosition) {dragCell.getDragHandle().setChecked(true);} else {dragCell.getDragHandle().setChecked(false);}}
4.在LanguageAndInputSettings.java中的buildPreferenceControllers注释掉相关代码即可:
private static List<AbstractPreferenceController> buildPreferenceControllers(@NonNull Context context, @Nullable Lifecycle lifecycle) {final List<AbstractPreferenceController> controllers = new ArrayList<>();// Languagecontrollers.add(new PhoneLanguagePreferenceController(context));// Inputfinal VirtualKeyboardPreferenceController virtualKeyboardPreferenceController =new VirtualKeyboardPreferenceController(context);final PhysicalKeyboardPreferenceController physicalKeyboardPreferenceController =new PhysicalKeyboardPreferenceController(context, lifecycle);controllers.add(virtualKeyboardPreferenceController);//controllers.add(physicalKeyboardPreferenceController);//controllers.add(new PreferenceCategoryController(context,// KEY_KEYBOARDS_CATEGORY).setChildren(// Arrays.asList(virtualKeyboardPreferenceController,// physicalKeyboardPreferenceController)));// Pointer and Ttsfinal TtsPreferenceController ttsPreferenceController =new TtsPreferenceController(context, KEY_TEXT_TO_SPEECH);//controllers.add(ttsPreferenceController);final PointerSpeedController pointerController = new PointerSpeedController(context);//controllers.add(pointerController);//controllers.add(new PreferenceCategoryController(context,// KEY_POINTER_AND_TTS_CATEGORY).setChildren(// Arrays.asList(pointerController, ttsPreferenceController)));// Input Assistance//controllers.add(new SpellCheckerPreferenceController(context));return controllers;}
5.在config.xml中将id为config_show_mobile_plan的属性设置为false即可去掉:
<!-- Whether to show a preference item for mobile plan --><bool name="config_show_mobile_plan">false</bool>
四、总结
- Settings应用是Android系统中的重要应用之一,用于管理和配置设备的各种设置选项。
- Settings应用的作用非常重要,它允许用户对设备进行个性化配置,调整系统设置,管理应用程序和权限,以及访问设备的各种功能和服务。
- Settings应用的架构主要由Activity、Fragment、Preference、Content Provider、Intent和Service等组件构成。
- Activity和Fragment用于展示不同的设置选项界面,Preference用于展示和管理设置选项的UI元素,Content Provider提供对设置数据的访问接口,Intent用于启动其他应用程序或组件,Service用于处理后台任务。
- 通过Settings应用,用户可以调整网络、声音、显示、安全、账户、应用管理等各种设置,以满足个性化需求和优化设备使用体验。
通过Settings应用,用户可以方便地管理和配置Android设备的各种设置,使设备符合个人喜好和需求。它是Android系统中不可或缺的一部分,为用户提供了丰富的个性化和管理选项。
本文仅代表个人观点和经验,难免存在不足之处。如果有任何错误或改进的建议,欢迎指正和交流,共同进步。