mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 13:58:40 +00:00
Update typing indicator intro screen.
This commit is contained in:
@@ -12,6 +12,7 @@ import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.View;
|
||||
|
||||
import com.melnykov.fab.FloatingActionButton;
|
||||
import com.nineoldandroids.animation.ArgbEvaluator;
|
||||
@@ -28,7 +29,7 @@ import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
public class ExperienceUpgradeActivity extends BaseActionBarActivity implements TypingIndicatorIntroFragment.Controller {
|
||||
private static final String TAG = ExperienceUpgradeActivity.class.getSimpleName();
|
||||
private static final String DISMISS_ACTION = "org.thoughtcrime.securesms.ExperienceUpgradeActivity.DISMISS_ACTION";
|
||||
private static final int NOTIFICATION_ID = 1339;
|
||||
@@ -42,7 +43,8 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
R.string.ExperienceUpgradeActivity_welcome_to_signal_excited,
|
||||
R.string.ExperienceUpgradeActivity_textsecure_is_now_signal,
|
||||
R.string.ExperienceUpgradeActivity_textsecure_is_now_signal_long,
|
||||
null),
|
||||
null,
|
||||
false),
|
||||
VIDEO_CALLS(245,
|
||||
new IntroPage(0xFF2090EA,
|
||||
BasicIntroFragment.newInstance(R.drawable.video_splash,
|
||||
@@ -51,7 +53,8 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
R.string.ExperienceUpgradeActivity_say_hello_to_video_calls,
|
||||
R.string.ExperienceUpgradeActivity_signal_now_supports_secure_video_calling,
|
||||
R.string.ExperienceUpgradeActivity_signal_now_supports_secure_video_calling_long,
|
||||
null),
|
||||
null,
|
||||
false),
|
||||
PROFILES(286,
|
||||
new IntroPage(0xFF2090EA,
|
||||
BasicIntroFragment.newInstance(R.drawable.profile_splash,
|
||||
@@ -60,21 +63,24 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
R.string.ExperienceUpgradeActivity_signal_profiles_are_here,
|
||||
R.string.ExperienceUpgradeActivity_now_you_can_share_a_profile_photo_and_name_with_friends_on_signal,
|
||||
R.string.ExperienceUpgradeActivity_now_you_can_share_a_profile_photo_and_name_with_friends_on_signal,
|
||||
CreateProfileActivity.class),
|
||||
CreateProfileActivity.class,
|
||||
false),
|
||||
READ_RECEIPTS(299,
|
||||
new IntroPage(0xFF2090EA,
|
||||
ReadReceiptsIntroFragment.newInstance()),
|
||||
R.string.experience_upgrade_preference_fragment__read_receipts_are_here,
|
||||
R.string.experience_upgrade_preference_fragment__optionally_see_and_share_when_messages_have_been_read,
|
||||
R.string.experience_upgrade_preference_fragment__optionally_see_and_share_when_messages_have_been_read,
|
||||
null),
|
||||
TYPING_INDICATORS(430,
|
||||
null,
|
||||
false),
|
||||
TYPING_INDICATORS(435,
|
||||
new IntroPage(0xFF2090EA,
|
||||
TypingIndicatorIntroFragment.newInstance()),
|
||||
R.string.ExperienceUpgradeActivity_introducing_typing_indicators,
|
||||
R.string.ExperienceUpgradeActivity_now_you_can_optionally_see_and_share_when_messages_are_being_typed,
|
||||
R.string.ExperienceUpgradeActivity_now_you_can_optionally_see_and_share_when_messages_are_being_typed,
|
||||
null);
|
||||
null,
|
||||
true);
|
||||
|
||||
private int version;
|
||||
private List<IntroPage> pages;
|
||||
@@ -82,13 +88,15 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
private @StringRes int notificationText;
|
||||
private @StringRes int notificationBigText;
|
||||
private @Nullable Class nextIntent;
|
||||
private boolean handlesNavigation;
|
||||
|
||||
ExperienceUpgrade(int version,
|
||||
@NonNull List<IntroPage> pages,
|
||||
@StringRes int notificationTitle,
|
||||
@StringRes int notificationText,
|
||||
@StringRes int notificationBigText,
|
||||
@Nullable Class nextIntent)
|
||||
@Nullable Class nextIntent,
|
||||
boolean handlesNavigation)
|
||||
{
|
||||
this.version = version;
|
||||
this.pages = pages;
|
||||
@@ -96,6 +104,7 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
this.notificationText = notificationText;
|
||||
this.notificationBigText = notificationBigText;
|
||||
this.nextIntent = nextIntent;
|
||||
this.handlesNavigation = handlesNavigation;
|
||||
}
|
||||
|
||||
ExperienceUpgrade(int version,
|
||||
@@ -103,9 +112,10 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
@StringRes int notificationTitle,
|
||||
@StringRes int notificationText,
|
||||
@StringRes int notificationBigText,
|
||||
@Nullable Class nextIntent)
|
||||
@Nullable Class nextIntent,
|
||||
boolean handlesNavigation)
|
||||
{
|
||||
this(version, Collections.singletonList(page), notificationTitle, notificationText, notificationBigText, nextIntent);
|
||||
this(version, Collections.singletonList(page), notificationTitle, notificationText, notificationBigText, nextIntent, handlesNavigation);
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
@@ -131,6 +141,10 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
public int getNotificationBigText() {
|
||||
return notificationBigText;
|
||||
}
|
||||
|
||||
public boolean handlesNavigation() {
|
||||
return handlesNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,7 +164,12 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
|
||||
pager.setAdapter(new IntroPagerAdapter(getSupportFragmentManager(), upgrade.get().getPages()));
|
||||
|
||||
fab.setOnClickListener(v -> onContinue(upgrade));
|
||||
if (upgrade.get().handlesNavigation()) {
|
||||
fab.setVisibility(View.GONE);
|
||||
} else {
|
||||
fab.setVisibility(View.VISIBLE);
|
||||
fab.setOnClickListener(v -> onContinue(upgrade));
|
||||
}
|
||||
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(upgrade.get().getPage(0).backgroundColor));
|
||||
ServiceUtil.getNotificationManager(this).cancel(NOTIFICATION_ID);
|
||||
@@ -195,6 +214,11 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
|
||||
return eligibleUpgrade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
onContinue(Optional.of(ExperienceUpgrade.TYPING_INDICATORS));
|
||||
}
|
||||
|
||||
private final class OnPageChangeListener implements ViewPager.OnPageChangeListener {
|
||||
private final ArgbEvaluator evaluator = new ArgbEvaluator();
|
||||
private final ExperienceUpgrade upgrade;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
@@ -15,6 +16,8 @@ import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
public class TypingIndicatorIntroFragment extends Fragment {
|
||||
|
||||
private Controller controller;
|
||||
|
||||
public static TypingIndicatorIntroFragment newInstance() {
|
||||
TypingIndicatorIntroFragment fragment = new TypingIndicatorIntroFragment();
|
||||
Bundle args = new Bundle();
|
||||
@@ -29,24 +32,45 @@ public class TypingIndicatorIntroFragment extends Fragment {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
if (!(getActivity() instanceof Controller)) {
|
||||
throw new IllegalStateException("Parent activity must implement the Controller interface.");
|
||||
}
|
||||
|
||||
controller = (Controller) getActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.experience_upgrade_typing_indicators_fragment, container, false);
|
||||
SwitchCompat preference = ViewUtil.findById(v, R.id.preference);
|
||||
View view = inflater.inflate(R.layout.experience_upgrade_typing_indicators_fragment, container, false);
|
||||
View yesButton = view.findViewById(R.id.experience_yes_button);
|
||||
View noButton = view.findViewById(R.id.experience_no_button);
|
||||
|
||||
((TypingIndicatorView) v.findViewById(R.id.typing_indicator)).startAnimation();
|
||||
((TypingIndicatorView) view.findViewById(R.id.typing_indicator)).startAnimation();
|
||||
|
||||
preference.setChecked(TextSecurePreferences.isTypingIndicatorsEnabled(getContext()));
|
||||
preference.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
TextSecurePreferences.setTypingIndicatorsEnabled(getContext(), isChecked);
|
||||
ApplicationContext.getInstance(requireContext())
|
||||
.getJobManager()
|
||||
.add(new MultiDeviceConfigurationUpdateJob(getContext(),
|
||||
TextSecurePreferences.isReadReceiptsEnabled(requireContext()),
|
||||
isChecked,
|
||||
TextSecurePreferences.isShowUnidentifiedDeliveryIndicatorsEnabled(getContext())));
|
||||
});
|
||||
|
||||
return v;
|
||||
yesButton.setOnClickListener(v -> onButtonClicked(true));
|
||||
noButton.setOnClickListener(v -> onButtonClicked(false));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void onButtonClicked(boolean typingEnabled) {
|
||||
TextSecurePreferences.setTypingIndicatorsEnabled(getContext(), typingEnabled);
|
||||
ApplicationContext.getInstance(requireContext())
|
||||
.getJobManager()
|
||||
.add(new MultiDeviceConfigurationUpdateJob(getContext(),
|
||||
TextSecurePreferences.isReadReceiptsEnabled(requireContext()),
|
||||
typingEnabled,
|
||||
TextSecurePreferences.isShowUnidentifiedDeliveryIndicatorsEnabled(getContext())));
|
||||
|
||||
controller.onFinished();
|
||||
}
|
||||
|
||||
public interface Controller {
|
||||
void onFinished();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user