@@ -607,6 +607,13 @@
|
|||||||
<string name="status_bar_clock_position_left">Left</string>
|
<string name="status_bar_clock_position_left">Left</string>
|
||||||
<string name="status_bar_clock_position_center">Center</string>
|
<string name="status_bar_clock_position_center">Center</string>
|
||||||
<string name="status_bar_clock_position_hidden">Hidden</string>
|
<string name="status_bar_clock_position_hidden">Hidden</string>
|
||||||
|
<string name="status_bar_clock_auto_hide_title">Auto hide</string>
|
||||||
|
<string name="status_bar_clock_auto_hide_launcher_summary">Hide clock if launcher is visible</string>
|
||||||
|
<string name="status_bar_clock_auto_hide_summary">Hide clock at regular interval</string>
|
||||||
|
<string name="status_bar_clock_auto_hide_hdur_title">Hide duration</string>
|
||||||
|
<string name="status_bar_clock_auto_hide_hdur_summary">Number of seconds to hide clock</string>
|
||||||
|
<string name="status_bar_clock_auto_hide_sdur_title">Show duration</string>
|
||||||
|
<string name="status_bar_clock_auto_hide_sdur_summary">Number of seconds to wait before hiding clock</string>
|
||||||
<string name="status_bar_am_pm_title">AM/PM style</string>
|
<string name="status_bar_am_pm_title">AM/PM style</string>
|
||||||
<string name="status_bar_am_pm_info">24-hour clock is enabled</string>
|
<string name="status_bar_am_pm_info">24-hour clock is enabled</string>
|
||||||
<string name="status_bar_am_pm_normal">Normal</string>
|
<string name="status_bar_am_pm_normal">Normal</string>
|
||||||
|
|||||||
@@ -8,6 +8,40 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
android:title="@string/status_bar_clock_title">
|
android:title="@string/status_bar_clock_title">
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
|
android:key="status_bar_clock_auto_hide_launcher"
|
||||||
|
android:title="@string/status_bar_clock_auto_hide_title"
|
||||||
|
android:summary="@string/status_bar_clock_auto_hide_launcher_summary"
|
||||||
|
android:defaultValue="false" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
|
android:key="status_bar_clock_auto_hide"
|
||||||
|
android:title="@string/status_bar_clock_auto_hide_title"
|
||||||
|
android:summary="@string/status_bar_clock_auto_hide_summary"
|
||||||
|
android:defaultValue="false" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||||
|
android:key="status_bar_clock_auto_hide_hduration"
|
||||||
|
android:title="@string/status_bar_clock_auto_hide_hdur_title"
|
||||||
|
android:summary="@string/status_bar_clock_auto_hide_hdur_summary"
|
||||||
|
android:max="300"
|
||||||
|
settings:min="5"
|
||||||
|
settings:interval="5"
|
||||||
|
android:dependency="status_bar_clock_auto_hide"
|
||||||
|
android:defaultValue="60"
|
||||||
|
settings:units="@string/unit_seconds" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||||
|
android:key="status_bar_clock_auto_hide_sduration"
|
||||||
|
android:title="@string/status_bar_clock_auto_hide_sdur_title"
|
||||||
|
android:summary="@string/status_bar_clock_auto_hide_sdur_summary"
|
||||||
|
android:max="300"
|
||||||
|
settings:min="5"
|
||||||
|
settings:interval="5"
|
||||||
|
android:dependency="status_bar_clock_auto_hide"
|
||||||
|
android:defaultValue="5"
|
||||||
|
settings:units="@string/unit_seconds" />
|
||||||
|
|
||||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
android:key="status_bar_clock_seconds"
|
android:key="status_bar_clock_seconds"
|
||||||
android:title="@string/status_bar_clock_seconds_title"
|
android:title="@string/status_bar_clock_seconds_title"
|
||||||
|
|||||||
@@ -15,11 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.cherish.settings.fragments;
|
package com.cherish.settings.fragments;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.DialogInterface.OnCancelListener;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
@@ -28,7 +25,6 @@ import android.os.Bundle;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||||
@@ -43,14 +39,11 @@ import com.android.settings.SettingsPreferenceFragment;
|
|||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
import com.cherish.settings.fragments.Clock;
|
|
||||||
import com.cherish.settings.preferences.SecureSettingSwitchPreference;
|
import com.cherish.settings.preferences.SecureSettingSwitchPreference;
|
||||||
import com.cherish.settings.preferences.SystemSettingListPreference;
|
import com.cherish.settings.preferences.SystemSettingListPreference;
|
||||||
import com.cherish.settings.preferences.SystemSettingSeekBarPreference;
|
import com.cherish.settings.preferences.SystemSettingSeekBarPreference;
|
||||||
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
|
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||||
public class Clock extends SettingsPreferenceFragment implements
|
public class Clock extends SettingsPreferenceFragment implements
|
||||||
Preference.OnPreferenceChangeListener {
|
Preference.OnPreferenceChangeListener {
|
||||||
@@ -58,27 +51,13 @@ public class Clock extends SettingsPreferenceFragment implements
|
|||||||
private static final String TAG = "Clock";
|
private static final String TAG = "Clock";
|
||||||
|
|
||||||
private static final String STATUS_BAR_AM_PM = "status_bar_am_pm";
|
private static final String STATUS_BAR_AM_PM = "status_bar_am_pm";
|
||||||
private static final String CLOCK_DATE_DISPLAY = "status_bar_clock_date_display";
|
|
||||||
private static final String CLOCK_DATE_POSITION = "status_bar_clock_date_position";
|
|
||||||
private static final String CLOCK_DATE_STYLE = "status_bar_clock_date_style";
|
|
||||||
private static final String CLOCK_DATE_FORMAT = "status_bar_clock_date_format";
|
|
||||||
|
|
||||||
private static final int CLOCK_DATE_STYLE_LOWERCASE = 1;
|
|
||||||
private static final int CLOCK_DATE_STYLE_UPPERCASE = 2;
|
|
||||||
private static final int CUSTOM_CLOCK_DATE_FORMAT_INDEX = 18;
|
|
||||||
|
|
||||||
private SystemSettingListPreference mStatusBarAmPm;
|
private SystemSettingListPreference mStatusBarAmPm;
|
||||||
private SystemSettingListPreference mClockDateDisplay;
|
|
||||||
private SystemSettingListPreference mClockDatePosition;
|
|
||||||
private SystemSettingListPreference mClockDateStyle;
|
|
||||||
private ListPreference mClockDateFormat;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
addPreferencesFromResource(R.xml.cherish_settings_status_bar_clock);
|
addPreferencesFromResource(R.xml.cherish_settings_status_bar_clock);
|
||||||
|
|
||||||
final ContentResolver resolver = getActivity().getContentResolver();
|
final ContentResolver resolver = getActivity().getContentResolver();
|
||||||
final Context mContext = getActivity().getApplicationContext();
|
final Context mContext = getActivity().getApplicationContext();
|
||||||
final PreferenceScreen prefScreen = getPreferenceScreen();
|
final PreferenceScreen prefScreen = getPreferenceScreen();
|
||||||
@@ -90,131 +69,14 @@ public class Clock extends SettingsPreferenceFragment implements
|
|||||||
mStatusBarAmPm.setEnabled(false);
|
mStatusBarAmPm.setEnabled(false);
|
||||||
mStatusBarAmPm.setSummary(R.string.status_bar_am_pm_info);
|
mStatusBarAmPm.setSummary(R.string.status_bar_am_pm_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dateDisplay = Settings.System.getIntForUser(resolver,
|
|
||||||
Settings.System.STATUS_BAR_CLOCK_DATE_DISPLAY, 0, UserHandle.USER_CURRENT);
|
|
||||||
|
|
||||||
mClockDateDisplay = (SystemSettingListPreference) findPreference(CLOCK_DATE_DISPLAY);
|
|
||||||
mClockDateDisplay.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
mClockDatePosition = (SystemSettingListPreference) findPreference(CLOCK_DATE_POSITION);
|
|
||||||
mClockDatePosition.setEnabled(dateDisplay > 0);
|
|
||||||
mClockDatePosition.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
mClockDateStyle = (SystemSettingListPreference) findPreference(CLOCK_DATE_STYLE);
|
|
||||||
mClockDateStyle.setEnabled(dateDisplay > 0);
|
|
||||||
mClockDateStyle.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
mClockDateFormat = (ListPreference) findPreference(CLOCK_DATE_FORMAT);
|
|
||||||
if (mClockDateFormat.getValue() == null) {
|
|
||||||
mClockDateFormat.setValue("EEE");
|
|
||||||
}
|
|
||||||
parseClockDateFormats();
|
|
||||||
mClockDateFormat.setEnabled(dateDisplay > 0);
|
|
||||||
mClockDateFormat.setOnPreferenceChangeListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
AlertDialog dialog;
|
|
||||||
ContentResolver resolver = getActivity().getContentResolver();
|
ContentResolver resolver = getActivity().getContentResolver();
|
||||||
if (preference == mClockDateDisplay) {
|
|
||||||
int val = Integer.parseInt((String) newValue);
|
|
||||||
if (val == 0) {
|
|
||||||
mClockDatePosition.setEnabled(false);
|
|
||||||
mClockDateStyle.setEnabled(false);
|
|
||||||
mClockDateFormat.setEnabled(false);
|
|
||||||
} else {
|
|
||||||
mClockDatePosition.setEnabled(true);
|
|
||||||
mClockDateStyle.setEnabled(true);
|
|
||||||
mClockDateFormat.setEnabled(true);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else if (preference == mClockDatePosition) {
|
|
||||||
parseClockDateFormats();
|
|
||||||
return true;
|
|
||||||
} else if (preference == mClockDateStyle) {
|
|
||||||
parseClockDateFormats();
|
|
||||||
return true;
|
|
||||||
} else if (preference == mClockDateFormat) {
|
|
||||||
int index = mClockDateFormat.findIndexOfValue((String) newValue);
|
|
||||||
|
|
||||||
if (index == CUSTOM_CLOCK_DATE_FORMAT_INDEX) {
|
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
|
|
||||||
alert.setTitle(R.string.status_bar_date_string_edittext_title);
|
|
||||||
alert.setMessage(R.string.status_bar_date_string_edittext_summary);
|
|
||||||
|
|
||||||
final EditText input = new EditText(getActivity());
|
|
||||||
String oldText = Settings.System.getString(
|
|
||||||
resolver,
|
|
||||||
Settings.System.STATUS_BAR_CLOCK_DATE_FORMAT);
|
|
||||||
if (oldText != null) {
|
|
||||||
input.setText(oldText);
|
|
||||||
}
|
|
||||||
alert.setView(input);
|
|
||||||
|
|
||||||
alert.setPositiveButton(R.string.menu_save, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialogInterface, int whichButton) {
|
|
||||||
String value = input.getText().toString();
|
|
||||||
if (value.equals("")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Settings.System.putString(resolver,
|
|
||||||
Settings.System.STATUS_BAR_CLOCK_DATE_FORMAT, value);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
alert.setNegativeButton(R.string.menu_cancel,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialogInterface, int which) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog = alert.create();
|
|
||||||
dialog.show();
|
|
||||||
} else {
|
|
||||||
if ((String) newValue != null) {
|
|
||||||
Settings.System.putString(resolver,
|
|
||||||
Settings.System.STATUS_BAR_CLOCK_DATE_FORMAT, (String) newValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseClockDateFormats() {
|
|
||||||
String[] dateEntries = getResources().getStringArray(
|
|
||||||
R.array.status_bar_date_format_entries_values);
|
|
||||||
CharSequence parsedDateEntries[];
|
|
||||||
parsedDateEntries = new String[dateEntries.length];
|
|
||||||
Date now = new Date();
|
|
||||||
|
|
||||||
int lastEntry = dateEntries.length - 1;
|
|
||||||
int dateFormat = Settings.System.getIntForUser(getActivity()
|
|
||||||
.getContentResolver(), Settings.System.STATUS_BAR_CLOCK_DATE_STYLE, 0, UserHandle.USER_CURRENT);
|
|
||||||
for (int i = 0; i < dateEntries.length; i++) {
|
|
||||||
if (i == lastEntry) {
|
|
||||||
parsedDateEntries[i] = dateEntries[i];
|
|
||||||
} else {
|
|
||||||
String newDate;
|
|
||||||
CharSequence dateString = DateFormat.format(dateEntries[i], now);
|
|
||||||
if (dateFormat == CLOCK_DATE_STYLE_LOWERCASE) {
|
|
||||||
newDate = dateString.toString().toLowerCase();
|
|
||||||
} else if (dateFormat == CLOCK_DATE_STYLE_UPPERCASE) {
|
|
||||||
newDate = dateString.toString().toUpperCase();
|
|
||||||
} else {
|
|
||||||
newDate = dateString.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
parsedDateEntries[i] = newDate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mClockDateFormat.setEntries(parsedDateEntries);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.CHERISH_SETTINGS;
|
return MetricsEvent.CHERISH_SETTINGS;
|
||||||
|
|||||||
Reference in New Issue
Block a user