[SQUASHED] Remove Carrier Label for now [2/2]

Revert "Carrier label: Ensure the dialog matches other dialogs"

This reverts commit 0a675cad6c.

Revert "Notch friendly carrier label [2/2]"

This reverts commit b4c3f73bb6.

Revert "Set a text length on the carrier label"

This reverts commit 1ff3e9673b.

Revert "Custom Carrier Label & Carrier Label Placement [2/2]"

This reverts commit df39ae045c.

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Hưng Phan
2022-01-28 06:36:47 +07:00
parent 4cbb5c5702
commit 3e51c53e23
5 changed files with 1 additions and 232 deletions

View File

@@ -216,20 +216,6 @@
<item>2</item>
</string-array>
<!-- Carrier Label -->
<string-array name="carrier_label_entries" translatable="false">
<item>@string/show_carrier_disabled</item>
<item>@string/show_carrier_keyguard</item>
<item>@string/show_carrier_statusbar</item>
<item>@string/show_carrier_enabled</item>
</string-array>
<string-array name="carrier_label_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
<!-- Battery percent -->
<string-array name="battery_percent_entries">
<item>@string/status_bar_battery_percentage_default</item>

View File

@@ -38,7 +38,7 @@
<string name="recents_title">Recents apps</string>
<string name="recents_summary">Slim recents</string>
<string name="statusbar_title">Status bar</string>
<string name="statusbar_summary">Clock, carrier, status icons</string>
<string name="statusbar_summary">Clock, status icons</string>
<string name="volume_title">Volume rockers</string>
<string name="volume_summary">Volume rockers</string>
<string name="notifications_title">Notifications</string>
@@ -420,18 +420,6 @@
<string name="notification_guts_kill_app_button_title">Kill app button</string>
<string name="notification_guts_kill_app_button_summary">Show a kill app button in the notification\'s longpress menu</string>
<!-- Custom carrier label and position -->
<string name="carrier_label_settings_title">Carrier label</string>
<string name="carrier_label_settings_summary">Customize the carrier label</string>
<string name="custom_carrier_label_title">Custom carrier label</string>
<string name="custom_carrier_label_explain">Enter a custom label. Leave blank to use your network name</string>
<string name="custom_carrier_label_notset">Custom label currently not set</string>
<string name="show_carrier_title">Carrier label location</string>
<string name="show_carrier_disabled">Disabled</string>
<string name="show_carrier_keyguard">Lockscreen</string>
<string name="show_carrier_statusbar">Statusbar</string>
<string name="show_carrier_enabled">Both</string>
<!-- Double Tap on Doze to wake -->
<string name="double_tap_on_doze_to_wake_title">Double-tap to wake on doze</string>
<string name="double_tap_on_doze_to_wake_summary">Double tap to wake when device is dreaming</string>

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2020 The CherishOS 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.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/carrier_label_settings_title"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="status_bar_show_carrier"
android:title="@string/show_carrier_title"
android:defaultValue="1" />
<Preference
android:key="custom_carrier_label"
android:title="@string/custom_carrier_label_title" />
</PreferenceScreen>

View File

@@ -30,11 +30,6 @@
android:key="statusbar_icons"
android:title="@string/sb_icons">
<Preference
android:key="carrier_label"
android:fragment="com.cherish.settings.fragments.CarrierLabel"
android:title="@string/carrier_label_settings_title" />
<Preference
android:key="status_bar_clock"
android:fragment="com.cherish.settings.fragments.ClockDateSettings"

View File

