Add megaphone for new avatar picker.

fork-5.53.8
Alex Hart 2021-07-21 09:07:37 -03:00 zatwierdzone przez Greyson Parrelli
rodzic 963c018e0c
commit a75f634c0a
5 zmienionych plików z 109 dodań i 1 usunięć

Wyświetl plik

@ -57,6 +57,7 @@ public class MegaphoneRepository {
database.markFinished(Event.RESEARCH);
database.markFinished(Event.GROUP_CALLING);
database.markFinished(Event.CHAT_COLORS);
database.markFinished(Event.ADD_A_PROFILE_PHOTO);
resetDatabaseCache();
});
}

Wyświetl plik

@ -25,7 +25,9 @@ import org.thoughtcrime.securesms.lock.v2.CreateKbsPinActivity;
import org.thoughtcrime.securesms.lock.v2.KbsMigrationActivity;
import org.thoughtcrime.securesms.messagerequests.MessageRequestMegaphoneActivity;
import org.thoughtcrime.securesms.notifications.NotificationChannels;
import org.thoughtcrime.securesms.profiles.AvatarHelper;
import org.thoughtcrime.securesms.profiles.ProfileName;
import org.thoughtcrime.securesms.profiles.manage.ManageProfileActivity;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.CommunicationActions;
import org.thoughtcrime.securesms.util.FeatureFlags;
@ -105,6 +107,7 @@ public final class Megaphones {
put(Event.ONBOARDING, shouldShowOnboardingMegaphone(context) ? ALWAYS : NEVER);
put(Event.NOTIFICATIONS, shouldShowNotificationsMegaphone(context) ? RecurringSchedule.every(TimeUnit.DAYS.toMillis(30)) : NEVER);
put(Event.CHAT_COLORS, ALWAYS);
put(Event.ADD_A_PROFILE_PHOTO, shouldShowAddAProfileMegaphone(context) ? ALWAYS : NEVER);
}};
}
@ -134,6 +137,8 @@ public final class Megaphones {
return buildNotificationsMegaphone(context);
case CHAT_COLORS:
return buildChatColorsMegaphone(context);
case ADD_A_PROFILE_PHOTO:
return buildAddAProfilePhotoMegaphone(context);
default:
throw new IllegalArgumentException("Event not handled!");
}
@ -320,6 +325,21 @@ public final class Megaphones {
.build();
}
private static @NonNull Megaphone buildAddAProfilePhotoMegaphone(@NonNull Context context) {
return new Megaphone.Builder(Event.ADD_A_PROFILE_PHOTO, Megaphone.Style.BASIC)
.setTitle(R.string.AddAProfilePhotoMegaphone__add_a_profile_photo)
.setImage(R.drawable.ic_add_a_profile_megaphone_image)
.setBody(R.string.AddAProfilePhotoMegaphone__choose_a_look_and_color)
.setActionButton(R.string.AddAProfilePhotoMegaphone__add_photo, (megaphone, listener) -> {
listener.onMegaphoneNavigationRequested(ManageProfileActivity.getIntentForAvatarEdit(context));
listener.onMegaphoneCompleted(Event.ADD_A_PROFILE_PHOTO);
})
.setSecondaryButton(R.string.AddAProfilePhotoMegaphone__not_now, (megaphone, listener) -> {
listener.onMegaphoneCompleted(Event.ADD_A_PROFILE_PHOTO);
})
.build();
}
private static boolean shouldShowMessageRequestsMegaphone() {
return Recipient.self().getProfileName() == ProfileName.EMPTY;
}
@ -363,6 +383,10 @@ public final class Megaphones {
return shouldShow;
}
private static boolean shouldShowAddAProfileMegaphone(@NonNull Context context) {
return !AvatarHelper.hasAvatar(context, Recipient.self().getId());
}
public enum Event {
REACTIONS("reactions"),
PINS_FOR_ALL("pins_for_all"),
@ -375,7 +399,8 @@ public final class Megaphones {
GROUP_CALLING("group_calling"),
ONBOARDING("onboarding"),
NOTIFICATIONS("notifications"),
CHAT_COLORS("chat_colors");
CHAT_COLORS("chat_colors"),
ADD_A_PROFILE_PHOTO("add_a_profile_photo");
private final String key;

Wyświetl plik

@ -25,6 +25,7 @@ public class ManageProfileActivity extends PassphraseRequiredActivity implements
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
public static final String START_AT_USERNAME = "start_at_username";
public static final String START_AT_AVATAR = "start_at_avatar";
public static @NonNull Intent getIntent(@NonNull Context context) {
return new Intent(context, ManageProfileActivity.class);
@ -36,6 +37,12 @@ public class ManageProfileActivity extends PassphraseRequiredActivity implements
return intent;
}
public static @NonNull Intent getIntentForAvatarEdit(@NonNull Context context) {
Intent intent = new Intent(context, ManageProfileActivity.class);
intent.putExtra(START_AT_AVATAR, true);
return intent;
}
@Override
public void onCreate(Bundle bundle, boolean ready) {
dynamicTheme.onCreate(this);
@ -52,6 +59,11 @@ public class ManageProfileActivity extends PassphraseRequiredActivity implements
NavDirections action = ManageProfileFragmentDirections.actionManageUsername();
Navigation.findNavController(this, R.id.nav_host_fragment).navigate(action);
}
if (extras != null && extras.getBoolean(START_AT_AVATAR, false)) {
NavDirections action = ManageProfileFragmentDirections.actionManageProfileFragmentToAvatarPicker(null, null);
Navigation.findNavController(this, R.id.nav_host_fragment).navigate(action);
}
}
}

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -3533,6 +3533,12 @@
<string name="ChatColorsMegaphone__appearance">Appearance</string>
<string name="ChatColorsMegaphone__not_now">Not now</string>
<!-- AddAProfilePhotoMegaphone -->
<string name="AddAProfilePhotoMegaphone__add_a_profile_photo">Add a profile photo</string>
<string name="AddAProfilePhotoMegaphone__choose_a_look_and_color">Choose a look and color or customize your initials.</string>
<string name="AddAProfilePhotoMegaphone__not_now">Not now</string>
<string name="AddAProfilePhotoMegaphone__add_photo">Add photo</string>
<!-- KeyboardPagerFragment -->
<string name="KeyboardPagerFragment_emoji">Emoji</string>
<string name="KeyboardPagerFragment_open_emoji_search">Open emoji search</string>