Replace the old SimpleProgressDialog with the new ProgressCard in WallpaperCropActivity.

This commit is contained in:
Sgn-32
2023-01-07 17:24:10 +01:00
committed by Alex Hart
parent 3738daf4a8
commit c099ad0aa7
2 changed files with 27 additions and 6 deletions

View File

@@ -15,7 +15,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.SwitchCompat;
import androidx.appcompat.widget.Toolbar;
@@ -29,6 +28,7 @@ import org.signal.imageeditor.core.model.EditorModel;
import org.signal.imageeditor.core.renderers.FaceBlurRenderer;
import org.thoughtcrime.securesms.BaseActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.ProgressCard;
import org.thoughtcrime.securesms.conversation.colors.ColorizerView;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.scribbles.UriGlideRenderer;
@@ -36,7 +36,6 @@ import org.thoughtcrime.securesms.util.AsynchronousCallback;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.Projection;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.views.SimpleProgressDialog;
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper;
import org.thoughtcrime.securesms.wallpaper.ChatWallpaperPreviewActivity;
@@ -55,6 +54,7 @@ public final class WallpaperCropActivity extends BaseActivity {
private ImageEditorView imageEditor;
private WallpaperCropViewModel viewModel;
private ProgressCard progressCard;
public static Intent newIntent(@NonNull Context context,
@Nullable RecipientId recipientId,
@@ -86,7 +86,9 @@ public final class WallpaperCropActivity extends BaseActivity {
WallpaperCropViewModel.Factory factory = new WallpaperCropViewModel.Factory(recipientId);
viewModel = new ViewModelProvider(this, factory).get(WallpaperCropViewModel.class);
imageEditor = findViewById(R.id.image_editor);
imageEditor = findViewById(R.id.image_editor);
progressCard = findViewById(R.id.wallpaper_crop_progress_card);
View sentBubble = findViewById(R.id.preview_bubble_2);
TextView bubble2Text = findViewById(R.id.chat_wallpaper_bubble2_text);
View setWallPaper = findViewById(R.id.preview_set_wallpaper);
@@ -156,17 +158,24 @@ public final class WallpaperCropActivity extends BaseActivity {
Point size = new Point(imageEditor.getWidth(), imageEditor.getHeight());
AlertDialog dialog = SimpleProgressDialog.show(this);
if (progressCard != null) {
progressCard.setVisibility(View.VISIBLE);
}
viewModel.render(this, model, size,
new AsynchronousCallback.MainThread<ChatWallpaper, WallpaperCropViewModel.Error>() {
@Override public void onComplete(@Nullable ChatWallpaper result) {
dialog.dismiss();
if (progressCard != null) {
progressCard.setVisibility(View.GONE);
}
setResult(RESULT_OK, new Intent().putExtra(ChatWallpaperPreviewActivity.EXTRA_CHAT_WALLPAPER, result));
finish();
}
@Override public void onError(@Nullable WallpaperCropViewModel.Error error) {
dialog.dismiss();
if (progressCard != null) {
progressCard.setVisibility(View.GONE);
}
Toast.makeText(WallpaperCropActivity.this, R.string.WallpaperCropActivity__error_setting_wallpaper, Toast.LENGTH_SHORT).show();
}
}.toWorkerCallback());