Reformatting applied.
This commit is contained in:
parent
2125d38a66
commit
a53a5d55bf
@ -58,6 +58,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
|
|
||||||
return R.layout.activity_login;
|
return R.layout.activity_login;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,13 +87,13 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
String[] allProtocols = res.getStringArray(R.array.protocolValues);
|
String[] allProtocols = res.getStringArray(R.array.protocolValues);
|
||||||
|
|
||||||
final ArrayAdapter<String> adapterProtocols = new ArrayAdapter<String>(Objects.requireNonNull(getApplicationContext()),
|
final ArrayAdapter<String> adapterProtocols = new ArrayAdapter<String>(Objects.requireNonNull(getApplicationContext()), R.layout.spinner_item, allProtocols);
|
||||||
R.layout.spinner_item, allProtocols);
|
|
||||||
|
|
||||||
adapterProtocols.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
adapterProtocols.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
||||||
protocolSpinner.setAdapter(adapterProtocols);
|
protocolSpinner.setAdapter(adapterProtocols);
|
||||||
|
|
||||||
protocolSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
protocolSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||||
|
|
||||||
String value = getResources().getStringArray(R.array.protocolValues)[pos];
|
String value = getResources().getStringArray(R.array.protocolValues)[pos];
|
||||||
@ -101,7 +102,9 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -179,6 +182,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener loginListener = new View.OnClickListener() {
|
private View.OnClickListener loginListener = new View.OnClickListener() {
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
@ -189,17 +193,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
};
|
};
|
||||||
|
|
||||||
private View.OnClickListener infoListener = new View.OnClickListener() {
|
private View.OnClickListener infoListener = new View.OnClickListener() {
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
new Tooltip.Builder(v)
|
|
||||||
.setText(R.string.urlInfoTooltip)
|
new Tooltip.Builder(v).setText(R.string.urlInfoTooltip).setTextColor(getResources().getColor(R.color.white)).setBackgroundColor(getResources().getColor(R.color.tooltipBackground)).setCancelable(true).setDismissOnClick(true).setPadding(30).setCornerRadius(R.dimen.tooltipCornor).setGravity(Gravity.BOTTOM).show();
|
||||||
.setTextColor(getResources().getColor(R.color.white))
|
|
||||||
.setBackgroundColor(getResources().getColor(R.color.tooltipBackground))
|
|
||||||
.setCancelable(true)
|
|
||||||
.setDismissOnClick(true)
|
|
||||||
.setPadding(30)
|
|
||||||
.setCornerRadius(R.dimen.tooltipCornor)
|
|
||||||
.setGravity(Gravity.BOTTOM)
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -238,7 +235,8 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
URI uri = null;
|
URI uri = null;
|
||||||
try {
|
try {
|
||||||
uri = new URI(instanceUrl);
|
uri = new URI(instanceUrl);
|
||||||
} catch (URISyntaxException e) {
|
}
|
||||||
|
catch(URISyntaxException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
assert uri != null;
|
assert uri != null;
|
||||||
@ -327,7 +325,8 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
URI uri = null;
|
URI uri = null;
|
||||||
try {
|
try {
|
||||||
uri = new URI(instanceUrl);
|
uri = new URI(instanceUrl);
|
||||||
} catch (URISyntaxException e) {
|
}
|
||||||
|
catch(URISyntaxException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
assert uri != null;
|
assert uri != null;
|
||||||
@ -388,10 +387,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
Call<GiteaVersion> callVersion = RetrofitClient
|
Call<GiteaVersion> callVersion = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().getGiteaVersion();
|
||||||
.getInstance(instanceUrl, getApplicationContext())
|
|
||||||
.getApiInterface()
|
|
||||||
.getGiteaVersion();
|
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
@ -417,19 +413,16 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
|
|
||||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
|
||||||
|
|
||||||
alertDialogBuilder
|
alertDialogBuilder.setTitle(getString(R.string.versionAlertDialogHeader)).setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setCancelable(true).setIcon(R.drawable.ic_warning).setNegativeButton(getString(R.string.cancelButton), new DialogInterface.OnClickListener() {
|
||||||
.setTitle(getString(R.string.versionAlertDialogHeader))
|
|
||||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion()))
|
|
||||||
.setCancelable(true)
|
|
||||||
.setIcon(R.drawable.ic_warning)
|
|
||||||
.setNegativeButton(getString(R.string.cancelButton), new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
})
|
}).setPositiveButton(getString(R.string.textContinue), new DialogInterface.OnClickListener() {
|
||||||
.setPositiveButton(getString(R.string.textContinue), new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
@ -456,6 +449,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void login(int loginType, String instanceUrl, String loginUid, String loginPass, int loginOTP, String loginToken_) {
|
private void login(int loginType, String instanceUrl, String loginUid, String loginPass, int loginOTP, String loginToken_) {
|
||||||
|
|
||||||
if(loginType == 1) {
|
if(loginType == 1) {
|
||||||
letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP);
|
letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP);
|
||||||
}
|
}
|
||||||
@ -470,8 +464,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
Log.e("onFailure-version", t.toString());
|
Log.e("onFailure-version", t.toString());
|
||||||
|
|
||||||
if(t instanceof NoRouteToHostException) {
|
if(t instanceof NoRouteToHostException) {
|
||||||
Toasty.info(getApplicationContext(), "Could not connect to host. Please check your url or port " +
|
Toasty.info(getApplicationContext(), "Could not connect to host. Please check your url or port " + "for issues.");
|
||||||
"for issues.");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.commentError));
|
Toasty.info(getApplicationContext(), getResources().getString(R.string.commentError));
|
||||||
@ -490,10 +483,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient
|
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().getUserInfo("token " + loginToken_);
|
||||||
.getInstance(instanceUrl, getApplicationContext())
|
|
||||||
.getApiInterface()
|
|
||||||
.getUserInfo("token " + loginToken_);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
|
|
||||||
@ -542,6 +532,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.genericError));
|
Toasty.info(getApplicationContext(), getResources().getString(R.string.genericError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
@ -557,16 +548,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
|
|
||||||
Call<List<UserTokens>> call;
|
Call<List<UserTokens>> call;
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
call = RetrofitClient
|
call = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||||
.getInstance(instanceUrl, getApplicationContext())
|
|
||||||
.getApiInterface()
|
|
||||||
.getUserTokensWithOTP(credential, loginOTP, loginUid);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
call = RetrofitClient
|
call = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().getUserTokens(credential, loginUid);
|
||||||
.getInstance(instanceUrl, getApplicationContext())
|
|
||||||
.getApiInterface()
|
|
||||||
.getUserTokens(credential, loginUid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<List<UserTokens>>() {
|
call.enqueue(new Callback<List<UserTokens>>() {
|
||||||
@ -619,16 +604,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
|
|
||||||
Call<UserTokens> callCreateToken;
|
Call<UserTokens> callCreateToken;
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
callCreateToken = RetrofitClient
|
callCreateToken = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||||
.getInstance(instanceUrl, getApplicationContext())
|
|
||||||
.getApiInterface()
|
|
||||||
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
callCreateToken = RetrofitClient
|
callCreateToken = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().createNewToken(credential, loginUid, createUserToken);
|
||||||
.getInstance(instanceUrl, getApplicationContext())
|
|
||||||
.getApiInterface()
|
|
||||||
.createNewToken(credential, loginUid, createUserToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callCreateToken.enqueue(new Callback<UserTokens>() {
|
callCreateToken.enqueue(new Callback<UserTokens>() {
|
||||||
@ -713,6 +692,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<UserTokens>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<UserTokens>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure-login", t.toString());
|
Log.e("onFailure-login", t.toString());
|
||||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.malformedJson));
|
Toasty.info(getApplicationContext(), getResources().getString(R.string.malformedJson));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user