Conversations/src/quicksy/java/eu/siacs/conversations/utils/SignupUtils.java

45 lines
1.7 KiB
Java
Raw Normal View History

package eu.siacs.conversations.utils;
import android.app.Activity;
import android.content.Intent;
2018-11-09 17:47:36 +01:00
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
2018-10-18 21:02:04 +02:00
import android.util.Log;
2018-10-18 21:02:04 +02:00
import eu.siacs.conversations.Config;
2018-10-20 16:37:59 +02:00
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.ui.ConversationsActivity;
2018-10-18 21:02:04 +02:00
import eu.siacs.conversations.ui.EnterPhoneNumberActivity;
2018-10-20 16:37:59 +02:00
import eu.siacs.conversations.ui.StartConversationActivity;
2018-11-09 17:47:36 +01:00
import eu.siacs.conversations.ui.TosActivity;
2018-10-20 16:37:59 +02:00
import eu.siacs.conversations.ui.VerifyActivity;
public class SignupUtils {
public static Intent getSignUpIntent(Activity activity) {
2018-10-18 21:02:04 +02:00
final Intent intent = new Intent(activity, EnterPhoneNumberActivity.class);
return intent;
}
public static Intent getRedirectionIntent(ConversationsActivity activity) {
2018-10-20 16:37:59 +02:00
final Intent intent;
final Account account = AccountUtils.getFirst(activity.xmppConnectionService);
if (account != null) {
if (account.isOptionSet(Account.OPTION_UNVERIFIED)) {
intent = new Intent(activity, VerifyActivity.class);
} else {
intent = new Intent(activity, StartConversationActivity.class);
}
} else {
2018-11-09 17:47:36 +01:00
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
if (preferences.getBoolean("tos",false)) {
intent = getSignUpIntent(activity);
} else {
intent = new Intent(activity, TosActivity.class);
}
2018-10-20 16:37:59 +02:00
}
2018-10-18 21:02:04 +02:00
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
return intent;
}
}