mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
implement login via token
This commit is contained in:
parent
bc2b609585
commit
96ab992264
@ -15,6 +15,7 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
@ -44,8 +45,9 @@ import retrofit2.Callback;
|
||||
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
private Button login_button;
|
||||
private EditText instance_url, login_uid, login_passwd, otpCode;
|
||||
private EditText instance_url, login_uid, login_passwd, otpCode, loginTokenCode;
|
||||
private Spinner protocolSpinner;
|
||||
private TextView otpInfo;
|
||||
final Context ctx = this;
|
||||
|
||||
@Override
|
||||
@ -62,9 +64,12 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
login_uid = findViewById(R.id.login_uid);
|
||||
login_passwd = findViewById(R.id.login_passwd);
|
||||
otpCode = findViewById(R.id.otpCode);
|
||||
otpInfo = findViewById(R.id.otpInfo);
|
||||
ImageView info_button = findViewById(R.id.info);
|
||||
final TextView viewTextAppVersion = findViewById(R.id.appVersion);
|
||||
protocolSpinner = findViewById(R.id.httpsSpinner);
|
||||
RadioGroup loginMethod = findViewById(R.id.loginMethod);
|
||||
loginTokenCode = findViewById(R.id.loginTokenCode);
|
||||
|
||||
viewTextAppVersion.setText(AppUtil.getAppVersion(getApplicationContext()));
|
||||
|
||||
@ -99,6 +104,25 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
|
||||
}
|
||||
|
||||
loginMethod.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
if(checkedId == R.id.loginUsernamePassword){
|
||||
login_uid.setVisibility(View.VISIBLE);
|
||||
login_passwd.setVisibility(View.VISIBLE);
|
||||
otpCode.setVisibility(View.VISIBLE);
|
||||
otpInfo.setVisibility(View.VISIBLE);
|
||||
loginTokenCode.setVisibility(View.GONE);
|
||||
} else {
|
||||
login_uid.setVisibility(View.GONE);
|
||||
login_passwd.setVisibility(View.GONE);
|
||||
otpCode.setVisibility(View.GONE);
|
||||
otpInfo.setVisibility(View.GONE);
|
||||
loginTokenCode.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//login_button.setOnClickListener(this);
|
||||
if(!tinyDb.getString("instanceUrlRaw").isEmpty()) {
|
||||
instance_url.setText(tinyDb.getString("instanceUrlRaw"));
|
||||
|
@ -24,6 +24,38 @@
|
||||
android:contentDescription="@string/app_name"
|
||||
android:src="@mipmap/app_logo" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/loginMethodText"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:gravity="start" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/loginMethod"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<RadioButton
|
||||
android:id="@+id/loginUsernamePassword"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/loginViaPassword"
|
||||
android:checked="true"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:textColor="@color/white"/>
|
||||
<RadioButton
|
||||
android:id="@+id/loginToken"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/loginViaToken"
|
||||
android:textColor="@color/white"/>
|
||||
</RadioGroup>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
@ -121,7 +153,26 @@
|
||||
android:inputType="number"
|
||||
android:textColorHighlight="@color/white"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/loginTokenCode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:padding="10dp"
|
||||
android:textSize="14sp"
|
||||
tools:ignore="Autofill"
|
||||
android:background="@drawable/shape_inputs"
|
||||
android:drawableStart="@drawable/ic_lock_24dp"
|
||||
android:drawablePadding="10dp"
|
||||
android:textColor="@color/white"
|
||||
android:textColorHint="@color/colorAccent"
|
||||
android:hint="@string/loginViaToken"
|
||||
android:inputType="text"
|
||||
android:visibility="gone"
|
||||
android:textColorHighlight="@color/white"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/otpInfo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/otpMessage"
|
||||
|
@ -527,4 +527,9 @@
|
||||
<string name="versionAlertDialogHeader">Unsupported Version of Gitea</string>
|
||||
<string name="versionAlertDialogCopyNegative">Cancel</string>
|
||||
<string name="versionAlertDialogCopyPositive">Continue</string>
|
||||
|
||||
<string name="loginViaPassword">Username / Password</string>
|
||||
<string name="loginViaToken">Token</string>
|
||||
<string name="loginMethodText">Choose your preferred login method to access your account. Token is more secure!</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user