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

Commit ef505d62 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Allow DPMs to restrict Remote Input on Keyguard" into nyc-dev

parents 1590b8c0 059b0fa0
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -15,14 +15,15 @@
  ~ limitations under the License
  -->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <CheckBox
            android:id="@+id/lockscreen_remote_input"
            android:layout_width="match_parent"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginStart="20dp"
            android:paddingStart="20dp"
            android:paddingEnd="?android:attr/dialogPreferredPadding"
@@ -32,4 +33,13 @@
            android:gravity="center_vertical"
            android:text="@string/lockscreen_remote_input"
        />
</FrameLayout>
 No newline at end of file

    <ImageView
            android:id="@+id/restricted_lock_icon_remote_input"
            android:layout_width="@dimen/restricted_icon_size"
            android:layout_height="@dimen/restricted_icon_size"
            android:src="@drawable/ic_info"
            android:layout_marginEnd="?android:attr/dialogPreferredPadding"
            android:layout_gravity="center_vertical"
            android:scaleType="centerInside" />
</LinearLayout>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@

    </RadioGroup>

    <CheckBox
    <com.android.settings.RestrictedCheckBox
        android:id="@+id/lockscreen_remote_input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@

            <!-- Place the checkbox inside RadioGroup and use SuwRadioButton style instead of
                 SuwCheckBox style so that the checkbox and text is aligned with radio buttons. -->
            <CheckBox
            <com.android.settings.RestrictedRadioButton
                android:id="@+id/lockscreen_remote_input"
                style="@style/SuwRadioButton"
                android:layout_width="wrap_content"
+75 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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
 */

package com.android.settings;

import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;

import android.content.Context;
import android.graphics.PorterDuff;
import android.util.AttributeSet;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.TextView;

import com.android.settingslib.RestrictedLockUtils;

/**
 * A checkbox that can be restricted by device policy, in which case it shows a dialog explaining
 * what component restricted it.
 */
public class RestrictedCheckBox extends CheckBox {
    private Context mContext;
    private boolean mDisabledByAdmin;
    private EnforcedAdmin mEnforcedAdmin;

    public RestrictedCheckBox(Context context) {
        this(context, null);
    }

    public RestrictedCheckBox(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
    }

    @Override
    public boolean performClick() {
        if (mDisabledByAdmin) {
            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, mEnforcedAdmin);
            return true;
        }
        return super.performClick();
    }

    public void setDisabledByAdmin(EnforcedAdmin admin) {
        final boolean disabled = (admin != null);
        mEnforcedAdmin = admin;
        if (mDisabledByAdmin != disabled) {
            mDisabledByAdmin = disabled;
            RestrictedLockUtils.setTextViewAsDisabledByAdmin(mContext, this, mDisabledByAdmin);
            if (mDisabledByAdmin) {
                getButtonDrawable().setColorFilter(mContext.getColor(R.color.disabled_text_color),
                        PorterDuff.Mode.MULTIPLY);
            } else {
                getButtonDrawable().clearColorFilter();
            }
        }
    }

    public boolean isDisabledByAdmin() {
        return mDisabledByAdmin;
    }
}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -283,6 +283,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
    }

    public void disableSuggestion(Tile suggestion) {
        if (mSuggestionParser == null) {
            return;
        }
        if (mSuggestionParser.dismissSuggestion(suggestion)) {
            mContext.getPackageManager().setComponentEnabledSetting(
                    suggestion.intent.getComponent(),
Loading