Delete old megaphones.

This commit is contained in:
Greyson Parrelli
2022-01-06 16:32:04 -05:00
committed by Alex Hart
parent 3922bfacf5
commit 62f5088553
20 changed files with 0 additions and 618 deletions

View File

@@ -6,7 +6,6 @@ import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.jobs.MultiDeviceConfigurationUpdateJob
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.megaphone.Megaphones
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.storage.StorageSyncHelper
import org.thoughtcrime.securesms.util.TextSecurePreferences
@@ -29,9 +28,6 @@ class ChatsSettingsRepository {
isLinkPreviewsEnabled
)
)
if (isLinkPreviewsEnabled) {
ApplicationDependencies.getMegaphoneRepository().markFinished(Megaphones.Event.LINK_PREVIEWS)
}
}
}
}

View File

@@ -1,48 +0,0 @@
package org.thoughtcrime.securesms.linkpreview;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.megaphone.Megaphone;
import org.thoughtcrime.securesms.megaphone.MegaphoneActionController;
public class LinkPreviewsMegaphoneView extends FrameLayout {
private View yesButton;
private View noButton;
public LinkPreviewsMegaphoneView(Context context) {
super(context);
initialize(context);
}
public LinkPreviewsMegaphoneView(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context);
}
private void initialize(@NonNull Context context) {
inflate(context, R.layout.link_previews_megaphone, this);
this.yesButton = findViewById(R.id.linkpreview_megaphone_ok);
this.noButton = findViewById(R.id.linkpreview_megaphone_disable);
}
public void present(@NonNull Megaphone megaphone, @NonNull MegaphoneActionController listener) {
this.yesButton.setOnClickListener(v -> {
SignalStore.settings().setLinkPreviewsEnabled(true);
listener.onMegaphoneCompleted(megaphone.getEvent());
});
this.noButton.setOnClickListener(v -> {
SignalStore.settings().setLinkPreviewsEnabled(false);
listener.onMegaphoneCompleted(megaphone.getEvent());
});
}
}

View File

