mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Fix app crashes in CopyTextBottomSheetFragment. Add LockScreenActivity.
This commit is contained in:
parent
ee4c25a465
commit
c08d06df2e
@ -176,6 +176,8 @@ dependencies {
|
||||
implementation "androidx.startup:startup-runtime:1.0.0"
|
||||
implementation 'com.github.FunkyMuse:Crashy:1.1.0'
|
||||
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
|
||||
|
||||
|
||||
/**** Builds and flavors ****/
|
||||
// debugImplementation because LeakCanary should only run in debug builds.
|
||||
|
@ -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" />
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
9
app/src/main/res/layout/activity_look_screen.xml
Normal file
9
app/src/main/res/layout/activity_look_screen.xml
Normal file
@ -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>
|
Loading…
Reference in New Issue
Block a user