aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java2
3 files changed, 34 insertions, 9 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
index 1c7c7649..63df2552 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
@@ -11,7 +11,10 @@ import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.lifecycle.ProcessLifecycleOwner;
import com.evernote.android.state.StateSaver;
import com.livefront.bridge.Bridge;
@@ -23,6 +26,7 @@ import org.greenrobot.eventbus.Subscribe;
import javax.inject.Inject;
import javax.inject.Named;
+import ml.docilealligator.infinityforreddit.activities.LockScreenActivity;
import ml.docilealligator.infinityforreddit.broadcastreceivers.NetworkWifiStatusReceiver;
import ml.docilealligator.infinityforreddit.broadcastreceivers.WallpaperChangeReceiver;
import ml.docilealligator.infinityforreddit.events.ChangeNetworkStatusEvent;
@@ -33,7 +37,7 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
public class Infinity extends Application implements LifecycleObserver {
private AppComponent mAppComponent;
private NetworkWifiStatusReceiver mNetworkWifiStatusReceiver;
- //private boolean lock = false;
+ private boolean lock = false;
private boolean isSecureMode;
@Inject
@Named("default")
@@ -66,11 +70,11 @@ public class Infinity extends Application implements LifecycleObserver {
@Override
public void onActivityResumed(@NonNull Activity activity) {
- /*if (lock && !(activity instanceof LockScreenActivity)) {
+ if (lock && !(activity instanceof LockScreenActivity)) {
lock = false;
Intent intent = new Intent(activity, LockScreenActivity.class);
activity.startActivity(intent);
- }*/
+ }
}
@Override
@@ -94,7 +98,7 @@ public class Infinity extends Application implements LifecycleObserver {
}
});
- //ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
Bridge.initialize(getApplicationContext(), new SavedStateHandler() {
@Override
@@ -119,7 +123,7 @@ public class Infinity extends Application implements LifecycleObserver {
registerReceiver(new WallpaperChangeReceiver(), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
}
- /*@OnLifecycleEvent(Lifecycle.Event.ON_START)
+ @OnLifecycleEvent(Lifecycle.Event.ON_START)
public void appInForeground() {
lock = true;
}
@@ -127,7 +131,7 @@ public class Infinity extends Application implements LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void appInBackground(){
- }*/
+ }
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
index 3ba73440..42544ecd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java
@@ -5,23 +5,32 @@ import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTI
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.biometric.BiometricManager;
import androidx.biometric.BiometricPrompt;
import androidx.core.content.ContextCompat;
+import com.google.android.material.button.MaterialButton;
+
import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
+import butterknife.BindView;
+import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
public class LockScreenActivity extends BaseActivity {
+ @BindView(R.id.text_view_lock_screen_activity)
+ TextView textView;
+ @BindView(R.id.unlock_button_lock_screen_activity)
+ MaterialButton unlockButton;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@@ -35,10 +44,20 @@ public class LockScreenActivity extends BaseActivity {
setImmersiveModeNotApplicable();
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_look_screen);
+ setContentView(R.layout.activity_lock_screen);
+
+ ButterKnife.bind(this);
applyCustomTheme();
+ unlockButton.setOnClickListener(view -> {
+ authenticate();
+ });
+
+ authenticate();
+ }
+
+ private void authenticate() {
BiometricManager biometricManager = BiometricManager.from(this);
if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) == BiometricManager.BIOMETRIC_SUCCESS) {
Executor executor = ContextCompat.getMainExecutor(this);
@@ -75,7 +94,9 @@ public class LockScreenActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
-
+ textView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
+ unlockButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
+ unlockButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme());
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 350fb7d5..b5b5a136 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -570,7 +570,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
} else {
if (post.getAuthorIconUrl() == null) {
- String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditNamePrefixed().substring(2) : post.getAuthor();
+ String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditName() : post.getAuthor();
mFragment.loadIcon(authorName, post.getAuthor().equals("[deleted]"), (subredditOrUserName, iconUrl) -> {
if (mActivity != null && getItemCount() > 0) {
if (iconUrl == null || iconUrl.equals("") && authorName.equals(subredditOrUserName)) {