From ed8010c92c522fc07be3ab891b95126c3a54bad0 Mon Sep 17 00:00:00 2001 From: mattcode55 Date: Thu, 16 Nov 2017 18:14:53 +0000 Subject: [PATCH] Set FLAG_SECURE to disable screenshots (#134) mattermost: https://taiga.getmonero.org/project/m2049r-monerujo/us/38 Sets FLAG_SECURE on all activities to prevent users accidentally screenshotting sensitive information. --- .../com/m2049r/xmrwallet/LoginActivity.java | 3 +- .../com/m2049r/xmrwallet/SecureActivity.java | 33 +++++++++++++++++++ .../com/m2049r/xmrwallet/WalletActivity.java | 3 +- 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/m2049r/xmrwallet/SecureActivity.java diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java index 657d704..c94e950 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java @@ -33,7 +33,6 @@ import android.support.design.widget.TextInputLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.AppCompatActivity; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; @@ -68,7 +67,7 @@ import java.net.SocketAddress; import java.nio.channels.FileChannel; import java.util.Date; -public class LoginActivity extends AppCompatActivity +public class LoginActivity extends SecureActivity implements LoginFragment.Listener, GenerateFragment.Listener, GenerateReviewFragment.Listener, GenerateReviewFragment.AcceptListener, ReceiveFragment.Listener { static final String TAG = "LoginActivity"; diff --git a/app/src/main/java/com/m2049r/xmrwallet/SecureActivity.java b/app/src/main/java/com/m2049r/xmrwallet/SecureActivity.java new file mode 100644 index 0000000..4be5d14 --- /dev/null +++ b/app/src/main/java/com/m2049r/xmrwallet/SecureActivity.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 m2049r + * + * 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.m2049r.xmrwallet; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; + +import static android.view.WindowManager.LayoutParams; + +public abstract class SecureActivity extends AppCompatActivity { + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // set FLAG_SECURE to prevent screenshots + getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE); + } +} diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java index 4cde481..108971c 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java @@ -31,7 +31,6 @@ import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.MenuItem; import android.widget.Toast; @@ -51,7 +50,7 @@ import com.m2049r.xmrwallet.util.TxData; import java.util.HashMap; import java.util.Map; -public class WalletActivity extends AppCompatActivity implements WalletFragment.Listener, +public class WalletActivity extends SecureActivity implements WalletFragment.Listener, WalletService.Observer, SendFragment.Listener, TxFragment.Listener, GenerateReviewFragment.ListenerWithWallet, GenerateReviewFragment.Listener,