|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 108 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 119 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 94 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 236 KiB |
|
After Width: | Height: | Size: 219 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 145 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 141 KiB |
|
After Width: | Height: | Size: 138 KiB |
|
After Width: | Height: | Size: 165 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 240 KiB |
@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
@ -0,0 +1 @@
|
||||
My Application
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\20922\.android\avd\Pixel_6_Pro_API_33.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2025-09-29T07:20:17.026786700Z" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1 @@
|
||||
/build
|
||||
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@ -0,0 +1,26 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.example.myapplication", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-feature
|
||||
android:glEsVersion="0x00020000"
|
||||
android:required="true" />
|
||||
|
||||
<!-- 网络权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
<!-- 高德地图SDK核心权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<!-- <uses-permission android:name="android.permission.WRITE_SETTINGS" /> 注释掉:此权限仅系统应用可用 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<!-- 高德地图导航相关权限 -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
|
||||
<!-- 课程提醒相关权限 -->
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||
|
||||
<!-- 笔记图片相关权限 -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.MyApplication"
|
||||
android:hardwareAccelerated="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="31">
|
||||
|
||||
<!-- 高德地图API Key -->
|
||||
<meta-data
|
||||
android:name="com.amap.api.v2.apikey"
|
||||
android:value="0c0a6f3a57e257c8bf0d9c8202110a37" />
|
||||
|
||||
<!-- 高德地图服务配置 -->
|
||||
<service android:name="com.amap.api.location.APSService"></service>
|
||||
|
||||
<activity
|
||||
android:name=".HomeActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="false"
|
||||
android:hardwareAccelerated="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden" />
|
||||
|
||||
<activity
|
||||
android:name=".LocationDetailsActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<!-- 教务系统登录WebView -->
|
||||
<activity
|
||||
android:name=".WebViewActivity"
|
||||
android:exported="false"
|
||||
android:label="教务系统登录"
|
||||
android:hardwareAccelerated="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden" />
|
||||
|
||||
<!-- 教务系统课表导入 -->
|
||||
<activity
|
||||
android:name=".EducationImportActivity"
|
||||
android:exported="false"
|
||||
android:label="教务系统课表导入"
|
||||
android:hardwareAccelerated="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden" />
|
||||
|
||||
<!-- 课程提醒全屏弹窗 -->
|
||||
<activity
|
||||
android:name=".ReminderAlertActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.AppCompat.Dialog.Alert"
|
||||
android:excludeFromRecents="true"
|
||||
android:finishOnTaskLaunch="true" />
|
||||
|
||||
<!-- 课程提醒弹窗(微信样式) -->
|
||||
<activity
|
||||
android:name=".CourseReminderActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/ReminderDialogTheme"
|
||||
android:excludeFromRecents="true"
|
||||
android:showWhenLocked="true"
|
||||
android:turnScreenOn="true"
|
||||
android:launchMode="singleTop" />
|
||||
|
||||
<!-- 全屏笔记编辑器 -->
|
||||
<activity
|
||||
android:name=".NoteEditorActivity"
|
||||
android:exported="false"
|
||||
android:label="编辑笔记"
|
||||
android:hardwareAccelerated="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden" />
|
||||
|
||||
<!-- 笔记阅读模式 -->
|
||||
<activity
|
||||
android:name=".NoteReaderActivity"
|
||||
android:exported="false"
|
||||
android:label="阅读笔记"
|
||||
android:hardwareAccelerated="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden" />
|
||||
|
||||
<!-- FileProvider for sharing files -->
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<!-- 课程提醒接收器 -->
|
||||
<receiver
|
||||
android:name=".CourseReminderReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
<receiver
|
||||
android:name=".ReminderReceiver"
|
||||
android:exported="false" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@ -0,0 +1,158 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GradeAdapter extends RecyclerView.Adapter<GradeAdapter.GradeViewHolder> {
|
||||
|
||||
private List<WebViewActivity.GradeItem> gradeItems;
|
||||
public interface OnItemUpdatedListener { void onScoreUpdated(); }
|
||||
private OnItemUpdatedListener onItemUpdatedListener;
|
||||
|
||||
public GradeAdapter() {
|
||||
this.gradeItems = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void updateData(List<WebViewActivity.GradeItem> newItems) {
|
||||
this.gradeItems.clear();
|
||||
this.gradeItems.addAll(newItems);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnItemUpdatedListener(OnItemUpdatedListener listener) {
|
||||
this.onItemUpdatedListener = listener;
|
||||
}
|
||||
|
||||
public List<WebViewActivity.GradeItem> getItems() { return gradeItems; }
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public GradeViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_grade, parent, false);
|
||||
return new GradeViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull GradeViewHolder holder, int position) {
|
||||
WebViewActivity.GradeItem item = gradeItems.get(position);
|
||||
|
||||
// 课程名称作为主标题
|
||||
String courseName = item.courseName != null && !item.courseName.isEmpty() ? item.courseName : "未知课程";
|
||||
holder.tvCourseName.setText(courseName);
|
||||
|
||||
// 课程编号
|
||||
String courseCode = item.courseCode != null && !item.courseCode.isEmpty() ? item.courseCode : "未知";
|
||||
holder.tvCourseCode.setText("编号: " + courseCode);
|
||||
|
||||
// 学分信息
|
||||
holder.tvCredit.setText("学分: " + (item.credit != null ? item.credit : "未知"));
|
||||
|
||||
// 成绩信息/输入切换
|
||||
boolean hasScore = item.score != null && !item.score.isEmpty();
|
||||
if (hasScore) {
|
||||
holder.tvScore.setVisibility(View.VISIBLE);
|
||||
holder.etScoreInput.setVisibility(View.GONE);
|
||||
holder.tvScore.setText("成绩: " + item.score);
|
||||
} else {
|
||||
holder.tvScore.setVisibility(View.GONE);
|
||||
holder.etScoreInput.setVisibility(View.VISIBLE);
|
||||
// 避免旧监听残留
|
||||
Object oldWatcher = holder.etScoreInput.getTag();
|
||||
if (oldWatcher instanceof TextWatcher) {
|
||||
holder.etScoreInput.removeTextChangedListener((TextWatcher) oldWatcher);
|
||||
}
|
||||
holder.etScoreInput.setText(item.score != null ? item.score : "");
|
||||
holder.etScoreInput.setHint("请输入成绩");
|
||||
|
||||
// 监听输入并计算绩点
|
||||
TextWatcher watcher = new TextWatcher() {
|
||||
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
@Override public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
@Override public void afterTextChanged(Editable s) {
|
||||
String text = s.toString().trim();
|
||||
item.score = text;
|
||||
String gpa = computeGpaFromScore(text);
|
||||
item.gpa = gpa;
|
||||
holder.tvGpa.setText("绩点: " + (gpa != null && !gpa.isEmpty() ? gpa : "0"));
|
||||
if (onItemUpdatedListener != null) onItemUpdatedListener.onScoreUpdated();
|
||||
}
|
||||
};
|
||||
holder.etScoreInput.addTextChangedListener(watcher);
|
||||
holder.etScoreInput.setTag(watcher);
|
||||
}
|
||||
|
||||
// 绩点信息
|
||||
holder.tvGpa.setText("绩点: " + (item.gpa != null && !item.gpa.isEmpty() ? item.gpa : "未知"));
|
||||
|
||||
// 学年/建议修读学年
|
||||
holder.tvYear.setText((hasScore ? "学年: " : "建议修读学年: ") + (item.year != null && !item.year.isEmpty() ? item.year : "未知"));
|
||||
|
||||
// 课程性质信息
|
||||
holder.tvStatus.setText("课程性质: " + (item.status != null ? item.status : "未知"));
|
||||
|
||||
// 学期/建议修读学期
|
||||
holder.tvTerm.setText((hasScore ? "学期: " : "建议修读学期: ") + (item.term != null && !item.term.isEmpty() ? item.term : "未知"));
|
||||
}
|
||||
|
||||
private String computeGpaFromScore(String scoreText) {
|
||||
if (scoreText == null || scoreText.isEmpty()) return "";
|
||||
try {
|
||||
int score = Integer.parseInt(scoreText);
|
||||
if (score >= 90) return "4.0";
|
||||
if (score >= 85) return "3.7";
|
||||
if (score >= 82) return "3.3";
|
||||
if (score >= 78) return "3.0";
|
||||
if (score >= 75) return "2.7";
|
||||
if (score >= 72) return "2.3";
|
||||
if (score >= 68) return "2.0";
|
||||
if (score >= 66) return "1.7";
|
||||
if (score >= 64) return "1.5";
|
||||
if (score >= 60) return "1.0";
|
||||
return "0";
|
||||
} catch (NumberFormatException e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return gradeItems.size();
|
||||
}
|
||||
|
||||
static class GradeViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvCourseName;
|
||||
TextView tvCourseCode;
|
||||
TextView tvCredit;
|
||||
TextView tvScore;
|
||||
EditText etScoreInput;
|
||||
TextView tvGpa;
|
||||
TextView tvTerm;
|
||||
TextView tvYear;
|
||||
TextView tvStatus;
|
||||
|
||||
public GradeViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
tvCourseName = itemView.findViewById(R.id.tv_course_name);
|
||||
tvCourseCode = itemView.findViewById(R.id.tv_course_code);
|
||||
tvCredit = itemView.findViewById(R.id.tv_credit);
|
||||
tvScore = itemView.findViewById(R.id.tv_score);
|
||||
etScoreInput = itemView.findViewById(R.id.et_score_input);
|
||||
tvGpa = itemView.findViewById(R.id.tv_gpa);
|
||||
tvTerm = itemView.findViewById(R.id.tv_term);
|
||||
tvYear = itemView.findViewById(R.id.tv_year);
|
||||
tvStatus = itemView.findViewById(R.id.tv_status);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
|
||||
public class HomeActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home);
|
||||
|
||||
// 获取四个功能卡片
|
||||
CardView cardTimetable = findViewById(R.id.card_timetable);
|
||||
CardView cardNotes = findViewById(R.id.card_notes);
|
||||
CardView cardGrades = findViewById(R.id.card_grades);
|
||||
CardView cardCampus = findViewById(R.id.card_campus);
|
||||
|
||||
// 课表按钮点击事件
|
||||
cardTimetable.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(HomeActivity.this, MainActivity.class);
|
||||
intent.putExtra("fragment", "timetable");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
// 笔记按钮点击事件
|
||||
cardNotes.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(HomeActivity.this, MainActivity.class);
|
||||
intent.putExtra("fragment", "notes");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
// 成绩按钮点击事件
|
||||
cardGrades.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(HomeActivity.this, MainActivity.class);
|
||||
intent.putExtra("fragment", "grades");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
// 校园导航按钮点击事件
|
||||
cardCampus.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(HomeActivity.this, MainActivity.class);
|
||||
intent.putExtra("fragment", "campus");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
try {
|
||||
// Configure window for better OpenGL rendering
|
||||
Window window = getWindow();
|
||||
window.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
|
||||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// 从Intent获取要显示的页面
|
||||
String fragmentType = getIntent().getStringExtra("fragment");
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
Fragment fragment = null;
|
||||
|
||||
if ("notes".equals(fragmentType)) {
|
||||
fragment = new NotesFragment();
|
||||
} else if ("grades".equals(fragmentType)) {
|
||||
fragment = new GradesFragment();
|
||||
} else if ("campus".equals(fragmentType)) {
|
||||
fragment = new CampusNavFragmentSimplified();
|
||||
} else {
|
||||
// 默认显示课表页面
|
||||
fragment = new TimetableFragment();
|
||||
}
|
||||
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(this, "应用初始化失败", Toast.LENGTH_LONG).show();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// 返回主页面
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,95 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Note implements Serializable {
|
||||
private String id;
|
||||
private String title; // 笔记标题
|
||||
private String content; // 笔记内容
|
||||
private String courseId; // 关联的课程ID
|
||||
private String courseName; // 关联的课程名称
|
||||
private long createTime; // 创建时间
|
||||
private long modifyTime; // 修改时间
|
||||
private List<String> imagePaths; // 图片路径列表
|
||||
|
||||
public Note() {
|
||||
this.id = String.valueOf(System.currentTimeMillis());
|
||||
this.createTime = System.currentTimeMillis();
|
||||
this.modifyTime = System.currentTimeMillis();
|
||||
this.imagePaths = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Note(String title, String content) {
|
||||
this();
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Note(String title, String content, String courseId, String courseName) {
|
||||
this(title, content);
|
||||
this.courseId = courseId;
|
||||
this.courseName = courseName;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
|
||||
public String getTitle() { return title; }
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
this.modifyTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getContent() { return content; }
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
this.modifyTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getCourseId() { return courseId; }
|
||||
public void setCourseId(String courseId) {
|
||||
this.courseId = courseId;
|
||||
this.modifyTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getCourseName() { return courseName; }
|
||||
public void setCourseName(String courseName) {
|
||||
this.courseName = courseName;
|
||||
this.modifyTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public long getCreateTime() { return createTime; }
|
||||
public void setCreateTime(long createTime) { this.createTime = createTime; }
|
||||
|
||||
public long getModifyTime() { return modifyTime; }
|
||||
public void setModifyTime(long modifyTime) { this.modifyTime = modifyTime; }
|
||||
|
||||
public List<String> getImagePaths() { return imagePaths; }
|
||||
public void setImagePaths(List<String> imagePaths) {
|
||||
this.imagePaths = imagePaths != null ? imagePaths : new ArrayList<>();
|
||||
this.modifyTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void addImagePath(String imagePath) {
|
||||
if (this.imagePaths == null) {
|
||||
this.imagePaths = new ArrayList<>();
|
||||
}
|
||||
this.imagePaths.add(imagePath);
|
||||
this.modifyTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void removeImagePath(String imagePath) {
|
||||
if (this.imagePaths != null) {
|
||||
this.imagePaths.remove(imagePath);
|
||||
this.modifyTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title + (courseName != null ? " (" + courseName + ")" : "");
|
||||
}
|
||||
}
|
||||