Change-Id: I5d6dd4f45a259806e4a7ec004e8b459b7e1651bd Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
184 lines
8.6 KiB
Java
184 lines
8.6 KiB
Java
/*
|
|
* Copyright (C) 2015 The OmniROM Project
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
package com.cherish.settings.fragments;
|
|
|
|
import com.android.internal.logging.nano.MetricsProto;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.content.ContentResolver;
|
|
import android.app.WallpaperManager;
|
|
import android.content.Intent;
|
|
import android.content.res.Resources;
|
|
import android.hardware.fingerprint.FingerprintManager;
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import androidx.preference.SwitchPreference;
|
|
import androidx.preference.ListPreference;
|
|
import androidx.preference.Preference;
|
|
import androidx.preference.PreferenceCategory;
|
|
import androidx.preference.PreferenceScreen;
|
|
|
|
import android.provider.Settings;
|
|
import com.android.settings.R;
|
|
import com.android.settings.SettingsPreferenceFragment;
|
|
|
|
import com.cherish.settings.preferences.SystemSettingListPreference;
|
|
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
|
import com.cherish.settings.preferences.SecureSettingListPreference;
|
|
|
|
public class LockScreenSettings extends SettingsPreferenceFragment implements
|
|
Preference.OnPreferenceChangeListener {
|
|
|
|
private static final String LOCK_CLOCK_FONTS = "lock_clock_fonts";
|
|
private static final String CUSTOM_TEXT_CLOCK_FONTS = "custom_text_clock_fonts";
|
|
private static final String LOCK_DATE_FONTS = "lock_date_fonts";
|
|
private static final String CLOCK_FONT_SIZE = "lockclock_font_size";
|
|
private static final String CUSTOM_TEXT_CLOCK_FONT_SIZE = "custom_text_clock_font_size";
|
|
private static final String DATE_FONT_SIZE = "lockdate_font_size";
|
|
private static final String LOCK_OWNERINFO_FONTS = "lock_ownerinfo_fonts";
|
|
private static final String LOCKOWNER_FONT_SIZE = "lockowner_font_size";
|
|
|
|
private ListPreference mLockClockFonts;
|
|
private ListPreference mLockDateFonts;
|
|
private ListPreference mTextClockFonts;
|
|
private ListPreference mLockOwnerInfoFonts;
|
|
private CustomSeekBarPreference mClockFontSize;
|
|
private CustomSeekBarPreference mDateFontSize;
|
|
private CustomSeekBarPreference mOwnerInfoFontSize;
|
|
private CustomSeekBarPreference mCustomTextClockFontSize;
|
|
|
|
@Override
|
|
public void onCreate(Bundle icicle) {
|
|
super.onCreate(icicle);
|
|
addPreferencesFromResource(R.xml.cherish_settings_lockscreen);
|
|
|
|
ContentResolver resolver = getActivity().getContentResolver();
|
|
final PreferenceScreen prefScreen = getPreferenceScreen();
|
|
Resources resources = getResources();
|
|
|
|
// Lockscren Clock Fonts
|
|
mLockClockFonts = (ListPreference) findPreference(LOCK_CLOCK_FONTS);
|
|
mLockClockFonts.setValue(String.valueOf(Settings.System.getInt(
|
|
getContentResolver(), Settings.System.LOCK_CLOCK_FONTS, 34)));
|
|
mLockClockFonts.setSummary(mLockClockFonts.getEntry());
|
|
mLockClockFonts.setOnPreferenceChangeListener(this);
|
|
|
|
// Lockscren Date Fonts
|
|
mLockDateFonts = (ListPreference) findPreference(LOCK_DATE_FONTS);
|
|
mLockDateFonts.setValue(String.valueOf(Settings.System.getInt(
|
|
getContentResolver(), Settings.System.LOCK_DATE_FONTS, 32)));
|
|
mLockDateFonts.setSummary(mLockDateFonts.getEntry());
|
|
mLockDateFonts.setOnPreferenceChangeListener(this);
|
|
|
|
// Lock Clock Size
|
|
mClockFontSize = (CustomSeekBarPreference) findPreference(CLOCK_FONT_SIZE);
|
|
mClockFontSize.setValue(Settings.System.getInt(getContentResolver(),
|
|
Settings.System.LOCKCLOCK_FONT_SIZE, 78));
|
|
mClockFontSize.setOnPreferenceChangeListener(this);
|
|
|
|
// Lock Date Size
|
|
mDateFontSize = (CustomSeekBarPreference) findPreference(DATE_FONT_SIZE);
|
|
mDateFontSize.setValue(Settings.System.getInt(getContentResolver(),
|
|
Settings.System.LOCKDATE_FONT_SIZE, 18));
|
|
mDateFontSize.setOnPreferenceChangeListener(this);
|
|
|
|
// Lockscren OwnerInfo Fonts
|
|
mLockOwnerInfoFonts = (ListPreference) findPreference(LOCK_OWNERINFO_FONTS);
|
|
mLockOwnerInfoFonts.setValue(String.valueOf(Settings.System.getInt(
|
|
getContentResolver(), Settings.System.LOCK_OWNERINFO_FONTS, 0)));
|
|
mLockOwnerInfoFonts.setSummary(mLockOwnerInfoFonts.getEntry());
|
|
mLockOwnerInfoFonts.setOnPreferenceChangeListener(this);
|
|
|
|
// Lockscren OwnerInfo Size
|
|
mOwnerInfoFontSize = (CustomSeekBarPreference) findPreference(LOCKOWNER_FONT_SIZE);
|
|
mOwnerInfoFontSize.setValue(Settings.System.getInt(getContentResolver(),
|
|
Settings.System.LOCKOWNER_FONT_SIZE,21));
|
|
mOwnerInfoFontSize.setOnPreferenceChangeListener(this);
|
|
|
|
// Lockscren Text Clock Fonts
|
|
mTextClockFonts = (ListPreference) findPreference(CUSTOM_TEXT_CLOCK_FONTS);
|
|
mTextClockFonts.setValue(String.valueOf(Settings.System.getInt(
|
|
getContentResolver(), Settings.System.CUSTOM_TEXT_CLOCK_FONTS, 32)));
|
|
mTextClockFonts.setSummary(mTextClockFonts.getEntry());
|
|
mTextClockFonts.setOnPreferenceChangeListener(this);
|
|
|
|
// Custom Text Clock Size
|
|
mCustomTextClockFontSize = (CustomSeekBarPreference) findPreference(CUSTOM_TEXT_CLOCK_FONT_SIZE);
|
|
mCustomTextClockFontSize.setValue(Settings.System.getInt(getContentResolver(),
|
|
Settings.System.CUSTOM_TEXT_CLOCK_FONT_SIZE, 40));
|
|
mCustomTextClockFontSize.setOnPreferenceChangeListener(this);
|
|
}
|
|
|
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
ContentResolver resolver = getActivity().getContentResolver();
|
|
|
|
if (preference == mLockClockFonts) {
|
|
Settings.System.putInt(getContentResolver(), Settings.System.LOCK_CLOCK_FONTS,
|
|
Integer.valueOf((String) newValue));
|
|
mLockClockFonts.setValue(String.valueOf(newValue));
|
|
mLockClockFonts.setSummary(mLockClockFonts.getEntry());
|
|
return true;
|
|
} else if (preference == mTextClockFonts) {
|
|
Settings.System.putInt(getContentResolver(), Settings.System.CUSTOM_TEXT_CLOCK_FONTS,
|
|
Integer.valueOf((String) newValue));
|
|
mTextClockFonts.setValue(String.valueOf(newValue));
|
|
mTextClockFonts.setSummary(mTextClockFonts.getEntry());
|
|
return true;
|
|
} else if (preference == mLockDateFonts) {
|
|
Settings.System.putInt(getContentResolver(), Settings.System.LOCK_DATE_FONTS,
|
|
Integer.valueOf((String) newValue));
|
|
mLockDateFonts.setValue(String.valueOf(newValue));
|
|
mLockDateFonts.setSummary(mLockDateFonts.getEntry());
|
|
return true;
|
|
} else if (preference == mClockFontSize) {
|
|
int top = (Integer) newValue;
|
|
Settings.System.putInt(getContentResolver(),
|
|
Settings.System.LOCKCLOCK_FONT_SIZE, top*1);
|
|
return true;
|
|
} else if (preference == mCustomTextClockFontSize) {
|
|
int top = (Integer) newValue;
|
|
Settings.System.putInt(getContentResolver(),
|
|
Settings.System.CUSTOM_TEXT_CLOCK_FONT_SIZE, top*1);
|
|
return true;
|
|
} else if (preference == mDateFontSize) {
|
|
int top = (Integer) newValue;
|
|
Settings.System.putInt(getContentResolver(),
|
|
Settings.System.LOCKDATE_FONT_SIZE, top*1);
|
|
return true;
|
|
} else if (preference == mLockOwnerInfoFonts) {
|
|
Settings.System.putInt(getContentResolver(), Settings.System.LOCK_OWNERINFO_FONTS,
|
|
Integer.valueOf((String) newValue));
|
|
mLockOwnerInfoFonts.setValue(String.valueOf(newValue));
|
|
mLockOwnerInfoFonts.setSummary(mLockOwnerInfoFonts.getEntry());
|
|
return true;
|
|
} else if (preference == mOwnerInfoFontSize) {
|
|
int top = (Integer) newValue;
|
|
Settings.System.putInt(getContentResolver(),
|
|
Settings.System.LOCKOWNER_FONT_SIZE, top*1);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int getMetricsCategory() {
|
|
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
|
}
|
|
|
|
} |