diff options
author | Diogo Ferreira <diogo@underdev.org> | 2016-02-05 15:45:05 +0000 |
---|---|---|
committer | Diogo Ferreira <diogo@underdev.org> | 2016-02-17 15:23:17 +0000 |
commit | 67365603060148a8a59dd0dde831174202554d61 (patch) | |
tree | 86b5f2f9e58a83dc41ca632f2fdb9204b1ea8057 /src/com/android/settings/cyanogenmod | |
parent | 1eb75899a890907cdd18868336d3329242cb9e60 (diff) | |
download | packages_apps_Settings-67365603060148a8a59dd0dde831174202554d61.zip packages_apps_Settings-67365603060148a8a59dd0dde831174202554d61.tar.gz packages_apps_Settings-67365603060148a8a59dd0dde831174202554d61.tar.bz2 |
Settings: Add CM-specific settings
Change-Id: Iae0f60a62a51e96893766c4fa50a60ac4a214102
Ticket: CYNGNOS-1577
Diffstat (limited to 'src/com/android/settings/cyanogenmod')
-rw-r--r-- | src/com/android/settings/cyanogenmod/LockscreenSettingsAlias.java | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/src/com/android/settings/cyanogenmod/LockscreenSettingsAlias.java b/src/com/android/settings/cyanogenmod/LockscreenSettingsAlias.java new file mode 100644 index 0000000..d6ca06a --- /dev/null +++ b/src/com/android/settings/cyanogenmod/LockscreenSettingsAlias.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2016 The CyanogenMod 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.android.settings.cyanogenmod; + +import com.android.internal.widget.LockPatternUtils; +import com.android.settings.SecuritySettings; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.SearchIndexableRaw; + +import android.content.Context; +import android.content.pm.PackageManager; +import android.content.res.Resources; +import android.hardware.fingerprint.FingerprintManager; +import android.os.Bundle; +import android.os.UserHandle; +import android.os.UserManager; +import android.provider.SearchIndexableResource; +import com.android.settings.R; +import java.util.ArrayList; +import java.util.List; + +public class LockscreenSettingsAlias extends SecuritySettings { + public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new SecuritySearchIndexProvider(); + + private static class SecuritySearchIndexProvider extends BaseSearchIndexProvider { + + boolean mIsPrimary; + + public SecuritySearchIndexProvider() { + super(); + + mIsPrimary = MY_USER_ID == UserHandle.USER_OWNER; + } + + @Override + public List<SearchIndexableResource> getXmlResourcesToIndex( + Context context, boolean enabled) { + + List<SearchIndexableResource> result = new ArrayList<SearchIndexableResource>(); + + LockPatternUtils lockPatternUtils = new LockPatternUtils(context); + // Add options for lock/unlock screen + int resId = getResIdForLockUnlockScreen(context, lockPatternUtils); + + SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = resId; + result.add(sir); + + return result; + } + + @Override + public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) { + final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>(); + final Resources res = context.getResources(); + + final String screenTitle = res.getString(R.string.lockscreen_settings); + + SearchIndexableRaw data = new SearchIndexableRaw(context); + data.title = screenTitle; + data.screenTitle = screenTitle; + result.add(data); + + if (!mIsPrimary) { + int resId = (UserManager.get(context).isLinkedUser()) ? + R.string.profile_info_settings_title : R.string.user_info_settings_title; + + data = new SearchIndexableRaw(context); + data.title = res.getString(resId); + data.screenTitle = screenTitle; + result.add(data); + } + + // Fingerprint + FingerprintManager fpm = + (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE); + if (fpm.isHardwareDetected()) { + // This catches the title which can be overloaded in an overlay + data = new SearchIndexableRaw(context); + data.title = res.getString(R.string.security_settings_fingerprint_preference_title); + data.screenTitle = screenTitle; + result.add(data); + // Fallback for when the above doesn't contain "fingerprint" + data = new SearchIndexableRaw(context); + data.title = res.getString(R.string.fingerprint_manage_category_title); + data.screenTitle = screenTitle; + result.add(data); + } + + PackageManager pm = context.getPackageManager(); + if (pm.hasSystemFeature(LIVE_LOCK_SCREEN_FEATURE)) { + data = new SearchIndexableRaw(context); + data.title = res.getString(R.string.live_lock_screen_title); + data.screenTitle = screenTitle; + result.add(data); + } + + return result; + } + } + + @Override + public void onCreate(Bundle savedInstanceState) { + Bundle bundle = getArguments(); + if (bundle != null) { + bundle.putInt(FILTER_TYPE_EXTRA, TYPE_LOCKSCREEN_EXTRA); + } + super.onCreate(savedInstanceState); + } +} |