change screen pinning settings UI

Fixes: 144306573
Test: manual
Change-Id: I7c80a17f90ed84e7245fe26c985aa3fe2e71cc8d
This commit is contained in:
Raff Tsai
2019-11-12 11:33:51 +08:00
parent be658e94f7
commit 72a65094fc
4 changed files with 24 additions and 68 deletions

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2014, The Android Open Source 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.
*/
-->
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/instructions_area"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/screen_pinning_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingTop="@dimen/screen_pinning_textview_padding"
android:text="@string/screen_pinning_description"
android:textAppearance="@style/TextAppearance.Medium"
android:paddingStart="@dimen/screen_pinning_padding_start"
android:paddingEnd="@dimen/screen_pinning_padding_end"
/>
</ScrollView>

View File

@@ -158,9 +158,6 @@
<!-- CryptKeeper pattern size for tablet --> <!-- CryptKeeper pattern size for tablet -->
<dimen name="crypt_keeper_pattern_size">354dip</dimen> <dimen name="crypt_keeper_pattern_size">354dip</dimen>
<!-- Screen pinning textview paddings -->
<dimen name="screen_pinning_textview_padding">40dp</dimen>
<!-- SIM Dialog Margin top --> <!-- SIM Dialog Margin top -->
<dimen name="sim_dialog_margin_top">8dip</dimen> <dimen name="sim_dialog_margin_top">8dip</dimen>
<!-- SIM Dialog Margin bottom --> <!-- SIM Dialog Margin bottom -->
@@ -329,10 +326,6 @@
<dimen name="reset_master_clear_margin_start">32dp</dimen> <dimen name="reset_master_clear_margin_start">32dp</dimen>
<dimen name="reset_master_clear_margin_end">12dp</dimen> <dimen name="reset_master_clear_margin_end">12dp</dimen>
<!-- Padding for screen pinning -->
<dimen name="screen_pinning_padding_start">64dp</dimen>
<dimen name="screen_pinning_padding_end">64dp</dimen>
<!-- Padding for the reset screens --> <!-- Padding for the reset screens -->
<dimen name="reset_checkbox_padding_end">8dp</dimen> <dimen name="reset_checkbox_padding_end">8dp</dimen>
<dimen name="reset_checkbox_title_padding_top">12dp</dimen> <dimen name="reset_checkbox_title_padding_top">12dp</dimen>

View File

@@ -16,6 +16,7 @@
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="screen_pinning_settings_screen" android:key="screen_pinning_settings_screen"
android:title="@string/screen_pinning_title"> android:title="@string/screen_pinning_title">
@@ -23,4 +24,10 @@
android:key="use_screen_lock" android:key="use_screen_lock"
android:title="@string/screen_pinning_unlock_none" /> android:title="@string/screen_pinning_unlock_none" />
<com.android.settingslib.widget.FooterPreference
android:key="screen_pinning_settings_screen_footer"
android:title="@string/screen_pinning_description"
android:selectable="false"
settings:searchable="false" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -23,9 +23,6 @@ import android.os.Bundle;
import android.os.UserHandle; import android.os.UserHandle;
import android.provider.SearchIndexableResource; import android.provider.SearchIndexableResource;
import android.provider.Settings; import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch; import android.widget.Switch;
import androidx.preference.Preference; import androidx.preference.Preference;
@@ -41,6 +38,7 @@ import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar; import com.android.settings.widget.SwitchBar;
import com.android.settingslib.search.SearchIndexable; import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.widget.FooterPreference;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -52,11 +50,13 @@ import java.util.List;
public class ScreenPinningSettings extends SettingsPreferenceFragment public class ScreenPinningSettings extends SettingsPreferenceFragment
implements SwitchBar.OnSwitchChangeListener { implements SwitchBar.OnSwitchChangeListener {
private static final CharSequence KEY_USE_SCREEN_LOCK = "use_screen_lock"; private static final String KEY_USE_SCREEN_LOCK = "use_screen_lock";
private static final String KEY_FOOTER = "screen_pinning_settings_screen_footer";
private static final int CHANGE_LOCK_METHOD_REQUEST = 43; private static final int CHANGE_LOCK_METHOD_REQUEST = 43;
private SwitchBar mSwitchBar; private SwitchBar mSwitchBar;
private SwitchPreference mUseScreenLock; private SwitchPreference mUseScreenLock;
private FooterPreference mFooterPreference;
private LockPatternUtils mLockPatternUtils; private LockPatternUtils mLockPatternUtils;
@Override @Override
@@ -77,6 +77,13 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
mSwitchBar.addOnSwitchChangeListener(this); mSwitchBar.addOnSwitchChangeListener(this);
mSwitchBar.show(); mSwitchBar.show();
mSwitchBar.setChecked(isLockToAppEnabled(getActivity())); mSwitchBar.setChecked(isLockToAppEnabled(getActivity()));
addPreferencesFromResource(R.xml.screen_pinning_settings);
final PreferenceScreen root = getPreferenceScreen();
mUseScreenLock = root.findPreference(KEY_USE_SCREEN_LOCK);
mFooterPreference = root.findPreference(KEY_FOOTER);
updateDisplay();
} }
@Override @Override
@@ -84,16 +91,6 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
return R.string.help_url_screen_pinning; return R.string.help_url_screen_pinning;
} }
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ViewGroup parent = (ViewGroup) view.findViewById(android.R.id.list_container);
View emptyView = LayoutInflater.from(getContext())
.inflate(R.layout.screen_pinning_instructions, parent, false);
parent.addView(emptyView);
setEmptyView(emptyView);
}
@Override @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
@@ -192,16 +189,10 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
updateDisplay(); updateDisplay();
} }
public void updateDisplay() { private void updateDisplay() {
PreferenceScreen root = getPreferenceScreen();
if (root != null) {
root.removeAll();
}
if (isLockToAppEnabled(getActivity())) { if (isLockToAppEnabled(getActivity())) {
addPreferencesFromResource(R.xml.screen_pinning_settings); mFooterPreference.setVisible(false);
root = getPreferenceScreen(); mUseScreenLock.setVisible(true);
mUseScreenLock = (SwitchPreference) root.findPreference(KEY_USE_SCREEN_LOCK);
mUseScreenLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { mUseScreenLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -210,6 +201,9 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
}); });
mUseScreenLock.setChecked(isScreenLockUsed()); mUseScreenLock.setChecked(isScreenLockUsed());
mUseScreenLock.setTitle(getCurrentSecurityTitle()); mUseScreenLock.setTitle(getCurrentSecurityTitle());
} else {
mFooterPreference.setVisible(true);
mUseScreenLock.setVisible(false);
} }
} }