mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Go to chatlist if app is already configured #10
This commit is contained in:
@@ -249,8 +249,7 @@
|
||||
android:id="@+id/smtp_login_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/RegistrationActivity_smtp_login"
|
||||
android:inputType="textPassword" />
|
||||
android:hint="@string/RegistrationActivity_smtp_login" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.connect.DcContextHelper;
|
||||
import org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
@@ -26,11 +26,9 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
public static final String LOCALE_EXTRA = "locale_extra";
|
||||
|
||||
private static final int STATE_NORMAL = 0;
|
||||
private static final int STATE_CREATE_PASSPHRASE = 1;
|
||||
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_NEEDS_REGISTER = 1;
|
||||
private static final int STATE_UPGRADE_DATABASE = 2;
|
||||
private static final int STATE_EXPERIENCE_UPGRADE = 3;
|
||||
|
||||
private SignalServiceNetworkAccess networkAccess;
|
||||
private BroadcastReceiver clearKeyReceiver;
|
||||
@@ -137,26 +135,17 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
Log.w(TAG, "routeApplicationState(), state: " + state);
|
||||
|
||||
switch (state) {
|
||||
case STATE_CREATE_PASSPHRASE: return getCreatePassphraseIntent();
|
||||
case STATE_PROMPT_PASSPHRASE: return getPromptPassphraseIntent();
|
||||
case STATE_UPGRADE_DATABASE: return getUpgradeDatabaseIntent();
|
||||
case STATE_PROMPT_PUSH_REGISTRATION: return getPushRegistrationIntent();
|
||||
case STATE_EXPERIENCE_UPGRADE: return getExperienceUpgradeIntent();
|
||||
case STATE_UPGRADE_DATABASE: return getUpgradeDatabaseIntent();
|
||||
case STATE_NEEDS_REGISTER: return getWelcomeIntent();
|
||||
case STATE_EXPERIENCE_UPGRADE: return getExperienceUpgradeIntent();
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int getApplicationState(boolean locked) {
|
||||
if (!MasterSecretUtil.isPassphraseInitialized(this)) {
|
||||
return STATE_CREATE_PASSPHRASE;
|
||||
} else if (locked) {
|
||||
return STATE_PROMPT_PASSPHRASE;
|
||||
} else if (DatabaseUpgradeActivity.isUpdate(this)) {
|
||||
return STATE_UPGRADE_DATABASE;
|
||||
} else if (!TextSecurePreferences.hasPromptedPushRegistration(this)) {
|
||||
return STATE_PROMPT_PUSH_REGISTRATION;
|
||||
} else if (ExperienceUpgradeActivity.isUpdate(this)) {
|
||||
return STATE_EXPERIENCE_UPGRADE;
|
||||
boolean isConfigured = DcContextHelper.isConfigured(getApplicationContext());
|
||||
if (!isConfigured) {
|
||||
return STATE_NEEDS_REGISTER;
|
||||
} else {
|
||||
return STATE_NORMAL;
|
||||
}
|
||||
@@ -174,17 +163,21 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
return getRoutedIntent(DatabaseUpgradeActivity.class,
|
||||
TextSecurePreferences.hasPromptedPushRegistration(this)
|
||||
? getConversationListIntent()
|
||||
: getPushRegistrationIntent());
|
||||
: getLoginIntent());
|
||||
}
|
||||
|
||||
private Intent getExperienceUpgradeIntent() {
|
||||
return getRoutedIntent(ExperienceUpgradeActivity.class, getIntent());
|
||||
}
|
||||
|
||||
private Intent getPushRegistrationIntent() {
|
||||
private Intent getWelcomeIntent() {
|
||||
return getRoutedIntent(WelcomeActivity.class, null);
|
||||
}
|
||||
|
||||
private Intent getLoginIntent() {
|
||||
return getRoutedIntent(RegistrationActivity.class, null);
|
||||
}
|
||||
|
||||
private Intent getCreateProfileIntent() {
|
||||
return getRoutedIntent(CreateProfileActivity.class, getConversationListIntent());
|
||||
}
|
||||
|
||||
@@ -6,29 +6,29 @@ import android.view.View.OnClickListener;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.RegistrationActivity;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.connect.DcContextHelper;
|
||||
|
||||
public class PushRegistrationReminder extends Reminder {
|
||||
|
||||
public PushRegistrationReminder(final Context context) {
|
||||
super(context.getString(R.string.reminder_header_push_title),
|
||||
context.getString(R.string.reminder_header_push_text));
|
||||
public PushRegistrationReminder(final Context context) {
|
||||
super(context.getString(R.string.reminder_header_push_title),
|
||||
context.getString(R.string.reminder_header_push_text));
|
||||
|
||||
final OnClickListener okListener = v -> {
|
||||
Intent intent = new Intent(context, RegistrationActivity.class);
|
||||
intent.putExtra(RegistrationActivity.RE_REGISTRATION_EXTRA, true);
|
||||
context.startActivity(intent);
|
||||
};
|
||||
final OnClickListener okListener = v -> {
|
||||
Intent intent = new Intent(context, RegistrationActivity.class);
|
||||
intent.putExtra(RegistrationActivity.RE_REGISTRATION_EXTRA, true);
|
||||
context.startActivity(intent);
|
||||
};
|
||||
|
||||
setOkListener(okListener);
|
||||
}
|
||||
setOkListener(okListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDismissable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isDismissable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEligible(Context context) {
|
||||
return !TextSecurePreferences.isPushRegistered(context);
|
||||
}
|
||||
public static boolean isEligible(Context context) {
|
||||
return !DcContextHelper.isConfigured(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.thoughtcrime.securesms.connect;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.b44t.messenger.DcContext;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
|
||||
public class DcContextHelper {
|
||||
|
||||
public static DcContext getDcContext(Context context) {
|
||||
return ApplicationContext.getInstance(context).dcContext;
|
||||
}
|
||||
|
||||
public static boolean isConfigured(Context context) {
|
||||
DcContext dcContext = getDcContext(context);
|
||||
return dcContext.isConfigured() == 1;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user