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 androidx.annotation.StringRes;
import androidx.preference.PreferenceManager;
import com.mgoogle.android.gms.R;
@ -96,6 +97,9 @@ public class LoginActivity extends AssistantActivity {
private ViewGroup authContent;
private int state = 0;
private String HuaweiButtonPreference = "huaweiloginbutton";
private String LoginButtonPreference = "standardloginbutton";
@SuppressLint("AddJavascriptInterface")
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -158,11 +162,11 @@ public class LoginActivity extends AssistantActivity {
super.onHuaweiButtonClicked();
state++;
if (state == 1) {
CheckinClient.isHuaweiButtonClicked = true;
if (CheckinClient.isLoginButtonClicked) {
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(HuaweiButtonPreference, true);
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(LoginButtonPreference, false)) {
LastCheckinInfo.ClearCheckinInfo(this);
CheckinClient.brandSpoof = true;
CheckinClient.isLoginButtonClicked = false;
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(LoginButtonPreference, true);
}
init();
}
@ -173,11 +177,11 @@ public class LoginActivity extends AssistantActivity {
super.onNextButtonClicked();
state++;
if (state == 1) {
CheckinClient.isLoginButtonClicked = true;
if (CheckinClient.isHuaweiButtonClicked) {
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(LoginButtonPreference, true);
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(HuaweiButtonPreference, false)) {
LastCheckinInfo.ClearCheckinInfo(this);
CheckinClient.brandSpoof = false;
CheckinClient.isHuaweiButtonClicked = false;
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(HuaweiButtonPreference, true);
}
init();
} 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<CheckinRequest.Checkin.Statistic> TODO_LIST_CHECKIN = new ArrayList<CheckinRequest.Checkin.Statistic>(); // TODO
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 CheckinResponse request(CheckinRequest request) throws IOException {