diff --git a/app/src/main/java/com/guardanis/applock/AppLock.java b/app/src/main/java/com/guardanis/applock/AppLock.java index ab3dd7acb..f6cf67bfe 100644 --- a/app/src/main/java/com/guardanis/applock/AppLock.java +++ b/app/src/main/java/com/guardanis/applock/AppLock.java @@ -67,6 +67,15 @@ public class AppLock { return false; } + public static void setAuthenticationRequired(Context context) { + AppLock helper = getInstance(context); + + helper.getPreferences() + .edit() + .putLong(PREF_UNLOCK_SUCCESS_TIME, 0) + .commit(); + } + /** * @return true if the user is enrolled in locking and the last successful unlock happened more than the default lock duration ago */ diff --git a/app/src/main/java/com/guardanis/applock/activities/LockCreationActivity.java b/app/src/main/java/com/guardanis/applock/activities/LockCreationActivity.java index d8e6a0c5c..ce0f4fd86 100644 --- a/app/src/main/java/com/guardanis/applock/activities/LockCreationActivity.java +++ b/app/src/main/java/com/guardanis/applock/activities/LockCreationActivity.java @@ -3,7 +3,10 @@ package com.guardanis.applock.activities; import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier; import android.app.Activity; +import android.os.Build; import android.os.Bundle; +import android.view.View; +import android.view.WindowInsetsController; import android.widget.LinearLayout; import android.widget.TextView; @@ -22,12 +25,23 @@ public class LockCreationActivity extends AppCompatActivity implements LockCreat super.onCreate(savedInstance); setContentView(getIdentifier("applock__activity_lock_creation", "layout")); - ((LinearLayout) findViewById(getIdentifier("applock__activity_lock_creation", "id"))).setBackgroundColor(ThemesUtils.getBackgroundContent()); + findViewById(getIdentifier("applock__activity_lock_creation", "id")).setBackgroundColor(ThemesUtils.getBackgroundContent()); ((TextView) findViewById(getIdentifier("pin__description", "id"))).setTextColor(ThemesUtils.getTextAttr()); this.viewController = new LockCreationViewController(this, findViewById(getIdentifier("pin__container", "id"))); this.viewController.setDelegate(this); this.viewController.setupRootFlow(); + + this.getWindow().setStatusBarColor(ThemesUtils.getBackgroundContent()); + this.getWindow().setNavigationBarColor(ThemesUtils.getBackgroundContent()); + + if (!ThemesUtils.isDarkTheme()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + this.getWindow().getInsetsController().setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS); + } else { + this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + } } @Override diff --git a/app/src/main/java/com/guardanis/applock/activities/UnlockActivity.java b/app/src/main/java/com/guardanis/applock/activities/UnlockActivity.java index 5372b9c0d..16b22be88 100644 --- a/app/src/main/java/com/guardanis/applock/activities/UnlockActivity.java +++ b/app/src/main/java/com/guardanis/applock/activities/UnlockActivity.java @@ -1,8 +1,11 @@ package com.guardanis.applock.activities; import android.app.Activity; +import android.os.Build; import android.os.Bundle; import android.view.KeyEvent; +import android.view.View; +import android.view.WindowInsetsController; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -25,15 +28,25 @@ public class UnlockActivity extends AppCompatActivity implements UnlockViewContr super.onCreate(savedInstance); setContentView(AndroidUtils.getIdentifier("applock__activity_unlock", "layout")); - ((LinearLayout) findViewById(AndroidUtils.getIdentifier("applock__activity_unlock", "id"))).setBackgroundColor(ThemesUtils.getBackgroundContent()); + findViewById(AndroidUtils.getIdentifier("applock__activity_unlock", "id")).setBackgroundColor(ThemesUtils.getBackgroundContent()); ((TextView) findViewById(AndroidUtils.getIdentifier("pin__description", "id"))).setTextColor(ThemesUtils.getTextAttr()); - this.viewController = new UnlockViewController(this, findViewById(AndroidUtils.getIdentifier("pin__container", "id"))); this.viewController.setAutoAuthorizationEnabled(false); // Disable auto authorization so fingerprint doesn't crash onResume this.viewController.setDelegate(this); this.viewController.setupRootFlow(); this.viewController.setAutoAuthorizationEnabled(true); + + this.getWindow().setStatusBarColor(ThemesUtils.getBackgroundContent()); + this.getWindow().setNavigationBarColor(ThemesUtils.getBackgroundContent()); + + if (!ThemesUtils.isDarkTheme()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + this.getWindow().getInsetsController().setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS); + } else { + this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + } } @Override diff --git a/app/src/main/java/ru/vtosters/lite/hooks/MainActivityInjector.java b/app/src/main/java/ru/vtosters/lite/hooks/MainActivityInjector.java index ac1c13aa9..6a58ad50a 100644 --- a/app/src/main/java/ru/vtosters/lite/hooks/MainActivityInjector.java +++ b/app/src/main/java/ru/vtosters/lite/hooks/MainActivityInjector.java @@ -1,16 +1,8 @@ package ru.vtosters.lite.hooks; -import static ru.vtosters.lite.ui.dialogs.ServerDialog.sendRequest; -import static ru.vtosters.lite.utils.CacheUtils.getInstance; -import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters; -import static ru.vtosters.lite.utils.Preferences.checkupdates; -import static ru.vtosters.lite.utils.ThemesUtils.setNeededTheme; - import android.app.Activity; import android.content.Intent; import android.os.Build; -import com.guardanis.applock.AppLock; -import com.guardanis.applock.activities.UnlockActivity; import b.h.g.k.VKProgressDialog; import com.vk.core.dialogs.alert.VkAlertDialog; import com.vtosters.lite.R; @@ -24,6 +16,12 @@ import ru.vtosters.lite.ui.dialogs.OTADialog; import ru.vtosters.lite.ui.dialogs.Start; import ru.vtosters.lite.utils.*; +import static ru.vtosters.lite.ui.dialogs.ServerDialog.sendRequest; +import static ru.vtosters.lite.utils.CacheUtils.getInstance; +import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters; +import static ru.vtosters.lite.utils.Preferences.checkupdates; +import static ru.vtosters.lite.utils.ThemesUtils.setNeededTheme; + public class MainActivityInjector { public static void inject(Activity activity) { setNeededTheme(activity); @@ -42,11 +40,6 @@ public class MainActivityInjector { NotificationChannels.createChannels(); } - if (AppLock.isEnrolled(activity)) { - var intent = new Intent(activity, UnlockActivity.class); - activity.startActivity(intent); - } - if(Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && ThemesManager.canApplyCustomAccent()) { Preferences.updateBuildNumber(); updateBinsAndTmpArchive(activity); diff --git a/app/src/main/java/ru/vtosters/lite/utils/LifecycleUtils.java b/app/src/main/java/ru/vtosters/lite/utils/LifecycleUtils.java index 06e70fba6..91bf275c4 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/LifecycleUtils.java +++ b/app/src/main/java/ru/vtosters/lite/utils/LifecycleUtils.java @@ -8,6 +8,8 @@ import android.content.pm.PackageManager; import android.os.Bundle; import android.os.Handler; +import com.guardanis.applock.AppLock; +import com.guardanis.applock.activities.UnlockActivity; import com.vk.core.fragments.FragmentImpl; import com.vk.navigation.Navigator; import com.vtosters.lite.MainActivity; @@ -45,6 +47,11 @@ public class LifecycleUtils { @Override // android.app.Application.ActivityLifecycleCallbacks public void onActivityCreated(Activity activity, Bundle bundle) { activities.add(activity); + + if (AppLock.isUnlockRequired(activity)) { + var intent = new Intent(activity, UnlockActivity.class); + activity.startActivity(intent); + } } @Override // android.app.Application.ActivityLifecycleCallbacks diff --git a/app/src/main/java/ru/vtosters/lite/utils/Preferences.java b/app/src/main/java/ru/vtosters/lite/utils/Preferences.java index 543372128..02e0c16cc 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Preferences.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Preferences.java @@ -2,10 +2,13 @@ package ru.vtosters.lite.utils; import android.app.Application; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Build; import android.os.StrictMode; +import com.guardanis.applock.AppLock; +import com.guardanis.applock.activities.UnlockActivity; import com.vtosters.lite.data.Users; import com.vtosters.lite.fragments.SettingsListFragment; import ru.vtosters.lite.ui.fragments.VTSettings; @@ -32,6 +35,10 @@ public class Preferences { setupFilters(); VTVerifications.load(application); LifecycleUtils.registerActivities(application); + + if (AppLock.isEnrolled(AndroidUtils.getGlobalContext())) { + AppLock.setAuthenticationRequired(AndroidUtils.getGlobalContext()); + } } // VK Init public static SharedPreferences getPreferences() { diff --git a/smali/AndroidManifest.xml b/smali/AndroidManifest.xml index 25661a1d1..934336c36 100644 --- a/smali/AndroidManifest.xml +++ b/smali/AndroidManifest.xml @@ -16,6 +16,7 @@ + @@ -196,6 +197,14 @@ android:name="ru.vtosters.lite.ui.activities.VKAdminTokenActivity" android:launchMode="singleTop"> + + + +