prevent screenshots on dialogs (#543)

This commit is contained in:
m2049r 2019-03-02 09:31:06 +01:00 committed by GitHub
parent 93a7be0452
commit 8d95de828b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 5 deletions

View File

@ -71,7 +71,7 @@
<provider <provider
android:name="android.support.v4.content.FileProvider" android:name="android.support.v4.content.FileProvider"
android:authorities="com.m2049r.xmrwallet.fileprovider" android:authorities="${applicationId}.fileprovider"
android:exported="false" android:exported="false"
android:grantUriPermissions="true"> android:grantUriPermissions="true">
<meta-data <meta-data

View File

@ -31,7 +31,7 @@ public abstract class SecureActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// set FLAG_SECURE to prevent screenshots in Release Mode // set FLAG_SECURE to prevent screenshots in Release Mode
if (!BuildConfig.DEBUG && !BuildConfig.FLAVOR_type.equals("alpha")) { if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE); getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
} }
} }

View File

@ -22,11 +22,11 @@ import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.m2049r.xmrwallet.BuildConfig;
import com.m2049r.xmrwallet.R; import com.m2049r.xmrwallet.R;
import java.util.Locale; import java.util.Locale;
@ -78,6 +78,11 @@ public class ProgressDialog extends AlertDialog {
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// set FLAG_SECURE to prevent screenshots in Release Mode
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
}
} }
public void setProgress(int value, int max) { public void setProgress(int value, int max) {

View File

@ -6,7 +6,6 @@ import android.os.Looper;
import com.m2049r.xmrwallet.R; import com.m2049r.xmrwallet.R;
import com.m2049r.xmrwallet.dialog.ProgressDialog; import com.m2049r.xmrwallet.dialog.ProgressDialog;
import com.m2049r.xmrwallet.model.WalletManager;
import timber.log.Timber; import timber.log.Timber;

View File

@ -587,6 +587,11 @@ public class Helper {
} }
}); });
// set FLAG_SECURE to prevent screenshots in Release Mode
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
openDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
}
Helper.showKeyboard(openDialog); Helper.showKeyboard(openDialog);
openDialog.show(); openDialog.show();
} }