master
user 2 months ago
parent 98fdb39a57
commit 365cafeb92

@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties

@ -0,0 +1,3 @@
# 默认忽略的文件
/shelf/
/workspace.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="21" />
</component>
</project>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-06-17T08:30:34.414931500Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\31671\.android\avd\Pixel_Fold_API_34.avd" />
</handle>
</Target>
</DropdownSelection>
<DialogSelection />
</SelectionState>
</selectionStates>
</component>
</project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveExternalAnnotations" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="1.8.10" />
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>

@ -0,0 +1,9 @@
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
</set>
</option>
</component>
</project>

@ -0,0 +1 @@
/build

@ -0,0 +1,35 @@
plugins {
id("com.android.application")
kotlin("android")
}
android {
namespace = "com.example.ruanjian"
compileSdk = 33
defaultConfig {
applicationId = "com.example.ruanjian"
minSdk = 21
targetSdk = 33
versionCode = 1
versionName = "1.0"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10")
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.9.0")
implementation("androidx.recyclerview:recyclerview:1.3.0")
}

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

@ -0,0 +1,26 @@
package com.example.ruanjian;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.ruanjian", appContext.getPackageName());
}
}

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ruanjian">
<!-- 新增通知权限 -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <!-- 新增精确闹钟权限(用于Android 12+) -->
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" /> <!-- 新增唤醒锁定权限(可选,确保设备休眠时也能提醒) -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="SimpleToDo"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Ruanjian">
<meta-data
android:name="com.google.android.actions"
android:resource="@xml/styles" />
<!-- 原有Activity声明保持不变 -->
<activity android:name=".DetailActivity" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <!-- 新增广播接收器,用于处理提醒 -->
<receiver
android:name=".ReminderReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver> <!-- 新增Application类声明(用于初始化通知渠道) -->
<activity android:name=".AddTaskActivity" />
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 KiB

@ -0,0 +1,32 @@
package com.example.ruanjian;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
public class AddTaskActivity extends AppCompatActivity {
private EditText editTextTask;
private Button btnSave;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_task);
editTextTask = findViewById(R.id.editTextTask);
btnSave = findViewById(R.id.btnSave);
btnSave.setOnClickListener(v -> {
String content = editTextTask.getText().toString().trim();
if (!content.isEmpty()) {
// 新建 Task 对象,默认优先级为 "中"
Task task = new Task(content, "中");
MainActivity.taskList.add(task); // 添加 Task 对象
}
finish(); // 关闭当前页面,返回主界面
});
}
}

