mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Endless loop when enabling screen lock option #181
This commit is contained in:
@@ -82,7 +82,7 @@ public class ApplicationContext extends MultiDexApplication implements DefaultLi
|
||||
@Override
|
||||
public void onStop(@NonNull LifecycleOwner owner) {
|
||||
isAppVisible = false;
|
||||
ScreenLockUtil.shouldLockApp = true;
|
||||
ScreenLockUtil.setShouldLockApp(true);
|
||||
}
|
||||
|
||||
public JobManager getJobManager() {
|
||||
|
||||
@@ -14,14 +14,12 @@ import android.view.ViewConfiguration;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.util.ScreenLockUtil;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.ScreenLockUtil;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Timer;
|
||||
|
||||
import static org.thoughtcrime.securesms.util.ScreenLockUtil.shouldLockApp;
|
||||
|
||||
|
||||
public abstract class BaseActionBarActivity extends AppCompatActivity {
|
||||
|
||||
@@ -29,6 +27,8 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
|
||||
|
||||
private Timer timer;
|
||||
|
||||
private boolean isWaitingForResult;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (BaseActivity.isMenuWorkaroundRequired()) {
|
||||
@@ -40,7 +40,7 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (ScreenLockUtil.isScreenLockEnabled(this) && shouldLockApp) {
|
||||
if (ScreenLockUtil.isScreenLockEnabled(this) && ScreenLockUtil.getShouldLockApp() && !isWaitingForResult) {
|
||||
ScreenLockUtil.applyScreenLock(this);
|
||||
}
|
||||
}
|
||||
@@ -48,11 +48,13 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
isWaitingForResult = false;
|
||||
if (requestCode == ScreenLockUtil.REQUEST_CODE_CONFIRM_CREDENTIALS) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
shouldLockApp = false;
|
||||
ScreenLockUtil.setShouldLockApp(false);
|
||||
} else {
|
||||
Toast.makeText(this, R.string.screenlock_authentication_failed, Toast.LENGTH_SHORT).show();
|
||||
ScreenLockUtil.applyScreenLock(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,4 +136,9 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
|
||||
ActivityCompat.startActivity(this, intent, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
isWaitingForResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ScreenLockUtil {
|
||||
|
||||
public static final int REQUEST_CODE_CONFIRM_CREDENTIALS = 1001;
|
||||
|
||||
public static boolean shouldLockApp = true;
|
||||
private static boolean shouldLockApp = true;
|
||||
|
||||
public static void applyScreenLock(Activity activity) {
|
||||
applyScreenLock(activity, REQUEST_CODE_CONFIRM_CREDENTIALS);
|
||||
@@ -65,4 +65,12 @@ public class ScreenLockUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getShouldLockApp() {
|
||||
return shouldLockApp;
|
||||
}
|
||||
|
||||
public static void setShouldLockApp(boolean newShouldLockApp) {
|
||||
shouldLockApp = newShouldLockApp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user