mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
Fixed landing scenario is broken and missing essential keys/settings setup.
This commit is contained in:
parent
85bac9fc46
commit
124632823e
@ -278,11 +278,6 @@
|
||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/NoAnimation.Theme.AppCompat.Light.DarkActionBar" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.ExperienceUpgradeActivity"
|
||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.PassphraseCreateActivity"
|
||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
||||
|
@ -1,282 +0,0 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.View;
|
||||
|
||||
import com.melnykov.fab.FloatingActionButton;
|
||||
import com.nineoldandroids.animation.ArgbEvaluator;
|
||||
|
||||
import org.thoughtcrime.securesms.IntroPagerAdapter.IntroPage;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
public class ExperienceUpgradeActivity extends BaseActionBarActivity implements TypingIndicatorIntroFragment.Controller, LinkPreviewsIntroFragment.Controller {
|
||||
private static final String TAG = ExperienceUpgradeActivity.class.getSimpleName();
|
||||
private static final String DISMISS_ACTION = "network.loki.securesms.ExperienceUpgradeActivity.DISMISS_ACTION";
|
||||
private static final int NOTIFICATION_ID = 1339;
|
||||
|
||||
private enum ExperienceUpgrade {
|
||||
TYPING_INDICATORS(432,
|
||||
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,
|
||||
true),
|
||||
LINK_PREVIEWS(449,
|
||||
new IntroPage(0xFF2090EA, LinkPreviewsIntroFragment.newInstance()),
|
||||
R.string.ExperienceUpgradeActivity_introducing_link_previews,
|
||||
R.string.ExperienceUpgradeActivity_optional_link_previews_are_now_supported,
|
||||
R.string.ExperienceUpgradeActivity_optional_link_previews_are_now_supported,
|
||||
null,
|
||||
true);
|
||||
|
||||
private int version;
|
||||
private List<IntroPage> pages;
|
||||
private @StringRes int notificationTitle;
|
||||
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,
|
||||
boolean handlesNavigation)
|
||||
{
|
||||
this.version = version;
|
||||
this.pages = pages;
|
||||
this.notificationTitle = notificationTitle;
|
||||
this.notificationText = notificationText;
|
||||
this.notificationBigText = notificationBigText;
|
||||
this.nextIntent = nextIntent;
|
||||
this.handlesNavigation = handlesNavigation;
|
||||
}
|
||||
|
||||
ExperienceUpgrade(int version,
|
||||
@NonNull IntroPage page,
|
||||
@StringRes int notificationTitle,
|
||||
@StringRes int notificationText,
|
||||
@StringRes int notificationBigText,
|
||||
@Nullable Class nextIntent,
|
||||
boolean handlesNavigation)
|
||||
{
|
||||
this(version, Collections.singletonList(page), notificationTitle, notificationText, notificationBigText, nextIntent, handlesNavigation);
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public List<IntroPage> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public IntroPage getPage(int i) {
|
||||
return pages.get(i);
|
||||
}
|
||||
|
||||
public int getNotificationTitle() {
|
||||
return notificationTitle;
|
||||
}
|
||||
|
||||
public int getNotificationText() {
|
||||
return notificationText;
|
||||
}
|
||||
|
||||
public int getNotificationBigText() {
|
||||
return notificationBigText;
|
||||
}
|
||||
|
||||
public boolean handlesNavigation() {
|
||||
return handlesNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final Optional<ExperienceUpgrade> upgrade = getExperienceUpgrade(this);
|
||||
if (!upgrade.isPresent()) {
|
||||
onContinue(upgrade);
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.experience_upgrade_activity);
|
||||
final ViewPager pager = ViewUtil.findById(this, R.id.pager);
|
||||
final FloatingActionButton fab = ViewUtil.findById(this, R.id.fab);
|
||||
|
||||
pager.setAdapter(new IntroPagerAdapter(getSupportFragmentManager(), upgrade.get().getPages()));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void onContinue(Optional<ExperienceUpgrade> seenUpgrade) {
|
||||
ServiceUtil.getNotificationManager(this).cancel(NOTIFICATION_ID);
|
||||
int latestVersion = seenUpgrade.isPresent() ? seenUpgrade.get().getVersion()
|
||||
: Util.getCanonicalVersionCode();
|
||||
TextSecurePreferences.setLastExperienceVersionCode(this, latestVersion);
|
||||
if (seenUpgrade.isPresent() && seenUpgrade.get().nextIntent != null) {
|
||||
Intent intent = new Intent(this, seenUpgrade.get().nextIntent);
|
||||
Intent nextIntent = new Intent(this, HomeActivity.class);
|
||||
intent.putExtra("next_intent", nextIntent);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
startActivity(getIntent().getParcelableExtra("next_intent"));
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
public static boolean isUpdate(Context context) {
|
||||
return getExperienceUpgrade(context).isPresent();
|
||||
}
|
||||
|
||||
public static Optional<ExperienceUpgrade> getExperienceUpgrade(Context context) {
|
||||
final int currentVersionCode = Util.getCanonicalVersionCode();
|
||||
final int lastSeenVersion = TextSecurePreferences.getLastExperienceVersionCode(context);
|
||||
Log.i(TAG, "getExperienceUpgrade(" + lastSeenVersion + ")");
|
||||
|
||||
if (lastSeenVersion >= currentVersionCode) {
|
||||
TextSecurePreferences.setLastExperienceVersionCode(context, currentVersionCode);
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
Optional<ExperienceUpgrade> eligibleUpgrade = Optional.absent();
|
||||
for (ExperienceUpgrade upgrade : ExperienceUpgrade.values()) {
|
||||
if (lastSeenVersion < upgrade.getVersion()) eligibleUpgrade = Optional.of(upgrade);
|
||||
}
|
||||
|
||||
return eligibleUpgrade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTypingIndicatorsFinished() {
|
||||
onContinue(Optional.of(ExperienceUpgrade.TYPING_INDICATORS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLinkPreviewsFinished() {
|
||||
onContinue(Optional.of(ExperienceUpgrade.LINK_PREVIEWS));
|
||||
}
|
||||
|
||||
private final class OnPageChangeListener implements ViewPager.OnPageChangeListener {
|
||||
private final ArgbEvaluator evaluator = new ArgbEvaluator();
|
||||
private final ExperienceUpgrade upgrade;
|
||||
|
||||
public OnPageChangeListener(ExperienceUpgrade upgrade) {
|
||||
this.upgrade = upgrade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
final int nextPosition = (position + 1) % upgrade.getPages().size();
|
||||
|
||||
final int color = (Integer)evaluator.evaluate(positionOffset,
|
||||
upgrade.getPage(position).backgroundColor,
|
||||
upgrade.getPage(nextPosition).backgroundColor);
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(color));
|
||||
}
|
||||
}
|
||||
|
||||
public static class AppUpgradeReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction()) &&
|
||||
intent.getData().getSchemeSpecificPart().equals(context.getPackageName()))
|
||||
{
|
||||
if (TextSecurePreferences.getLastExperienceVersionCode(context) < 339 &&
|
||||
!TextSecurePreferences.isPasswordDisabled(context))
|
||||
{
|
||||
Notification notification = new NotificationCompat.Builder(context, NotificationChannels.OTHER)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setColor(context.getResources().getColor(R.color.signal_primary))
|
||||
.setContentTitle(context.getString(R.string.ExperienceUpgradeActivity_unlock_to_complete_update))
|
||||
.setContentText(context.getString(R.string.ExperienceUpgradeActivity_please_unlock_signal_to_complete_update))
|
||||
.setStyle(new NotificationCompat.BigTextStyle().bigText(context.getString(R.string.ExperienceUpgradeActivity_please_unlock_signal_to_complete_update)))
|
||||
.setAutoCancel(true)
|
||||
.setContentIntent(PendingIntent.getActivity(context, 0,
|
||||
context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT))
|
||||
.build();
|
||||
|
||||
ServiceUtil.getNotificationManager(context).notify(NOTIFICATION_ID, notification);
|
||||
}
|
||||
|
||||
Optional<ExperienceUpgrade> experienceUpgrade = getExperienceUpgrade(context);
|
||||
|
||||
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, NotificationChannels.OTHER)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setColor(context.getResources().getColor(R.color.signal_primary))
|
||||
.setContentTitle(context.getString(experienceUpgrade.get().getNotificationTitle()))
|
||||
.setContentText(context.getString(experienceUpgrade.get().getNotificationText()))
|
||||
.setStyle(new NotificationCompat.BigTextStyle().bigText(context.getString(experienceUpgrade.get().getNotificationBigText())))
|
||||
.setAutoCancel(true)
|
||||
.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.getCanonicalVersionCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IntroPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
public static class IntroPage {
|
||||
final int backgroundColor;
|
||||
final Fragment fragment;
|
||||
|
||||
public IntroPage(int backgroundColor, Fragment fragment) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
this.fragment = fragment;
|
||||
}
|
||||
}
|
||||
|
||||
private List<IntroPage> pages;
|
||||
|
||||
public IntroPagerAdapter(FragmentManager fm, List<IntroPage> pages) {
|
||||
super(fm);
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int i) {
|
||||
IntroPage page = pages.get(i);
|
||||
return page.fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return pages.size();
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -13,23 +14,21 @@ import androidx.fragment.app.Fragment;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.LandingActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.SeedActivity;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
//TODO AC: Rename to ScreenLockActionBarActivity.
|
||||
public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarActivity {
|
||||
private static final String TAG = PassphraseRequiredActionBarActivity.class.getSimpleName();
|
||||
|
||||
public static final String LOCALE_EXTRA = "locale_extra";
|
||||
|
||||
private static final int STATE_NORMAL = 0;
|
||||
private static final int STATE_PROMPT_PASSPHRASE = 2;
|
||||
private static final int STATE_UPGRADE_DATABASE = 3;
|
||||
private static final int STATE_PROMPT_PUSH_REGISTRATION = 4;
|
||||
private static final int STATE_EXPERIENCE_UPGRADE = 5;
|
||||
private static final int STATE_WELCOME_SCREEN = 6;
|
||||
private static final int STATE_PROMPT_PASSPHRASE = 1; //TODO AC: Rename to STATE_SCREEN_LOCKED
|
||||
private static final int STATE_UPGRADE_DATABASE = 2; //TODO AC: Rename to STATE_MIGRATE_DATA
|
||||
private static final int STATE_WELCOME_SCREEN = 3;
|
||||
|
||||
private BroadcastReceiver clearKeyReceiver;
|
||||
|
||||
@ -120,8 +119,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
case STATE_PROMPT_PASSPHRASE: return getPromptPassphraseIntent();
|
||||
case STATE_UPGRADE_DATABASE: return getUpgradeDatabaseIntent();
|
||||
case STATE_WELCOME_SCREEN: return getWelcomeIntent();
|
||||
case STATE_PROMPT_PUSH_REGISTRATION: return getPushRegistrationIntent();
|
||||
case STATE_EXPERIENCE_UPGRADE: return getExperienceUpgradeIntent();
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
@ -133,13 +130,7 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
return STATE_UPGRADE_DATABASE;
|
||||
} else if (!TextSecurePreferences.hasSeenWelcomeScreen(this)) {
|
||||
return STATE_WELCOME_SCREEN;
|
||||
} else if (!TextSecurePreferences.hasPromptedPushRegistration(this)) {
|
||||
return STATE_PROMPT_PUSH_REGISTRATION;
|
||||
}
|
||||
// else if (ExperienceUpgradeActivity.isUpdate(this)) {
|
||||
// return STATE_EXPERIENCE_UPGRADE;
|
||||
// }
|
||||
else {
|
||||
} else {
|
||||
return STATE_NORMAL;
|
||||
}
|
||||
}
|
||||
@ -149,22 +140,15 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
}
|
||||
|
||||
private Intent getUpgradeDatabaseIntent() {
|
||||
return getRoutedIntent(DatabaseUpgradeActivity.class,
|
||||
TextSecurePreferences.hasPromptedPushRegistration(this)
|
||||
? getConversationListIntent()
|
||||
: getPushRegistrationIntent());
|
||||
}
|
||||
|
||||
private Intent getExperienceUpgradeIntent() {
|
||||
return getRoutedIntent(ExperienceUpgradeActivity.class, getIntent());
|
||||
return getRoutedIntent(DatabaseUpgradeActivity.class, getConversationListIntent());
|
||||
}
|
||||
|
||||
private Intent getWelcomeIntent() {
|
||||
return getRoutedIntent(LandingActivity.class, getPushRegistrationIntent());
|
||||
return getRoutedIntent(LandingActivity.class, getConversationListIntent());
|
||||
}
|
||||
|
||||
private Intent getPushRegistrationIntent() {
|
||||
return getRoutedIntent(SeedActivity.class, getConversationListIntent());
|
||||
private Intent getConversationListIntent() {
|
||||
return new Intent(this, HomeActivity.class);
|
||||
}
|
||||
|
||||
private Intent getRoutedIntent(Class<?> destination, @Nullable Intent nextIntent) {
|
||||
@ -173,10 +157,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
return intent;
|
||||
}
|
||||
|
||||
private Intent getConversationListIntent() {
|
||||
return new Intent(this, HomeActivity.class);
|
||||
}
|
||||
|
||||
private void initializeClearKeyReceiver() {
|
||||
Log.i(TAG, "initializeClearKeyReceiver()");
|
||||
this.clearKeyReceiver = new BroadcastReceiver() {
|
||||
|
@ -22,6 +22,7 @@ import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.session.libsignal.libsignal.ecc.ECPublicKey;
|
||||
import org.thoughtcrime.securesms.backup.BackupProtos;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.session.libsignal.libsignal.IdentityKey;
|
||||
@ -40,7 +41,6 @@ import java.util.List;
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
//TODO AC: Delete
|
||||
public class IdentityKeyUtil {
|
||||
|
||||
private static final String MASTER_SECRET_UTIL_PREFERENCES_NAME = "SecureSMS-Preferences";
|
||||
@ -86,6 +86,14 @@ public class IdentityKeyUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void generateIdentityKeyPair(@NonNull Context context) {
|
||||
ECKeyPair keyPair = Curve.generateKeyPair();
|
||||
ECPublicKey publicKey = keyPair.getPublicKey();
|
||||
ECPrivateKey privateKey = keyPair.getPrivateKey();
|
||||
save(context, IDENTITY_PUBLIC_KEY_PREF, Base64.encodeBytes(publicKey.serialize()));
|
||||
save(context, IDENTITY_PRIVATE_KEY_PREF, Base64.encodeBytes(privateKey.serialize()));
|
||||
}
|
||||
|
||||
public static List<BackupProtos.SharedPreference> getBackupRecords(@NonNull Context context) {
|
||||
final String prefName = MASTER_SECRET_UTIL_PREFERENCES_NAME;
|
||||
SharedPreferences preferences = context.getSharedPreferences(prefName, 0);
|
||||
|
@ -189,7 +189,6 @@ class BackupRestoreViewModel(application: Application): AndroidViewModel(applica
|
||||
TextSecurePreferences.setRestorationTime(context, System.currentTimeMillis())
|
||||
TextSecurePreferences.setHasViewedSeed(context, true)
|
||||
TextSecurePreferences.setHasSeenWelcomeScreen(context, true)
|
||||
TextSecurePreferences.setPromptedPushRegistration(context, true)
|
||||
TextSecurePreferences.setHasSeenMultiDeviceRemovalSheet(context)
|
||||
TextSecurePreferences.setHasSeenLightThemeIntroSheet(context)
|
||||
val application = ApplicationContext.getInstance(context)
|
||||
|
@ -2,15 +2,17 @@ package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import kotlinx.android.synthetic.main.activity_landing.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.loki.views.FakeChatView
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
|
||||
class LandingActivity : BaseActionBarActivity() {
|
||||
|
||||
@ -18,13 +20,23 @@ class LandingActivity : BaseActionBarActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_landing)
|
||||
setUpActionBarSessionLogo(true)
|
||||
fakeChatView.startAnimating()
|
||||
registerButton.setOnClickListener { register() }
|
||||
restoreButton.setOnClickListener { restoreFromRecoveryPhrase() }
|
||||
restoreBackupButton.setOnClickListener { restoreFromBackup() }
|
||||
findViewById<FakeChatView>(R.id.fakeChatView).startAnimating()
|
||||
|
||||
findViewById<View>(R.id.registerButton).setOnClickListener { register() }
|
||||
findViewById<View>(R.id.restoreButton).setOnClickListener { restoreFromRecoveryPhrase() }
|
||||
findViewById<View>(R.id.restoreBackupButton).setOnClickListener { restoreFromBackup() }
|
||||
|
||||
if (TextSecurePreferences.getWasUnlinked(this)) {
|
||||
Toast.makeText(this, R.string.activity_landing_device_unlinked_dialog_title, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
// Setup essentials for a new user.
|
||||
IdentityKeyUtil.generateIdentityKeyPair(this)
|
||||
|
||||
TextSecurePreferences.setLastExperienceVersionCode(this, Util.getCanonicalVersionCode())
|
||||
TextSecurePreferences.setPasswordDisabled(this, true)
|
||||
TextSecurePreferences.setReadReceiptsEnabled(this, true)
|
||||
TextSecurePreferences.setTypingIndicatorsEnabled(this, true)
|
||||
}
|
||||
|
||||
private fun register() {
|
||||
@ -46,7 +58,6 @@ class LandingActivity : BaseActionBarActivity() {
|
||||
IdentityKeyUtil.delete(this, IdentityKeyUtil.LOKI_SEED)
|
||||
TextSecurePreferences.removeLocalNumber(this)
|
||||
TextSecurePreferences.setHasSeenWelcomeScreen(this, false)
|
||||
TextSecurePreferences.setPromptedPushRegistration(this, false)
|
||||
val application = ApplicationContext.getInstance(this)
|
||||
application.stopPolling()
|
||||
}
|
||||
|
@ -151,7 +151,6 @@ class PNModeActivity : BaseActionBarActivity() {
|
||||
return
|
||||
}
|
||||
TextSecurePreferences.setHasSeenWelcomeScreen(this, true)
|
||||
TextSecurePreferences.setPromptedPushRegistration(this, true)
|
||||
TextSecurePreferences.setIsUsingFCM(this, (selectedOptionView == fcmOptionView))
|
||||
TextSecurePreferences.setHasSeenMultiDeviceRemovalSheet(this)
|
||||
TextSecurePreferences.setHasSeenLightThemeIntroSheet(this)
|
||||
|
@ -15,12 +15,6 @@ object KeyPairUtilities {
|
||||
|
||||
private val sodium = LazySodiumAndroid(SodiumAndroid())
|
||||
|
||||
data class KeyPairGenerationResult(
|
||||
val seed: ByteArray,
|
||||
val ed25519KeyPair: KeyPair,
|
||||
val x25519KeyPair: ECKeyPair
|
||||
)
|
||||
|
||||
fun generate(): KeyPairGenerationResult {
|
||||
val seed = sodium.randomBytesBuf(16)
|
||||
try {
|
||||
@ -45,4 +39,10 @@ object KeyPairUtilities {
|
||||
IdentityKeyUtil.save(context, IdentityKeyUtil.ED25519_PUBLIC_KEY, Base64.encodeBytes(ed25519KeyPair.publicKey.asBytes))
|
||||
IdentityKeyUtil.save(context, IdentityKeyUtil.ED25519_SECRET_KEY, Base64.encodeBytes(ed25519KeyPair.secretKey.asBytes))
|
||||
}
|
||||
|
||||
data class KeyPairGenerationResult(
|
||||
val seed: ByteArray,
|
||||
val ed25519KeyPair: KeyPair,
|
||||
val x25519KeyPair: ECKeyPair
|
||||
)
|
||||
}
|
@ -81,7 +81,6 @@ public class TextSecurePreferences {
|
||||
public static final String REGISTERED_GCM_PREF = "pref_gcm_registered";
|
||||
private static final String GCM_PASSWORD_PREF = "pref_gcm_password";
|
||||
private static final String SEEN_WELCOME_SCREEN_PREF = "pref_seen_welcome_screen";
|
||||
private static final String PROMPTED_PUSH_REGISTRATION_PREF = "pref_prompted_push_registration";
|
||||
private static final String PROMPTED_DEFAULT_SMS_PREF = "pref_prompted_default_sms";
|
||||
private static final String PROMPTED_OPTIMIZE_DOZE_PREF = "pref_prompted_optimize_doze";
|
||||
private static final String PROMPTED_SHARE_PREF = "pref_prompted_share";
|
||||
@ -879,21 +878,13 @@ public class TextSecurePreferences {
|
||||
}
|
||||
|
||||
public static boolean hasSeenWelcomeScreen(Context context) {
|
||||
return getBooleanPreference(context, SEEN_WELCOME_SCREEN_PREF, true);
|
||||
return getBooleanPreference(context, SEEN_WELCOME_SCREEN_PREF, false);
|
||||
}
|
||||
|
||||
public static void setHasSeenWelcomeScreen(Context context, boolean value) {
|
||||
setBooleanPreference(context, SEEN_WELCOME_SCREEN_PREF, value);
|
||||
}
|
||||
|
||||
public static boolean hasPromptedPushRegistration(Context context) {
|
||||
return getBooleanPreference(context, PROMPTED_PUSH_REGISTRATION_PREF, false);
|
||||
}
|
||||
|
||||
public static void setPromptedPushRegistration(Context context, boolean value) {
|
||||
setBooleanPreference(context, PROMPTED_PUSH_REGISTRATION_PREF, value);
|
||||
}
|
||||
|
||||
public static boolean hasPromptedDefaultSmsProvider(Context context) {
|
||||
return getBooleanPreference(context, PROMPTED_DEFAULT_SMS_PREF, false);
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class VersionTracker {
|
||||
|
||||
public static int getLastSeenVersion(@NonNull Context context) {
|
||||
return TextSecurePreferences.getLastVersionCode(context);
|
||||
}
|
||||
|
||||
public static void updateLastSeenVersion(@NonNull Context context) {
|
||||
try {
|
||||
int currentVersionCode = Util.getCanonicalVersionCode();
|
||||
TextSecurePreferences.setLastVersionCode(context, currentVersionCode);
|
||||
} catch (IOException ioe) {
|
||||
throw new AssertionError(ioe);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import android.content.Context
|
||||
import java.io.IOException
|
||||
import java.lang.RuntimeException
|
||||
|
||||
object VersionTracker {
|
||||
|
||||
@JvmStatic
|
||||
fun getLastSeenVersion(context: Context): Int {
|
||||
var version = TextSecurePreferences.getLastVersionCode(context)
|
||||
// Zero means the app is freshly installed = user is actually on the current version.
|
||||
if (version == 0) {
|
||||
version = updateLastSeenVersion(context)
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun updateLastSeenVersion(context: Context): Int {
|
||||
return try {
|
||||
val currentVersionCode = Util.getCanonicalVersionCode()
|
||||
TextSecurePreferences.setLastVersionCode(context, currentVersionCode)
|
||||
currentVersionCode
|
||||
} catch (e: IOException) {
|
||||
throw RuntimeException("Failed to update the last seen app version.", e)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:fab="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/container"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<Button android:id="@+id/continue_button"
|
||||
android:layout_width="140sp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/experience_upgrade_activity__continue"
|
||||
android:visibility="invisible"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<com.melnykov.fab.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="25dp"
|
||||
android:src="@drawable/ic_arrow_forward_white_24dp"
|
||||
android:focusable="true"
|
||||
android:contentDescription="@string/conversation_list_fragment__fab_content_description"
|
||||
fab:fab_shadow="false"
|
||||
fab:fab_colorNormal="#33000000"
|
||||
fab:fab_colorPressed="#66000000"
|
||||
fab:fab_colorRipple="#66000000" />
|
||||
</FrameLayout>
|
Loading…
x
Reference in New Issue
Block a user