Fix progress dialog deprecation warnings.

Moves everything under our own class and ignores the deprecation. Also
gives us future ability to re-style all blocking UI dialogs in the
future for mat3 compat.
This commit is contained in:
Cody Henthorne
2022-12-13 11:41:11 -05:00
parent 5f0d37739a
commit 3478e13d38
6 changed files with 61 additions and 22 deletions

View File

@@ -1,17 +1,18 @@
package org.thoughtcrime.securesms.util.task;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import androidx.annotation.CallSuper;
import org.thoughtcrime.securesms.components.SignalProgressDialog;
import java.lang.ref.WeakReference;
public abstract class ProgressDialogAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
private final WeakReference<Context> contextReference;
private ProgressDialog progress;
private SignalProgressDialog progress;
private final String title;
private final String message;
@@ -29,7 +30,7 @@ public abstract class ProgressDialogAsyncTask<Params, Progress, Result> extends
@Override
protected void onPreExecute() {
final Context context = contextReference.get();
if (context != null) progress = ProgressDialog.show(context, title, message, true);
if (context != null) progress = SignalProgressDialog.show(context, title, message, true);
}
@CallSuper

View File

@@ -1,7 +1,5 @@
package org.thoughtcrime.securesms.util.task;
import android.app.ProgressDialog;
import android.graphics.Color;
import android.os.AsyncTask;
import android.view.View;
@@ -12,6 +10,7 @@ import androidx.lifecycle.Lifecycle;
import com.google.android.material.snackbar.Snackbar;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.components.SignalProgressDialog;
public abstract class SnackbarAsyncTask<Params>
extends AsyncTask<Params, Void, Void>
@@ -27,8 +26,8 @@ public abstract class SnackbarAsyncTask<Params>
private final int snackbarDuration;
private final boolean showProgress;
private @Nullable Params reversibleParameter;
private @Nullable ProgressDialog progressDialog;
private @Nullable Params reversibleParameter;
private @Nullable SignalProgressDialog progressDialog;
public SnackbarAsyncTask(@NonNull Lifecycle lifecycle,
@NonNull View view,
@@ -49,7 +48,7 @@ public abstract class SnackbarAsyncTask<Params>
@Override
protected void onPreExecute() {
if (this.showProgress) this.progressDialog = ProgressDialog.show(view.getContext(), "", "", true);
if (this.showProgress) this.progressDialog = SignalProgressDialog.show(view.getContext(), "", "", true);
else this.progressDialog = null;
}
@@ -83,7 +82,7 @@ public abstract class SnackbarAsyncTask<Params>
new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
if (showProgress) progressDialog = ProgressDialog.show(view.getContext(), "", "", true);
if (showProgress) progressDialog = SignalProgressDialog.show(view.getContext(), "", "", true);
else progressDialog = null;
}