Lock pattern security issues
When user press cancel/back on the pattern screen sometimes the Delta Chat screen (with the sensitive content) is briefly shown. 
Also when the app is put in background/minimized and user go to the app again, the chats list is shown (all chats and their last message are visible) when the user tries to open a chat, then the pattern screen is shown.

- Platform (android/blackberry/anbox): Android 6.0
- Device: BLU
- Delta Chat Version: 0.98.2
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0f2b7d064..a98b4fef2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -417,7 +417,7 @@
 
     <!-- screen lock -->
     <string name="screenlock_title">Screen lock</string>
-    <string name="screenlock_explain">Lock Delta Chat access with Android screen lock or fingerprint</string>
+    <string name="screenlock_explain">Lock access with Android screen lock or fingerprint; to avoid appearing the previous content, please also enable \"Screen security\"</string>
     <string name="screenlock_authentication_failed">Authentication failed.</string>
     <string name="screenlock_unlock_title">Unlock Delta Chat</string>
     <string name="screenlock_unlock_description">Please enter your system defined secret to unlock Delta Chat.</string>
diff --git a/src/org/thoughtcrime/securesms/BaseActionBarActivity.java b/src/org/thoughtcrime/securesms/BaseActionBarActivity.java
index 50d4badd0..78952ea2b 100644
--- a/src/org/thoughtcrime/securesms/BaseActionBarActivity.java
+++ b/src/org/thoughtcrime/securesms/BaseActionBarActivity.java
@@ -28,6 +28,7 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
   private Timer timer;
 
   private boolean isWaitingForResult;
+  private boolean isHiddenByScreenLock;
 
   @Override
   protected void onCreate(Bundle savedInstanceState) {
@@ -39,13 +40,25 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
 
     @Override
     protected void onStart() {
-        super.onStart();
         if (ScreenLockUtil.isScreenLockEnabled(this) && ScreenLockUtil.getShouldLockApp() && !isWaitingForResult) {
-            ScreenLockUtil.applyScreenLock(this);
+          ScreenLockUtil.applyScreenLock(this);
+        } else if (isHiddenByScreenLock) {
+          findViewById(android.R.id.content).setVisibility(View.VISIBLE);
+          isHiddenByScreenLock = false;
         }
+        super.onStart();
     }
 
-    @Override
+  @Override
+  protected void onStop() {
+    if (ScreenLockUtil.isScreenLockEnabled(this)) {
+      findViewById(android.R.id.content).setVisibility(View.GONE);
+      isHiddenByScreenLock = true;
+    }
+    super.onStop();
+  }
+
+  @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
       super.onActivityResult(requestCode, resultCode, data);
       isWaitingForResult = false;
@@ -139,6 +152,8 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
   @Override
   public void startActivityForResult(Intent intent, int requestCode) {
     super.startActivityForResult(intent, requestCode);
-    isWaitingForResult = true;
+    if (requestCode != -1) {
+      isWaitingForResult = true;
+    }
   }
 }
diff --git a/src/org/thoughtcrime/securesms/ConversationListActivity.java b/src/org/thoughtcrime/securesms/ConversationListActivity.java
index 0fa498da0..b6d6743bc 100644
--- a/src/org/thoughtcrime/securesms/ConversationListActivity.java
+++ b/src/org/thoughtcrime/securesms/ConversationListActivity.java
@@ -82,11 +82,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
     dynamicLanguage.onResume(this);
   }
 
-  @Override
-  public void onDestroy() {
-    super.onDestroy();
-  }
-
   @Override
   public boolean onPrepareOptionsMenu(Menu menu) {
     MenuInflater inflater = this.getMenuInflater();
diff --git a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java
index a2022ba3e..acb42aefb 100644
--- a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java
+++ b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java
@@ -262,6 +262,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
+      super.onActivityResult(requestCode, resultCode, data);
       if (requestCode == REQUEST_CODE_PICK_RINGTONE && resultCode == RESULT_OK && data != null) {
         Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
 
diff --git a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java
index 8ba068af4..45eae8e19 100644
--- a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java
+++ b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java
@@ -137,6 +137,7 @@ public class AdvancedPreferenceFragment extends CorrectedPreferenceFragment
 
   @Override
   public void onActivityResult(int requestCode, int resultCode, Intent data) {
+    super.onActivityResult(requestCode, resultCode, data);
       if (resultCode == RESULT_OK) {
         if (requestCode == REQUEST_CODE_CONFIRM_CREDENTIALS_BACKUP) {
           performBackup();
diff --git a/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java
index 4ce31c271..f1b7d8543 100644
--- a/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java
+++ b/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java
@@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.components.SwitchPreferenceCompat;
 import org.thoughtcrime.securesms.connect.ApplicationDcContext;
 import org.thoughtcrime.securesms.connect.DcHelper;
 import org.thoughtcrime.securesms.util.Prefs;
+import org.thoughtcrime.securesms.util.ScreenLockUtil;
 
 import java.util.concurrent.TimeUnit;
 
@@ -114,6 +115,7 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
             boolean enabled = (Boolean) newValue;
             manageScreenLockChildren(enabled);
             Prefs.setScreenLockEnabled(getContext(), enabled);
+            ScreenLockUtil.setShouldLockApp(false);
             return true;
         }
     }
diff --git a/src/org/thoughtcrime/securesms/preferences/ChatBackgroundActivity.java b/src/org/thoughtcrime/securesms/preferences/ChatBackgroundActivity.java
index 563021349..47e4a7df0 100644
--- a/src/org/thoughtcrime/securesms/preferences/ChatBackgroundActivity.java
+++ b/src/org/thoughtcrime/securesms/preferences/ChatBackgroundActivity.java
@@ -156,6 +156,7 @@ public class ChatBackgroundActivity extends BaseActionBarActivity {
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
         final Context context = getApplicationContext();
         if (data != null && context != null && resultCode == RESULT_OK && requestCode == ApplicationPreferencesActivity.REQUEST_CODE_SET_BACKGROUND) {
             imageUri = data.getData();
diff --git a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java
index b0b86506c..67f6a12ed 100644
--- a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java
+++ b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java
@@ -82,6 +82,7 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
 
   @Override
   public void onActivityResult(int requestCode, int resultCode, Intent data) {
+    super.onActivityResult(requestCode, resultCode, data);
     if (requestCode == REQUEST_CODE_NOTIFICATION_SELECTED && resultCode == RESULT_OK && data != null) {
       Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
 
['src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java', 'src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java', 'src/org/thoughtcrime/securesms/ConversationListActivity.java', 'src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java', 'src/org/thoughtcrime/securesms/preferences/ChatBackgroundActivity.java', 'res/values/strings.xml', 'src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java', 'src/org/thoughtcrime/securesms/BaseActionBarActivity.java']