Skip to content

Commit

Permalink
1. update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ekibun committed Aug 11, 2022
1 parent d1f2d35 commit 0a93b48
Show file tree
Hide file tree
Showing 36 changed files with 703 additions and 442 deletions.
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

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

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

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

14 changes: 13 additions & 1 deletion .idea/misc.xml

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

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ android {
defaultConfig {
applicationId "soko.ekibun.stitch"
minSdkVersion 21
//noinspection OldTargetApi
targetSdkVersion 31
versionCode gitVersionCode()
versionName gitVersionTag()
Expand Down
11 changes: 4 additions & 7 deletions app/src/main/java/soko/ekibun/stitch/App.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package soko.ekibun.stitch

import android.app.Application
import android.preference.PreferenceManager
import android.content.Context
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.runBlocking
import java.io.File
import java.util.concurrent.Executors

class App : Application() {
val sp by lazy { PreferenceManager.getDefaultSharedPreferences(this) }
val sp by lazy { getSharedPreferences(packageName + "_preferences", Context.MODE_PRIVATE)!! }
private val bitmapCache by lazy { BitmapCache(this) }
private val projects by lazy { HashMap<String, Stitch.StitchProject>() }

Expand All @@ -18,7 +18,7 @@ class App : Application() {
}

val dataDirPath: String by lazy {
dataDir.path + File.separator + "Project"
applicationInfo.dataDir + File.separator + "Project"
}

companion object {
Expand All @@ -43,10 +43,7 @@ class App : Application() {
return File(app.dataDirPath + File.separator + projectKey + File.separator + ".project")
}

fun newProject(): String {
val projectKey = System.currentTimeMillis().toString(16)
return projectKey
}
fun newProject(): String = System.currentTimeMillis().toString(16)

fun clearProjects() {
val file = File(app.dataDirPath)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/soko/ekibun/stitch/BitmapCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.graphics.BitmapFactory
import android.util.LruCache
import androidx.core.content.FileProvider
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import java.io.File
import java.io.FileOutputStream
Expand Down Expand Up @@ -65,7 +65,7 @@ class BitmapCache(var app: App) {
return saveBitmap(project, bmp, saveToMemory)
}
lastKey = key
GlobalScope.launch(Dispatchers.IO) {
MainScope().launch(Dispatchers.IO) {
try {
if (saveToMemory) addBitmapToMemoryCache(key, bmp)
val file = File(app.dataDirPath, key)
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/soko/ekibun/stitch/CaptureService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package soko.ekibun.stitch
import android.app.Service
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.IBinder
import android.widget.Toast

Expand Down Expand Up @@ -36,7 +37,9 @@ class CaptureService : Service() {
}

override fun onCreate() {
startService(Intent(this, QuickTileService::class.java))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
startService(Intent(this, QuickTileService::class.java))
}
floatButton.run { }
notification.run { }
}
Expand All @@ -58,7 +61,9 @@ class CaptureService : Service() {
stopForeground(true)
screenCapture?.destroy()
floatButton.destroy()
startService(Intent(this, QuickTileService::class.java))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
startService(Intent(this, QuickTileService::class.java))
}
}

override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
Expand Down
Loading

0 comments on commit 0a93b48

Please sign in to comment.