diff --git a/.gitignore b/.gitignore index 39b6783..aa724b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,65 +1,15 @@ -# Built application files -*.apk -*.ap_ - -# Files for the ART/Dalvik VM -*.dex - -# Java class files -*.class - -# Generated files -bin/ -gen/ -out/ - -# Gradle files -.gradle/ -build/ - -# Local configuration file (sdk path, etc) -local.properties - -# Proguard folder generated by Eclipse -proguard/ - -# Log Files -*.log - -# Android Studio Navigation editor temp files -.navigation/ - -# Android Studio captures folder -captures/ - -# IntelliJ *.iml -.idea/workspace.xml -.idea/tasks.xml -.idea/gradle.xml -.idea/assetWizardSettings.xml -.idea/dictionaries -.idea/libraries -.idea/caches - -# Keystore files -# Uncomment the following line if you do not want to check your keystore files in. -#*.jks - -# External native build folder generated in Android Studio 2.2 and later +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures .externalNativeBuild - -# Google Services (e.g. APIs or Firebase) -google-services.json - -# Freeline -freeline.py -freeline/ -freeline_project_description.json - -# fastlane -fastlane/report.xml -fastlane/Preview.html -fastlane/screenshots -fastlane/test_output -fastlane/readme.md +.cxx +local.properties diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..fee9790 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +schedule \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..e58d3e4 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..366eb33 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,26 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 3963879..bde23a4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,30 +1,47 @@ - + - + diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 22eec71..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..8306744 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,7 @@ + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 1cf7442..22dcd18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,14 +1,16 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 26 + namespace = "com.example.can301.things" + compileSdk 33 + defaultConfig { - applicationId "com.example.yzbkaka.things" - minSdkVersion 15 - targetSdkVersion 26 + applicationId "com.example.can301.things" + minSdk 26 +// targetSdkVersion 26 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { release { @@ -16,18 +18,36 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + dependenciesInfo { + includeInApk false + includeInBundle false + } + buildFeatures { + viewBinding true + } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:26.0.0-beta1' - implementation 'com.android.support.constraint:constraint-layout:1.0.2' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:0.5' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2' - compile 'com.android.support:design:26.1.0' - compile 'com.android.support:recyclerview-v7:26.1.0' - compile 'com.android.support:cardview-v7:26.1.0' + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.lifecycle:lifecycle-livedata:2.0.0' + implementation 'androidx.lifecycle:lifecycle-viewmodel:2.0.0' + implementation 'androidx.navigation:navigation-fragment:2.0.0-rc02' + implementation 'androidx.navigation:navigation-ui:2.0.0-rc02' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.0.0' + implementation 'androidx.cardview:cardview:1.0.0' implementation 'org.litepal.android:java:3.0.0' - compile 'com.prolificinteractive:material-calendarview:1.4.3' +// implementation 'com.pr7olificinteractive:material-calendarview:1.4.3' + implementation 'com.prolificinteractive:material-calendarview:1.4.3' + //MPAndroidChart + implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") } diff --git a/app/release/output.json b/app/release/output.json index 329172d..3327710 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.example.yzbkaka.things","split":"","minSdkVersion":"15"}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.example.can301.things","split":"","minSdkVersion":"15"}}] \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/yzbkaka/things/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/can301/things/ExampleInstrumentedTest.java similarity index 53% rename from app/src/androidTest/java/com/example/yzbkaka/things/ExampleInstrumentedTest.java rename to app/src/androidTest/java/com/example/can301/things/ExampleInstrumentedTest.java index 8823b60..c5bd871 100644 --- a/app/src/androidTest/java/com/example/yzbkaka/things/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/com/example/can301/things/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ -package com.example.yzbkaka.things; +package com.example.can301.things; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,8 +19,9 @@ public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); +// Context appContext = InstrumentationRegistry.getTargetContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.example.yzbkaka.things", appContext.getPackageName()); + assertEquals("com.example.can301.things", appContext.getPackageName()); } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b8aa198..eb7a713 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,10 @@ + package="com.example.can301.things"> + + - - + + - + - - - - + + + + - + + + + + + - + - + + + - \ No newline at end of file diff --git a/app/src/main/assets/Litepal.xml b/app/src/main/assets/Litepal.xml index 6a24fb0..ed1f7a9 100644 --- a/app/src/main/assets/Litepal.xml +++ b/app/src/main/assets/Litepal.xml @@ -1,10 +1,11 @@ - + - - + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/yzbkaka/things/ActivityCollector.java b/app/src/main/java/com/example/can301/things/ActivityCollector.java similarity index 87% rename from app/src/main/java/com/example/yzbkaka/things/ActivityCollector.java rename to app/src/main/java/com/example/can301/things/ActivityCollector.java index 81d381a..c184fef 100644 --- a/app/src/main/java/com/example/yzbkaka/things/ActivityCollector.java +++ b/app/src/main/java/com/example/can301/things/ActivityCollector.java @@ -1,14 +1,10 @@ -package com.example.yzbkaka.things; +package com.example.can301.things; import android.app.Activity; import java.util.ArrayList; import java.util.List; -/** - * Created by yzbkaka on 19-5-5. - */ - public class ActivityCollector { public static List activities = new ArrayList<>(); diff --git a/app/src/main/java/com/example/yzbkaka/things/Adapter/HistoryAdapter.java b/app/src/main/java/com/example/can301/things/Adapter/HistoryAdapter.java similarity index 78% rename from app/src/main/java/com/example/yzbkaka/things/Adapter/HistoryAdapter.java rename to app/src/main/java/com/example/can301/things/Adapter/HistoryAdapter.java index b7e7486..28b9ae6 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Adapter/HistoryAdapter.java +++ b/app/src/main/java/com/example/can301/things/Adapter/HistoryAdapter.java @@ -1,20 +1,17 @@ -package com.example.yzbkaka.things.Adapter; +package com.example.can301.things.Adapter; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Plan; +import com.example.can301.things.R; +import com.example.can301.things.db.Plan; import java.util.List; -/** - * Created by yzbkaka on 19-4-12. - */ public class HistoryAdapter extends RecyclerView.Adapter { private List mDataList; @@ -40,7 +37,7 @@ public HistoryAdapter(List dataList){ @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){ - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.history_item,parent,false); //加载子项布局 + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.history_item,parent,false); //view object final ViewHolder holder = new ViewHolder(view); return holder; } @@ -49,7 +46,7 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){ @Override public void onBindViewHolder(ViewHolder holder , final int position){ Plan plan = mDataList.get(position); - holder.time.setText(plan.getMonth() + "月" + plan.getDay() + "日"); + holder.time.setText(plan.getMonth() + "month" + plan.getDay() + "day"); holder.history.setText(plan.getWritePlan()); } diff --git a/app/src/main/java/com/example/yzbkaka/things/Adapter/LogAdapter.java b/app/src/main/java/com/example/can301/things/Adapter/LogAdapter.java similarity index 89% rename from app/src/main/java/com/example/yzbkaka/things/Adapter/LogAdapter.java rename to app/src/main/java/com/example/can301/things/Adapter/LogAdapter.java index c717bed..9e6cbe9 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Adapter/LogAdapter.java +++ b/app/src/main/java/com/example/can301/things/Adapter/LogAdapter.java @@ -1,8 +1,8 @@ -package com.example.yzbkaka.things.Adapter; +package com.example.can301.things.Adapter; import android.content.Intent; -import android.support.v7.widget.CardView; -import android.support.v7.widget.RecyclerView; +import androidx.cardview.widget.CardView; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -10,20 +10,17 @@ import android.widget.ImageView; import android.widget.TextView; -import com.example.yzbkaka.things.Log.AlterLogActivity; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Log; +import com.example.can301.things.Log.AlterLogActivity; +import com.example.can301.things.R; +import com.example.can301.things.db.Log; import org.litepal.LitePal; import java.util.List; -import static com.example.yzbkaka.things.Log.LogActivity.logAdapter; +import static com.example.can301.things.Log.LogActivity.logAdapter; -/** - * Created by yzbkaka on 19-4-7. - */ public class LogAdapter extends RecyclerView.Adapter { private List mLogList; diff --git a/app/src/main/java/com/example/can301/things/Adapter/RecordAdapter.java b/app/src/main/java/com/example/can301/things/Adapter/RecordAdapter.java new file mode 100644 index 0000000..d551812 --- /dev/null +++ b/app/src/main/java/com/example/can301/things/Adapter/RecordAdapter.java @@ -0,0 +1,60 @@ +package com.example.can301.things.Adapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.example.can301.things.db.UserRecord; +import com.example.can301.things.R; + +import java.util.List; + +public class RecordAdapter extends RecyclerView.Adapter{ + //导入需要处理的数据 + private List userRecords; + //创建构造方法 + public RecordAdapter(List userRecords) { + this.userRecords = userRecords; + } + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + // 使用 LayoutInflater 从布局文件中创建视图 + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user_record, parent, false); + return new ViewHolder(view); + } + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + UserRecord userRecord = userRecords.get(position); + // 将用户记录的属性设置到对应的 TextView 中 + holder.textViewAction.setText(userRecord.getActionDescription()); + holder.textViewDuration.setText(String.valueOf(userRecord.getDuration())); + holder.textViewCategory.setText(userRecord.getCategory()); + holder.textViewTime.setText(userRecord.getYear()+"Year"+userRecord.getMonth() + "Month"+ userRecord.getDay()+"Day" ); +// holder.textViewTime.setText(userRecord.getCreateTime()); + } + @Override + public int getItemCount() { + return userRecords.size(); + } + public static class ViewHolder extends RecyclerView.ViewHolder { + TextView textViewAction; + TextView textViewDuration; + TextView textViewCategory; + TextView textViewTime; + public ViewHolder(View itemView) { + super(itemView); + textViewAction = itemView.findViewById(R.id.textViewAction); + textViewDuration = itemView.findViewById(R.id.textViewDuration); + textViewCategory = itemView.findViewById(R.id.textViewCategory); + textViewTime = itemView.findViewById(R.id.time); + } + } + + + +} diff --git a/app/src/main/java/com/example/yzbkaka/things/Adapter/ScheduleAdapter.java b/app/src/main/java/com/example/can301/things/Adapter/ScheduleAdapter.java similarity index 62% rename from app/src/main/java/com/example/yzbkaka/things/Adapter/ScheduleAdapter.java rename to app/src/main/java/com/example/can301/things/Adapter/ScheduleAdapter.java index f76b83b..a3ae5db 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Adapter/ScheduleAdapter.java +++ b/app/src/main/java/com/example/can301/things/Adapter/ScheduleAdapter.java @@ -1,28 +1,25 @@ -package com.example.yzbkaka.things.Adapter; +package com.example.can301.things.Adapter; import android.content.Intent; -import android.support.v7.widget.RecyclerView; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.Schedule.AlterScheduleActivity; -import com.example.yzbkaka.things.Today.AlterTodayActivity; -import com.example.yzbkaka.things.db.Plan; +import com.example.can301.things.R; +import com.example.can301.things.Schedule.AlterScheduleActivity; +import com.example.can301.things.db.Plan; import org.litepal.LitePal; import java.util.List; -import static com.example.yzbkaka.things.Schedule.ScheduleViewActivity.scheduleAdapter; +import static com.example.can301.things.Schedule.ScheduleViewActivity.scheduleAdapter; + +import androidx.recyclerview.widget.RecyclerView; -/** - * Created by yzbkaka on 19-4-13. - */ public class ScheduleAdapter extends RecyclerView.Adapter { private List mDataList; @@ -32,16 +29,17 @@ static class ViewHolder extends RecyclerView.ViewHolder{ TextView schedule; ImageView kuang; TextView time; - Button delete; - + ImageView alt_finish; + ImageView delete_schedule; public ViewHolder(View view){ super(view); scheduleView = view; schedule = (TextView)view.findViewById(R.id.schedule_plan); kuang = (ImageView)view.findViewById(R.id.kuang); + delete_schedule = (ImageView)view.findViewById(R.id.delete_schedule); + alt_finish = (ImageView)view.findViewById(R.id.alt_finish); time = (TextView)view.findViewById(R.id.schedule_time); - delete = (Button)view.findViewById(R.id.delete_schedule); } } @@ -62,9 +60,15 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){ @Override public void onBindViewHolder(final ViewHolder holder , final int position){ Plan plan = mDataList.get(position); - holder.time.setText(plan.getMonth() + "月" + plan.getDay() + "日"); + holder.time.setText(plan.getMonth() + "Month" + plan.getDay() + "Day"); holder.schedule.setText(plan.getWritePlan()); + if(mDataList.get(position).getStatus() == false){ + holder.kuang.setImageResource(R.drawable.no); + }else { + holder.kuang.setImageResource(R.drawable.yes); + } + holder.scheduleView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -77,27 +81,32 @@ public void onClick(View view) { } }); - holder.scheduleView.setOnLongClickListener(new View.OnLongClickListener() { + holder.delete_schedule.setOnClickListener(new View.OnClickListener() { @Override - public boolean onLongClick(View view) { - holder.delete.setVisibility(View.VISIBLE); - return true; + public void onClick(View v) { + int scheduleDeletePosition = holder.getAdapterPosition(); + Plan scheduleDeletePlan = mDataList.get(scheduleDeletePosition); + String scheduleDeletePlanWrite = scheduleDeletePlan.getWritePlan(); + mDataList.remove(scheduleDeletePosition); + scheduleAdapter.notifyDataSetChanged(); + LitePal.deleteAll(Plan.class,"writePlan = ?",scheduleDeletePlanWrite); } }); - - holder.delete.setOnClickListener(new View.OnClickListener() { + holder.alt_finish.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(View v) { int scheduleDeletePosition = holder.getAdapterPosition(); Plan scheduleDeletePlan = mDataList.get(scheduleDeletePosition); String scheduleDeletePlanWrite = scheduleDeletePlan.getWritePlan(); - mDataList.remove(scheduleDeletePosition); + mDataList.get(scheduleDeletePosition).setStatus(true); scheduleAdapter.notifyDataSetChanged(); - LitePal.deleteAll(Plan.class,"writePlan = ?",scheduleDeletePlanWrite); - holder.delete.setVisibility(View.INVISIBLE); + Plan plan = new Plan(); + plan.setStatus(true); + plan.updateAll("writePlan = ?",scheduleDeletePlanWrite); } }); + } diff --git a/app/src/main/java/com/example/yzbkaka/things/Adapter/TodayAdapter.java b/app/src/main/java/com/example/can301/things/Adapter/TodayAdapter.java similarity index 66% rename from app/src/main/java/com/example/yzbkaka/things/Adapter/TodayAdapter.java rename to app/src/main/java/com/example/can301/things/Adapter/TodayAdapter.java index 9971a55..2e0373f 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Adapter/TodayAdapter.java +++ b/app/src/main/java/com/example/can301/things/Adapter/TodayAdapter.java @@ -1,9 +1,9 @@ -package com.example.yzbkaka.things.Adapter; +package com.example.can301.things.Adapter; import android.content.Intent; import android.os.Message; import android.provider.AlarmClock; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -13,12 +13,10 @@ import android.widget.ImageView; import android.widget.TextView; -import com.example.yzbkaka.things.DoubleClickListener; -import com.example.yzbkaka.things.MainActivity; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.Today.AlterTodayActivity; -import com.example.yzbkaka.things.Today.NoteActivity; -import com.example.yzbkaka.things.db.Plan; +import com.example.can301.things.DoubleClickListener; +import com.example.can301.things.R; +import com.example.can301.things.Today.AlterTodayActivity; +import com.example.can301.things.db.Plan; import java.util.List; @@ -29,17 +27,14 @@ import org.litepal.LitePal; -import static com.example.yzbkaka.things.MainActivity.todayCount; -import static com.example.yzbkaka.things.Today.NoteActivity.todayAdapter; +import static com.example.can301.things.MainActivity.todayCount; +import static com.example.can301.things.Today.NoteActivity.todayAdapter; -/** - * Created by yzbkaka on 19-4-4. - */ public class TodayAdapter extends RecyclerView.Adapter { private List mDataList; - private static int imagePosition; //将点击前面框框顺序的位置设置为静态变量 + private static int imagePosition; //Set the position of the clicked checkbox in the front as a static variable static class ViewHolder extends RecyclerView.ViewHolder{ View todayView; @@ -63,7 +58,7 @@ public TodayAdapter(List dataList){ @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){ - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.today_item,parent,false); //加载子项布局 + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.today_item,parent,false); //Load sub-item layout final ViewHolder holder = new ViewHolder(view); return holder; } @@ -74,14 +69,14 @@ public void onBindViewHolder(final ViewHolder holder , final int i){ final Plan plan = mDataList.get(i); holder.todayText.setText(plan.getWritePlan()); - final Handler handler = new Handler() { //异步消息处理机制来在非主线程中来修改UI + final Handler handler = new Handler() { //Asynchronous message handling mechanism to modify UI in non-main thread public void handleMessage(Message msg){ switch (msg.what){ case 1: - mDataList.remove(imagePosition); //将该Plan从列表中移除(此时数据库中的没有移除) - todayAdapter.notifyDataSetChanged(); //更新适配器以达到更新列表的效果 - holder.imageView.setImageResource(R.drawable.no); //将前面的框框换回成灰色 + mDataList.remove(imagePosition); //Remove the Plan from the list (there is no removal in the database at this time) + todayAdapter.notifyDataSetChanged(); //Update the adapter to update the list + holder.imageView.setImageResource(R.drawable.no); //Change the front box back to gray break; default: @@ -90,7 +85,7 @@ public void handleMessage(Message msg){ } }; - holder.todayView.setOnClickListener(new View.OnClickListener() { //当点击文字时会进入修改activity + holder.todayView.setOnClickListener(new View.OnClickListener() { //When you click the text, you enter the Modify activity @Override public void onClick(View view) { int writePosition = holder.getAdapterPosition(); @@ -103,60 +98,59 @@ public void onClick(View view) { }); - holder.imageView.setOnClickListener(new View.OnClickListener() { //当点击前面的勾选框时会改变勾选框的图片 + holder.imageView.setOnClickListener(new View.OnClickListener() { //When you click on the previous checkbox, the picture of the checkbox changes @Override public void onClick(View view) { imagePosition = holder.getAdapterPosition(); Plan ImagePlan = mDataList.get(imagePosition); - holder.imageView.setImageResource(R.drawable.yes); //切换图片 - ImagePlan.setStatus(true); //状态设置为完成 - ImagePlan.save(); //保存该状态 - todayCount--; //移除之后数量减1 + holder.imageView.setImageResource(R.drawable.yes); //Switch picture + ImagePlan.setStatus(true); //The status is set to Done + ImagePlan.save(); //Save the state + todayCount--; //After removal, the quantity is reduced by 1 - TimerTask task1 = new TimerTask() { //设置定时任务 + TimerTask task1 = new TimerTask() { //Setting a scheduled Task public void run() { Message message = new Message(); message.what = 1; - handler.sendMessage(message); //发送异步Message + handler.sendMessage(message); //Send asynchronous Message } }; Timer timer = new Timer(); - timer.schedule(task1, 800); //设置延时的时间,单位是毫秒 + timer.schedule(task1, 800); //Set the delay time in milliseconds - Animation animation = AnimationUtils.loadAnimation(view.getContext(),R.anim.today_anim); //设置动画 + Animation animation = AnimationUtils.loadAnimation(view.getContext(),R.anim.today_anim); //Set animation holder.todayView.startAnimation(animation); } }); - holder.todayView.setOnLongClickListener(new View.OnLongClickListener() { //长按机制 + holder.todayView.setOnLongClickListener(new View.OnLongClickListener() { //Long press mechanism @Override - public boolean onLongClick(View view) { //长按效果 - holder.delete.setVisibility(View.VISIBLE); //将删除按钮显示出来 + public boolean onLongClick(View view) { //Long press effect + holder.delete.setVisibility(View.VISIBLE); //The delete button is displayed return true; } }); - holder.todayView.setOnClickListener(new DoubleClickListener() { //双击事件 + holder.todayView.setOnClickListener(new DoubleClickListener() { //Double click event @Override public void onDoubleClick(View view) { - Intent alarmsIntent = new Intent(AlarmClock.ACTION_SET_ALARM); //调用系统闹钟 - view.getContext().startActivity(alarmsIntent); + Intent alarmsIntent = new Intent(AlarmClock.ACTION_SET_ALARM); //Call system alarm } }); holder.delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - int deletePosition = holder.getAdapterPosition(); //得到点击的顺序 + int deletePosition = holder.getAdapterPosition(); //Get the click order Plan deletePlan = mDataList.get(deletePosition); String deletePlanWrite = deletePlan.getWritePlan(); mDataList.remove(deletePosition); - todayCount--; //数量减少 - todayAdapter.notifyDataSetChanged(); //更新适配器 - LitePal.deleteAll(Plan.class,"writePlan = ?",deletePlanWrite); //将该条today删除 + todayCount--; //Decrease in number + todayAdapter.notifyDataSetChanged(); //Update adapter + LitePal.deleteAll(Plan.class,"writePlan = ?",deletePlanWrite); //Delete this article today TimerTask deleteTask = new TimerTask() { @@ -166,7 +160,7 @@ public void run() { } }; Timer deleteTimer = new Timer(); - deleteTimer.schedule(deleteTask,0); //一秒钟之后自动隐藏删除按钮 + deleteTimer.schedule(deleteTask,0); //The delete button is automatically hidden after one second } }); } diff --git a/app/src/main/java/com/example/yzbkaka/things/DoubleClickListener.java b/app/src/main/java/com/example/can301/things/DoubleClickListener.java similarity index 86% rename from app/src/main/java/com/example/yzbkaka/things/DoubleClickListener.java rename to app/src/main/java/com/example/can301/things/DoubleClickListener.java index 8525bd4..99869e8 100644 --- a/app/src/main/java/com/example/yzbkaka/things/DoubleClickListener.java +++ b/app/src/main/java/com/example/can301/things/DoubleClickListener.java @@ -1,10 +1,7 @@ -package com.example.yzbkaka.things; +package com.example.can301.things; import android.view.View; -/** - * Created by yzbkaka on 19-5-10. - */ public abstract class DoubleClickListener implements View.OnClickListener { diff --git a/app/src/main/java/com/example/yzbkaka/things/History/HistoryActivity.java b/app/src/main/java/com/example/can301/things/History/HistoryActivity.java similarity index 74% rename from app/src/main/java/com/example/yzbkaka/things/History/HistoryActivity.java rename to app/src/main/java/com/example/can301/things/History/HistoryActivity.java index 57537e0..45677cb 100644 --- a/app/src/main/java/com/example/yzbkaka/things/History/HistoryActivity.java +++ b/app/src/main/java/com/example/can301/things/History/HistoryActivity.java @@ -1,17 +1,17 @@ -package com.example.yzbkaka.things.History; +package com.example.can301.things.History; import android.os.Build; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.widget.Button; import android.widget.Toast; -import com.example.yzbkaka.things.Adapter.HistoryAdapter; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Plan; +import com.example.can301.things.Adapter.HistoryAdapter; +import com.example.can301.things.R; +import com.example.can301.things.db.Plan; import org.litepal.LitePal; @@ -45,20 +45,20 @@ public void onClick(View view) { } }); - clear.setOnClickListener(new View.OnClickListener() { //点击之后会清空列表 + clear.setOnClickListener(new View.OnClickListener() { //clear the list once clicked @Override public void onClick(View view) { - Toast.makeText(HistoryActivity.this, "清空!", Toast.LENGTH_SHORT).show(); + Toast.makeText(HistoryActivity.this, "now empty", Toast.LENGTH_SHORT).show(); historyList.clear(); - myAdapter.notifyDataSetChanged(); //适配器在每一次list更新的时候都需要进行一次更新 - LitePal.deleteAll(Plan.class,"status = ?","1"); //删除所有status为true的plan + myAdapter.notifyDataSetChanged(); //refresh the adapter each time the list is updated + LitePal.deleteAll(Plan.class,"status = ?","1"); //delete all the plans whose status is true from the database } }); if(dataList.size() > 0){ historyList.clear(); for(Plan plan : dataList){ - if(plan.getStatus() == true){ //如果状态是完成,则加入到历史列表当中 + if(plan.getStatus() == true){ //if the status is true(complete), then add to the historyList historyList.add(plan); } } diff --git a/app/src/main/java/com/example/yzbkaka/things/Log/AlterLogActivity.java b/app/src/main/java/com/example/can301/things/Log/AlterLogActivity.java similarity index 87% rename from app/src/main/java/com/example/yzbkaka/things/Log/AlterLogActivity.java rename to app/src/main/java/com/example/can301/things/Log/AlterLogActivity.java index b1345af..8e474e8 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Log/AlterLogActivity.java +++ b/app/src/main/java/com/example/can301/things/Log/AlterLogActivity.java @@ -1,16 +1,16 @@ -package com.example.yzbkaka.things.Log; +package com.example.can301.things.Log; import android.content.Intent; import android.os.Build; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Log; +import com.example.can301.things.R; +import com.example.can301.things.db.Log; import org.litepal.LitePal; @@ -50,7 +50,7 @@ public void onClick(View view) { else{ log.setLogWrite(newLog); log.updateAll("logWrite = ?",oldLog); //不能使用save的方法 - Toast.makeText(AlterLogActivity.this, "修改成功", Toast.LENGTH_SHORT).show(); + Toast.makeText(AlterLogActivity.this, "Updated successfully", Toast.LENGTH_SHORT).show(); } finish(); } diff --git a/app/src/main/java/com/example/yzbkaka/things/Log/LogActivity.java b/app/src/main/java/com/example/can301/things/Log/LogActivity.java similarity index 85% rename from app/src/main/java/com/example/yzbkaka/things/Log/LogActivity.java rename to app/src/main/java/com/example/can301/things/Log/LogActivity.java index 5057b65..b1ef8cc 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Log/LogActivity.java +++ b/app/src/main/java/com/example/can301/things/Log/LogActivity.java @@ -1,18 +1,18 @@ -package com.example.yzbkaka.things.Log; +package com.example.can301.things.Log; import android.content.Intent; import android.os.Build; -import android.support.design.widget.FloatingActionButton; -import android.support.v7.app.AppCompatActivity; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.StaggeredGridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; import android.view.View; import android.widget.Button; -import com.example.yzbkaka.things.Adapter.LogAdapter; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Log; +import com.example.can301.things.Adapter.LogAdapter; +import com.example.can301.things.R; +import com.example.can301.things.db.Log; import org.litepal.LitePal; diff --git a/app/src/main/java/com/example/yzbkaka/things/Log/LogCreateActivity.java b/app/src/main/java/com/example/can301/things/Log/LogCreateActivity.java similarity index 89% rename from app/src/main/java/com/example/yzbkaka/things/Log/LogCreateActivity.java rename to app/src/main/java/com/example/can301/things/Log/LogCreateActivity.java index 5b49c22..b451233 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Log/LogCreateActivity.java +++ b/app/src/main/java/com/example/can301/things/Log/LogCreateActivity.java @@ -1,14 +1,14 @@ -package com.example.yzbkaka.things.Log; +package com.example.can301.things.Log; import android.os.Build; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Log; +import com.example.can301.things.R; +import com.example.can301.things.db.Log; public class LogCreateActivity extends AppCompatActivity { private Button back; diff --git a/app/src/main/java/com/example/yzbkaka/things/MainActivity.java b/app/src/main/java/com/example/can301/things/MainActivity.java similarity index 70% rename from app/src/main/java/com/example/yzbkaka/things/MainActivity.java rename to app/src/main/java/com/example/can301/things/MainActivity.java index 72d27b2..d6a3f73 100644 --- a/app/src/main/java/com/example/yzbkaka/things/MainActivity.java +++ b/app/src/main/java/com/example/can301/things/MainActivity.java @@ -1,21 +1,22 @@ -package com.example.yzbkaka.things; +package com.example.can301.things; import android.content.Intent; import android.os.Build; -import android.support.v4.view.GravityCompat; -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import androidx.core.view.GravityCompat; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.appcompat.app.AppCompatActivity; import android.view.View; import android.widget.Button; - -import com.example.yzbkaka.things.History.HistoryActivity; -import com.example.yzbkaka.things.Log.LogActivity; -import com.example.yzbkaka.things.Schedule.ScheduleViewActivity; -import com.example.yzbkaka.things.Setting.SettingActivity; -import com.example.yzbkaka.things.Today.NoteActivity; +import com.example.can301.things.History.HistoryActivity; +import com.example.can301.things.Log.LogActivity; +import com.example.can301.things.Record.RecordActivity; +import com.example.can301.things.Schedule.ScheduleViewActivity; +import com.example.can301.things.Setting.SettingActivity; +import com.example.can301.things.Today.NoteActivity; +import com.example.can301.things.Tomato.TomatoActivity; public class MainActivity extends AppCompatActivity { @@ -23,6 +24,8 @@ public class MainActivity extends AppCompatActivity { private Button schedule; private Button log; private Button history; + private Button record; + private Button tomato; private Button openDrawer; private Button setting; DrawerLayout mDrawerLayout; @@ -37,6 +40,8 @@ protected void onCreate(Bundle savedInstanceState) { schedule = (Button)findViewById(R.id.select_plan); log = (Button)findViewById(R.id.select_log); history = (Button)findViewById(R.id.select_history); + record = (Button)findViewById(R.id.select_record); + tomato = (Button)findViewById(R.id.select_tomato); openDrawer = (Button)findViewById(R.id.open_drawer); setting = (Button)findViewById(R.id.setting); mDrawerLayout = (DrawerLayout)findViewById(R.id.draw_layout); @@ -75,6 +80,22 @@ public void onClick(View view) { } }); + record.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(MainActivity.this, RecordActivity.class); + startActivity(intent); + } + }); + + tomato.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(MainActivity.this, TomatoActivity.class); + startActivity(intent); + } + }); + openDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/app/src/main/java/com/example/can301/things/Record/AnalyzeActivity.java b/app/src/main/java/com/example/can301/things/Record/AnalyzeActivity.java new file mode 100644 index 0000000..9c83193 --- /dev/null +++ b/app/src/main/java/com/example/can301/things/Record/AnalyzeActivity.java @@ -0,0 +1,112 @@ +package com.example.can301.things.Record; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import com.example.can301.things.db.UserRecord; +import com.example.can301.things.R; +import com.github.mikephil.charting.charts.LineChart; +import com.github.mikephil.charting.charts.PieChart; +import com.github.mikephil.charting.components.Description; +import com.github.mikephil.charting.data.PieData; +import com.github.mikephil.charting.data.PieDataSet; +import com.github.mikephil.charting.data.PieEntry; +import com.github.mikephil.charting.utils.ColorTemplate; + +import org.litepal.LitePal; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class AnalyzeActivity extends AppCompatActivity { + private LineChart lineChart; + private List xValues; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_analyze); + + // 获取PieChart控件 + PieChart pieChart = findViewById(R.id.pieChart); + + //获取Activity2传来的Map数据 +// Intent getmessage = getIntent(); +// Map lableTimeMap = (HashMap) getmessage.getSerializableExtra("LabelTimeMap"); + + List userRecords = LitePal.findAll(UserRecord.class); + + Map lableTimeMap = new HashMap<>(); + for (UserRecord userRecord : userRecords) { + String category = userRecord.getCategory(); + double duration = userRecord.getDuration(); + + // 如果该Category已经在Map中,则累加时长,否则直接放入Map + if (lableTimeMap.containsKey(category)) { + float currentDuration = lableTimeMap.get(category); + lableTimeMap.put(category, currentDuration + (float) duration); + } else { + lableTimeMap.put(category, (float) duration); + } + } + + // 创建饼状图数据 + List entries = new ArrayList<>(); + for (Map.Entry entry : lableTimeMap.entrySet()) { + entries.add(new PieEntry(entry.getValue().floatValue(), entry.getKey())); + } + + // 设置饼状图数据集 + PieDataSet dataSet = new PieDataSet(entries, "Label Time"); + dataSet.setColors(ColorTemplate.COLORFUL_COLORS); + dataSet.setValueTextColor(Color.BLACK); + dataSet.setValueTextSize(16f); + + PieData data = new PieData(dataSet); + + pieChart.setCenterText("Categories"); + pieChart.animate(); + + // 设置饼状图描述 + Description description = new Description(); + description.setText("Label Time Analysis"); + pieChart.setDescription(description); + + // 将数据设置给饼状图 + pieChart.setData(data); + + // 刷新饼状图 + pieChart.invalidate(); + + //定义goHistory Button 用于返回Acitivity2 + Button goHistory = (Button)findViewById(R.id.goHistory); + goHistory.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent goHistory = new Intent(AnalyzeActivity.this, RecordListActivity.class); + startActivity(goHistory); + } + }); + //定义goRecord Button 用于返回Activity1 + Button goRecord = (Button)findViewById(R.id.goRecord); + goRecord.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent goRecord = new Intent(AnalyzeActivity.this, RecordActivity.class); + startActivity(goRecord); + } + }); + + + + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/can301/things/Record/RecordActivity.java b/app/src/main/java/com/example/can301/things/Record/RecordActivity.java new file mode 100644 index 0000000..7f497c6 --- /dev/null +++ b/app/src/main/java/com/example/can301/things/Record/RecordActivity.java @@ -0,0 +1,89 @@ +package com.example.can301.things.Record; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.Toast; + +import com.example.can301.things.db.UserRecord; +import com.example.can301.things.R; + +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +public class RecordActivity extends AppCompatActivity { +// private static List recordList = new ArrayList<>(); +// private static Map lableTimeMap = new HashMap<>(); + private Calendar calendar; + + Date date; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_record); + + //定义各个Container对象 + EditText textBoxAction = (EditText) findViewById(R.id.editTextActionBox); + EditText textBoxDuration = (EditText) findViewById(R.id.editTextDurationBox); + Spinner ActionCategory = (Spinner) findViewById(R.id.spinnerAction); + +// calendar = Calendar.getInstance(); //获得实例 + //设置为中国区的时间 + + //定义Record button对象及点击功能,即点击Record按钮后,将用户输入数据保存到db UserRecord中 + Button recordButton = (Button) findViewById(R.id.buttonRecord); + recordButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + UserRecord userRecord = new UserRecord(); + //获取Container内的数据 + String Action = textBoxAction.getText().toString(); + //需先获取String,再转换成double + String DurationToString = textBoxDuration.getText().toString(); + double Duration = Double.parseDouble(DurationToString); + String selectedAction = ActionCategory.getSelectedItem().toString(); + //将这些获取到的数据写入db UserRecord + userRecord.setCategory(selectedAction); + userRecord.setDuration(Duration); + userRecord.setActionDescription(Action); + //获取时间信息将数据写入db UserRecord + calendar = Calendar.getInstance(); + calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); + String year = String.valueOf(calendar.get(Calendar.YEAR)); + String month = String.valueOf(calendar.get(Calendar.MONTH) + 1); // 注意月份是从0开始的,所以要加1 + String day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)); +// Log.d("MainActivity", "Year: " + year + ", Month: " + month + ", Day: " + day); + userRecord.setYear(year); + userRecord.setMonth(month); + userRecord.setDay(day); + + userRecord.save(); + Toast.makeText(RecordActivity.this, "record successfully", Toast.LENGTH_SHORT).show(); + textBoxAction.setText(""); + textBoxDuration.setText(""); + } + }); + + //定义History Button对象及点击功能,即单纯跳转到MainAcitivity2 + Button detailButton = (Button) findViewById(R.id.buttonGoNext); + detailButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Log.d("RecordActivity", "Button clicked. Starting RecordListActivity."); + Intent goToMainActivity2 = new Intent(RecordActivity.this, RecordListActivity.class); + startActivity(goToMainActivity2); + } + }); + } + + + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/can301/things/Record/RecordListActivity.java b/app/src/main/java/com/example/can301/things/Record/RecordListActivity.java new file mode 100644 index 0000000..963e78c --- /dev/null +++ b/app/src/main/java/com/example/can301/things/Record/RecordListActivity.java @@ -0,0 +1,79 @@ +package com.example.can301.things.Record; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; + +import com.example.can301.things.Adapter.RecordAdapter; +import com.example.can301.things.db.UserRecord; +import com.example.can301.things.R; + +import org.litepal.LitePal; + +import java.util.ArrayList; +import java.util.List; + +public class RecordListActivity extends AppCompatActivity { + private RecyclerView messageContainer; + private RecordAdapter adapter; + private List dataList = new ArrayList<>(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_record_list); + + messageContainer = (RecyclerView) findViewById(R.id.messageContainer); + LinearLayoutManager manager = new LinearLayoutManager(this); + messageContainer.setLayoutManager(manager); + + Button goBackButton = (Button) findViewById(R.id.buttonGoHome); + goBackButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent goBack = new Intent(RecordListActivity.this, RecordActivity.class); + startActivity(goBack); + } + }); + +// List dataList = LitePal.findAll(UserRecord.class); +// RecordAdapter adapter = new RecordAdapter(dataList); +// messageContainer.setAdapter(adapter); + Button Analyze = (Button) findViewById(R.id.AnalyzedDataButton); + Analyze.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent Anlyze = new Intent(RecordListActivity.this, AnalyzeActivity.class); + startActivity(Anlyze); + } + }); + + Button delete = (Button) findViewById(R.id.delete); + delete.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + LitePal.deleteAll(UserRecord.class); + dataList.clear(); + adapter.notifyDataSetChanged(); + messageContainer.setAdapter(null); + } + }); + + } + + public void onResume(){ + super.onResume(); + List dataList = LitePal.findAll(UserRecord.class); + Log.d("RecordActivity", "Data size: " + dataList.size()); // 添加的日志 + adapter = new RecordAdapter(dataList); + messageContainer.setAdapter(adapter); + adapter.notifyDataSetChanged(); + } + +} diff --git a/app/src/main/java/com/example/yzbkaka/things/Schedule/AlterScheduleActivity.java b/app/src/main/java/com/example/can301/things/Schedule/AlterScheduleActivity.java similarity index 68% rename from app/src/main/java/com/example/yzbkaka/things/Schedule/AlterScheduleActivity.java rename to app/src/main/java/com/example/can301/things/Schedule/AlterScheduleActivity.java index ae33f1d..e47ac5a 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Schedule/AlterScheduleActivity.java +++ b/app/src/main/java/com/example/can301/things/Schedule/AlterScheduleActivity.java @@ -1,22 +1,19 @@ -package com.example.yzbkaka.things.Schedule; +package com.example.can301.things.Schedule; import android.content.Intent; import android.os.Build; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.Today.AlterTodayActivity; -import com.example.yzbkaka.things.db.Plan; +import com.example.can301.things.R; +import com.example.can301.things.db.Plan; import org.litepal.LitePal; -import static com.example.yzbkaka.things.MainActivity.todayCount; - public class AlterScheduleActivity extends AppCompatActivity { private EditText editText; private Button finish; @@ -31,20 +28,20 @@ protected void onCreate(Bundle savedInstanceState) { editText = (EditText) findViewById(R.id.old_text); finish = (Button)findViewById(R.id.finish); Intent intent = getIntent(); - oldWrite = intent.getStringExtra("write"); //得到之前的数据 - editText.setText(oldWrite); //将之前的数据显示在EditText上 + oldWrite = intent.getStringExtra("write"); //get the previous data + editText.setText(oldWrite); //Displays the previous data on the EditText finish.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - String newWrite = editText.getText().toString(); //得到用户修改之后的新数据 + String newWrite = editText.getText().toString(); //Get the new data after the user changes if(newWrite.isEmpty()){ - LitePal.deleteAll(Plan.class,"writePlan = ?",oldWrite); //如果修改之后为空则自动删除 + LitePal.deleteAll(Plan.class,"writePlan = ?",oldWrite); //If the value is null after modification, it is automatically deleted } else{ - plan.setWritePlan(newWrite); //LitePal语法,先设置新的内容,再寻找条件更新 + plan.setWritePlan(newWrite); //LitePal syntax, first set the new content, and then look for conditional updates plan.updateAll("writePlan = ?",oldWrite); - Toast.makeText(AlterScheduleActivity.this, "修改成功", Toast.LENGTH_SHORT).show(); + Toast.makeText(AlterScheduleActivity.this, "Changed successfully!", Toast.LENGTH_SHORT).show(); } finish(); diff --git a/app/src/main/java/com/example/yzbkaka/things/Schedule/ScheduleActivity.java b/app/src/main/java/com/example/can301/things/Schedule/ScheduleActivity.java similarity index 83% rename from app/src/main/java/com/example/yzbkaka/things/Schedule/ScheduleActivity.java rename to app/src/main/java/com/example/can301/things/Schedule/ScheduleActivity.java index aa6a577..a70adc4 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Schedule/ScheduleActivity.java +++ b/app/src/main/java/com/example/can301/things/Schedule/ScheduleActivity.java @@ -1,16 +1,15 @@ -package com.example.yzbkaka.things.Schedule; +package com.example.can301.things.Schedule; import android.content.Intent; import android.os.Build; -import android.support.annotation.NonNull; -import android.support.v7.app.AppCompatActivity; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.Today.TodayCreateActivitty; +import com.example.can301.things.R; import com.prolificinteractive.materialcalendarview.CalendarDay; import com.prolificinteractive.materialcalendarview.MaterialCalendarView; import com.prolificinteractive.materialcalendarview.OnDateSelectedListener; @@ -31,7 +30,7 @@ protected void onCreate(Bundle savedInstanceState) { back = (Button)findViewById(R.id.back); calendarView = (MaterialCalendarView)findViewById(R.id.calendarView); - Calendar calendar = Calendar.getInstance(); //得到今天的时间 + Calendar calendar = Calendar.getInstance(); //Get the time today calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); final String todayYear = String.valueOf(calendar.get(Calendar.YEAR)); final String todayMonth = String.valueOf(calendar.get(Calendar.MONTH)+1); @@ -47,12 +46,12 @@ public void onClick(View view) { calendarView.setOnDateChangedListener(new OnDateSelectedListener() { @Override public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) { - String year = String.valueOf(date.getYear()); //得到选中的时间 + String year = String.valueOf(date.getYear()); //get chosen time String month = String.valueOf(date.getMonth()+1); String day = String.valueOf(date.getDay()); - if(((year.equals(todayYear) && month.equals(todayMonth) && Integer.parseInt(day) < Integer.parseInt(todayDay))) || (year.equals(todayYear) && Integer.parseInt(month) < Integer.parseInt(todayMonth)) || (Integer.parseInt(year) < Integer.parseInt(todayYear))){ //如果选中的是今天,则会创建失败 - Toast.makeText(ScheduleActivity.this, "请选择未来的时间点哦", Toast.LENGTH_SHORT).show(); + if(((year.equals(todayYear) && month.equals(todayMonth) && Integer.parseInt(day) < Integer.parseInt(todayDay))) || (year.equals(todayYear) && Integer.parseInt(month) < Integer.parseInt(todayMonth)) || (Integer.parseInt(year) < Integer.parseInt(todayYear))){ //If today is selected, the creation will fail + Toast.makeText(ScheduleActivity.this, "Please choose a future time", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(ScheduleActivity.this, ScheduleCreateActivity.class); diff --git a/app/src/main/java/com/example/yzbkaka/things/Schedule/ScheduleCreateActivity.java b/app/src/main/java/com/example/can301/things/Schedule/ScheduleCreateActivity.java similarity index 84% rename from app/src/main/java/com/example/yzbkaka/things/Schedule/ScheduleCreateActivity.java rename to app/src/main/java/com/example/can301/things/Schedule/ScheduleCreateActivity.java index 0c5dde1..2ff7a3d 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Schedule/ScheduleCreateActivity.java +++ b/app/src/main/java/com/example/can301/things/Schedule/ScheduleCreateActivity.java @@ -1,15 +1,17 @@ -package com.example.yzbkaka.things.Schedule; +package com.example.can301.things.Schedule; import android.content.Intent; -import android.support.v7.app.AppCompatActivity; + import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Plan; +import androidx.appcompat.app.AppCompatActivity; + +import com.example.can301.things.R; +import com.example.can301.things.db.Plan; import java.util.Calendar; import java.util.Date; @@ -29,7 +31,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_schedule_create); finish = (Button)findViewById(R.id.finish); editText = (EditText)findViewById(R.id.edit_text); - calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); //设置为中国区的时间 + calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); //Set to the time in China Intent intent = getIntent(); final String scheduleYear = intent.getStringExtra("year"); @@ -45,9 +47,10 @@ public void onClick(View view) { plan.setYear(scheduleYear); plan.setMonth(scheduleMonth); plan.setDay(scheduleDay); + plan.setStatus(false);///// date = new Date(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH)+1,calendar.get(Calendar.DATE)); plan.save(); - Toast.makeText(ScheduleCreateActivity.this, "创建成功,记得要完成哦", Toast.LENGTH_SHORT).show(); + Toast.makeText(ScheduleCreateActivity.this, "Created successfully, remember to finish it", Toast.LENGTH_SHORT).show(); } finish(); } diff --git a/app/src/main/java/com/example/yzbkaka/things/Schedule/ScheduleViewActivity.java b/app/src/main/java/com/example/can301/things/Schedule/ScheduleViewActivity.java similarity index 82% rename from app/src/main/java/com/example/yzbkaka/things/Schedule/ScheduleViewActivity.java rename to app/src/main/java/com/example/can301/things/Schedule/ScheduleViewActivity.java index 907ff50..d178558 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Schedule/ScheduleViewActivity.java +++ b/app/src/main/java/com/example/can301/things/Schedule/ScheduleViewActivity.java @@ -1,18 +1,18 @@ -package com.example.yzbkaka.things.Schedule; +package com.example.can301.things.Schedule; import android.content.Intent; import android.os.Build; -import android.support.design.widget.FloatingActionButton; -import android.support.v7.app.AppCompatActivity; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.widget.Button; -import com.example.yzbkaka.things.Adapter.ScheduleAdapter; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Plan; +import com.example.can301.things.Adapter.ScheduleAdapter; +import com.example.can301.things.R; +import com.example.can301.things.db.Plan; import org.litepal.LitePal; @@ -66,7 +66,7 @@ public void onResume(){ create.setVisibility(View.VISIBLE); - Calendar calendar = Calendar.getInstance(); //获取到今天的时间 + Calendar calendar = Calendar.getInstance(); //get today's time calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); String year = String.valueOf(calendar.get(Calendar.YEAR)); String month = String.valueOf(calendar.get(Calendar.MONTH)+1); @@ -75,9 +75,9 @@ public void onResume(){ if (dataList.size() > 0){ scheduleList.clear(); for(Plan plan : dataList){ - if((plan.getYear().equals(year) && plan.getMonth().equals(month) && Integer.parseInt(plan.getDay()) > Integer.parseInt(day) ) || ( plan.getYear().equals(year) && Integer.parseInt(plan.getMonth()) > Integer.parseInt(month) ) || (Integer.parseInt(plan.getYear()) > Integer.parseInt(year)) ){ //只要不是今天的就会显示在计划列表当中 + if((plan.getYear().equals(year) && plan.getMonth().equals(month) && Integer.parseInt(plan.getDay()) > Integer.parseInt(day) ) || ( plan.getYear().equals(year) && Integer.parseInt(plan.getMonth()) > Integer.parseInt(month) ) || (Integer.parseInt(plan.getYear()) > Integer.parseInt(year)) ){ //Anything that isn't today will show up in the plan list scheduleList.add(plan); - //排序 + //Sort } } } diff --git a/app/src/main/java/com/example/yzbkaka/things/Service/SendMessage.java b/app/src/main/java/com/example/can301/things/Service/SendMessage.java similarity index 59% rename from app/src/main/java/com/example/yzbkaka/things/Service/SendMessage.java rename to app/src/main/java/com/example/can301/things/Service/SendMessage.java index 0acd8dd..50ba0eb 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Service/SendMessage.java +++ b/app/src/main/java/com/example/can301/things/Service/SendMessage.java @@ -1,4 +1,4 @@ -package com.example.yzbkaka.things.Service; +package com.example.can301.things.Service; import android.app.AlarmManager; import android.app.Notification; @@ -11,13 +11,13 @@ import android.os.Build; import android.os.IBinder; import android.os.SystemClock; -import android.support.v4.app.NotificationCompat; +import androidx.core.app.NotificationCompat; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.Today.NoteActivity; +import com.example.can301.things.R; +import com.example.can301.things.Today.NoteActivity; -import static com.example.yzbkaka.things.MainActivity.todayCount; -import static com.example.yzbkaka.things.Setting.SettingActivity.count; +import static com.example.can301.things.MainActivity.todayCount; +import static com.example.can301.things.Setting.SettingActivity.count; public class SendMessage extends Service { public SendMessage() { @@ -33,40 +33,40 @@ public int onStartCommand(Intent intent,int flags,int startId){ new Thread(new Runnable() { @Override public void run() { - if(count%2 == 0){ //根据次数来切换图片 - Intent notificationIntent = new Intent(SendMessage.this,NoteActivity.class); //开始设置通知效果 - PendingIntent pendingIntent = PendingIntent.getActivity(SendMessage.this,0, notificationIntent,0); //设置PendingIntent + if(count%2 == 0){ //Switch images according to the number of times + Intent notificationIntent = new Intent(SendMessage.this,NoteActivity.class); //Start setting the notification effect + PendingIntent pendingIntent = PendingIntent.getActivity(SendMessage.this,0, notificationIntent,0); //Set PendingIntent NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ //判断系统是否大于8.0 + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ //Check whether the value is greater than 8.0 NotificationChannel notificationChannel = new NotificationChannel("channel","channel",NotificationManager.IMPORTANCE_HIGH); manager.createNotificationChannel(notificationChannel); Notification notification = new NotificationCompat.Builder(SendMessage.this,"channel") - .setContentTitle("任务清单已送达") - .setContentText("小主,今天还有" + todayCount + "件任务要完成哦!") - .setWhen(System.currentTimeMillis()) //发送通知的时间 - .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.logo144)) //设置大图标 - .setContentIntent(pendingIntent) //设置通知的点击效果 - .setAutoCancel(true) //设置点击之后自动关闭通知 + .setContentTitle("The task list has been delivered") + .setContentText("Lord, there's more today" + todayCount + "tasks to complete oh!") + .setWhen(System.currentTimeMillis()) //Time to send the notification + .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.logo144)) //Set large icon + .setContentIntent(pendingIntent) //Set the click effect of the notification + .setAutoCancel(true) //Set to automatically turn off notifications when clicked .build(); if(todayCount > 0){ - manager.notify(1,notification); //显示通知 + manager.notify(1,notification); //Display notification } } else{ Notification notification = new NotificationCompat.Builder(SendMessage.this) - .setContentTitle("今天的任务清单") - .setContentText("小主今天还有" + todayCount + "件计划要完成哦!") - .setWhen(System.currentTimeMillis()) //发送通知的时间 - .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.logo144)) //设置大图标 - .setContentIntent(pendingIntent) //设置通知的点击效果 - .setAutoCancel(true) //设置点击之后自动关闭通知 + .setContentTitle("Today's to-do list") + .setContentText("The little master still has today" + todayCount + "tasks to complete oh!") + .setWhen(System.currentTimeMillis()) //Time to send the notification + .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.logo144)) //Set large icon + .setContentIntent(pendingIntent) //Set the click effect of the notification + .setAutoCancel(true) //Set to automatically turn off notifications when clicked .build(); if(todayCount > 0){ - manager.notify(1,notification); //显示通知 + manager.notify(1,notification); //Display notification } } } @@ -77,8 +77,8 @@ public void run() { } }).start(); - AlarmManager manager = (AlarmManager)getSystemService(ALARM_SERVICE); //设置定时服务 - int fourHour = 4*60*60*1000; //单位是毫秒(4小时) + AlarmManager manager = (AlarmManager)getSystemService(ALARM_SERVICE); //Set timing service + int fourHour = 4*60*60*1000; //The unit is milliseconds (4 hours). long time = SystemClock.elapsedRealtime() + fourHour; Intent i = new Intent(this,SendMessage.class); PendingIntent pi = PendingIntent.getService(this,0,i,0); diff --git a/app/src/main/java/com/example/can301/things/Setting/ExplainActivity_Log.java b/app/src/main/java/com/example/can301/things/Setting/ExplainActivity_Log.java new file mode 100644 index 0000000..a945b0a --- /dev/null +++ b/app/src/main/java/com/example/can301/things/Setting/ExplainActivity_Log.java @@ -0,0 +1,74 @@ +package com.example.can301.things.Setting; + +import android.os.Build; +import android.os.Bundle; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.LinearLayout; + +import androidx.appcompat.app.AppCompatActivity; + +import com.example.can301.things.R; + +import java.util.Timer; +import java.util.TimerTask; + +public class ExplainActivity_Log extends AppCompatActivity { + private Button back; + private LinearLayout explain3; + private ImageView img3; + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_explain_log); + back = (Button)findViewById(R.id.back); + explain3 = (LinearLayout)findViewById(R.id.explain_three); + img3 = (ImageView)findViewById(R.id.explain_button_three); + + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + + img3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + img3.setImageResource(R.drawable.yes); + Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Log.this,R.anim.today_anim); //设置动画 + explain3.startAnimation(animation); + TimerTask task = new TimerTask() { + @Override + public void run() { + runOnUiThread(new Runnable() { + @Override + public void run() { + explain3.setVisibility(View.GONE); + } + }); + } + }; + Timer timer = new Timer(); + timer.schedule(task,800); + + } + }); + + setLightMode(); + + + } + + private void setLightMode(){ + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + } +} diff --git a/app/src/main/java/com/example/can301/things/Setting/ExplainActivity_Today.java b/app/src/main/java/com/example/can301/things/Setting/ExplainActivity_Today.java new file mode 100644 index 0000000..baf4d10 --- /dev/null +++ b/app/src/main/java/com/example/can301/things/Setting/ExplainActivity_Today.java @@ -0,0 +1,160 @@ +package com.example.can301.things.Setting; + +import android.os.Build; +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.LinearLayout; + +import com.example.can301.things.R; + +import java.util.Timer; +import java.util.TimerTask; + +public class ExplainActivity_Today extends AppCompatActivity { + private Button back; + private LinearLayout explain1; + private LinearLayout explain2; +// private LinearLayout explain3; + private LinearLayout explain4; + private LinearLayout explain5; + private ImageView img1; + private ImageView img2; +// private ImageView img3; + private ImageView img4; + private ImageView img5; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_explain_today); + back = (Button)findViewById(R.id.back); + explain1 = (LinearLayout)findViewById(R.id.explain_one); + explain2 = (LinearLayout)findViewById(R.id.explain_two); +// explain3 = (LinearLayout)findViewById(R.id.explain_three); + explain4 = (LinearLayout)findViewById(R.id.explain_four); + explain5 = (LinearLayout)findViewById(R.id.explain_five); + img1 = (ImageView)findViewById(R.id.explain_button_one); + img2 = (ImageView)findViewById(R.id.explain_button_two); +// img3 = (ImageView)findViewById(R.id.explain_button_three); + img4 = (ImageView)findViewById(R.id.explain_button_four); + img5 = (ImageView)findViewById(R.id.explain_button_five); + + + + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + + img1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + img1.setImageResource(R.drawable.yes); + final Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Today.this,R.anim.today_anim); //设置动画 + explain1.startAnimation(animation); + TimerTask task = new TimerTask() { + @Override + public void run() { + runOnUiThread(new Runnable() { + @Override + public void run() { + explain1.setVisibility(View.GONE); + } + }); + } + }; + Timer timer = new Timer(); + timer.schedule(task, 800); + + } + }); + + img2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + img2.setImageResource(R.drawable.yes); + Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Today.this,R.anim.today_anim); //设置动画 + explain2.startAnimation(animation); + + TimerTask task = new TimerTask() { + @Override + public void run() { + runOnUiThread(new Runnable() { + @Override + public void run() { + explain2.setVisibility(View.GONE); + } + }); + } + }; + Timer timer = new Timer(); + timer.schedule(task,800); + + + } + }); + + img4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + img4.setImageResource(R.drawable.yes); + Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Today.this,R.anim.today_anim); //设置动画 + explain4.startAnimation(animation); + TimerTask task = new TimerTask() { + @Override + public void run() { + runOnUiThread(new Runnable() { + @Override + public void run() { + explain4.setVisibility(View.GONE); + } + }); + } + }; + Timer timer = new Timer(); + timer.schedule(task,800); + + } + }); + + img5.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + img5.setImageResource(R.drawable.yes); + Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Today.this,R.anim.today_anim); //设置动画 + explain5.startAnimation(animation); + TimerTask task = new TimerTask() { + @Override + public void run() { + runOnUiThread(new Runnable() { + @Override + public void run() { + explain5.setVisibility(View.GONE); + } + }); + } + }; + Timer timer = new Timer(); + timer.schedule(task,800); + } + }); + + setLightMode(); + + + } + + private void setLightMode(){ + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + } +} diff --git a/app/src/main/java/com/example/yzbkaka/things/Setting/ExplainActivity.java b/app/src/main/java/com/example/can301/things/Setting/ExplainActivity_Tomato.java similarity index 91% rename from app/src/main/java/com/example/yzbkaka/things/Setting/ExplainActivity.java rename to app/src/main/java/com/example/can301/things/Setting/ExplainActivity_Tomato.java index 9063969..48d7baa 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Setting/ExplainActivity.java +++ b/app/src/main/java/com/example/can301/things/Setting/ExplainActivity_Tomato.java @@ -1,7 +1,6 @@ -package com.example.yzbkaka.things.Setting; +package com.example.can301.things.Setting; import android.os.Build; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; @@ -10,12 +9,14 @@ import android.widget.ImageView; import android.widget.LinearLayout; -import com.example.yzbkaka.things.R; +import androidx.appcompat.app.AppCompatActivity; + +import com.example.can301.things.R; import java.util.Timer; import java.util.TimerTask; -public class ExplainActivity extends AppCompatActivity { +public class ExplainActivity_Tomato extends AppCompatActivity { private Button back; private LinearLayout explain1; private LinearLayout explain2; @@ -32,7 +33,7 @@ public class ExplainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_explain); + setContentView(R.layout.activity_explain_tomato); back = (Button)findViewById(R.id.back); explain1 = (LinearLayout)findViewById(R.id.explain_one); explain2 = (LinearLayout)findViewById(R.id.explain_two); @@ -58,7 +59,7 @@ public void onClick(View view) { @Override public void onClick(View view) { img1.setImageResource(R.drawable.yes); - final Animation animation = AnimationUtils.loadAnimation(ExplainActivity.this,R.anim.today_anim); //设置动画 + final Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Tomato.this,R.anim.today_anim); //设置动画 explain1.startAnimation(animation); TimerTask task = new TimerTask() { @Override @@ -81,7 +82,7 @@ public void run() { @Override public void onClick(View view) { img2.setImageResource(R.drawable.yes); - Animation animation = AnimationUtils.loadAnimation(ExplainActivity.this,R.anim.today_anim); //设置动画 + Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Tomato.this,R.anim.today_anim); //设置动画 explain2.startAnimation(animation); TimerTask task = new TimerTask() { @@ -106,7 +107,7 @@ public void run() { @Override public void onClick(View view) { img3.setImageResource(R.drawable.yes); - Animation animation = AnimationUtils.loadAnimation(ExplainActivity.this,R.anim.today_anim); //设置动画 + Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Tomato.this,R.anim.today_anim); //设置动画 explain3.startAnimation(animation); TimerTask task = new TimerTask() { @Override @@ -129,7 +130,7 @@ public void run() { @Override public void onClick(View view) { img4.setImageResource(R.drawable.yes); - Animation animation = AnimationUtils.loadAnimation(ExplainActivity.this,R.anim.today_anim); //设置动画 + Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Tomato.this,R.anim.today_anim); //设置动画 explain4.startAnimation(animation); TimerTask task = new TimerTask() { @Override @@ -152,7 +153,7 @@ public void run() { @Override public void onClick(View view) { img5.setImageResource(R.drawable.yes); - Animation animation = AnimationUtils.loadAnimation(ExplainActivity.this,R.anim.today_anim); //设置动画 + Animation animation = AnimationUtils.loadAnimation(ExplainActivity_Tomato.this,R.anim.today_anim); //设置动画 explain5.startAnimation(animation); TimerTask task = new TimerTask() { @Override diff --git a/app/src/main/java/com/example/yzbkaka/things/Setting/SettingActivity.java b/app/src/main/java/com/example/can301/things/Setting/SettingActivity.java similarity index 57% rename from app/src/main/java/com/example/yzbkaka/things/Setting/SettingActivity.java rename to app/src/main/java/com/example/can301/things/Setting/SettingActivity.java index c0d6d3b..6e4c848 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Setting/SettingActivity.java +++ b/app/src/main/java/com/example/can301/things/Setting/SettingActivity.java @@ -1,25 +1,26 @@ -package com.example.yzbkaka.things.Setting; +package com.example.can301.things.Setting; import android.content.Intent; import android.os.Build; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; -import com.example.yzbkaka.things.ActivityCollector; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.Service.SendMessage; -import com.prolificinteractive.materialcalendarview.WeekView; +import com.example.can301.things.ActivityCollector; +import com.example.can301.things.R; +import com.example.can301.things.Service.SendMessage; public class SettingActivity extends AppCompatActivity { private Button checkSendMessage; private Button back; - private LinearLayout explain; - private LinearLayout about; - private LinearLayout exit; + private LinearLayout explain_schedule; + private LinearLayout explain_log; + private LinearLayout explain_tomato; +// private LinearLayout about; +// private LinearLayout exit; public static int count = 0; private Button dark; @@ -30,9 +31,11 @@ protected void onCreate(Bundle savedInstanceState) { ActivityCollector.addActivity(this); checkSendMessage = (Button) findViewById(R.id.check_send); back = (Button)findViewById(R.id.back); - explain = (LinearLayout)findViewById(R.id.how_to_use); - about = (LinearLayout)findViewById(R.id.about); - exit = (LinearLayout)findViewById(R.id.exit); + explain_schedule = (LinearLayout)findViewById(R.id.how_to_use_today); + explain_tomato = (LinearLayout)findViewById(R.id.how_to_use_tomato); + explain_log = (LinearLayout)findViewById(R.id.how_to_use_log); +// about = (LinearLayout)findViewById(R.id.about); +// exit = (LinearLayout)findViewById(R.id.exit); if(count%2 == 0){ checkSendMessage.setBackgroundResource(R.drawable.checkno); @@ -57,30 +60,47 @@ public void onClick(View view) { } }); - explain.setOnClickListener(new View.OnClickListener() { + explain_schedule.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent explainIntent = new Intent(SettingActivity.this,ExplainActivity.class); + Intent explainIntent = new Intent(SettingActivity.this, ExplainActivity_Today.class); startActivity(explainIntent); } }); - about.setOnClickListener(new View.OnClickListener() { + explain_tomato.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent aboutIntent = new Intent(SettingActivity.this,AboutActivity.class); - startActivity(aboutIntent); + Intent explainTomatoIntent = new Intent(SettingActivity.this,ExplainActivity_Tomato.class); + startActivity(explainTomatoIntent); } }); - exit.setOnClickListener(new View.OnClickListener() { + explain_log.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - ActivityCollector.finishAll(); + Intent explainLogIntent = new Intent(SettingActivity.this, ExplainActivity_Log.class); + startActivity(explainLogIntent); } }); +// about.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// Intent aboutIntent = new Intent(SettingActivity.this,AboutActivity.class); +// startActivity(aboutIntent); +// } +// }); +// +// exit.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// ActivityCollector.finishAll(); +// } +// }); + + back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/app/src/main/java/com/example/yzbkaka/things/StartActivity.java b/app/src/main/java/com/example/can301/things/StartActivity.java similarity index 85% rename from app/src/main/java/com/example/yzbkaka/things/StartActivity.java rename to app/src/main/java/com/example/can301/things/StartActivity.java index 5ea50d2..456f8e8 100644 --- a/app/src/main/java/com/example/yzbkaka/things/StartActivity.java +++ b/app/src/main/java/com/example/can301/things/StartActivity.java @@ -1,9 +1,8 @@ -package com.example.yzbkaka.things; +package com.example.can301.things; import android.content.Intent; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -import android.widget.ImageView; import java.util.Timer; import java.util.TimerTask; diff --git a/app/src/main/java/com/example/yzbkaka/things/Today/AlterTodayActivity.java b/app/src/main/java/com/example/can301/things/Today/AlterTodayActivity.java similarity index 63% rename from app/src/main/java/com/example/yzbkaka/things/Today/AlterTodayActivity.java rename to app/src/main/java/com/example/can301/things/Today/AlterTodayActivity.java index 1153b89..cbb5197 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Today/AlterTodayActivity.java +++ b/app/src/main/java/com/example/can301/things/Today/AlterTodayActivity.java @@ -1,21 +1,21 @@ -package com.example.yzbkaka.things.Today; +package com.example.can301.things.Today; import android.content.Intent; import android.os.Build; -import android.support.design.widget.FloatingActionButton; -import android.support.v7.app.AppCompatActivity; + +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Plan; +import com.example.can301.things.R; +import com.example.can301.things.db.Plan; import org.litepal.LitePal; -import static com.example.yzbkaka.things.MainActivity.todayCount; +import static com.example.can301.things.MainActivity.todayCount; public class AlterTodayActivity extends AppCompatActivity { private EditText editText; @@ -31,21 +31,20 @@ protected void onCreate(Bundle savedInstanceState) { editText = (EditText) findViewById(R.id.old_text); finish = (Button)findViewById(R.id.finish); Intent intent = getIntent(); - oldWrite = intent.getStringExtra("write"); //得到之前的数据 - editText.setText(oldWrite); //将之前的数据显示在EditText上 - + oldWrite = intent.getStringExtra("write"); //Get the previous data + editText.setText(oldWrite); //Display the previous data on the EditText finish.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - String newWrite = editText.getText().toString(); //得到用户修改之后的新数据 + String newWrite = editText.getText().toString(); //Get the new data after user modification if(newWrite.isEmpty()){ - LitePal.deleteAll(Plan.class,"writePlan = ?",oldWrite); //如果修改之后为空则自动删除 - todayCount--; //删除之后则统计数量减1 + LitePal.deleteAll(Plan.class,"writePlan = ?",oldWrite); //Automatically deleted if empty after modification + todayCount--; //After deletion, the number of statistics is reduced by 1 } else{ - plan.setWritePlan(newWrite); //LitePal语法,先设置新的内容,再寻找条件更新 + plan.setWritePlan(newWrite); //LitePal syntax, set new content first, then look for conditional updates plan.updateAll("writePlan = ?",oldWrite); - Toast.makeText(AlterTodayActivity.this, "修改成功", Toast.LENGTH_SHORT).show(); + Toast.makeText(AlterTodayActivity.this, "Modify Successfully", Toast.LENGTH_SHORT).show(); } finish(); diff --git a/app/src/main/java/com/example/yzbkaka/things/Today/NoteActivity.java b/app/src/main/java/com/example/can301/things/Today/NoteActivity.java similarity index 64% rename from app/src/main/java/com/example/yzbkaka/things/Today/NoteActivity.java rename to app/src/main/java/com/example/can301/things/Today/NoteActivity.java index af96057..4cc278c 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Today/NoteActivity.java +++ b/app/src/main/java/com/example/can301/things/Today/NoteActivity.java @@ -1,25 +1,20 @@ -package com.example.yzbkaka.things.Today; +package com.example.can301.things.Today; +import android.annotation.SuppressLint; import android.content.Intent; import android.os.Build; -import android.support.design.widget.FloatingActionButton; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.View; -import android.view.ViewGroup; import android.widget.Button; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.TextView; - -import com.example.yzbkaka.things.Adapter.TodayAdapter; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Plan; +import com.example.can301.things.Adapter.TodayAdapter; +import com.example.can301.things.R; +import com.example.can301.things.db.Plan; import org.litepal.LitePal; @@ -28,16 +23,14 @@ import java.util.List; import java.util.TimeZone; -import static com.example.yzbkaka.things.MainActivity.todayCount; - public class NoteActivity extends AppCompatActivity { - private Button back; //后退键 - private RecyclerView todayView; //显示今天所有任务的ListView - private List todayList = new ArrayList<>(); //今天任务的列表 - private List dataList = new ArrayList<>(); //获得Plan数据库的列表 - private FloatingActionButton create; //创建新任务的按钮 - public static TodayAdapter todayAdapter; //适配器 + private Button back; //Backspace + private RecyclerView todayView; //ListView showing all tasks for today + private List todayList = new ArrayList<>(); //List of today's tasks + private List dataList = new ArrayList<>(); //Get a list of Plan databases + private FloatingActionButton create; //Button to create a new task + public static TodayAdapter todayAdapter; //adapter @Override protected void onCreate(Bundle savedInstanceState) { @@ -48,9 +41,10 @@ protected void onCreate(Bundle savedInstanceState) { create = (FloatingActionButton) findViewById(R.id.create); - LinearLayoutManager layoutManager = new LinearLayoutManager(this); //一定要为RecyclerView设置布局管理器 + LinearLayoutManager layoutManager = new LinearLayoutManager(this); //Be sure to set up a layout manager for the RecyclerView todayView.setLayoutManager(layoutManager); + //back back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -58,11 +52,13 @@ public void onClick(View view) { } }); + //create create.setOnClickListener(new View.OnClickListener() { + @SuppressLint("RestrictedApi") @Override public void onClick(View view) { Intent intent = new Intent(NoteActivity.this, TodayCreateActivitty.class); - create.setVisibility(View.GONE); + //create.setVisibility(View.GONE); startActivity(intent); } }); @@ -74,13 +70,14 @@ public void onClick(View view) { } + @SuppressLint("RestrictedApi") @Override public void onResume() { super.onResume(); - create.setVisibility(View.VISIBLE); //右下角的创建按钮显示出来 + create.setVisibility(View.VISIBLE); //The Create button in the lower right corner shows up dataList = LitePal.findAll(Plan.class); - Calendar calendar = Calendar.getInstance(); //获得今天的时间 + Calendar calendar = Calendar.getInstance(); //Get the time of day calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); String year = String.valueOf(calendar.get(Calendar.YEAR)); String month = String.valueOf(calendar.get(Calendar.MONTH)+1); @@ -92,7 +89,7 @@ public void onResume() { for(Plan plan:dataList){ if(plan.getYear().equals(year) && plan.getMonth().equals(month) && plan.getDay().equals(day) && plan.getStatus()== false){ todayList.add(plan); - //todayCount++; //today统计数量加1 + //todayCount++; //Add 1 to the number of today statistics } } } @@ -102,6 +99,7 @@ public void onResume() { } + @SuppressLint("RestrictedApi") @Override public void onPause(){ super.onPause(); diff --git a/app/src/main/java/com/example/yzbkaka/things/Today/TodayCreateActivitty.java b/app/src/main/java/com/example/can301/things/Today/TodayCreateActivitty.java similarity index 63% rename from app/src/main/java/com/example/yzbkaka/things/Today/TodayCreateActivitty.java rename to app/src/main/java/com/example/can301/things/Today/TodayCreateActivitty.java index 2d01491..5f900fc 100644 --- a/app/src/main/java/com/example/yzbkaka/things/Today/TodayCreateActivitty.java +++ b/app/src/main/java/com/example/can301/things/Today/TodayCreateActivitty.java @@ -1,28 +1,28 @@ -package com.example.yzbkaka.things.Today; +package com.example.can301.things.Today; import android.os.Build; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; -import com.example.yzbkaka.things.R; -import com.example.yzbkaka.things.db.Plan; +import com.example.can301.things.R; +import com.example.can301.things.db.Plan; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; -import static com.example.yzbkaka.things.MainActivity.todayCount; +import static com.example.can301.things.MainActivity.todayCount; public class TodayCreateActivitty extends AppCompatActivity { - private EditText editText; //写下的计划 - private Button finish; //完成后的按钮 - private String write; //输入的内容 - private Calendar calendar; //获得时间 + private EditText editText; //Plans written down + private Button finish; //Finished button + private String write; //Inputs + private Calendar calendar; //Acquisition time Date date; Plan plan = new Plan(); @@ -31,23 +31,24 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_today_create_activitty); editText = (EditText)findViewById(R.id.edit_text); + editText.setHint("Write down your plans for today!"); finish = (Button)findViewById(R.id.finish); - calendar = Calendar.getInstance(); //获得实例 - calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); //设置为中国区的时间 + calendar = Calendar.getInstance(); //Getting instances + calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); //Set to China time finish.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - write = String.valueOf(editText.getText()); //获得输入的内容 + write = String.valueOf(editText.getText()); //Getting the input if(!write.isEmpty()){ plan.setWritePlan(write); - plan.setYear(String.valueOf(calendar.get(Calendar.YEAR))); //设置写下的时间,年 - plan.setMonth(String.valueOf(calendar.get(Calendar.MONTH)+1)); //设置月份(系统中是从0开始的) - plan.setDay(String.valueOf(calendar.get(Calendar.DATE))); //设置日期 - date = new Date(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH)+1,calendar.get(Calendar.DATE)); //设置plan中的date + plan.setYear(String.valueOf(calendar.get(Calendar.YEAR))); //Set the time and year of writing + plan.setMonth(String.valueOf(calendar.get(Calendar.MONTH)+1)); //Set the month (starts from 0 in the system) + plan.setDay(String.valueOf(calendar.get(Calendar.DATE))); //Setting the date + date = new Date(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH)+1,calendar.get(Calendar.DATE)); //Setting the date in plan plan.setCreateTime(date); - todayCount++; //today统计数量加1 + todayCount++; //Add 1 to the number of today statistics plan.save(); } finish(); diff --git a/app/src/main/java/com/example/can301/things/Tomato/TomatoActivity.java b/app/src/main/java/com/example/can301/things/Tomato/TomatoActivity.java new file mode 100644 index 0000000..e1c0ac3 --- /dev/null +++ b/app/src/main/java/com/example/can301/things/Tomato/TomatoActivity.java @@ -0,0 +1,283 @@ +package com.example.can301.things.Tomato; + +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.media.MediaPlayer; +import android.os.Bundle; +import android.os.CountDownTimer; +import android.os.Vibrator; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.RelativeLayout; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; +import android.app.AlertDialog; + +import androidx.appcompat.app.AppCompatActivity; + +import com.example.can301.things.R; +import com.example.can301.things.Record.RecordListActivity; +import com.example.can301.things.db.UserRecord; + +import java.util.Calendar; +import java.util.TimeZone; + + +public class TomatoActivity extends AppCompatActivity { + private Button back; + private TextView timerTextView; + private Button startButton; + private CountDownTimer countDownTimer; + private EditText action; + private EditText editTextTime; + private Spinner categories; + private boolean isTimerRunning = false; + private Calendar calendar; + private MediaPlayer mediaPlayer; + private Vibrator vibrator; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_tomato); + + back = (Button)findViewById(R.id.back); + timerTextView = findViewById(R.id.timerTextView); + startButton = findViewById(R.id.startButton); + + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + onBackPressed(); + } + }); + + startButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (isTimerRunning) { + stopConfirmationDialog(); + } else { + startTimer(); + } + } + }); + } + + private void startTimer() { + // 如果计时器已经在运行,不再创建新的计时器 + if (isTimerRunning && countDownTimer != null) { + return; + } + + // 获取用户输入的时间和活动 + action = findViewById(R.id.editAction); + editTextTime = findViewById(R.id.editTextTime); + categories = findViewById(R.id.categories); + String inputTime = editTextTime.getText().toString().trim(); + String inputAction = action.getText().toString().trim(); + String inputCategories = categories.getSelectedItem().toString(); + + //get calendar + calendar = Calendar.getInstance(); + calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); + String year = String.valueOf(calendar.get(Calendar.YEAR)); + String month = String.valueOf(calendar.get(Calendar.MONTH) + 1); // 注意月份是从0开始的,所以要加1 + String day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)); + + + // 检查用户是否输入了时间和活动 + if (!inputTime.isEmpty() && !inputAction.isEmpty() && !inputCategories.isEmpty()) { + int customTime = Integer.parseInt(inputTime); + + // 实现计时逻辑,使用用户输入的时间 + countDownTimer = new CountDownTimer(customTime * 60 * 1000, 1000) { + @Override + public void onTick(long millisUntilFinished) { + updateTimerText(millisUntilFinished); + } + + @Override + public void onFinish() { + // 完成工作时钟,可以处理相应逻辑 + UserRecord userRecord = new UserRecord(); + + //将这些获取到的数据写入db UserRecord + userRecord.setCategory(inputCategories); + userRecord.setDuration(customTime); + userRecord.setActionDescription(inputAction); + userRecord.setYear(year); + userRecord.setMonth(month); + userRecord.setDay(day); + userRecord.save(); + + stopTimer(); + //FinishMessage + showCompletionMessage(); + } + }.start(); + + startButton.setText("Stop"); + isTimerRunning = true; + + // 将时钟和按钮设置为可见 + timerTextView.setVisibility(View.VISIBLE); + }else if (inputCategories.isEmpty()) { + // 用户没有选择,可以显示一个提示 + Toast.makeText(this, "Please select a action.", Toast.LENGTH_SHORT).show(); + } else if (inputAction.isEmpty()) { + // 用户没有输入时间,可以显示一个提示 + Toast.makeText(this, "Please enter a valid action.", Toast.LENGTH_SHORT).show(); + } else { + // 用户没有输入活动,可以显示一个提示 + Toast.makeText(this, "Please enter a valid time.", Toast.LENGTH_SHORT).show(); + } + } + + + private void stopTimer() { + if (countDownTimer != null) { + countDownTimer.cancel(); + } + + startButton.setText("Start"); + isTimerRunning = false; + } + + private void showCompletionMessage() { + // 弹出 Toast 消息 + Toast.makeText(TomatoActivity.this, "Task completed! Your record was loading!", Toast.LENGTH_LONG).show(); + + // 播放铃声 + playRingtone(); + + // 执行震动 + vibrate(); + + // 创建按钮 + Button toRecordActivityButton = new Button(this); + toRecordActivityButton.setText("View all your work"); + // 设置按钮的背景颜色为橙色 + toRecordActivityButton.setBackgroundColor(getResources().getColor(android.R.color.holo_orange_light)); + + // 设置按钮的点击监听器 + toRecordActivityButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // 停止播放铃声 + stopRingtone(); + // 停止震动 + stopVibration(); + // 在按钮点击时执行跳转逻辑 + Intent intent = new Intent(TomatoActivity.this, RecordListActivity.class); + startActivity(intent); + } + }); + + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.WRAP_CONTENT, + RelativeLayout.LayoutParams.WRAP_CONTENT + ); + layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); + layoutParams.addRule(RelativeLayout.BELOW, R.id.startButton); // 改成你想要放置按钮的位置 + + ((RelativeLayout) findViewById(R.id.RelativeLayout)).addView(toRecordActivityButton, layoutParams); + } + + private void playRingtone() { + // 初始化 MediaPlayer + mediaPlayer = MediaPlayer.create(this, R.raw.ring); // 替换为你的铃声资源 + + // 设置循环播放 + mediaPlayer.setLooping(false); + + // 开始播放 + mediaPlayer.start(); + } + private void stopRingtone() { + if (mediaPlayer != null && mediaPlayer.isPlaying()) { + mediaPlayer.stop(); + mediaPlayer.release(); + mediaPlayer = null; + } + } + + + private void vibrate() { + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + + // 震动 500 毫秒(可以根据需要调整) + if (vibrator != null) { + vibrator.vibrate(500); + } + } + private void stopVibration() { + if (vibrator != null) { + vibrator.cancel(); + } + } + + private void updateTimerText(long millisUntilFinished) { + int minutes = (int) (millisUntilFinished / 1000) / 60; + int seconds = (int) (millisUntilFinished / 1000) % 60; + + String timeLeftFormatted = String.format("%02d:%02d", minutes, seconds); + timerTextView.setText(timeLeftFormatted); + } + + //退出提示 + @Override + public void onBackPressed() { + if (isTimerRunning) { + showExitConfirmationDialog(); + } else { + super.onBackPressed(); + } + } + + private void showExitConfirmationDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); + builder.setTitle("Confirmation") + .setMessage("Are you want to cancel the timer? Finish your job will record it in your list.") + .setPositiveButton("Yes", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // 用户确认退出,停止计时器并关闭应用 + stopTimer(); + finish(); + } + }) + .setNegativeButton("No", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // 用户取消退出,继续计时器 + dialog.dismiss(); + } + }) + .show(); + } + private void stopConfirmationDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); + builder.setTitle("Confirmation") + .setMessage("Are you want to stop the timer? Finish your job will record it in your list.") + .setPositiveButton("Yes", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // 用户确认退出,停止计时器并关闭应用 + stopTimer(); + } + }) + .setNegativeButton("No", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // 用户取消退出,继续计时器 + dialog.dismiss(); + } + }) + .show(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/yzbkaka/things/db/Log.java b/app/src/main/java/com/example/can301/things/db/Log.java similarity index 82% rename from app/src/main/java/com/example/yzbkaka/things/db/Log.java rename to app/src/main/java/com/example/can301/things/db/Log.java index d74a794..d2936cd 100644 --- a/app/src/main/java/com/example/yzbkaka/things/db/Log.java +++ b/app/src/main/java/com/example/can301/things/db/Log.java @@ -1,10 +1,7 @@ -package com.example.yzbkaka.things.db; +package com.example.can301.things.db; import org.litepal.crud.LitePalSupport; -/** - * Created by yzbkaka on 19-4-7. - */ public class Log extends LitePalSupport { int id; diff --git a/app/src/main/java/com/example/yzbkaka/things/db/Plan.java b/app/src/main/java/com/example/can301/things/db/Plan.java similarity index 93% rename from app/src/main/java/com/example/yzbkaka/things/db/Plan.java rename to app/src/main/java/com/example/can301/things/db/Plan.java index 5e9bd9f..55356a9 100644 --- a/app/src/main/java/com/example/yzbkaka/things/db/Plan.java +++ b/app/src/main/java/com/example/can301/things/db/Plan.java @@ -1,12 +1,9 @@ -package com.example.yzbkaka.things.db; +package com.example.can301.things.db; import org.litepal.crud.LitePalSupport; import java.util.Date; -/** - * Created by yzbkaka on 19-4-4. - */ public class Plan extends LitePalSupport { int id; diff --git a/app/src/main/java/com/example/can301/things/db/UserRecord.java b/app/src/main/java/com/example/can301/things/db/UserRecord.java new file mode 100644 index 0000000..4180c2f --- /dev/null +++ b/app/src/main/java/com/example/can301/things/db/UserRecord.java @@ -0,0 +1,70 @@ +package com.example.can301.things.db; + +import org.litepal.crud.LitePalSupport; + +public class UserRecord extends LitePalSupport { + int id; + private String category; + private String actionDescription; + private double duration; + String year; + String month; + String Day; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getActionDescription() { + return actionDescription; + } + + public void setActionDescription(String actionDescription) { + this.actionDescription = actionDescription; + } + + public double getDuration() { + return duration; + } + + public void setDuration(double duration) { + this.duration = duration; + } + + public String getYear() { + return year; + } + + public void setYear(String year) { + this.year = year; + } + + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } + + public String getDay() { + return Day; + } + + public void setDay(String Day) { + this.Day = Day; + } + +} diff --git a/app/src/main/java/com/example/can301/things/ui/dashboard/DashboardFragment.java b/app/src/main/java/com/example/can301/things/ui/dashboard/DashboardFragment.java new file mode 100644 index 0000000..e450591 --- /dev/null +++ b/app/src/main/java/com/example/can301/things/ui/dashboard/DashboardFragment.java @@ -0,0 +1,36 @@ +package com.example.can301.things.ui.dashboard; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.ViewModelProvider; + +import com.example.can301.things.databinding.FragmentDashboardBinding; + +public class DashboardFragment extends Fragment { + + private FragmentDashboardBinding binding; + + public View onCreateView(@NonNull LayoutInflater inflater, + ViewGroup container, Bundle savedInstanceState) { + DashboardViewModel dashboardViewModel = + new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(DashboardViewModel.class); + + binding = FragmentDashboardBinding.inflate(inflater, container, false); + View root = binding.getRoot(); + + final TextView textView = binding.textDashboard; + dashboardViewModel.getText().observe(getViewLifecycleOwner(), textView::setText); + return root; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/can301/things/ui/dashboard/DashboardViewModel.java b/app/src/main/java/com/example/can301/things/ui/dashboard/DashboardViewModel.java new file mode 100644 index 0000000..cdd568f --- /dev/null +++ b/app/src/main/java/com/example/can301/things/ui/dashboard/DashboardViewModel.java @@ -0,0 +1,19 @@ +package com.example.can301.things.ui.dashboard; + +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +public class DashboardViewModel extends ViewModel { + + private final MutableLiveData mText; + + public DashboardViewModel() { + mText = new MutableLiveData<>(); + mText.setValue("This is dashboard fragment"); + } + + public LiveData getText() { + return mText; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/can301/things/ui/home/HomeFragment.java b/app/src/main/java/com/example/can301/things/ui/home/HomeFragment.java new file mode 100644 index 0000000..92191f9 --- /dev/null +++ b/app/src/main/java/com/example/can301/things/ui/home/HomeFragment.java @@ -0,0 +1,36 @@ +package com.example.can301.things.ui.home; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.ViewModelProvider; + +import com.example.can301.things.databinding.FragmentHomeBinding; + +public class HomeFragment extends Fragment { + + private FragmentHomeBinding binding; + + public View onCreateView(@NonNull LayoutInflater inflater, + ViewGroup container, Bundle savedInstanceState) { + HomeViewModel homeViewModel = + new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(HomeViewModel.class); + + binding = FragmentHomeBinding.inflate(inflater, container, false); + View root = binding.getRoot(); + + final TextView textView = binding.textHome; + homeViewModel.getText().observe(getViewLifecycleOwner(), textView::setText); + return root; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/can301/things/ui/home/HomeViewModel.java b/app/src/main/java/com/example/can301/things/ui/home/HomeViewModel.java new file mode 100644 index 0000000..2bbc205 --- /dev/null +++ b/app/src/main/java/com/example/can301/things/ui/home/HomeViewModel.java @@ -0,0 +1,19 @@ +package com.example.can301.things.ui.home; + +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +public class HomeViewModel extends ViewModel { + + private final MutableLiveData mText; + + public HomeViewModel() { + mText = new MutableLiveData<>(); + mText.setValue("This is home fragment"); + } + + public LiveData getText() { + return mText; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/can301/things/ui/notifications/NotificationsFragment.java b/app/src/main/java/com/example/can301/things/ui/notifications/NotificationsFragment.java new file mode 100644 index 0000000..5121dbe --- /dev/null +++ b/app/src/main/java/com/example/can301/things/ui/notifications/NotificationsFragment.java @@ -0,0 +1,36 @@ +package com.example.can301.things.ui.notifications; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.ViewModelProvider; + +import com.example.can301.things.databinding.FragmentNotificationsBinding; + +public class NotificationsFragment extends Fragment { + + private FragmentNotificationsBinding binding; + + public View onCreateView(@NonNull LayoutInflater inflater, + ViewGroup container, Bundle savedInstanceState) { + NotificationsViewModel notificationsViewModel = + new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(NotificationsViewModel.class); + + binding = FragmentNotificationsBinding.inflate(inflater, container, false); + View root = binding.getRoot(); + + final TextView textView = binding.textNotifications; + notificationsViewModel.getText().observe(getViewLifecycleOwner(), textView::setText); + return root; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/can301/things/ui/notifications/NotificationsViewModel.java b/app/src/main/java/com/example/can301/things/ui/notifications/NotificationsViewModel.java new file mode 100644 index 0000000..91d4598 --- /dev/null +++ b/app/src/main/java/com/example/can301/things/ui/notifications/NotificationsViewModel.java @@ -0,0 +1,19 @@ +package com.example.can301.things.ui.notifications; + +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +public class NotificationsViewModel extends ViewModel { + + private final MutableLiveData mText; + + public NotificationsViewModel() { + mText = new MutableLiveData<>(); + mText.setValue("This is notifications fragment"); + } + + public LiveData getText() { + return mText; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/yzbkaka/things/Setting/AboutActivity.java b/app/src/main/java/com/example/yzbkaka/things/Setting/AboutActivity.java deleted file mode 100644 index 2e435b8..0000000 --- a/app/src/main/java/com/example/yzbkaka/things/Setting/AboutActivity.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.example.yzbkaka.things.Setting; - -import android.os.Build; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.view.View; -import android.webkit.WebView; -import android.webkit.WebViewClient; - -import com.example.yzbkaka.things.R; - -public class AboutActivity extends AppCompatActivity { - private WebView webView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_about); - webView = (WebView)findViewById(R.id.webview); - webView.getSettings().setJavaScriptEnabled(true); - webView.setWebViewClient(new WebViewClient()); - webView.loadUrl("https://github.com/yzbkaka/Schedule"); - setLightMode(); - } - - private void setLightMode(){ - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } -} diff --git a/app/src/main/res/drawable/background.png b/app/src/main/res/drawable/background.png index e1adcd4..d03e4cb 100644 Binary files a/app/src/main/res/drawable/background.png and b/app/src/main/res/drawable/background.png differ diff --git a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml new file mode 100644 index 0000000..46fc8de --- /dev/null +++ b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_home_black_24dp.xml b/app/src/main/res/drawable/ic_home_black_24dp.xml new file mode 100644 index 0000000..f8bb0b5 --- /dev/null +++ b/app/src/main/res/drawable/ic_home_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_menu_camera.xml b/app/src/main/res/drawable/ic_menu_camera.xml new file mode 100644 index 0000000..0a54e80 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_camera.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_menu_gallery.xml b/app/src/main/res/drawable/ic_menu_gallery.xml new file mode 100644 index 0000000..dc44a72 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_gallery.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_menu_slideshow.xml b/app/src/main/res/drawable/ic_menu_slideshow.xml new file mode 100644 index 0000000..a306e81 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_slideshow.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml new file mode 100644 index 0000000..78b75c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_notifications_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/record.png b/app/src/main/res/drawable/record.png new file mode 100644 index 0000000..0fbf01c Binary files /dev/null and b/app/src/main/res/drawable/record.png differ diff --git a/app/src/main/res/drawable/side_nav_bar.xml b/app/src/main/res/drawable/side_nav_bar.xml new file mode 100644 index 0000000..6d81870 --- /dev/null +++ b/app/src/main/res/drawable/side_nav_bar.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/tomato.png b/app/src/main/res/drawable/tomato.png new file mode 100644 index 0000000..e41e309 Binary files /dev/null and b/app/src/main/res/drawable/tomato.png differ diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml deleted file mode 100644 index 45065c1..0000000 --- a/app/src/main/res/layout/activity_about.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/app/src/main/res/layout/activity_alter_schedule.xml b/app/src/main/res/layout/activity_alter_schedule.xml index 83a0f89..0599602 100644 --- a/app/src/main/res/layout/activity_alter_schedule.xml +++ b/app/src/main/res/layout/activity_alter_schedule.xml @@ -27,7 +27,7 @@ android:layout_gravity="center_vertical" android:layout_marginLeft="5dp" android:textSize="20dp" - android:hint="写下今天的计划吧!" + android:hint="Write down your plans for today!" android:singleLine="true"/>