@@ -215,12 +215,6 @@ public class Megaphone {
}
enum Style {
/** Specialized style for announcing reactions. */
REACTIONS,
/** Specialized style for announcing link previews. */
LINK_PREVIEWS,
/** Specialized style for onboarding. */
ONBOARDING,

View File

@@ -50,11 +50,6 @@ public class MegaphoneRepository {
@AnyThread
public void onFirstEverAppLaunch() {
executor.execute(() -> {
database.markFinished(Event.REACTIONS);
database.markFinished(Event.MESSAGE_REQUESTS);
database.markFinished(Event.LINK_PREVIEWS);
database.markFinished(Event.RESEARCH);
database.markFinished(Event.GROUP_CALLING);
database.markFinished(Event.CHAT_COLORS);
database.markFinished(Event.ADD_A_PROFILE_PHOTO);
database.markFinished(Event.NOTIFICATION_PROFILES);

View File

@@ -6,9 +6,6 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.linkpreview.LinkPreviewsMegaphoneView;
import org.thoughtcrime.securesms.reactions.ReactionsMegaphoneView;
public class MegaphoneViewBuilder {
public static @Nullable View build(@NonNull Context context,
@@ -20,10 +17,6 @@ public class MegaphoneViewBuilder {
return buildBasicMegaphone(context, megaphone, listener);
case FULLSCREEN:
return null;
case REACTIONS:
return buildReactionsMegaphone(context, megaphone, listener);
case LINK_PREVIEWS:
return buildLinkPreviewsMegaphone(context, megaphone, listener);
case ONBOARDING:
return buildOnboardingMegaphone(context, megaphone, listener);
case POPUP:
@@ -42,24 +35,6 @@ public class MegaphoneViewBuilder {
return view;
}
private static @NonNull View buildReactionsMegaphone(@NonNull Context context,
@NonNull Megaphone megaphone,
@NonNull MegaphoneActionController listener)
{
ReactionsMegaphoneView view = new ReactionsMegaphoneView(context);
view.present(megaphone, listener);
return view;
}
private static @NonNull View buildLinkPreviewsMegaphone(@NonNull Context context,
@NonNull Megaphone megaphone,
@NonNull MegaphoneActionController listener)
{
LinkPreviewsMegaphoneView view = new LinkPreviewsMegaphoneView(context);
view.present(megaphone, listener);
return view;
}
private static @NonNull View buildOnboardingMegaphone(@NonNull Context context,
@NonNull Megaphone megaphone,
@NonNull MegaphoneActionController listener)

View File

@@ -96,14 +96,9 @@ public final class Megaphones {
*/
private static Map<Event, MegaphoneSchedule> buildDisplayOrder(@NonNull Context context) {
return new LinkedHashMap<Event, MegaphoneSchedule>() {{
put(Event.REACTIONS, ALWAYS);
put(Event.PINS_FOR_ALL, new PinsForAllSchedule());
put(Event.PIN_REMINDER, new SignalPinReminderSchedule());
put(Event.MESSAGE_REQUESTS, shouldShowMessageRequestsMegaphone() ? ALWAYS : NEVER);
put(Event.LINK_PREVIEWS, shouldShowLinkPreviewsMegaphone(context) ? ALWAYS : NEVER);
put(Event.CLIENT_DEPRECATED, SignalStore.misc().isClientDeprecated() ? ALWAYS : NEVER);
put(Event.RESEARCH, shouldShowResearchMegaphone(context) ? ShowForDurationSchedule.showForDays(7) : NEVER);
put(Event.GROUP_CALLING, shouldShowGroupCallingMegaphone() ? ALWAYS : NEVER);
put(Event.ONBOARDING, shouldShowOnboardingMegaphone(context) ? ALWAYS : NEVER);
put(Event.NOTIFICATIONS, shouldShowNotificationsMegaphone(context) ? RecurringSchedule.every(TimeUnit.DAYS.toMillis(30)) : NEVER);
put(Event.CHAT_COLORS, ALWAYS);
@@ -115,22 +110,12 @@ public final class Megaphones {
private static @NonNull Megaphone forRecord(@NonNull Context context, @NonNull MegaphoneRecord record) {
switch (record.getEvent()) {
case REACTIONS:
return buildReactionsMegaphone();
case PINS_FOR_ALL:
return buildPinsForAllMegaphone(record);
case PIN_REMINDER:
return buildPinReminderMegaphone(context);
case MESSAGE_REQUESTS:
return buildMessageRequestsMegaphone(context);
case LINK_PREVIEWS:
return buildLinkPreviewsMegaphone();
case CLIENT_DEPRECATED:
return buildClientDeprecatedMegaphone(context);
case RESEARCH:
return buildResearchMegaphone(context);
case GROUP_CALLING:
return buildGroupCallingMegaphone(context);
case ONBOARDING:
return buildOnboardingMegaphone();
case NOTIFICATIONS:
@@ -148,12 +133,6 @@ public final class Megaphones {
}
}
private static @NonNull Megaphone buildReactionsMegaphone() {
return new Megaphone.Builder(Event.REACTIONS, Megaphone.Style.REACTIONS)
.setPriority(Megaphone.Priority.DEFAULT)
.build();
}
private static @NonNull Megaphone buildPinsForAllMegaphone(@NonNull MegaphoneRecord record) {
if (PinsForAllSchedule.shouldDisplayFullScreen(record.getFirstVisible(), System.currentTimeMillis())) {
return new Megaphone.Builder(Event.PINS_FOR_ALL, Megaphone.Style.FULLSCREEN)
@@ -213,24 +192,6 @@ public final class Megaphones {
.build();
}
@SuppressWarnings("CodeBlock2Expr")
private static @NonNull Megaphone buildMessageRequestsMegaphone(@NonNull Context context) {
return new Megaphone.Builder(Event.MESSAGE_REQUESTS, Megaphone.Style.FULLSCREEN)
.disableSnooze()
.setPriority(Megaphone.Priority.HIGH)
.setOnVisibleListener(((megaphone, listener) -> {
listener.onMegaphoneNavigationRequested(new Intent(context, MessageRequestMegaphoneActivity.class),
ConversationListFragment.MESSAGE_REQUESTS_REQUEST_CODE_CREATE_NAME);
}))
.build();
}
private static @NonNull Megaphone buildLinkPreviewsMegaphone() {
return new Megaphone.Builder(Event.LINK_PREVIEWS, Megaphone.Style.LINK_PREVIEWS)
.setPriority(Megaphone.Priority.HIGH)
.build();
}
private static @NonNull Megaphone buildClientDeprecatedMegaphone(@NonNull Context context) {
return new Megaphone.Builder(Event.CLIENT_DEPRECATED, Megaphone.Style.FULLSCREEN)
.disableSnooze()
@@ -239,34 +200,6 @@ public final class Megaphones {
.build();
}
private static @NonNull Megaphone buildResearchMegaphone(@NonNull Context context) {
return new Megaphone.Builder(Event.RESEARCH, Megaphone.Style.BASIC)
.disableSnooze()
.setTitle(R.string.ResearchMegaphone_tell_signal_what_you_think)
.setBody(R.string.ResearchMegaphone_to_make_signal_the_best_messaging_app_on_the_planet)
.setImage(R.drawable.ic_research_megaphone)
.setActionButton(R.string.ResearchMegaphone_learn_more, (megaphone, controller) -> {
controller.onMegaphoneCompleted(megaphone.getEvent());
controller.onMegaphoneDialogFragmentRequested(new ResearchMegaphoneDialog());
})
.setSecondaryButton(R.string.ResearchMegaphone_dismiss, (megaphone, controller) -> controller.onMegaphoneCompleted(megaphone.getEvent()))
.setPriority(Megaphone.Priority.DEFAULT)
.build();
}
private static @NonNull Megaphone buildGroupCallingMegaphone(@NonNull Context context) {
return new Megaphone.Builder(Event.GROUP_CALLING, Megaphone.Style.BASIC)
.disableSnooze()
.setTitle(R.string.GroupCallingMegaphone__introducing_group_calls)
.setBody(R.string.GroupCallingMegaphone__open_a_new_group_to_start)
.setImage(R.drawable.ic_group_calls_megaphone)
.setActionButton(android.R.string.ok, (megaphone, controller) -> {
controller.onMegaphoneCompleted(megaphone.getEvent());
})
.setPriority(Megaphone.Priority.DEFAULT)
.build();
}
private static @NonNull Megaphone buildOnboardingMegaphone() {
return new Megaphone.Builder(Event.ONBOARDING, Megaphone.Style.ONBOARDING)
.setPriority(Megaphone.Priority.DEFAULT)
@@ -359,14 +292,6 @@ public final class Megaphones {
.build();
}
private static boolean shouldShowMessageRequestsMegaphone() {
return Recipient.self().getProfileName() == ProfileName.EMPTY;
}
private static boolean shouldShowResearchMegaphone(@NonNull Context context) {
return VersionTracker.getDaysSinceFirstInstalled(context) > 7 && LocaleFeatureFlags.isInResearchMegaphone();
}
private static boolean shouldShowDonateMegaphone(@NonNull Context context) {
return VersionTracker.getDaysSinceFirstInstalled(context) >= 3 &&
LocaleFeatureFlags.isInDonateMegaphone() &&
@@ -378,14 +303,6 @@ public final class Megaphones {
.noneMatch(badge -> badge.getCategory() == Badge.Category.Donor);
}
private static boolean shouldShowLinkPreviewsMegaphone(@NonNull Context context) {
return TextSecurePreferences.wereLinkPreviewsEnabled(context) && !SignalStore.settings().isLinkPreviewsEnabled();
}
private static boolean shouldShowGroupCallingMegaphone() {
return Build.VERSION.SDK_INT > 19;
}
private static boolean shouldShowOnboardingMegaphone(@NonNull Context context) {
return SignalStore.onboarding().hasOnboarding(context);
}
@@ -424,14 +341,9 @@ public final class Megaphones {
}
public enum Event {
REACTIONS("reactions"),
PINS_FOR_ALL("pins_for_all"),
PIN_REMINDER("pin_reminder"),
MESSAGE_REQUESTS("message_requests"),
LINK_PREVIEWS("link_previews"),
CLIENT_DEPRECATED("client_deprecated"),
RESEARCH("research"),
GROUP_CALLING("group_calling"),
ONBOARDING("onboarding"),
NOTIFICATIONS("notifications"),
CHAT_COLORS("chat_colors"),

View File

@@ -1,41 +0,0 @@
package org.thoughtcrime.securesms.megaphone;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.FullScreenDialogFragment;
import org.thoughtcrime.securesms.util.CommunicationActions;
public class ResearchMegaphoneDialog extends FullScreenDialogFragment {
private static final String SURVEY_URL = "https://surveys.signalusers.org/s3";
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
TextView content = view.findViewById(R.id.research_megaphone_content);
content.setText(Html.fromHtml(requireContext().getString(R.string.ResearchMegaphoneDialog_we_believe_in_privacy)));
view.findViewById(R.id.research_megaphone_dialog_take_the_survey)
.setOnClickListener(v -> CommunicationActions.openBrowserLink(requireContext(), SURVEY_URL));
view.findViewById(R.id.research_megaphone_dialog_no_thanks)
.setOnClickListener(v -> dismissAllowingStateLoss());
}
@Override
protected @StringRes int getTitle() {
return R.string.ResearchMegaphoneDialog_signal_research;
}
@Override
protected int getDialogLayoutResource() {
return R.layout.research_megaphone_dialog;
}
}

View File

@@ -54,7 +54,6 @@ public class MessageRequestMegaphoneActivity extends PassphraseRequiredActivity
if (requestCode == EDIT_PROFILE_REQUEST_CODE &&
resultCode == RESULT_OK &&
Recipient.self().getProfileName() != ProfileName.EMPTY) {
ApplicationDependencies.getMegaphoneRepository().markFinished(Megaphones.Event.MESSAGE_REQUESTS);
setResult(RESULT_OK);
finish();
}

View File

@@ -1,37 +0,0 @@
package org.thoughtcrime.securesms.reactions;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.megaphone.Megaphone;
import org.thoughtcrime.securesms.megaphone.MegaphoneActionController;
public class ReactionsMegaphoneView extends FrameLayout {
private View closeButton;
public ReactionsMegaphoneView(Context context) {
super(context);
initialize(context);
}
public ReactionsMegaphoneView(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context);
}
private void initialize(@NonNull Context context) {
inflate(context, R.layout.reactions_megaphone, this);
this.closeButton = findViewById(R.id.reactions_megaphone_x);
}
public void present(@NonNull Megaphone megaphone, @NonNull MegaphoneActionController listener) {
this.closeButton.setOnClickListener(v -> listener.onMegaphoneCompleted(megaphone.getEvent()));
}
}

View File

@@ -30,13 +30,6 @@ public final class LocaleFeatureFlags {
private static final String COUNTRY_WILDCARD = "*";
private static final int NOT_FOUND = -1;
/**
* In research megaphone group for given country code
*/
public static boolean isInResearchMegaphone() {
return false;
}
/**
* In donate megaphone group for given country code
*/