aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/AndroidManifest.xml5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java54
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java85
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java6
-rw-r--r--app/src/main/res/layout/activity_look_screen.xml9
6 files changed, 158 insertions, 6 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 97dc80d3..4cde57e7 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -32,7 +32,10 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:replace="android:label">
- <activity android:name=".activities.AnonymousSubscriptionsActivity"
+ <activity android:name=".activities.LockScreenActivity"
+ android:theme="@style/AppTheme.NoActionBar" />
+ <activity
+ android:name=".activities.AnonymousSubscriptionsActivity"
android:label="@string/subscriptions"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index b0506a82..922642f2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -21,11 +21,12 @@ import ml.docilealligator.infinityforreddit.activities.FullMarkdownActivity;
import ml.docilealligator.infinityforreddit.activities.GiveAwardActivity;
import ml.docilealligator.infinityforreddit.activities.InboxActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
+import ml.docilealligator.infinityforreddit.activities.LockScreenActivity;
import ml.docilealligator.infinityforreddit.activities.LoginActivity;
import ml.docilealligator.infinityforreddit.activities.MainActivity;
import ml.docilealligator.infinityforreddit.activities.MultiredditSelectionActivity;
-import ml.docilealligator.infinityforreddit.activities.PostFilterUsageListingActivity;
import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
+import ml.docilealligator.infinityforreddit.activities.PostFilterUsageListingActivity;
import ml.docilealligator.infinityforreddit.activities.PostImageActivity;
import ml.docilealligator.infinityforreddit.activities.PostLinkActivity;
import ml.docilealligator.infinityforreddit.activities.PostTextActivity;
@@ -263,4 +264,6 @@ public interface AppComponent {
void inject(CrashReportsFragment crashReportsFragment);
void inject(AnonymousSubscriptionsActivity anonymousSubscriptionsActivity);
+
+ void inject(LockScreenActivity lockScreenActivity);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
index 274d1ad7..1514b745 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
@@ -7,6 +7,7 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.lifecycle.LifecycleObserver;
import com.evernote.android.state.StateSaver;
import com.livefront.bridge.Bridge;
@@ -18,7 +19,7 @@ import ml.docilealligator.infinityforreddit.broadcastreceivers.NetworkWifiStatus
import ml.docilealligator.infinityforreddit.events.ChangeNetworkStatusEvent;
import ml.docilealligator.infinityforreddit.utils.Utils;
-public class Infinity extends Application {
+public class Infinity extends Application implements LifecycleObserver {
private AppComponent mAppComponent;
private NetworkWifiStatusReceiver mNetworkWifiStatusReceiver;
@@ -26,12 +27,49 @@ public class Infinity extends Application {
public void onCreate() {
super.onCreate();
- //RedScreenOfDeath.init(this);
-
mAppComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();
+ //ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
+
+ /*registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
+ @Override
+ public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) {
+ activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
+ }
+
+ @Override
+ public void onActivityStarted(@NonNull Activity activity) {
+
+ }
+
+ @Override
+ public void onActivityResumed(@NonNull Activity activity) {
+
+ }
+
+ @Override
+ public void onActivityPaused(@NonNull Activity activity) {
+
+ }
+
+ @Override
+ public void onActivityStopped(@NonNull Activity activity) {
+
+ }
+
+ @Override
+ public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) {
+
+ }
+
+ @Override
+ public void onActivityDestroyed(@NonNull Activity activity) {
+
+ }
+ });*/
+
Bridge.initialize(getApplicationContext(), new SavedStateHandler() {
@Override
public void saveInstanceState(@NonNull Object target, @NonNull Bundle state) {
@@ -51,6 +89,16 @@ public class Infinity extends Application {
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
+// @OnLifecycleEvent(Lifecycle.Event.ON_START)
+// public void appInForeground(){
+// Toast.makeText(this, "Foreground", Toast.LENGTH_SHORT).show();
+// }
+//
+// @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
+// public void appInBackground(){
+// Toast.makeText(this, "Background", Toast.LENGTH_SHORT).show();
+// }
+
public AppComponent getAppComponent() {
return mAppComponent;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java
new file mode 100644
index 00000000..8dc39275
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java
@@ -0,0 +1,85 @@
+package ml.docilealligator.infinityforreddit.activities;
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+
+import androidx.annotation.NonNull;
+import androidx.biometric.BiometricManager;
+import androidx.biometric.BiometricPrompt;
+import androidx.core.content.ContextCompat;
+
+import java.util.concurrent.Executor;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import ml.docilealligator.infinityforreddit.Infinity;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+
+import static androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_STRONG;
+import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL;
+
+public class LockScreenActivity extends BaseActivity {
+
+ @Inject
+ @Named("default")
+ SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ ((Infinity) getApplication()).getAppComponent().inject(this);
+
+ setImmersiveModeNotApplicable();
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_look_screen);
+
+ applyCustomTheme();
+
+ BiometricManager biometricManager = BiometricManager.from(this);
+ if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) == BiometricManager.BIOMETRIC_SUCCESS) {
+ Executor executor = ContextCompat.getMainExecutor(this);
+ BiometricPrompt biometricPrompt = new BiometricPrompt(this,
+ executor, new BiometricPrompt.AuthenticationCallback() {
+ @Override
+ public void onAuthenticationSucceeded(
+ @NonNull BiometricPrompt.AuthenticationResult result) {
+ super.onAuthenticationSucceeded(result);
+ finish();
+ }
+ });
+
+ BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder()
+ .setTitle(getString(R.string.unlock_account_section))
+ .setAllowedAuthenticators(BIOMETRIC_STRONG | DEVICE_CREDENTIAL)
+ .build();
+
+ biometricPrompt.authenticate(promptInfo);
+ } else {
+ finish();
+ }
+ }
+
+ @Override
+ protected SharedPreferences getDefaultSharedPreferences() {
+ return mSharedPreferences;
+ }
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+
+ }
+
+ @Override
+ public void onBackPressed() {
+ moveTaskToBack(true);
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
index d29a1510..6e87c4ee 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
@@ -39,6 +39,7 @@ public class CopyTextBottomSheetFragment extends RoundedBottomSheetDialogFragmen
TextView copyAllMarkdownTextView;
private Activity activity;
+ private String markdownText;
public CopyTextBottomSheetFragment() {
// Required empty public constructor
@@ -53,7 +54,10 @@ public class CopyTextBottomSheetFragment extends RoundedBottomSheetDialogFragmen
ButterKnife.bind(this, rootView);
String rawText = getArguments().getString(EXTRA_RAW_TEXT);
- String markdownText = getArguments().getString(EXTRA_MARKDOWN).replaceAll("<sup>", "^").replaceAll("</sup>", "");
+ markdownText = getArguments().getString(EXTRA_MARKDOWN);
+ if (markdownText != null) {
+ markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
+ }
copyRawTextTextView.setOnClickListener(view -> {
showCopyDialog(rawText);
diff --git a/app/src/main/res/layout/activity_look_screen.xml b/app/src/main/res/layout/activity_look_screen.xml
new file mode 100644
index 00000000..ff5c4fc4
--- /dev/null
+++ b/app/src/main/res/layout/activity_look_screen.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".activities.LockScreenActivity">
+
+</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file