From 72fe9fad0ce59e8a1edb90362f1cc29f7b756bb1 Mon Sep 17 00:00:00 2001 From: Mihai Adrian <48995920+mcarare@users.noreply.github.com> Date: Fri, 17 Apr 2020 06:33:57 +0300 Subject: [PATCH] For #9987: Set FLAG_SECURE to dialog when flag set in activity. (#9998) * For #9987: Add extension to secures dialog if parent activity is secured * For #9987: Set FLAG_SECURE to dialog when flag set in activity --- .../main/java/org/mozilla/fenix/ext/Dialog.kt | 24 +++++++++++++++++++ .../account/AccountSettingsFragment.kt | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/org/mozilla/fenix/ext/Dialog.kt diff --git a/app/src/main/java/org/mozilla/fenix/ext/Dialog.kt b/app/src/main/java/org/mozilla/fenix/ext/Dialog.kt new file mode 100644 index 000000000..b41d4b6c0 --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/ext/Dialog.kt @@ -0,0 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.ext + +import android.app.Activity +import android.app.Dialog +import android.view.WindowManager + +/** + * Checks if activity's window has a FLAG_SECURE set and sets it to dialog + */ +fun Dialog.secure(activity: Activity?) { + this.window.apply { + val flags = activity?.window?.attributes?.flags + if (flags != null && flags and WindowManager.LayoutParams.FLAG_SECURE != 0) { + this?.setFlags( + WindowManager.LayoutParams.FLAG_SECURE, + WindowManager.LayoutParams.FLAG_SECURE + ) + } + } +} diff --git a/app/src/main/java/org/mozilla/fenix/settings/account/AccountSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/account/AccountSettingsFragment.kt index 9237ffce0..b1fdacfd4 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/account/AccountSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/account/AccountSettingsFragment.kt @@ -42,6 +42,7 @@ import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.ext.requireComponents +import org.mozilla.fenix.ext.secure import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.showToolbar @@ -240,7 +241,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() { startActivity(intent) } create() - }.show() + }.show().secure(activity) it.settings().incrementShowLoginsSecureWarningSyncCount() } }