Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Commit

Permalink
Show warning about possible password leak
Browse files Browse the repository at this point in the history
See also #87
  • Loading branch information
schaal committed May 30, 2018
1 parent 74c372a commit 1a5c016
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
40 changes: 39 additions & 1 deletion app/src/main/java/email/schaal/ocreader/ListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
package email.schaal.ocreader;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.databinding.DataBindingUtil;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
Expand Down Expand Up @@ -191,11 +194,46 @@ protected void onResume() {
@Override
protected void onStart() {
super.onStart();
if(!Preferences.hasCredentials(PreferenceManager.getDefaultSharedPreferences(this))) {
final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

if(!Preferences.SYS_PW_LEAK_WARNING_SHOWN.getBoolean(sharedPreferences)) {
showPwLeakWarning();
} else if(!Preferences.hasCredentials(sharedPreferences)) {
startActivityForResult(new Intent(this, LoginActivity.class), LoginActivity.REQUEST_CODE);
}
}

private void showPwLeakWarning() {
final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.setTitle("Possible password leak")
.setIcon(R.drawable.ic_warning)
.setMessage("If you sent a report in the past using this app's builtin crash reporter, it is possible your password was leaked. It is strongly advised to change your server password in this case")
.setCancelable(false)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
sharedPreferences
.edit()
.putBoolean(Preferences.SYS_PW_LEAK_WARNING_SHOWN.getKey(), true)
.apply();

dialog.dismiss();

if(!Preferences.hasCredentials(sharedPreferences)) {
startActivityForResult(new Intent(this, LoginActivity.class), LoginActivity.REQUEST_CODE);
}
})
.setNeutralButton("more info", (dialog, which) -> {
try {
final Intent moreInfoIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/schaal/ocreader/wiki/Information-about-possible-password-leak"));
startActivity(moreInfoIntent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}).show();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/email/schaal/ocreader/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public enum Preferences {
SYS_ISFEED("isfeed", false),

SYS_DETECTED_API_LEVEL("detected_api_level"),
SYS_APIv2_ETAG("apiv2_etag");
SYS_APIv2_ETAG("apiv2_etag"),

SYS_PW_LEAK_WARNING_SHOWN("pw_leak_warning_shown", false);

/**
* What to do after the preference changes
Expand Down

0 comments on commit 1a5c016

Please sign in to comment.