Merge "Make the Media Projection dialog consistent (1/3)" into tm-dev am: bd94485c38

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16976084

Change-Id: I55937cbf8c25cf79771e8964874d1f4ee32e491d
This commit is contained in:
Jordan Demeulenaere
2022-02-28 10:36:21 +00:00
committed by Automerger Merge Worker
2 changed files with 9 additions and 58 deletions

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019, 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.
-->
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:theme="@style/Theme.SystemUI.MediaProjectionAlertDialog"
android:paddingStart="?android:attr/dialogPreferredPadding"
android:paddingEnd="?android:attr/dialogPreferredPadding"
android:orientation="vertical">
<ImageView
android:id="@+id/dialog_icon"
android:src="@drawable/ic_media_projection_permission"
android:layout_height="24dp"
android:layout_width="24dp"
android:layout_marginTop="18dp"
android:layout_marginBottom="12dp"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/dialog_title"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Title" />
</LinearLayout>

View File

@@ -38,12 +38,10 @@ import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.util.Utils; import com.android.systemui.util.Utils;
public class MediaProjectionPermissionActivity extends Activity public class MediaProjectionPermissionActivity extends Activity
@@ -56,7 +54,7 @@ public class MediaProjectionPermissionActivity extends Activity
private int mUid; private int mUid;
private IMediaProjectionManager mService; private IMediaProjectionManager mService;
private AlertDialog mDialog; private SystemUIDialog mDialog;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@@ -143,25 +141,18 @@ public class MediaProjectionPermissionActivity extends Activity
dialogTitle = getString(R.string.media_projection_dialog_title, appName); dialogTitle = getString(R.string.media_projection_dialog_title, appName);
} }
View dialogTitleView = View.inflate(this, R.layout.media_projection_dialog_title, null); mDialog = new SystemUIDialog(this);
TextView titleText = (TextView) dialogTitleView.findViewById(R.id.dialog_title); mDialog.setTitle(dialogTitle);
titleText.setText(dialogTitle); mDialog.setIcon(R.drawable.ic_media_projection_permission);
mDialog.setMessage(dialogText);
mDialog = new AlertDialog.Builder(this) mDialog.setPositiveButton(R.string.media_projection_action_text, this);
.setCustomTitle(dialogTitleView) mDialog.setNeutralButton(android.R.string.cancel, this);
.setMessage(dialogText) mDialog.setOnCancelListener(this);
.setPositiveButton(R.string.media_projection_action_text, this)
.setNegativeButton(android.R.string.cancel, this)
.setOnCancelListener(this)
.create();
mDialog.create(); mDialog.create();
mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setFilterTouchesWhenObscured(true); mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setFilterTouchesWhenObscured(true);
final Window w = mDialog.getWindow(); final Window w = mDialog.getWindow();
// QS is not closed when pressing CastTile. Match the type of the dialog shown from the
// tile.
w.setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
w.addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); w.addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
mDialog.show(); mDialog.show();