Skip to content

Commit

Permalink
Merge pull request #5 from SukiEva/dev-compose
Browse files Browse the repository at this point in the history
Dev compose
  • Loading branch information
SukiEva authored Oct 6, 2021
2 parents fc32e3b + a561bc3 commit 6b55b42
Show file tree
Hide file tree
Showing 56 changed files with 1,705 additions and 353 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/dictionaries/Mr_right.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 19 additions & 12 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
}



android {
val androidTargetSdkVersion: Int by rootProject.extra
val androidMinSdkVersion: Int by rootProject.extra
val targetSdkVersion: Int by rootProject.extra
val minSdkVersion: Int by rootProject.extra
val androidBuildToolsVersion: String by rootProject.extra
val androidCompileSdkVersion: Int by rootProject.extra
val androidCompileNdkVersion: String by rootProject.extra
val defaultManagerPackageName: String by rootProject.extra
val compileSdkVersion: Int by rootProject.extra
val compileNdkVersion: String by rootProject.extra
val packageName: String by rootProject.extra
val verCode: Int by rootProject.extra
val verName: String by rootProject.extra


compileSdk = androidCompileSdkVersion
ndkVersion = androidCompileNdkVersion
compileSdk = compileSdkVersion
ndkVersion = compileNdkVersion
buildToolsVersion = androidBuildToolsVersion

defaultConfig {
applicationId = defaultManagerPackageName
minSdk = androidMinSdkVersion
targetSdk = androidTargetSdkVersion
applicationId = packageName
minSdk = minSdkVersion
targetSdk = targetSdkVersion
versionCode = verCode
versionName = verName

Expand Down Expand Up @@ -69,6 +68,14 @@ dependencies {
implementation(libs.bundles.accompanist)
implementation(libs.bundles.lifecycle)
implementation(libs.bundles.retrofit)
implementation(libs.bundles.room)
implementation(libs.bundles.thirdparty)

kapt("androidx.room:room-compiler:2.3.0")

implementation("androidx.appcompat:appcompat:1.3.1")

debugImplementation("androidx.compose.ui:ui-tooling:1.0.2")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.0.2")

}
13 changes: 8 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
android:supportsRtl="true"
android:theme="@style/Theme.Hhu.NoActionBar"
android:usesCleartextTraffic="true">

<activity
android:name=".ui.activity.ConfigActivity"
android:name=".ui.activity.results.ResultsActivity"
android:exported="false" />
<activity
android:name=".ui.activity.FavouriteActivity"
android:name=".ui.activity.config.ConfigActivity"
android:exported="false"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.activity.favourite.FavouriteActivity"
android:exported="false" />
<activity
android:name=".ui.activity.AboutActivity"
android:name=".ui.activity.about.AboutActivity"
android:exported="false"
android:label="@string/title_activity_about"
android:theme="@style/AppTheme.About" />
<activity
android:name=".ui.activity.MainActivity"
android:name=".ui.activity.home.HomeActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/github/sukieva/hhu/data/entity/Website.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package github.sukieva.hhu.data.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey

@Entity(indices = [Index(value = ["site_name"], unique = true)])
data class Website(
@ColumnInfo(name = "site_name")
var siteName: String,
@ColumnInfo(name = "site_address")
var siteAddress: String
) {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package github.sukieva.hhu.data.bean
package github.sukieva.hhu.data.entity.bean


data class Course(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package github.sukieva.hhu.data.bean
package github.sukieva.hhu.data.entity.bean


import java.math.BigInteger
import java.security.MessageDigest


data class LoginData(
var username: String,
var password: String,
var captcha: String
var password: String
) {
init { // md5 加密(小写字母+数字)
val md = MessageDigest.getInstance("MD5")
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/github/sukieva/hhu/data/entity/bean/PostData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package github.sukieva.hhu.data.entity.bean


data class PostData(
var maccount: String,
var mwid: String,
var mname: String,
var maid: String,
var minstitute: String,
var mgrade: String,
var mclass: String,
var mbuilding: String,
var mroom: String,
var mphone: String
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package github.sukieva.hhu.data.bean
package github.sukieva.hhu.data.entity.bean

data class Rank(
var name: String,
Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/github/sukieva/hhu/data/local/AppDatabase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package github.sukieva.hhu.data.local

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import github.sukieva.hhu.data.entity.Website
import github.sukieva.hhu.data.local.dao.FavDao

@Database(version = 1, exportSchema = false, entities = [Website::class])
abstract class AppDatabase : RoomDatabase() {

abstract fun favDao(): FavDao


companion object { // 全局只创建一个数据库实例
private var instance: AppDatabase? = null

@Synchronized
fun getDatabase(context: Context): AppDatabase {
instance?.let {
return it
}
return Room.databaseBuilder(context.applicationContext, AppDatabase::class.java, "app_database")
.fallbackToDestructiveMigration() // 数据库升级时销毁,测试用
.build().apply {
instance = this
}
}
}

}
24 changes: 24 additions & 0 deletions app/src/main/java/github/sukieva/hhu/data/local/dao/FavDao.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package github.sukieva.hhu.data.local.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import github.sukieva.hhu.data.entity.Website

@Dao
interface FavDao {

@Insert
suspend fun insertWeb(website: Website): Long


@Query("select * from Website")
suspend fun loadAllWebs(): List<Website>

@Query("delete from Website")
suspend fun deleteAllWebs()

@Query("delete from Website where site_name = :siteName")
suspend fun deleteWebBySiteName(siteName: String): Int
}
Loading

0 comments on commit 6b55b42

Please sign in to comment.