Switch from static to preferences variables

This commit is contained in:
Oizaro 2020-10-10 21:24:19 +02:00
parent 042aae92de
commit 42465a888c
2 changed files with 10 additions and 8 deletions

View File

@ -43,6 +43,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import androidx.preference.PreferenceManager;
import com.mgoogle.android.gms.R; import com.mgoogle.android.gms.R;
@ -96,6 +97,9 @@ public class LoginActivity extends AssistantActivity {
private ViewGroup authContent; private ViewGroup authContent;
private int state = 0; private int state = 0;
private String HuaweiButtonPreference = "huaweiloginbutton";
private String LoginButtonPreference = "standardloginbutton";
@SuppressLint("AddJavascriptInterface") @SuppressLint("AddJavascriptInterface")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -158,11 +162,11 @@ public class LoginActivity extends AssistantActivity {
super.onHuaweiButtonClicked(); super.onHuaweiButtonClicked();
state++; state++;
if (state == 1) { if (state == 1) {
CheckinClient.isHuaweiButtonClicked = true; PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(HuaweiButtonPreference, true);
if (CheckinClient.isLoginButtonClicked) { if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(LoginButtonPreference, false)) {
LastCheckinInfo.ClearCheckinInfo(this); LastCheckinInfo.ClearCheckinInfo(this);
CheckinClient.brandSpoof = true; CheckinClient.brandSpoof = true;
CheckinClient.isLoginButtonClicked = false; PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(LoginButtonPreference, true);
} }
init(); init();
} }
@ -173,11 +177,11 @@ public class LoginActivity extends AssistantActivity {
super.onNextButtonClicked(); super.onNextButtonClicked();
state++; state++;
if (state == 1) { if (state == 1) {
CheckinClient.isLoginButtonClicked = true; PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(LoginButtonPreference, true);
if (CheckinClient.isHuaweiButtonClicked) { if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(HuaweiButtonPreference, false)) {
LastCheckinInfo.ClearCheckinInfo(this); LastCheckinInfo.ClearCheckinInfo(this);
CheckinClient.brandSpoof = false; CheckinClient.brandSpoof = false;
CheckinClient.isHuaweiButtonClicked = false; PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(HuaweiButtonPreference, true);
} }
init(); init();
} else if (state == -1) { } else if (state == -1) {

View File

@ -45,8 +45,6 @@ public class CheckinClient {
private static final List<String> TODO_LIST_STRING = new ArrayList<>(); // TODO private static final List<String> TODO_LIST_STRING = new ArrayList<>(); // TODO
private static final List<CheckinRequest.Checkin.Statistic> TODO_LIST_CHECKIN = new ArrayList<CheckinRequest.Checkin.Statistic>(); // TODO private static final List<CheckinRequest.Checkin.Statistic> TODO_LIST_CHECKIN = new ArrayList<CheckinRequest.Checkin.Statistic>(); // TODO
private static final String SERVICE_URL = "https://android.clients.google.com/checkin"; private static final String SERVICE_URL = "https://android.clients.google.com/checkin";
public static boolean isHuaweiButtonClicked = false;
public static boolean isLoginButtonClicked = false;
public static boolean brandSpoof = false; public static boolean brandSpoof = false;
public static CheckinResponse request(CheckinRequest request) throws IOException { public static CheckinResponse request(CheckinRequest request) throws IOException {