parent
d50957c776
commit
0365d0de84
@ -0,0 +1,72 @@
|
||||
package net.micode.notes.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import net.micode.notes.R;
|
||||
|
||||
public class LoginActivity extends Activity {
|
||||
private EditText accountEdict;
|
||||
private EditText passwordEdict;
|
||||
private Button login;
|
||||
private Button cancel;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_login);
|
||||
accountEdict = (EditText) findViewById(R.id.account);
|
||||
accountEdict.setSingleLine();
|
||||
passwordEdict = (EditText) findViewById(R.id.password);
|
||||
passwordEdict.setSingleLine();
|
||||
login = (Button) findViewById(R.id.login);
|
||||
cancel = (Button) findViewById(R.id.cancel);
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(LoginActivity.this,R.string.app_already_quit,Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
login.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String account = accountEdict.getText().toString();
|
||||
String password = passwordEdict.getText().toString();
|
||||
|
||||
|
||||
if(account.equals("czx") && password.equals("123456")){
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
|
||||
builder.setMessage(getString(R.string.Loading));
|
||||
builder.setCancelable(true);
|
||||
AlertDialog progressDialog = builder.create();
|
||||
progressDialog.show();
|
||||
|
||||
Intent intent = new Intent(LoginActivity.this,NotesListActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}else {
|
||||
Toast.makeText(LoginActivity.this, R.string.invalid,Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
// ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
// Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
// v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
// return insets;
|
||||
// });
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 168 KiB |
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.LoginActivity"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center">
|
||||
<TextView
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/prompt_account" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/account"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:maxLines="1" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center">
|
||||
<TextView
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/prompt_password" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:maxLines="1"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/prompt_login"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/cancel"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
Loading…
Reference in new issue