-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84802e7
commit ea4abde
Showing
114 changed files
with
3,066 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Android CI | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: set up JDK 17 | ||
uses: actions/[email protected] | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: gradle | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew assembleRelease | ||
|
||
- uses: ilharp/sign-android-release@nightly | ||
name: Sign APK | ||
id: sign_app | ||
with: | ||
releaseDir: app/build/outputs/apk/release | ||
signingKey: ${{ secrets.ANDROID_SIGNING_KEY }} | ||
keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }} | ||
keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | ||
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }} | ||
buildToolsVersion: 33.0.0 | ||
|
||
- name: Upload APK | ||
uses: actions/[email protected] | ||
with: | ||
name: Release | ||
path: ${{steps.sign_app.outputs.signedFile}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,5 @@ google-services.json | |
|
||
# Android Profiling | ||
*.hprof | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# ToDo | ||
# 待办 | ToDo | ||
简单的待办应用,遵循Material Design 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
val baseVersionName = "1.0.0" | ||
val commitHash by lazy { "git rev-parse --short HEAD".exec() } | ||
val verCode by lazy { "git rev-list --count HEAD".exec().toInt() } | ||
|
||
android { | ||
namespace = "cn.super12138.todo" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "cn.super12138.todo" | ||
minSdk = 24 | ||
targetSdk = 34 | ||
versionCode = verCode | ||
versionName = "${baseVersionName}-${commitHash}" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = true | ||
isShrinkResources = true | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
viewBinding = true | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
// AndroidX | ||
implementation("androidx.core:core-ktx:1.12.0") | ||
implementation("androidx.appcompat:appcompat:1.6.1") | ||
implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||
implementation("androidx.fragment:fragment:1.6.2") | ||
implementation("androidx.fragment:fragment-ktx:1.6.2") | ||
implementation("androidx.recyclerview:recyclerview:1.3.2") | ||
implementation("androidx.lifecycle:lifecycle-viewmodel:2.6.2") | ||
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2") | ||
implementation("androidx.preference:preference:1.2.1") | ||
implementation("androidx.preference:preference-ktx:1.2.1") | ||
// Material Design | ||
implementation("com.google.android.material:material:1.12.0-alpha02") | ||
// Test | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
} | ||
|
||
fun String.exec(): String = exec(this) | ||
|
||
@Suppress("UnstableApiUsage") | ||
fun Project.exec(command: String): String = providers.exec { | ||
commandLine(command.split(" ")) | ||
}.standardOutput.asText.get().trim() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "cn.super12138.todo", | ||
"variantName": "release", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 1, | ||
"versionName": "1.0.0", | ||
"outputFile": "app-release.apk" | ||
} | ||
], | ||
"elementType": "File" | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/androidTest/kotlin/cn/super12138/todo/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package cn.super12138.todo | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("cn.super12138.todo", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<application | ||
android:name=".ToDoApplication" | ||
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:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.ToDo" | ||
tools:targetApi="34"> | ||
|
||
<activity | ||
android:name=".views.main.MainActivity" | ||
android:exported="true" | ||
android:launchMode="singleTask"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".views.settings.SettingsActivity" | ||
android:exported="false" | ||
android:label="@string/settings_label" | ||
android:launchMode="singleTask" /> | ||
<activity | ||
android:name=".views.about.AboutActivity" | ||
android:exported="false" | ||
android:label="@string/about_label" | ||
android:launchMode="singleTask" /> | ||
<activity | ||
android:name=".views.crash.CrashActivity" | ||
android:exported="false" /> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cn.super12138.todo | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Application | ||
import android.content.Context | ||
import cn.super12138.todo.views.crash.CrashHandler | ||
import com.google.android.material.color.DynamicColors | ||
|
||
class ToDoApplication : Application() { | ||
companion object { | ||
@SuppressLint("StaticFieldLeak") | ||
lateinit var context: Context | ||
} | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
DynamicColors.applyToActivitiesIfAvailable(this) | ||
context = applicationContext | ||
|
||
val crashHandler = CrashHandler(this) | ||
Thread.setDefaultUncaughtExceptionHandler(crashHandler) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/kotlin/cn/super12138/todo/constant/Constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cn.super12138.todo.constant | ||
|
||
object Constants { | ||
const val DB_NAME = "ToDo.db" | ||
const val DB_VERSION = 1 | ||
const val TABLE_NAME = "ToDo" | ||
|
||
const val AUTHOR_GITHUB_URL = "https://github.com/Super12138/" | ||
const val REPO_GITHUB_URL = "https://github.com/Super12138/ToDo" | ||
const val UPDATE_URL = "https://github.com/Super12138/ToDo/releases" | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/kotlin/cn/super12138/todo/logic/Repository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cn.super12138.todo.logic | ||
|
||
import android.content.ContentValues | ||
import android.content.Context | ||
import cn.super12138.todo.logic.database.DBHelper | ||
import cn.super12138.todo.logic.database.SPHelper | ||
|
||
object Repository { | ||
fun getCompleteTotalCount() = DBHelper.getCompleteTotalCount() | ||
|
||
fun insertData(data: ContentValues) = DBHelper.insertData(data) | ||
|
||
fun deleteData(deleteAll: Boolean, uuid: String?) = DBHelper.deleteData(deleteAll, uuid) | ||
|
||
fun updateData(uuid: String, newData: ContentValues) = DBHelper.updateData(uuid, newData) | ||
|
||
fun getAllData() = DBHelper.getAllData() | ||
|
||
fun getPreferenceString(context: Context, key: String, defaultValue: String) = SPHelper.getPreferenceString(context, key, defaultValue) | ||
} |
Oops, something went wrong.