Add restricted settings UI in Settings accessibility screeen
If OP_ACCESS_RESTRICTED_SETTINGS is rejected, it means accessibility page for that app is gray out and app info won't show "unlock restricted settings menu" If OP_ACCESS_RESTRICTED_SETTINGS is ignored, it means accessibility page for that app is gray out, but app info shows "unlock restricted settings menu" If OP_ACCESS_RESTRICTED_SETTINGS is allowed(default), it means users can access accessibility page for that app. OP_ACCESS_RESTRICTED_SETTINGS will be changed to ignored if user visited the restricted settings dialog. OP_ACCESS_RESTRICTED_SETTINGS will be changed to allowed if user passes the confirmation screen. Bug: 202130031 Test: Tested the UI and it works correctly Change-Id: I3dfb94cee440658b4726a1c3f7265f93cd19ed3e
This commit is contained in:
88
src/com/android/settings/ActionDisabledByAppOpsHelper.java
Normal file
88
src/com/android/settings/ActionDisabledByAppOpsHelper.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.android.settingslib.HelpUtils;
|
||||
|
||||
final class ActionDisabledByAppOpsHelper {
|
||||
|
||||
private final ViewGroup mDialogView;
|
||||
private final Activity mActivity;
|
||||
|
||||
ActionDisabledByAppOpsHelper(Activity activity) {
|
||||
mActivity = activity;
|
||||
mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate(
|
||||
R.layout.support_details_dialog, null);
|
||||
}
|
||||
|
||||
public AlertDialog.Builder prepareDialogBuilder() {
|
||||
final String helpUrl = mActivity.getString(
|
||||
R.string.help_url_action_disabled_by_restricted_settings);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
|
||||
.setPositiveButton(R.string.okay, null)
|
||||
.setView(mDialogView);
|
||||
if (!TextUtils.isEmpty(helpUrl)) {
|
||||
builder.setNeutralButton(R.string.learn_more,
|
||||
(DialogInterface.OnClickListener) (dialog, which) -> {
|
||||
final Intent intent = HelpUtils.getHelpIntent(mActivity,
|
||||
helpUrl, mActivity.getClass().getName());
|
||||
if (intent != null) {
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
initializeDialogViews(mDialogView);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public void updateDialog() {
|
||||
initializeDialogViews(mDialogView);
|
||||
}
|
||||
|
||||
private void initializeDialogViews(View root) {
|
||||
setSupportTitle(root);
|
||||
setSupportDetails(root);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setSupportTitle(View root) {
|
||||
final TextView titleView = root.findViewById(R.id.admin_support_dialog_title);
|
||||
if (titleView == null) {
|
||||
return;
|
||||
}
|
||||
titleView.setText(R.string.blocked_by_restricted_settings_title);
|
||||
}
|
||||
|
||||
void setSupportDetails(final View root) {
|
||||
final TextView textView = root.findViewById(R.id.admin_support_msg);
|
||||
textView.setText(R.string.blocked_by_restricted_settings_content);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user