@ -0,0 +1,201 @@
package com.example.ruanjian;
import android.app.AlarmManager;
import android.app.DatePickerDialog;
import android.app.PendingIntent;
import android.app.TimePickerDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ArrayAdapter;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class DetailActivity extends AppCompatActivity {
private EditText editTextTaskDetail;
private Spinner spinnerPriority;
private Button buttonSave, buttonDelete, buttonCancel, btnSetDeadline;
private TextView tvDeadline;
private int taskIndex = -1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
// 初始化原有视图
editTextTaskDetail = findViewById(R.id.editTextTaskDetail);
spinnerPriority = findViewById(R.id.spinnerPriority);
buttonSave = findViewById(R.id.buttonSave);
buttonDelete = findViewById(R.id.buttonDelete);
buttonCancel = findViewById(R.id.buttonCancel);
// 初始化新增视图
btnSetDeadline = findViewById(R.id.btnSetDeadline);
tvDeadline = findViewById(R.id.tvDeadline);
// 原有优先级下拉列表设置
ArrayAdapter<String> priorityAdapter = new ArrayAdapter<>(
this,
android.R.layout.simple_spinner_item,
new String[]{"高", "中", "低"});
priorityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerPriority.setAdapter(priorityAdapter);
// 原有任务数据加载
taskIndex = getIntent().getIntExtra("index", -1);
if (taskIndex != -1 && taskIndex < MainActivity.taskList.size()) {
Task task = MainActivity.taskList.get(taskIndex);
editTextTaskDetail.setText(task.getContent());
// 原有优先级设置
int spinnerPos = priorityAdapter.getPosition(task.getPriority());
spinnerPriority.setSelection(spinnerPos);
// 新增截止时间显示
if (task.getDeadline() != null) {
tvDeadline.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(task.getDeadline()));
}
} else {
Toast.makeText(this, "任务不存在", Toast.LENGTH_SHORT).show();
finish();
}
// 原有按钮点击事件
buttonSave.setOnClickListener(v -> {
String newContent = editTextTaskDetail.getText().toString().trim();
String newPriority = spinnerPriority.getSelectedItem().toString();
if (!newContent.isEmpty()) {
Task originalTask = MainActivity.taskList.get(taskIndex);
Task updatedTask = new Task(newContent, newPriority);
// 保留原有创建时间和完成状态
updatedTask.setCreateTime(originalTask.getCreateTime());
updatedTask.setCompleted(originalTask.isCompleted());
// 保留新增的截止时间和提醒设置
updatedTask.setDeadline(originalTask.getDeadline());
updatedTask.setHasReminder(originalTask.hasReminder());
MainActivity.taskList.set(taskIndex, updatedTask);
Toast.makeText(DetailActivity.this, "任务已保存", Toast.LENGTH_SHORT).show();
finish();
} else {
Toast.makeText(DetailActivity.this, "任务内容不能为空", Toast.LENGTH_SHORT).show();
}
});
buttonDelete.setOnClickListener(v -> {
MainActivity.taskList.remove(taskIndex);
Toast.makeText(DetailActivity.this, "任务已删除", Toast.LENGTH_SHORT).show();
finish();
});
buttonCancel.setOnClickListener(v -> {
Toast.makeText(DetailActivity.this, "已取消,未保存任务", Toast.LENGTH_SHORT).show();
finish();
});
// 新增截止时间设置按钮
btnSetDeadline.setOnClickListener(v -> showDateTimePicker());
}
// 新增方法:显示日期时间选择器
private void showDateTimePicker() {
final Calendar calendar = Calendar.getInstance();
Task currentTask = MainActivity.taskList.get(taskIndex);
// 如果已有截止时间,使用该时间初始化
if (currentTask.getDeadline() != null) {
calendar.setTime(currentTask.getDeadline());
}
// 先选择日期
new DatePickerDialog(
this,
(view, year, month, day) -> {
calendar.set(year, month, day);
// 再选择时间
new TimePickerDialog(
this,
(view1, hour, minute) -> {
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
// 设置截止时间
currentTask.setDeadline(calendar.getTime());
tvDeadline.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(calendar.getTime()));
// 询问是否设置提醒
showReminderDialog(currentTask);
},
calendar.get(Calendar.HOUR_OF_DAY),
calendar.get(Calendar.MINUTE),
true)
.show();
},
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH))
.show();
}
// 新增方法:显示提醒设置对话框
private void showReminderDialog(Task task) {
new AlertDialog.Builder(this)
.setTitle("设置提醒")
.setMessage("要在截止时间前15分钟提醒吗")
.setPositiveButton("是", (dialog, which) -> {
task.setHasReminder(true);
scheduleReminder(task);
Toast.makeText(this, "已设置提醒", Toast.LENGTH_SHORT).show();
})
.setNegativeButton("否", (dialog, which) -> {
task.setHasReminder(false);
cancelReminder(task);
})
.show();
}
// 新增方法:设置提醒
private void scheduleReminder(Task task) {
if (task.getDeadline() == null) return;
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent intent = new Intent(this, ReminderReceiver.class);
intent.putExtra("task_content", task.getContent());
PendingIntent pendingIntent = PendingIntent.getBroadcast(
this,
task.getContent().hashCode(),
intent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
// 截止时间前15分钟提醒
long reminderTime = task.getDeadline().getTime() - (15 * 60 * 1000);
alarmManager.setExact(AlarmManager.RTC_WAKEUP, reminderTime, pendingIntent);
}
// 新增方法:取消提醒
private void cancelReminder(Task task) {
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent intent = new Intent(this, ReminderReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
this,
task.getContent().hashCode(),
intent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
alarmManager.cancel(pendingIntent);
}
}

@ -0,0 +1,172 @@
package com.example.ruanjian;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.ArrayAdapter;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private TaskAdapter adapter;
private Button btnAddTask, btnSort;
private EditText editTextSearch;
private int currentSortType = 0; // 0=默认1=优先级2=时间
public static ArrayList<Task> taskList = new ArrayList<>();
private ArrayList<Task> filteredList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recyclerView);
btnAddTask = findViewById(R.id.btnAddTask);
btnSort = findViewById(R.id.btnSort);
editTextSearch = findViewById(R.id.editTextSearch);
adapter = new TaskAdapter(filteredList, position -> {
Task clickedTask = filteredList.get(position);
int realIndex = taskList.indexOf(clickedTask);
Intent intent = new Intent(MainActivity.this, DetailActivity.class);
intent.putExtra("index", realIndex);
startActivity(intent);
});
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
btnAddTask.setOnClickListener(v -> showAddTaskDialog());
btnSort.setOnClickListener(v -> showSortDialog());
editTextSearch.addTextChangedListener(new TextWatcher() {
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override public void onTextChanged(CharSequence s, int start, int before, int count) {
filterTasks(s.toString());
}
@Override public void afterTextChanged(Editable s) {}
});
filterTasks("");
}
private void filterTasks(String query) {
filteredList.clear();
for (Task task : taskList) {
if (task.getContent().toLowerCase().contains(query.toLowerCase())) {
filteredList.add(task);
}
}
applyCurrentSort();
adapter.notifyDataSetChanged();
}
private void applyCurrentSort() {
switch (currentSortType) {
case 1:
sortByPriority();
break;
case 2:
sortByCreateTime();
break;
default:
// 默认不排序
break;
}
}
private void sortByPriority() {
Collections.sort(filteredList, (t1, t2) -> {
int p1 = getPriorityValue(t1.getPriority());
int p2 = getPriorityValue(t2.getPriority());
return p2 - p1; // 降序
});
currentSortType = 1;
adapter.notifyDataSetChanged();
}
private void sortByCreateTime() {
Collections.sort(filteredList, (t1, t2) ->
t2.getCreateTime().compareTo(t1.getCreateTime())
);
currentSortType = 2;
adapter.notifyDataSetChanged();
}
private int getPriorityValue(String priority) {
switch (priority) {
case "高": return 3;
case "中": return 2;
case "低": return 1;
default: return 0;
}
}
private void showAddTaskDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("添加任务");
final EditText input = new EditText(this);
input.setHint("请输入任务内容");
input.setSingleLine();
input.setPadding(30, 20, 30, 20);
final Spinner prioritySpinner = new Spinner(this);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(
this, android.R.layout.simple_spinner_item,
new String[]{"高", "中", "低"});
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
prioritySpinner.setAdapter(spinnerAdapter);
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setPadding(30, 20, 30, 10);
layout.addView(input);
layout.addView(prioritySpinner);
builder.setView(layout);
builder.setPositiveButton("确定", (dialog, which) -> {
String content = input.getText().toString().trim();
String priority = prioritySpinner.getSelectedItem().toString();
if (!content.isEmpty()) {
taskList.add(new Task(content, priority));
filterTasks(editTextSearch.getText().toString());
}
});
builder.setNegativeButton("取消", null);
builder.show();
}
private void showSortDialog() {
new AlertDialog.Builder(this)
.setTitle("排序方式")
.setItems(new String[]{"默认顺序", "按优先级排序", "按创建时间排序"}, (dialog, which) -> {
currentSortType = which;
applyCurrentSort();
})
.show();
}
@Override
protected void onResume() {
super.onResume();
filterTasks(editTextSearch.getText().toString());
}
}

