Add splash screen for setting profiles

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-09-03 19:44:33 -07:00
parent 3e3ae5f865
commit 2add02c62f
15 changed files with 114 additions and 37 deletions

View File

@ -572,6 +572,10 @@
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<data android:scheme="package" />
</intent-filter>
<intent-filter>
<action android:name="org.thoughtcrime.securesms.ExperienceUpgradeActivity.DISMISS_ACTION"/>
</intent-filter>
</receiver>
<receiver

View File

@ -263,6 +263,7 @@ android {
'proguard-webrtc.pro',
'proguard-klinker.pro',
'proguard-retrolambda.pro',
'proguard-okhttp.pro',
'proguard.cfg'
testProguardFiles 'proguard-automation.pro',
'proguard.cfg'

3
proguard-okhttp.pro Normal file
View File

@ -0,0 +1,3 @@
-dontwarn okio.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:background="#FF2090ea">
tools:background="#FF2090ea">
<TextView android:layout_width="match_parent"
android:layout_height="0dp"
@ -16,21 +16,18 @@
android:gravity="center_horizontal|bottom"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_marginTop="30dp"
android:fontFamily="sans-serif-light"
tools:text="@string/ExperienceUpgradeActivity_welcome_to_signal_dgaf"
tools:text="@string/ExperienceUpgradeActivity_ready_for_your_closeup"
android:textColor="@android:color/white" />
<ImageView android:id="@+id/watermark"
android:layout_width="@dimen/onboarding_watermark_size"
android:layout_height="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxHeight="@dimen/onboarding_watermark_size"
android:scaleType="fitCenter"
tools:src="@drawable/splash_logo"
android:layout_gravity="center_horizontal"
android:layout_below="@id/blurb"
android:layout_marginBottom="20dp"
android:layout_marginTop="@dimen/onboarding_margin_vert" />
tools:src="@drawable/profile_splash"
android:layout_gravity="center_horizontal"/>
<TextView android:layout_width="match_parent"
android:layout_height="0dp"
@ -39,11 +36,10 @@
android:textSize="@dimen/onboarding_subtitle_size"
android:textIsSelectable="false"
android:gravity="center_horizontal"
android:layout_marginTop="20dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:fontFamily="sans-serif-light"
tools:text="@string/ExperienceUpgradeActivity_textsecure_is_now_called_signal"
tools:text="@string/ExperienceUpgradeActivity_now_you_can_share_a_profile_photo_and_name_with_friends_on_signal"
android:textColor="@android:color/white" />
</LinearLayout>

View File

@ -61,7 +61,7 @@
android:layout_marginLeft="3dp"
android:layout_gravity="center_vertical"
android:textColor="#73B7F0"
android:text="Who can see this information?"/>
android:text="@string/profile_create_activity__who_can_see_this_information"/>
</LinearLayout>
@ -73,7 +73,7 @@
android:clipToPadding="false">
<Button android:id="@+id/finish_button"
android:text="FINISH"
android:text="@string/profile_create_activity__finish"
android:textAllCaps="true"
android:background="@color/signal_primary"
android:textColor="@color/white"
@ -82,6 +82,15 @@
android:layout_marginBottom="20dp"
android:layout_gravity="center_horizontal"/>
<TextView android:id="@+id/skip_button"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="20dp"
android:textColor="@color/gray50"
android:text="@string/profile_create_activity__set_later"/>
<org.thoughtcrime.securesms.components.emoji.EmojiDrawer
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/emoji_drawer"

View File

@ -287,6 +287,10 @@
<string name="ExperienceUpgradeActivity_signal_now_supports_secure_video_calling">Signal now supports secure video calling.</string>
<string name="ExperienceUpgradeActivity_signal_now_supports_secure_video_calling_long">Signal now supports secure video calling. Tap to explore.</string>
<string name="ExperienceUpgradeActivity_ready_for_your_closeup">Ready for your closeup?</string>
<string name="ExperienceUpgradeActivity_now_you_can_share_a_profile_photo_and_name_with_friends_on_signal">Now you can share a profile photo and name with friends on Signal</string>
<string name="ExperienceUpgradeActivity_signal_profiles_are_here">Signal profiles are here</string>
<!-- ExportFragment -->
<string name="ExportFragment_export">Export</string>
<string name="ExportFragment_export_plaintext_to_storage">Export plaintext to storage?</string>
@ -975,6 +979,11 @@
<string name="prompt_mms_activity__signal_requires_mms_settings_to_deliver_media_and_group_messages">Signal requires MMS settings to deliver media and group messages through your wireless carrier. Your device does not make this information available, which is occasionally true for locked devices and other restrictive configurations.</string>
<string name="prompt_mms_activity__to_send_media_and_group_messages_tap_ok">To send media and group messages, tap \'OK\' and complete the requested settings. The MMS settings for your carrier can generally be located by searching for \'your carrier APN\'. You will only need to do this once.</string>
<!-- profile_create_activity -->
<string name="profile_create_activity__set_later">Set later</string>
<string name="profile_create_activity__finish">FINISH</string>
<string name="profile_create_activity__who_can_see_this_information">Who can see this information?</string>
<!-- recipient_preferences_activity -->
<string name="recipient_preference_activity__blocked">BLOCKED</string>
@ -1447,7 +1456,6 @@
<string name="transport_selection_list_item__transport_icon">Transport icon</string>
<!-- EOF -->
</resources>

View File

@ -22,6 +22,7 @@ import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
@ -80,6 +81,7 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
private InputAwareLayout container;
private ImageView avatar;
private Button finishButton;
private TextView skipButton;
private EditText name;
private EmojiToggle emojiToggle;
private EmojiDrawer emojiDrawer;
@ -165,6 +167,7 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
this.emojiDrawer = ViewUtil.findById(this, R.id.emoji_drawer);
this.container = ViewUtil.findById(this, R.id.container);
this.finishButton = ViewUtil.findById(this, R.id.finish_button);
this.skipButton = ViewUtil.findById(this, R.id.skip_button);
this.nextIntent = getIntent().getParcelableExtra(NEXT_INTENT);
this.avatar.setImageDrawable(ContactPhotoFactory.getResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp)
@ -202,6 +205,11 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
this.finishButton.setOnClickListener(view -> {
handleUpload();
});
this.skipButton.setOnClickListener(view -> {
if (nextIntent != null) startActivity(nextIntent);
finish();
});
}
private void initializeProfileName(boolean excludeSystem) {

View File

@ -8,6 +8,7 @@ import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.app.NotificationCompat;
import android.support.v4.view.ViewPager;
@ -30,6 +31,7 @@ import java.util.List;
public class ExperienceUpgradeActivity extends BaseActionBarActivity {
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;
private enum ExperienceUpgrade {
@ -40,7 +42,8 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
R.string.ExperienceUpgradeActivity_textsecure_is_now_called_signal)),
R.string.ExperienceUpgradeActivity_welcome_to_signal_excited,
R.string.ExperienceUpgradeActivity_textsecure_is_now_signal,
R.string.ExperienceUpgradeActivity_textsecure_is_now_signal_long),
R.string.ExperienceUpgradeActivity_textsecure_is_now_signal_long,
null),
VIDEO_CALLS(245,
new IntroPage(0xFF2090EA,
BasicIntroFragment.newInstance(R.drawable.video_splash,
@ -48,34 +51,48 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
R.string.ExperienceUpgradeActivity_signal_now_supports_secure_video_calls)),
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);
R.string.ExperienceUpgradeActivity_signal_now_supports_secure_video_calling_long,
null),
PROFILES(286,
new IntroPage(0xFF2090EA,
BasicIntroFragment.newInstance(R.drawable.profile_splash,
R.string.ExperienceUpgradeActivity_ready_for_your_closeup,
R.string.ExperienceUpgradeActivity_now_you_can_share_a_profile_photo_and_name_with_friends_on_signal)),
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);
private int version;
private List<IntroPage> pages;
private @StringRes int notificationTitle;
private @StringRes int notificationText;
private @StringRes int notificationBigText;
private @Nullable Class nextIntent;
ExperienceUpgrade(int version,
@NonNull List<IntroPage> pages,
@StringRes int notificationTitle,
@StringRes int notificationText,
@StringRes int notificationBigText)
@StringRes int notificationBigText,
@Nullable Class nextIntent)
{
this.version = version;
this.pages = pages;
this.notificationTitle = notificationTitle;
this.notificationText = notificationText;
this.version = version;
this.pages = pages;
this.notificationTitle = notificationTitle;
this.notificationText = notificationText;
this.notificationBigText = notificationBigText;
this.nextIntent = nextIntent;
}
ExperienceUpgrade(int version,
@NonNull IntroPage page,
@StringRes int notificationTitle,
@StringRes int notificationText,
@StringRes int notificationBigText)
@StringRes int notificationBigText,
@Nullable Class nextIntent)
{
this(version, Collections.singletonList(page), notificationTitle, notificationText, notificationBigText);
this(version, Collections.singletonList(page), notificationTitle, notificationText, notificationBigText, nextIntent);
}
public int getVersion() {
@ -136,7 +153,15 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
int latestVersion = seenUpgrade.isPresent() ? seenUpgrade.get().getVersion()
: Util.getCurrentApkReleaseVersion(this);
TextSecurePreferences.setLastExperienceVersionCode(this, latestVersion);
startActivity((Intent)getIntent().getParcelableExtra("next_intent"));
if (seenUpgrade.isPresent() && seenUpgrade.get().nextIntent != null) {
Intent intent = new Intent(this, seenUpgrade.get().nextIntent);
Intent nextIntent = new Intent(this, ConversationListActivity.class);
intent.putExtra("next_intent", nextIntent);
startActivity(intent);
} else {
startActivity((Intent) getIntent().getParcelableExtra("next_intent"));
}
finish();
}
@ -190,13 +215,23 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
public static class AppUpgradeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if(Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction()) &&
intent.getData().getSchemeSpecificPart().equals(context.getPackageName()))
if (Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction()) &&
intent.getData().getSchemeSpecificPart().equals(context.getPackageName()))
{
Optional<ExperienceUpgrade> experienceUpgrade = getExperienceUpgrade(context);
if (!experienceUpgrade.isPresent()) return;
Intent targetIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
if (!experienceUpgrade.isPresent()) {
return;
}
if (experienceUpgrade.get().getVersion() == TextSecurePreferences.getExperienceDismissedVersionCode(context)) {
return;
}
Intent targetIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
Intent dismissIntent = new Intent(context, AppUpgradeReceiver.class);
dismissIntent.setAction(DISMISS_ACTION);
Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon_notification)
.setColor(context.getResources().getColor(R.color.signal_primary))
@ -207,8 +242,14 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
.setContentIntent(PendingIntent.getActivity(context, 0,
targetIntent,
PendingIntent.FLAG_UPDATE_CURRENT))
.setDeleteIntent(PendingIntent.getBroadcast(context, 0,
dismissIntent,
PendingIntent.FLAG_UPDATE_CURRENT))
.build();
ServiceUtil.getNotificationManager(context).notify(NOTIFICATION_ID, notification);
} else if (DISMISS_ACTION.equals(intent.getAction())) {
TextSecurePreferences.setExperienceDismissedVersionCode(context, Util.getCurrentApkReleaseVersion(context));
}
}
}

