diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..eaf91e2
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index a8fce2b..8e0edab 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,6 +1,22 @@
+
+
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..245a82c
--- /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
index 8708f9d..cb41453 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -15,6 +15,7 @@
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7bfef59..d5d35ec 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/.idea/terminal.xml b/.idea/terminal.xml
new file mode 100644
index 0000000..90d1c0b
--- /dev/null
+++ b/.idea/terminal.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/app/build.gradle b/app/build.gradle
index 0d3e8ac..1506460 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -4,6 +4,7 @@ import java.time.format.DateTimeFormatter
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
+apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
android {
@@ -39,25 +40,31 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
- implementation 'androidx.core:core-ktx:1.3.0'
- implementation 'androidx.appcompat:appcompat:1.1.0'
- implementation 'com.google.android.material:material:1.1.0'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
- implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
+ implementation 'androidx.core:core-ktx:1.3.2'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'com.google.android.material:material:1.2.1'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
+ implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
+ implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0@aar'
implementation 'com.google.zxing:core:3.3.2'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'androidx.preference:preference:1.1.1'
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
+ implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-beta01'
+ implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-beta01'
+ def room_version = "2.2.5"
+ implementation "androidx.room:room-runtime:$room_version"
+ kapt "androidx.room:room-compiler:$room_version"
+ implementation "androidx.room:room-ktx:$room_version"
testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
static def getVersion() {
- def version = "„Library at Home“ Version "
+ def version = "„Elektronische Privileg-Verwaltung“ Version "
version += LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "."
def proc = "git log --format=\"%h\" -n 1".execute()
proc.in.eachLine { line -> version += line }
diff --git a/app/release/app-release.apk b/app/release/app-release.apk
new file mode 100644
index 0000000..d6edaf6
Binary files /dev/null and b/app/release/app-release.apk differ
diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json
new file mode 100644
index 0000000..7fb86c3
--- /dev/null
+++ b/app/release/output-metadata.json
@@ -0,0 +1,18 @@
+{
+ "version": 2,
+ "artifactType": {
+ "type": "APK",
+ "kind": "Directory"
+ },
+ "applicationId": "eu.smoser.libraryathome",
+ "variantName": "processReleaseResources",
+ "elements": [
+ {
+ "type": "SINGLE",
+ "filters": [],
+ "versionCode": 1,
+ "versionName": "1.0",
+ "outputFile": "app-release.apk"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/app/src/main/java/eu/smoser/epv/Database.kt b/app/src/main/java/eu/smoser/epv/Database.kt
new file mode 100644
index 0000000..b9bbf81
--- /dev/null
+++ b/app/src/main/java/eu/smoser/epv/Database.kt
@@ -0,0 +1,73 @@
+package eu.smoser.epv
+
+import android.content.Context
+import androidx.room.*
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+
+fun CoroutineScope.executeAsyncTask(
+ onPreExecute: () -> Unit,
+ doInBackground: () -> R,
+ onPostExecute: (R) -> Unit
+) = launch {
+ onPreExecute()
+ val result = withContext(Dispatchers.IO) {
+ doInBackground()
+ }
+ onPostExecute(result)
+}
+
+@Entity
+data class User(
+ @PrimaryKey val uid: Long,
+ @ColumnInfo(name = "privilegien") val privilegien: Int,
+)
+
+@Dao
+interface UserDao {
+ @Query("SELECT * FROM user")
+ fun getAll(): List
+
+ @Query("UPDATE user SET privilegien = privilegien + :modifier WHERE uid IN (:userIds)")
+ fun updateAllPrivilegien(userIds: LongArray, modifier: Int)
+
+ @Query("SELECT * FROM user WHERE uid == :id")
+ fun findById(id: Long): User
+
+ @Query("UPDATE user SET privilegien = :newPriv WHERE uid == :id")
+ fun updatePrivilegien(id: Long, newPriv: Int)
+
+ @Insert
+ fun insert(user: User)
+
+ @Delete
+ fun delete(user: User)
+}
+
+@Database(entities = [User::class], version = 2)
+abstract class AppDatabase : RoomDatabase() {
+ abstract fun userDao(): UserDao?
+
+ companion object {
+ private const val DB_NAME = "UserDatabase.db"
+
+ @Volatile
+ private var appDatabase: AppDatabase? = null
+
+ @Synchronized
+ fun getInstance(context: Context): AppDatabase {
+ if (appDatabase == null) appDatabase = create(context)
+ return appDatabase!!
+ }
+
+ private fun create(context: Context): AppDatabase {
+ return Room.databaseBuilder(
+ context,
+ AppDatabase::class.java,
+ DB_NAME
+ ).fallbackToDestructiveMigration().build()
+ }
+ }
+}
diff --git a/app/src/main/java/eu/smoser/epv/HelpActivity.kt b/app/src/main/java/eu/smoser/epv/HelpActivity.kt
index c5b53cd..5f7a2c0 100644
--- a/app/src/main/java/eu/smoser/epv/HelpActivity.kt
+++ b/app/src/main/java/eu/smoser/epv/HelpActivity.kt
@@ -2,6 +2,9 @@ package eu.smoser.epv
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
+import android.widget.Button
+import android.widget.TextView
+import androidx.lifecycle.lifecycleScope
class HelpActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -10,6 +13,18 @@ class HelpActivity : AppCompatActivity() {
setSupportActionBar(findViewById(R.id.toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
+
+ findViewById