@ -0,0 +1,11 @@
package com.example.ruanjian;
import android.app.Application;
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
NotificationHelper.createNotificationChannel(this);
}
}

@ -0,0 +1,41 @@
// NotificationHelper.java
package com.example.ruanjian;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Build;
import androidx.core.app.NotificationCompat;
public class NotificationHelper {
private static final String CHANNEL_ID = "task_reminder_channel";
public static void createNotificationChannel(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID,
"Task Reminders",
NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("Channel for task reminder notifications");
NotificationManager manager = context.getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
}
}
public static void showNotification(Context context, String title, String content) {
Notification notification = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(title)
.setContentText(content)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true)
.build();
NotificationManager manager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify((int) System.currentTimeMillis(), notification);
}
}

@ -0,0 +1,17 @@
// ReminderReceiver.java
package com.example.ruanjian;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class ReminderReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String taskContent = intent.getStringExtra("task_content");
NotificationHelper.showNotification(
context,
"任务提醒",
"您的任务 '" + taskContent + "' 即将到期!");
}
}

@ -0,0 +1,79 @@
package com.example.ruanjian;
import java.util.Date;
public class Task {
private String content;
private String priority; // "高", "中", "低"
private boolean completed;
private Date createTime;
private Date deadline; // 新增截止时间
private boolean hasReminder; // 新增是否设置提醒
public Task(String content, String priority) {
this.content = content;
this.priority = priority;
this.completed = false;
this.createTime = new Date();
this.deadline = null;
this.hasReminder = false;
}
// 原有方法
public String getContent() {
return content;
}
public String getPriority() {
return priority;
}
public boolean isCompleted() {
return completed;
}
public Date getCreateTime() {
return createTime;
}
public void setContent(String content) {
this.content = content;
}
public void setPriority(String priority) {
this.priority = priority;
}
public void setCompleted(boolean completed) {
this.completed = completed;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
// 新增方法
public Date getDeadline() {
return deadline;
}
public void setDeadline(Date deadline) {
this.deadline = deadline;
}
public boolean hasReminder() {
return hasReminder;
}
public void setHasReminder(boolean hasReminder) {
this.hasReminder = hasReminder;
}
// 新增辅助方法
public String getFormattedDeadline() {
if (deadline == null) {
return "未设置";
}
return new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm").format(deadline);
}
}

@ -0,0 +1,114 @@
package com.example.ruanjian;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
public class TaskAdapter extends RecyclerView.Adapter<TaskAdapter.TaskViewHolder> {
private ArrayList<Task> taskList;
private OnItemClickListener listener;
public interface OnItemClickListener {
void onItemClick(int position);
}
public TaskAdapter(ArrayList<Task> taskList, OnItemClickListener listener) {
this.taskList = taskList;
this.listener = listener;
}
@NonNull
@Override
public TaskViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_task, parent, false);
return new TaskViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull TaskViewHolder holder, int position) {
Task task = taskList.get(position);
holder.textViewTask.setText(task.getContent());
// 先移除监听,避免复用导致多次触发
holder.checkBoxCompleted.setOnCheckedChangeListener(null);
holder.checkBoxCompleted.setChecked(task.isCompleted());
if (task.isCompleted()) {
holder.textViewTask.setPaintFlags(holder.textViewTask.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
holder.textViewTask.setTextColor(Color.GRAY);
} else {
holder.textViewTask.setPaintFlags(holder.textViewTask.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
switch (task.getPriority()) {
case "高":
holder.textViewTask.setTextColor(Color.RED);
break;
case "中":
holder.textViewTask.setTextColor(Color.parseColor("#FF9800")); // 橙色
break;
case "低":
holder.textViewTask.setTextColor(Color.parseColor("#4CAF50")); // 绿色
break;
default:
holder.textViewTask.setTextColor(Color.BLACK);
break;
}
}
// 重新设置监听,避免闪退
holder.checkBoxCompleted.setOnCheckedChangeListener((buttonView, isChecked) -> {
task.setCompleted(isChecked);
// 直接更新UI不调用 notifyItemChanged(position)
if (isChecked) {
holder.textViewTask.setPaintFlags(holder.textViewTask.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
holder.textViewTask.setTextColor(Color.GRAY);
} else {
holder.textViewTask.setPaintFlags(holder.textViewTask.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
switch (task.getPriority()) {
case "高":
holder.textViewTask.setTextColor(Color.RED);
break;
case "中":
holder.textViewTask.setTextColor(Color.parseColor("#FF9800"));
break;
case "低":
holder.textViewTask.setTextColor(Color.parseColor("#4CAF50"));
break;
default:
holder.textViewTask.setTextColor(Color.BLACK);
break;
}
}
});
holder.itemView.setOnClickListener(v -> listener.onItemClick(position));
}
@Override
public int getItemCount() {
return taskList.size();
}
static class TaskViewHolder extends RecyclerView.ViewHolder {
TextView textViewTask;
CheckBox checkBoxCompleted;
public TaskViewHolder(@NonNull View itemView) {
super(itemView);
textViewTask = itemView.findViewById(R.id.textViewTask);
checkBoxCompleted = itemView.findViewById(R.id.checkBoxCompleted);
}
}
}

@ -0,0 +1,62 @@
package com.example.ruanjian;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
public class ToDoAdapter extends RecyclerView.Adapter<ToDoAdapter.ViewHolder> {
private ArrayList<ToDoItem> todoList;
public ToDoAdapter(ArrayList<ToDoItem> todoList) {
this.todoList = todoList;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView todoText;
public CardView card;
public ViewHolder(View view) {
super(view);
todoText = view.findViewById(R.id.todoText);
card = view.findViewById(R.id.cardView);
}
}
@Override
public ToDoAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_todo, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
ToDoItem item = todoList.get(position);
holder.todoText.setText(item.getText());
if (item.isDone()) {
holder.todoText.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
holder.card.setCardBackgroundColor(0xFFE0E0E0); // 灰色
} else {
holder.todoText.setPaintFlags(0);
holder.card.setCardBackgroundColor(0xFFFFFFFF); // 白色
}
holder.itemView.setOnClickListener(v -> {
item.toggleDone();
notifyItemChanged(position);
});
}
@Override
public int getItemCount() {
return todoList.size();
}
}

@ -0,0 +1,23 @@
package com.example.ruanjian;
public class ToDoItem {
private String text;
private boolean isDone;
public ToDoItem(String text) {
this.text = text;
this.isDone = false;
}
public String getText() {
return text;
}
public boolean isDone() {
return isDone;
}
public void toggleDone() {
this.isDone = !this.isDone;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<gradient xmlns:android="http://schemas.android.com/apk/res/android"
android:startColor="#4A148C"
android:endColor="#7B1FA2"
android:angle="45"/>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners android:radius="12dp"/>
<padding
android:left="12dp"
android:top="12dp"
android:right="12dp"
android:bottom="12dp" />
</shape>

@ -0,0 +1,14 @@
<?xml version ="1.0" encoding ="utf-8"?><!-- Learn More about how to use App Actions: https://developer.android.com/guide/actions/index.html -->
<!-- res/drawable/dialog_bg.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 圆角 + 渐变背景 -->
<corners android:radius="16dp" />
<gradient
android:startColor="#FF6B6B"
android:endColor="#FFA3A3"
android:angle="45" />
<stroke
android:width="1dp"
android:color="#80FFFFFF" />
</shape>

@ -0,0 +1,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<corners android:radius="10dp" />
<stroke android:width="1dp" android:color="#CCCCCC" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>

@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF">
<path
android:fillColor="@android:color/white"
android:pathData="M18,17v-6c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.93 6,11v6l-2,2v1h16v-1l-2,-2zM12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
android:background="@drawable/gu">
<EditText
android:id="@+id/editTextTask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入任务内容"
android:padding="12dp"
android:background="@android:drawable/editbox_background" />
<Button
android:id="@+id/btnSave"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="保存任务"
android:layout_marginTop="20dp"
android:background="#4CAF50"
android:textColor="#FFFFFF" />
</LinearLayout>

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gu"
android:orientation="vertical"
android:padding="20dp">
<EditText
android:id="@+id/editTextTaskDetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:background="#E8D5D5"
android:hint="请输入任务内容"
android:padding="16dp"
android:textColor="#212121"
android:textSize="18sp" />
<Spinner
android:id="@+id/spinnerPriority"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp" />
<Button
android:id="@+id/btnSetDeadline"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:backgroundTint="#E8F5E9"
android:text="⏰ 设置截止时间"
android:textColor="#222121"
android:textSize="18sp" />
<TextView
android:id="@+id/tvDeadline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:padding="8dp"
android:text="未设置截止时间"
android:textColor="#757575" />
<Button
android:id="@+id/buttonSave"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:background="#4CAF50"
android:padding="12dp"
android:text="💾 保存修改"
android:textAllCaps="false"
android:textColor="#FFFFFF" />
<Button
android:id="@+id/buttonDelete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:background="#F44336"
android:padding="12dp"
android:text="🗑 删除任务"
android:textAllCaps="false"
android:textColor="#FFFFFF" />
<Button
android:id="@+id/buttonCancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E0E0E0"
android:padding="12dp"
android:text="❌ 取消返回"
android:textAllCaps="false"
android:textColor="#333333" />
</LinearLayout>

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_main"
tools:context=".MainActivity">
<!-- 标题和排序按钮 -->
<LinearLayout
android:id="@+id/titleLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_marginTop="32dp">
<TextView
android:id="@+id/titleTextView"
android:layout_width="226dp"
android:layout_height="match_parent"
android:background="@drawable/gou"
android:fontFamily="sans-serif-medium"
android:text="我的任务列表"
android:gravity="center"
android:textColor="#0E0D0D"
android:textSize="24sp" />
<Button
android:id="@+id/btnSort"
android:layout_width="150dp"
android:layout_height="35dp"
android:layout_marginStart="24dp"
android:background="@drawable/gou"
android:text="排序"
android:textColor="#141313"
android:textSize="24sp" />
</LinearLayout>
<!-- 搜索输入框 -->
<!-- RecyclerView 显示任务 -->
<EditText
android:id="@+id/editTextSearch"
android:layout_width="700dp"
android:layout_height="65dp"
android:layout_below="@id/titleLayout"
android:layout_centerHorizontal="true"
android:layout_marginLeft="7dp"
android:layout_marginTop="17dp"
android:layout_marginRight="16dp"
android:background="@drawable/wa"
android:hint=""
android:inputType="text"
android:padding="10dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@id/editTextSearch"
android:layout_above="@id/btnAddTask"
android:layout_marginTop="8dp"
android:padding="16dp"
android:clipToPadding="false" />
<!-- 添加任务按钮 -->
<Button
android:id="@+id/btnAddTask"
android:layout_width="298dp"
android:layout_height="66dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:background="@drawable/an"
android:elevation="4dp"
android:minWidth="150dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="添加任务"
android:textAllCaps="false"
android:textColor="#191717"
android:tint="@null" />
</RelativeLayout>

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp"
android:background="#F5F5F5"
android:layout_marginBottom="8dp">
<CheckBox
android:id="@+id/checkBoxCompleted"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:focusable="false"
android:focusableInTouchMode="false"
/>
<TextView
android:id="@+id/textViewTask"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#212121"
android:layout_weight="1"
android:padding="12dp" />
</LinearLayout>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
card_view:cardElevation="4dp"
card_view:cardCornerRadius="12dp"
android:padding="12dp">
<TextView
android:id="@+id/todoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="@android:color/black" />
</androidx.cardview.widget.CardView>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

@ -0,0 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.Ruanjian" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your dark theme here. -->
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
</style>
</resources>

@ -0,0 +1,7 @@
<resources>
<string-array name="priority_array">
<item></item>
<item></item>
<item></item>
</string-array>
</resources>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="dialogBg">#FF6B6B</color>
<color name="dialogText">#C71C1C</color>
</resources>

@ -0,0 +1,3 @@
<resources>
<string name="app_name">ruanjian</string>
</resources>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SortDialogTheme">sm</style>
</resources>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Ruanjian" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#6200EE</item>
<item name="colorPrimaryDark">#3700B3</item>
<item name="colorAccent">#03DAC5</item>
</style>
</resources>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>

@ -0,0 +1,14 @@
<?xml version ="1.0" encoding ="utf-8"?><!-- Learn More about how to use App Actions: https://developer.android.com/guide/actions/index.html -->
<!-- res/values/styles.xml -->
<resources>
<!-- 基础主题 -->
<style name="MyDialogTheme" parent="Theme.MaterialComponents.Dialog">
<!-- 背景颜色 -->
<item name="android:windowBackground">@color/dialog_background</item>
<!-- 标题文字颜色 -->
<item name="android:textColorPrimary">@color/dialog_text_primary</item>
<!-- 按钮颜色 -->
<item name="colorPrimary">@color/button_primary</item>
<item name="colorOnPrimary">@color/white</item>
</style>
</resources>

@ -0,0 +1,17 @@
package com.example.ruanjian;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

@ -0,0 +1,4 @@
plugins {
kotlin("android") version "1.8.10" apply false
id("com.android.application") version "8.1.0" apply false
}

@ -0,0 +1,21 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

@ -0,0 +1,22 @@
[versions]
agp = "8.7.2"
junit = "4.13.2"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
appcompat = "1.6.1"
material = "1.10.0"
activity = "1.8.0"
constraintlayout = "2.1.4"
[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }

Binary file not shown.

@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

185
doc/ruanjian/gradlew vendored

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

@ -0,0 +1,18 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "ruanjian"
include(":app")

Binary file not shown.
Loading…
Cancel
Save