mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-01-27 09:41:34 +01:00
Reformatting applied.
This commit is contained in:
parent
2125d38a66
commit
a53a5d55bf
@ -58,6 +58,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
|
||||
return R.layout.activity_login;
|
||||
}
|
||||
|
||||
@ -86,13 +87,13 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
Resources res = getResources();
|
||||
String[] allProtocols = res.getStringArray(R.array.protocolValues);
|
||||
|
||||
final ArrayAdapter<String> adapterProtocols = new ArrayAdapter<String>(Objects.requireNonNull(getApplicationContext()),
|
||||
R.layout.spinner_item, allProtocols);
|
||||
final ArrayAdapter<String> adapterProtocols = new ArrayAdapter<String>(Objects.requireNonNull(getApplicationContext()), R.layout.spinner_item, allProtocols);
|
||||
|
||||
adapterProtocols.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
||||
protocolSpinner.setAdapter(adapterProtocols);
|
||||
|
||||
protocolSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
|
||||
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) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -179,6 +182,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
}
|
||||
|
||||
private View.OnClickListener loginListener = new View.OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
|
||||
disableProcessButton();
|
||||
@ -189,17 +193,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
};
|
||||
|
||||
private View.OnClickListener infoListener = new View.OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
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();
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
@ -238,7 +235,8 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
URI uri = null;
|
||||
try {
|
||||
uri = new URI(instanceUrl);
|
||||
} catch (URISyntaxException e) {
|
||||
}
|
||||
catch(URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assert uri != null;
|
||||
@ -327,7 +325,8 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
URI uri = null;
|
||||
try {
|
||||
uri = new URI(instanceUrl);
|
||||
} catch (URISyntaxException e) {
|
||||
}
|
||||
catch(URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assert uri != null;
|
||||
@ -388,10 +387,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
Call<GiteaVersion> callVersion = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getGiteaVersion();
|
||||
Call<GiteaVersion> callVersion = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().getGiteaVersion();
|
||||
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
|
||||
@ -417,19 +413,16 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
|
||||
|
||||
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() {
|
||||
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() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
dialog.dismiss();
|
||||
enableProcessButton();
|
||||
}
|
||||
})
|
||||
.setPositiveButton(getString(R.string.textContinue), new DialogInterface.OnClickListener() {
|
||||
}).setPositiveButton(getString(R.string.textContinue), new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
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_) {
|
||||
|
||||
if(loginType == 1) {
|
||||
letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP);
|
||||
}
|
||||
@ -470,8 +464,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
Log.e("onFailure-version", t.toString());
|
||||
|
||||
if(t instanceof NoRouteToHostException) {
|
||||
Toasty.info(getApplicationContext(), "Could not connect to host. Please check your url or port " +
|
||||
"for issues.");
|
||||
Toasty.info(getApplicationContext(), "Could not connect to host. Please check your url or port " + "for issues.");
|
||||
}
|
||||
else {
|
||||
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());
|
||||
|
||||
Call<UserInfo> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getUserInfo("token " + loginToken_);
|
||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().getUserInfo("token " + loginToken_);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
@ -542,6 +532,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.genericError));
|
||||
enableProcessButton();
|
||||
@ -557,16 +548,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
|
||||
Call<List<UserTokens>> call;
|
||||
if(loginOTP != 0) {
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||
call = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||
}
|
||||
else {
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getUserTokens(credential, loginUid);
|
||||
call = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().getUserTokens(credential, loginUid);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<List<UserTokens>>() {
|
||||
@ -619,16 +604,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
|
||||
Call<UserTokens> callCreateToken;
|
||||
if(loginOTP != 0) {
|
||||
callCreateToken = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||
}
|
||||
else {
|
||||
callCreateToken = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewToken(credential, loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getInstance(instanceUrl, getApplicationContext()).getApiInterface().createNewToken(credential, loginUid, createUserToken);
|
||||
}
|
||||
|
||||
callCreateToken.enqueue(new Callback<UserTokens>() {
|
||||
@ -713,6 +692,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserTokens>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-login", t.toString());
|
||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.malformedJson));
|
||||
enableProcessButton();
|
||||
|
Loading…
x
Reference in New Issue
Block a user