@@ -1,169 +0,0 @@
/*
* Copyright (C) 2020 The CherishOS 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.cherish.settings.fragments;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.InputFilter;
import android.text.Spannable;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.SwitchPreference;
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.util.cherish.CherishUtils;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.cherish.settings.preferences.SystemSettingListPreference;
public class CarrierLabel extends SettingsPreferenceFragment
implements Preference.OnPreferenceChangeListener {
public static final String TAG = "CarrierLabel";
private static final String CUSTOM_CARRIER_LABEL = "custom_carrier_label";
private static final String KEY_CARRIER_LABEL = "status_bar_show_carrier";
private Preference mCarrierLabel;
private String mCarrierLabelText;
private SystemSettingListPreference mShowCarrierLabel;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContentResolver resolver = getActivity().getContentResolver();
addPreferencesFromResource(R.xml.carrier_label);
PreferenceScreen prefSet = getPreferenceScreen();
mCarrierLabel = (Preference) findPreference(CUSTOM_CARRIER_LABEL);
updateCustomLabelTextSummary();
mShowCarrierLabel = (SystemSettingListPreference) findPreference(KEY_CARRIER_LABEL);
int showCarrierLabel = Settings.System.getInt(resolver,
Settings.System.STATUS_BAR_SHOW_CARRIER, 1);
CharSequence[] NonNotchEntries = { getResources().getString(R.string.show_carrier_disabled),
getResources().getString(R.string.show_carrier_keyguard),
getResources().getString(R.string.show_carrier_statusbar), getResources().getString(
R.string.show_carrier_enabled) };
CharSequence[] NotchEntries = { getResources().getString(R.string.show_carrier_disabled),
getResources().getString(R.string.show_carrier_keyguard) };
CharSequence[] NonNotchValues = {"0", "1" , "2", "3"};
CharSequence[] NotchValues = {"0", "1"};
mShowCarrierLabel.setEntries(CherishUtils.hasNotch(getActivity()) ? NotchEntries : NonNotchEntries);
mShowCarrierLabel.setEntryValues(CherishUtils.hasNotch(getActivity()) ? NotchValues : NonNotchValues);
mShowCarrierLabel.setValue(String.valueOf(showCarrierLabel));
mShowCarrierLabel.setSummary(mShowCarrierLabel.getEntry());
mShowCarrierLabel.setOnPreferenceChangeListener(this);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
ContentResolver resolver = getActivity().getContentResolver();
if (preference == mShowCarrierLabel) {
int value = Integer.parseInt((String) newValue);
updateCarrierLabelSummary(value);
return true;
}
return false;
}
private void updateCarrierLabelSummary(int value) {
Resources res = getResources();
if (value == 0) {
// Carrier Label disabled
mShowCarrierLabel.setSummary(res.getString(R.string.show_carrier_disabled));
} else if (value == 1) {
mShowCarrierLabel.setSummary(res.getString(R.string.show_carrier_keyguard));
} else if (value == 2) {
mShowCarrierLabel.setSummary(res.getString(R.string.show_carrier_statusbar));
} else if (value == 3) {
mShowCarrierLabel.setSummary(res.getString(R.string.show_carrier_enabled));
}
}
public boolean onPreferenceTreeClick(Preference preference) {
ContentResolver resolver = getActivity().getContentResolver();
boolean value;
if (preference == mCarrierLabel) {
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setTitle(R.string.custom_carrier_label_title);
alert.setMessage(R.string.custom_carrier_label_explain);
LinearLayout container = new LinearLayout(getActivity());
container.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(55, 20, 55, 20);
final EditText input = new EditText(getActivity());
int maxLength = 25;
input.setLayoutParams(lp);
input.setGravity(android.view.Gravity.TOP| Gravity.START);
input.setText(TextUtils.isEmpty(mCarrierLabelText) ? "" : mCarrierLabelText);
input.setFilters(new InputFilter[] {new InputFilter.LengthFilter(maxLength)});
container.addView(input);
alert.setView(container);
alert.setPositiveButton(getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = ((Spannable) input.getText()).toString().trim();
Settings.System.putString(resolver, Settings.System.CUSTOM_CARRIER_LABEL, value);
updateCustomLabelTextSummary();
Intent i = new Intent();
i.setAction(Intent.ACTION_CUSTOM_CARRIER_LABEL_CHANGED);
getActivity().sendBroadcast(i);
}
});
alert.setNegativeButton(getString(android.R.string.cancel), null);
alert.show();
return true;
}
return false;
}
private void updateCustomLabelTextSummary() {
mCarrierLabelText = Settings.System.getString(
getContentResolver(), Settings.System.CUSTOM_CARRIER_LABEL);
if (TextUtils.isEmpty(mCarrierLabelText)) {
mCarrierLabel.setSummary(R.string.custom_carrier_label_notset);
} else {
mCarrierLabel.setSummary(mCarrierLabelText);
}
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
}
}