View File

@ -2,18 +2,16 @@ package org.thoughtcrime.securesms.jobs;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.util.Base64;
import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule.SignalMessageSenderFactory;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.jobqueue.JobParameters;
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
@ -35,7 +33,7 @@ public class MultiDeviceProfileKeyUpdateJob extends MasterSecretJob implements I
private static final long serialVersionUID = 1L;
private static final String TAG = MultiDeviceProfileKeyUpdateJob.class.getSimpleName();
@Inject SignalServiceMessageSender messageSender;
@Inject SignalMessageSenderFactory messageSender;
public MultiDeviceProfileKeyUpdateJob(Context context) {
super(context, JobParameters.newBuilder()
@ -73,7 +71,7 @@ public class MultiDeviceProfileKeyUpdateJob extends MasterSecretJob implements I
SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, false));
messageSender.sendMessage(syncMessage);
messageSender.create().sendMessage(syncMessage);
}
@Override

View File

@ -48,6 +48,7 @@ public class TextSecurePreferences {
private static final String LAST_VERSION_CODE_PREF = "last_version_code";
private static final String LAST_EXPERIENCE_VERSION_PREF = "last_experience_version_code";
private static final String EXPERIENCE_DISMISSED_PREF = "experience_dismissed";
public static final String RINGTONE_PREF = "pref_key_ringtone";
private static final String VIBRATE_PREF = "pref_key_vibrate";
private static final String NOTIFICATION_PREF = "pref_key_enable_notifications";
@ -488,6 +489,14 @@ public class TextSecurePreferences {
setIntegerPrefrence(context, LAST_EXPERIENCE_VERSION_PREF, versionCode);
}
public static int getExperienceDismissedVersionCode(Context context) {
return getIntegerPreference(context, EXPERIENCE_DISMISSED_PREF, 0);
}
public static void setExperienceDismissedVersionCode(Context context, int versionCode) {
setIntegerPrefrence(context, EXPERIENCE_DISMISSED_PREF, versionCode);
}
public static String getTheme(Context context) {
return getStringPreference(context, THEME_PREF, "light");
}