Add megaphone for new avatar picker.
This commit is contained in:
parent
963c018e0c
commit
a75f634c0a
5 changed files with 109 additions and 1 deletions
|
@ -57,6 +57,7 @@ public class MegaphoneRepository {
|
||||||
database.markFinished(Event.RESEARCH);
|
database.markFinished(Event.RESEARCH);
|
||||||
database.markFinished(Event.GROUP_CALLING);
|
database.markFinished(Event.GROUP_CALLING);
|
||||||
database.markFinished(Event.CHAT_COLORS);
|
database.markFinished(Event.CHAT_COLORS);
|
||||||
|
database.markFinished(Event.ADD_A_PROFILE_PHOTO);
|
||||||
resetDatabaseCache();
|
resetDatabaseCache();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,9 @@ import org.thoughtcrime.securesms.lock.v2.CreateKbsPinActivity;
|
||||||
import org.thoughtcrime.securesms.lock.v2.KbsMigrationActivity;
|
import org.thoughtcrime.securesms.lock.v2.KbsMigrationActivity;
|
||||||
import org.thoughtcrime.securesms.messagerequests.MessageRequestMegaphoneActivity;
|
import org.thoughtcrime.securesms.messagerequests.MessageRequestMegaphoneActivity;
|
||||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||||
|
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||||
|
import org.thoughtcrime.securesms.profiles.manage.ManageProfileActivity;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
|
@ -105,6 +107,7 @@ public final class Megaphones {
|
||||||
put(Event.ONBOARDING, shouldShowOnboardingMegaphone(context) ? ALWAYS : NEVER);
|
put(Event.ONBOARDING, shouldShowOnboardingMegaphone(context) ? ALWAYS : NEVER);
|
||||||
put(Event.NOTIFICATIONS, shouldShowNotificationsMegaphone(context) ? RecurringSchedule.every(TimeUnit.DAYS.toMillis(30)) : NEVER);
|
put(Event.NOTIFICATIONS, shouldShowNotificationsMegaphone(context) ? RecurringSchedule.every(TimeUnit.DAYS.toMillis(30)) : NEVER);
|
||||||
put(Event.CHAT_COLORS, ALWAYS);
|
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);
|
return buildNotificationsMegaphone(context);
|
||||||
case CHAT_COLORS:
|
case CHAT_COLORS:
|
||||||
return buildChatColorsMegaphone(context);
|
return buildChatColorsMegaphone(context);
|
||||||
|
case ADD_A_PROFILE_PHOTO:
|
||||||
|
return buildAddAProfilePhotoMegaphone(context);
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Event not handled!");
|
throw new IllegalArgumentException("Event not handled!");
|
||||||
}
|
}
|
||||||
|
@ -320,6 +325,21 @@ public final class Megaphones {
|
||||||
.build();
|
.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() {
|
private static boolean shouldShowMessageRequestsMegaphone() {
|
||||||
return Recipient.self().getProfileName() == ProfileName.EMPTY;
|
return Recipient.self().getProfileName() == ProfileName.EMPTY;
|
||||||
}
|
}
|
||||||
|
@ -363,6 +383,10 @@ public final class Megaphones {
|
||||||
return shouldShow;
|
return shouldShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean shouldShowAddAProfileMegaphone(@NonNull Context context) {
|
||||||
|
return !AvatarHelper.hasAvatar(context, Recipient.self().getId());
|
||||||
|
}
|
||||||
|
|
||||||
public enum Event {
|
public enum Event {
|
||||||
REACTIONS("reactions"),
|
REACTIONS("reactions"),
|
||||||
PINS_FOR_ALL("pins_for_all"),
|
PINS_FOR_ALL("pins_for_all"),
|
||||||
|
@ -375,7 +399,8 @@ public final class Megaphones {
|
||||||
GROUP_CALLING("group_calling"),
|
GROUP_CALLING("group_calling"),
|
||||||
ONBOARDING("onboarding"),
|
ONBOARDING("onboarding"),
|
||||||
NOTIFICATIONS("notifications"),
|
NOTIFICATIONS("notifications"),
|
||||||
CHAT_COLORS("chat_colors");
|
CHAT_COLORS("chat_colors"),
|
||||||
|
ADD_A_PROFILE_PHOTO("add_a_profile_photo");
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class ManageProfileActivity extends PassphraseRequiredActivity implements
|
||||||
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
|
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
|
||||||
|
|
||||||
public static final String START_AT_USERNAME = "start_at_username";
|
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) {
|
public static @NonNull Intent getIntent(@NonNull Context context) {
|
||||||
return new Intent(context, ManageProfileActivity.class);
|
return new Intent(context, ManageProfileActivity.class);
|
||||||
|
@ -36,6 +37,12 @@ public class ManageProfileActivity extends PassphraseRequiredActivity implements
|
||||||
return intent;
|
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
|
@Override
|
||||||
public void onCreate(Bundle bundle, boolean ready) {
|
public void onCreate(Bundle bundle, boolean ready) {
|
||||||
dynamicTheme.onCreate(this);
|
dynamicTheme.onCreate(this);
|
||||||
|
@ -52,6 +59,11 @@ public class ManageProfileActivity extends PassphraseRequiredActivity implements
|
||||||
NavDirections action = ManageProfileFragmentDirections.actionManageUsername();
|
NavDirections action = ManageProfileFragmentDirections.actionManageUsername();
|
||||||
Navigation.findNavController(this, R.id.nav_host_fragment).navigate(action);
|
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
|
@ -3533,6 +3533,12 @@
|
||||||
<string name="ChatColorsMegaphone__appearance">Appearance</string>
|
<string name="ChatColorsMegaphone__appearance">Appearance</string>
|
||||||
<string name="ChatColorsMegaphone__not_now">Not now</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 -->
|
<!-- KeyboardPagerFragment -->
|
||||||
<string name="KeyboardPagerFragment_emoji">Emoji</string>
|
<string name="KeyboardPagerFragment_emoji">Emoji</string>
|
||||||
<string name="KeyboardPagerFragment_open_emoji_search">Open emoji search</string>
|
<string name="KeyboardPagerFragment_open_emoji_search">Open emoji search</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue