Skip to content

Commit 0968fa1

Browse files
authored
Merge pull request #164 from Telephone2019/work
Work
2 parents ef586d0 + fb3cbba commit 0968fa1

24 files changed

+421
-148
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ android {
99
minSdkVersion 26
1010
targetSdkVersion 30
1111
versionCode 3
12-
versionName "3.5"
12+
versionName "3.6"
1313

1414
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1515

app/src/main/java/com/telephone/coursetable/CourseCardFragment.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public void onClick(View v) {
102102
}
103103
}
104104

105+
view.findViewById(R.id.course_card_cno).setTag(card.getCno()); // the cno
106+
view.findViewById(R.id.course_card_cno).setTag(CourseCard.TITLE_TAG_KEY, "课号"); // the cno title
105107
view.findViewById(R.id.course_card_cname).setTag(card.getCname()); // the cname
106108
view.findViewById(R.id.course_card_cname).setTag(CourseCard.TITLE_TAG_KEY, "课程名称"); // the cname title
107109
view.findViewById(R.id.course_card_sysccommet).setTag(card.getSys_comm()); // the system comment
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.telephone.coursetable.Database;
2+
3+
import androidx.room.Database;
4+
import androidx.room.RoomDatabase;
5+
6+
@Database(entities = {ExamTotal.class, GradeTotal.class}, version = 1, exportSchema = false)
7+
public abstract class AppDatabaseCompare extends RoomDatabase {
8+
public abstract ExamTotalDao examTotalDao();
9+
public abstract GradeTotalDao gradeTotalDao();
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.telephone.coursetable.Database;
2+
3+
import androidx.room.Database;
4+
import androidx.room.RoomDatabase;
5+
6+
@Database(entities = {ExamTotal.class, GradeTotal.class}, version = 1, exportSchema = false)
7+
public abstract class AppDatabaseCompareTest extends RoomDatabase {
8+
public abstract ExamTotalDao examTotalDao();
9+
public abstract GradeTotalDao gradeTotalDao();
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.telephone.coursetable.Database;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.room.Entity;
5+
import androidx.room.PrimaryKey;
6+
7+
@Entity
8+
public class ExamTotal {
9+
@NonNull
10+
@PrimaryKey
11+
public String total;
12+
public boolean read = false;
13+
14+
public ExamTotal(@NonNull String total) {
15+
this.total = total;
16+
}
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.telephone.coursetable.Database;
2+
3+
import androidx.room.Dao;
4+
import androidx.room.Insert;
5+
import androidx.room.OnConflictStrategy;
6+
import androidx.room.Query;
7+
8+
import java.util.List;
9+
10+
@Dao
11+
public interface ExamTotalDao {
12+
@Query("update ExamTotal set read=1")
13+
void readAll();
14+
15+
@Query("select count(*) from ExamTotal where read=0")
16+
int unreadNum();
17+
18+
@Query("select count(*) from ExamTotal")
19+
int totalNum();
20+
21+
@Insert(onConflict = OnConflictStrategy.IGNORE)
22+
void insert(ExamTotal tuple);
23+
24+
@Query("select * from ExamTotal")
25+
List<ExamTotal> selectAll();
26+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.telephone.coursetable.Database;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.room.Entity;
5+
import androidx.room.PrimaryKey;
6+
7+
@Entity
8+
public class GradeTotal {
9+
@NonNull
10+
@PrimaryKey
11+
public String total;
12+
public boolean read = false;
13+
14+
public GradeTotal(@NonNull String total) {
15+
this.total = total;
16+
}
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.telephone.coursetable.Database;
2+
3+
import androidx.room.Dao;
4+
import androidx.room.Insert;
5+
import androidx.room.OnConflictStrategy;
6+
import androidx.room.Query;
7+
8+
import java.util.List;
9+
10+
@Dao
11+
public interface GradeTotalDao {
12+
@Query("update GradeTotal set read=1")
13+
void readAll();
14+
15+
@Query("select count(*) from GradeTotal where read=0")
16+
int unreadNum();
17+
18+
@Query("select count(*) from GradeTotal")
19+
int totalNum();
20+
21+
@Insert(onConflict = OnConflictStrategy.IGNORE)
22+
void insert(GradeTotal tuple);
23+
24+
@Query("select * from GradeTotal")
25+
List<GradeTotal> selectAll();
26+
}

app/src/main/java/com/telephone/coursetable/Database/LAB.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ public LAB(String term, String labid, String itemname, String courseid, String c
7373

7474
public static String getLabName(String cname){return cname + "实验";}
7575
public static String getFullLabName(String cname, String item_name){return cname + "实验" + ": " + item_name;}
76-
public static String getUniqueSerialNumber(String project_id, String batch_no){return project_id + batch_no;}
76+
public static String getUniqueSerialNumber(String project_id, String batch_no){return project_id + ".批次" + batch_no;}
7777
}

app/src/main/java/com/telephone/coursetable/FetchService.java

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@
2424
import com.telephone.coursetable.Clock.FindClassOfCurrentOrNextTimeRes;
2525
import com.telephone.coursetable.Clock.Locate;
2626
import com.telephone.coursetable.Database.AppDatabase;
27+
import com.telephone.coursetable.Database.AppDatabaseCompare;
2728
import com.telephone.coursetable.Database.CET;
2829
import com.telephone.coursetable.Database.CETDao;
2930
import com.telephone.coursetable.Database.ClassInfo;
3031
import com.telephone.coursetable.Database.ClassInfoDao;
3132
import com.telephone.coursetable.Database.ExamInfo;
3233
import com.telephone.coursetable.Database.ExamInfoDao;
34+
import com.telephone.coursetable.Database.ExamTotal;
3335
import com.telephone.coursetable.Database.GoToClass;
3436
import com.telephone.coursetable.Database.GoToClassDao;
37+
import com.telephone.coursetable.Database.GradeTotal;
3538
import com.telephone.coursetable.Database.Grades;
3639
import com.telephone.coursetable.Database.GradesDao;
3740
import com.telephone.coursetable.Database.GraduationScore;
@@ -582,6 +585,7 @@ private void service_fetch_lan(){
582585
editor_test.clear().commit();
583586
// edit by Telephone 2020/11/23 18:15, use the comment map from formal database, NOT test database
584587
boolean fetch_merge_res = Login.fetch_merge(
588+
false,
585589
FetchService.this,
586590
cookie_builder.toString(),
587591
user.username,
@@ -658,29 +662,29 @@ public void lan_merge(
658662
ExamInfoDao e, ExamInfoDao e_t,
659663
CETDao cet, CETDao cet_t,
660664
LABDao lab, LABDao lab_t
661-
){
665+
) {
662666
Login.deleteOldDataFromDatabase(username, g, c, t, p, gs, gr, e, cet, lab);
663667
// editor.clear().commit();
664668
List<PersonInfo> p_t_all = p_t.selectAll();
665-
for (PersonInfo p_a : p_t_all){
669+
for (PersonInfo p_a : p_t_all) {
666670
p.insert(p_a);
667671
}
668672
List<TermInfo> t_t_all = t_t.selectAll();
669-
for (int i = 0; i < t_t_all.size(); i++){
673+
for (int i = 0; i < t_t_all.size(); i++) {
670674
TermInfo t_a = t_t_all.get(i);
671675
t_a.setDelay(delay_week_to_apply.get(i));
672676
t.insert(t_a);
673677
}
674678
List<GoToClass> g_t_all = g_t.selectAll(username);
675-
for (GoToClass g_a : g_t_all){
679+
for (GoToClass g_a : g_t_all) {
676680
g.insert(g_a);
677681
}
678682
List<ClassInfo> c_t_all = c_t.selectAll(username);
679-
for (ClassInfo c_a : c_t_all){
683+
for (ClassInfo c_a : c_t_all) {
680684
c.insert(c_a);
681685
}
682686
List<GraduationScore> gs_t_all = gs_t.selectAll();
683-
for (GraduationScore gs_a : gs_t_all){
687+
for (GraduationScore gs_a : gs_t_all) {
684688
gs.insert(gs_a);
685689
}
686690
// Set<String> keys = pref_t.getAll().keySet();
@@ -690,21 +694,47 @@ public void lan_merge(
690694
// }
691695
// editor.commit();
692696
List<Grades> gr_t_all = gr_t.selectAll();
693-
for (Grades gr_a : gr_t_all){
697+
for (Grades gr_a : gr_t_all) {
694698
gr.insert(gr_a);
695699
}
696700
List<ExamInfo> e_t_all = e_t.selectAll();
697-
for (ExamInfo e_a : e_t_all){
701+
for (ExamInfo e_a : e_t_all) {
698702
e.insert(e_a);
699703
}
700704
List<CET> cet_t_all = cet_t.selectAll();
701-
for (CET cet_a : cet_t_all){
705+
for (CET cet_a : cet_t_all) {
702706
cet.insert(cet_a);
703707
}
704708
List<LAB> lab_t_all = lab_t.selectAll();
705-
for (LAB lab_a : lab_t_all){
709+
for (LAB lab_a : lab_t_all) {
706710
lab.insert(lab_a);
707711
}
712+
List<ExamTotal> examTotalList_from_test = MyApp.getDb_compare_test().examTotalDao().selectAll();
713+
for (ExamTotal i : examTotalList_from_test) {
714+
MyApp.getDb_compare().examTotalDao().insert(i);
715+
}
716+
if (MyApp.getDb_compare().examTotalDao().unreadNum() > 0) {
717+
sendNotification(
718+
FetchService.this,
719+
MyApp.notification_channel_id_new_data,
720+
"您有新的考试安排",
721+
"到 “更多-考试安排” 中查看 >>",
722+
MyApp.notification_id_new_exam
723+
);
724+
}
725+
List<GradeTotal> gradeTotalList_from_test = MyApp.getDb_compare_test().gradeTotalDao().selectAll();
726+
for (GradeTotal i : gradeTotalList_from_test) {
727+
MyApp.getDb_compare().gradeTotalDao().insert(i);
728+
}
729+
if (MyApp.getDb_compare().gradeTotalDao().unreadNum() > 0) {
730+
sendNotification(
731+
FetchService.this,
732+
MyApp.notification_channel_id_new_data,
733+
"出成绩了!",
734+
"到 “更多-成绩单” 中查看 >>",
735+
MyApp.notification_id_new_grade
736+
);
737+
}
708738
}
709739

710740
private void lan_start(){
@@ -743,6 +773,22 @@ private void lan_notify_login_wrong_password(){
743773
NotificationManagerCompat.from(this).notify(MyApp.notification_id_fetch_service_lan_password_wrong, notification);
744774
}
745775

776+
public static void sendNotification(@NonNull Context c, @NonNull String channel_id, @NonNull String title, @NonNull String msg, int notification_id){
777+
Intent notificationIntent = new Intent(c, MainActivity.class);
778+
PendingIntent pendingIntent =
779+
PendingIntent.getActivity(c, 0, notificationIntent, 0);
780+
Notification notification =
781+
new NotificationCompat.Builder(c, channel_id)
782+
.setContentTitle(title)
783+
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
784+
.setSmallIcon(R.drawable.feather_pen_trans)
785+
.setContentIntent(pendingIntent)
786+
.setAutoCancel(true)
787+
.setTicker(title)
788+
.build();
789+
NotificationManagerCompat.from(c).notify(notification_id, notification);
790+
}
791+
746792
private void lan_fetch_service_loginFail(HttpConnectionAndCode res){
747793
final String NAME = "lan_fetch_service_loginFail()";
748794
com.telephone.coursetable.LogMe.LogMe.e(NAME,"it fail...");

0 commit comments

Comments
 (0)