Directly reference activity for remove avatar confirmation prompt.

This commit is contained in:
Alan Evans 2020-12-09 11:15:48 -04:00 committed by GitHub
parent 3f2b4d60fd
commit 974c33fe37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 19 deletions

View file

@ -465,17 +465,11 @@
android:windowSoftInputMode="adjustResize" android:windowSoftInputMode="adjustResize"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ClearProfileAvatarActivity" <activity android:name=".ClearAvatarPromptActivity"
android:theme="@style/Theme.AppCompat.Dialog.Alert" android:theme="@style/Theme.AppCompat.Dialog.Alert"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:icon="@drawable/clear_profile_avatar" android:icon="@drawable/clear_profile_avatar"
android:label="@string/AndroidManifest_remove_photo"> android:label="@string/AndroidManifest_remove_photo"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<intent-filter>
<action android:name="org.thoughtcrime.securesms.action.CLEAR_PROFILE_PHOTO"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".contacts.TurnOffContactJoinedNotificationsActivity" <activity android:name=".contacts.TurnOffContactJoinedNotificationsActivity"
android:theme="@style/Theme.AppCompat.Dialog.Alert" /> android:theme="@style/Theme.AppCompat.Dialog.Alert" />

View file

@ -7,18 +7,21 @@ import android.view.ContextThemeWrapper;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.util.DynamicTheme; import org.thoughtcrime.securesms.util.DynamicTheme;
public class ClearProfileAvatarActivity extends Activity { public final class ClearAvatarPromptActivity extends Activity {
private static final String ARG_TITLE = "arg_title"; private static final String ARG_TITLE = "arg_title";
public static Intent createForUserProfilePhoto() { public static Intent createForUserProfilePhoto() {
return new Intent("org.thoughtcrime.securesms.action.CLEAR_PROFILE_PHOTO"); Intent intent = new Intent(ApplicationDependencies.getApplication(), ClearAvatarPromptActivity.class);
intent.putExtra(ARG_TITLE, R.string.ClearProfileActivity_remove_profile_photo);
return intent;
} }
public static Intent createForGroupProfilePhoto() { public static Intent createForGroupProfilePhoto() {
Intent intent = new Intent("org.thoughtcrime.securesms.action.CLEAR_PROFILE_PHOTO"); Intent intent = new Intent(ApplicationDependencies.getApplication(), ClearAvatarPromptActivity.class);
intent.putExtra(ARG_TITLE, R.string.ClearProfileActivity_remove_group_photo); intent.putExtra(ARG_TITLE, R.string.ClearProfileActivity_remove_group_photo);
return intent; return intent;
} }
@ -27,10 +30,10 @@ public class ClearProfileAvatarActivity extends Activity {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
int titleId = getIntent().getIntExtra(ARG_TITLE, R.string.ClearProfileActivity_remove_profile_photo); int message = getIntent().getIntExtra(ARG_TITLE, 0);
new AlertDialog.Builder(new ContextThemeWrapper(this, DynamicTheme.isDarkTheme(this) ? R.style.TextSecure_DarkTheme : R.style.TextSecure_LightTheme)) new AlertDialog.Builder(new ContextThemeWrapper(this, DynamicTheme.isDarkTheme(this) ? R.style.TextSecure_DarkTheme : R.style.TextSecure_LightTheme))
.setMessage(titleId) .setMessage(message)
.setNegativeButton(android.R.string.cancel, (dialog, which) -> finish()) .setNegativeButton(android.R.string.cancel, (dialog, which) -> finish())
.setPositiveButton(R.string.ClearProfileActivity_remove, (dialog, which) -> { .setPositiveButton(R.string.ClearProfileActivity_remove, (dialog, which) -> {
Intent result = new Intent(); Intent result = new Intent();

View file

@ -22,7 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import org.thoughtcrime.securesms.ClearProfileAvatarActivity; import org.thoughtcrime.securesms.ClearAvatarPromptActivity;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.permissions.Permissions; import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.util.ThemeUtil; import org.thoughtcrime.securesms.util.ThemeUtil;
@ -146,8 +146,8 @@ public class AvatarSelectionBottomSheetDialogFragment extends BottomSheetDialogF
case GALLERY: case GALLERY:
return AvatarSelectionActivity.getIntentForGallery(context); return AvatarSelectionActivity.getIntentForGallery(context);
case DELETE: case DELETE:
return isGroup ? ClearProfileAvatarActivity.createForGroupProfilePhoto() return isGroup ? ClearAvatarPromptActivity.createForGroupProfilePhoto()
: ClearProfileAvatarActivity.createForUserProfilePhoto(); : ClearAvatarPromptActivity.createForUserProfilePhoto();
default: default:
throw new IllegalStateException("Unknown option: " + selectionOption); throw new IllegalStateException("Unknown option: " + selectionOption);
} }