Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a19e37a0 authored by Raff Tsai's avatar Raff Tsai Committed by Android (Google) Code Review
Browse files

Merge "change screen pinning settings UI"

parents f529543d 72a65094
Loading
Loading
Loading
Loading
+0 −38
Original line number Diff line number Diff line
<?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>
+0 −7
Original line number Diff line number Diff line
@@ -158,9 +158,6 @@
    <!-- CryptKeeper pattern size for tablet -->
    <dimen name="crypt_keeper_pattern_size">354dip</dimen>

    <!-- Screen pinning textview paddings -->
    <dimen name="screen_pinning_textview_padding">40dp</dimen>

    <!-- SIM Dialog Margin top -->
    <dimen name="sim_dialog_margin_top">8dip</dimen>
    <!-- SIM Dialog Margin bottom -->
@@ -329,10 +326,6 @@
    <dimen name="reset_master_clear_margin_start">32dp</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 -->
    <dimen name="reset_checkbox_padding_end">8dp</dimen>
    <dimen name="reset_checkbox_title_padding_top">12dp</dimen>
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

<PreferenceScreen
    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:title="@string/screen_pinning_title">

@@ -23,4 +24,10 @@
        android:key="use_screen_lock"
        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>
+17 −23
Original line number Diff line number Diff line
@@ -23,9 +23,6 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;

import androidx.preference.Preference;
@@ -41,6 +38,7 @@ import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.widget.FooterPreference;

import java.util.Arrays;
import java.util.List;
@@ -52,11 +50,13 @@ import java.util.List;
public class ScreenPinningSettings extends SettingsPreferenceFragment
        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 SwitchBar mSwitchBar;
    private SwitchPreference mUseScreenLock;
    private FooterPreference mFooterPreference;
    private LockPatternUtils mLockPatternUtils;

    @Override
@@ -77,6 +77,13 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
        mSwitchBar.addOnSwitchChangeListener(this);
        mSwitchBar.show();
        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
@@ -84,16 +91,6 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
        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
    public void onDestroyView() {
        super.onDestroyView();
@@ -192,16 +189,10 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
        updateDisplay();
    }

    public void updateDisplay() {
        PreferenceScreen root = getPreferenceScreen();
        if (root != null) {
            root.removeAll();
        }
    private void updateDisplay() {
        if (isLockToAppEnabled(getActivity())) {
            addPreferencesFromResource(R.xml.screen_pinning_settings);
            root = getPreferenceScreen();

            mUseScreenLock = (SwitchPreference) root.findPreference(KEY_USE_SCREEN_LOCK);
            mFooterPreference.setVisible(false);
            mUseScreenLock.setVisible(true);
            mUseScreenLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -210,6 +201,9 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
            });
            mUseScreenLock.setChecked(isScreenLockUsed());
            mUseScreenLock.setTitle(getCurrentSecurityTitle());
        } else {
            mFooterPreference.setVisible(true);
            mUseScreenLock.setVisible(false);
        }
    }