commit
1b80de9aef
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WizardSettings">
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="vectorWizard">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="vectorAssetStep">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="clipartAsset">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="url" value="jar:file:/D:/Android%20Studio/plugins/android/lib/android.jar!/images/material/icons/materialicons/delete/baseline_delete_24.xml" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="outputName" value="ic_delete" />
|
||||
<entry key="sourceFile" value="D:\gitnote\notes" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
#Mon Dec 30 21:15:38 CST 2024
|
||||
#Wed Jan 08 10:29:59 CST 2025
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,20 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "net.micode.notes",
|
||||
"variantName": "debug",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "0.1",
|
||||
"outputFile": "app-debug.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package net.micode.notes.login;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.micode.notes.R;
|
||||
import net.micode.notes.data.NotesDatabaseHelper;
|
||||
|
||||
public class UserListAdapter extends BaseAdapter {
|
||||
|
||||
private Context context;
|
||||
private Cursor cursor;
|
||||
private NotesDatabaseHelper dbHelper;
|
||||
|
||||
public UserListAdapter(Context context, Cursor cursor, NotesDatabaseHelper dbHelper) {
|
||||
this.context = context;
|
||||
this.cursor = cursor;
|
||||
this.dbHelper = dbHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return cursor.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
cursor.moveToPosition(position);
|
||||
return cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
cursor.moveToPosition(position);
|
||||
return cursor.getLong(cursor.getColumnIndex("id"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(context).inflate(R.layout.item_user, parent, false);
|
||||
}
|
||||
|
||||
TextView usernameTextView = (TextView) convertView.findViewById(R.id.text_username);
|
||||
Button deleteButton = (Button) convertView.findViewById(R.id.btn_delete_user);
|
||||
|
||||
if (cursor.moveToPosition(position)) {
|
||||
String username = cursor.getString(cursor.getColumnIndex("username"));
|
||||
usernameTextView.setText(username);
|
||||
|
||||
deleteButton.setOnClickListener(v -> {
|
||||
dbHelper.deleteUser(username);
|
||||
Toast.makeText(context, "用户已删除", Toast.LENGTH_SHORT).show();
|
||||
cursor.requery(); // 刷新数据
|
||||
notifyDataSetChanged(); // 更新列表
|
||||
});
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,73 @@
|
||||
package net.micode.notes.login;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
|
||||
import net.micode.notes.R;
|
||||
import net.micode.notes.data.NotesDatabaseHelper;
|
||||
|
||||
public class UserManagementActivity extends Activity {
|
||||
|
||||
private NotesDatabaseHelper dbHelper;
|
||||
private ListView userListView;
|
||||
private UserListAdapter userListAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_user_management);
|
||||
|
||||
dbHelper = new NotesDatabaseHelper(this);
|
||||
|
||||
userListView = (ListView) findViewById(R.id.list_view_users);
|
||||
|
||||
loadUsers();
|
||||
|
||||
findViewById(R.id.btn_add_user).setOnClickListener(v -> showAddUserDialog());
|
||||
}
|
||||
|
||||
private void loadUsers() {
|
||||
Cursor cursor = dbHelper.getAllUsers();
|
||||
userListAdapter = new UserListAdapter(this, cursor, dbHelper);
|
||||
userListView.setAdapter(userListAdapter);
|
||||
}
|
||||
|
||||
private void showAddUserDialog() {
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.dialog_add_user, null);
|
||||
EditText usernameInput = (EditText) view.findViewById(R.id.input_username);
|
||||
EditText passwordInput = (EditText) view.findViewById(R.id.input_password);
|
||||
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("添加用户")
|
||||
.setView(view)
|
||||
.setPositiveButton("添加", (dialog, which) -> {
|
||||
String username = usernameInput.getText().toString();
|
||||
String password = passwordInput.getText().toString();
|
||||
|
||||
if (TextUtils.isEmpty(username) || TextUtils.isEmpty(password)) {
|
||||
Toast.makeText(this, "用户名和密码不能为空", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
long result = dbHelper.addUser(username, password);
|
||||
if (result != -1) {
|
||||
Toast.makeText(this, "用户添加成功", Toast.LENGTH_SHORT).show();
|
||||
loadUsers();
|
||||
} else {
|
||||
Toast.makeText(this, "添加失败,用户名可能已存在", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton("取消", null)
|
||||
.show();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue