Skip to content

Commit 0e7e7e3

Browse files
TileMode will be applied to all images && updated dependencies (#292)
* ⬆️ Bump androidx.profileinstaller:profileinstaller (#267) Bumps androidx.profileinstaller:profileinstaller from 1.2.2 to 1.3.0. --- updated-dependencies: - dependency-name: androidx.profileinstaller:profileinstaller dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ⬆️ Bump roomVersion from 2.5.0 to 2.5.1 (#263) Bumps `roomVersion` from 2.5.0 to 2.5.1. Updates `androidx.room:room-runtime` from 2.5.0 to 2.5.1 Updates `androidx.room:room-ktx` from 2.5.0 to 2.5.1 Updates `androidx.room:room-compiler` from 2.5.0 to 2.5.1 --- updated-dependencies: - dependency-name: androidx.room:room-runtime dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: androidx.room:room-ktx dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: androidx.room:room-compiler dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ⬆️ Bump androidx.fragment:fragment-ktx from 1.5.5 to 1.5.6 (#266) Bumps androidx.fragment:fragment-ktx from 1.5.5 to 1.5.6. --- updated-dependencies: - dependency-name: androidx.fragment:fragment-ktx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ⬆️ Bump androidx.lifecycle:lifecycle-runtime-ktx (#265) Bumps androidx.lifecycle:lifecycle-runtime-ktx from 2.5.1 to 2.6.1. --- updated-dependencies: - dependency-name: androidx.lifecycle:lifecycle-runtime-ktx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ⬆️ Bump androidx.activity:activity-ktx from 1.6.1 to 1.7.0 (#264) Bumps androidx.activity:activity-ktx from 1.6.1 to 1.7.0. --- updated-dependencies: - dependency-name: androidx.activity:activity-ktx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Updated gradle-wrapper.properties to use the new distributionUrl for Gradle-7.5, and updated settings.gradle.kts to use the new version of com.android.tools.build:gradle:7.4.2. * :arrow_up: Bump roomVersion from 2.5.1 to 2.5.2 (#287) Bumps `roomVersion` from 2.5.1 to 2.5.2. Updates `androidx.room:room-runtime` from 2.5.1 to 2.5.2 Updates `androidx.room:room-ktx` from 2.5.1 to 2.5.2 Updates `androidx.room:room-compiler` from 2.5.1 to 2.5.2 --- updated-dependencies: - dependency-name: androidx.room:room-runtime dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: androidx.room:room-ktx dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: androidx.room:room-compiler dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ⬆️ Bump androidx.profileinstaller:profileinstaller (#277) Bumps androidx.profileinstaller:profileinstaller from 1.3.0 to 1.3.1. --- updated-dependencies: - dependency-name: androidx.profileinstaller:profileinstaller dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ⬆️ Bump androidx.core:core-ktx from 1.7.20 to 1.10.1 (#278) Bumps androidx.core:core-ktx from 1.7.20 to 1.10.1. --- updated-dependencies: - dependency-name: androidx.core:core-ktx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ⬆️ Bump androidx.activity:activity-ktx from 1.7.0 to 1.7.2 (#282) Bumps androidx.activity:activity-ktx from 1.7.0 to 1.7.2. --- updated-dependencies: - dependency-name: androidx.activity:activity-ktx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ⬆️ Bump kotlinVersion from 1.8.0 to 1.8.22 (#285) Bumps `kotlinVersion` from 1.8.0 to 1.8.22. Updates `org.jetbrains.kotlin:kotlin-gradle-plugin` from 1.8.0 to 1.8.22 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin:kotlin-stdlib` from 1.8.0 to 1.8.22 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-stdlib dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ⬆️ Bump androidx.fragment:fragment-ktx from 1.5.6 to 1.6.1 (#290) Bumps androidx.fragment:fragment-ktx from 1.5.6 to 1.6.1. --- updated-dependencies: - dependency-name: androidx.fragment:fragment-ktx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update build.gradle.kts to use Kotlin jvmToolchain(17) instead of compileOptions. Update build.gradle.kts to use Kotlin jvmToolchain(17) instead of kotlinOptions. Add Kotlin jvmToolchain(17) to build.gradle.kts. Update build.gradle.kts to use classpath "com.android.tools.build:gradle:8.1.0" instead of libs.tools.gradle. Add android.defaults.buildfeatures.buildconfig=true, android.nonTransitiveRClass=false, android.nonFinalResIds=false to gradle.properties. Update distributionUrl to https\://services.gradle.org/distributions/gradle-8.2-bin.zip in gradle-wrapper.properties. * Update java version from 11 to 17 in pr_pre_check.yml and release.yml * Refactor ImageInfo.kt, IntExtension.kt, MainViewModel.kt, TileModeFragment.kt, WaterMark.kt, WaterMarkImageView.kt, and WaterMarkRepository.kt (#289) - Removed imports for android.graphics.Shader and android.os.Build from ImageInfo.kt and WaterMark.kt respectively. - Removed the obtainTileMode() function from ImageInfo.kt and added it to IntExtension.kt as an extension function named toTileMode(). - Renamed the parameter "imageInfo" in the updateTileMode() function of MainViewModel.kt to "tmpConfig". - Renamed the parameter "imageInfo" in the updateTileMode() function of WaterMarkRepository.kt to "mode". - Removed unnecessary null check in TileModeFragment.kt for the selectedImage LiveData. - Simplified comparisons of tileMode in TileModeFragment.kt and WaterMarkImageView.kt. - Refactored the updateTileMode() function of WaterMarkRepository.kt to save the tileMode value to DataStore and emit the updated value to the corresponding LiveData. * [AboutActivity.kt] - Removed the code block related to checking the SDK version and setting the foreground to null for the window. [WaterMarkImageView.kt] - Removed the condition to check the SDK version for creating a static layout instance and created a static layout unconditionally. [MainActivity.kt] - Removed the code block related to checking the SDK version and setting the foreground to null for the window. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent b81a3df commit 0e7e7e3

18 files changed

Lines changed: 75 additions & 104 deletions

File tree

.github/workflows/pr_pre_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/setup-java@v2
1717
with:
1818
distribution: 'adopt'
19-
java-version: 11
19+
java-version: 17
2020
- name: Cache Gradle
2121
uses: actions/cache@v2
2222
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/setup-java@v2
1616
with:
1717
distribution: 'adopt'
18-
java-version: 11
18+
java-version: 17
1919
- name: Cache Gradle
2020
uses: actions/cache@v2
2121
with:

app/build.gradle.kts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ android {
4646
}
4747
}
4848

49-
compileOptions {
50-
sourceCompatibility(JavaVersion.VERSION_11)
51-
targetCompatibility(JavaVersion.VERSION_11)
52-
}
53-
5449
// change output apk name
5550
applicationVariants.all {
5651
outputs.all {
@@ -64,15 +59,16 @@ android {
6459
}
6560

6661
android.buildFeatures.viewBinding = true
67-
68-
kotlinOptions {
69-
jvmTarget = "11"
70-
}
62+
7163
namespace = "me.rosuh.easywatermark"
7264

7365
lint {
7466
baseline = file("lint-baseline.xml")
7567
}
68+
69+
kotlin {
70+
jvmToolchain(17)
71+
}
7672
}
7773

7874
kapt {

app/src/main/java/me/rosuh/easywatermark/data/model/ImageInfo.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package me.rosuh.easywatermark.data.model
22

3-
import android.graphics.Shader
43
import android.net.Uri
5-
import android.os.Build
64
import androidx.annotation.FloatRange
75

86
data class ImageInfo(
@@ -15,26 +13,12 @@ data class ImageInfo(
1513
var result: Result<*>? = null,
1614
var jobState: JobState = JobState.Ready,
1715
var isInDelModel: Boolean = false,
18-
val tileMode: Int = Shader.TileMode.REPEAT.ordinal,
1916
@FloatRange(from = 0.0, to = 1.0) val offsetX: Float = 0.5f,
2017
@FloatRange(from = 0.0, to = 1.0) val offsetY: Float = 0.5f,
2118
) {
2219
val shareUri: Uri?
2320
get() = result?.data as? Uri?
2421

25-
fun obtainTileMode(): Shader.TileMode {
26-
return when (tileMode) {
27-
Shader.TileMode.CLAMP.ordinal -> Shader.TileMode.CLAMP
28-
Shader.TileMode.MIRROR.ordinal -> Shader.TileMode.MIRROR
29-
Shader.TileMode.REPEAT.ordinal -> Shader.TileMode.REPEAT
30-
else -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
31-
Shader.TileMode.DECAL
32-
} else {
33-
Shader.TileMode.CLAMP
34-
}
35-
}
36-
}
37-
3822
fun isSameItem(other: ImageInfo): Boolean {
3923
return uri == other.uri
4024
&& result == other.result
@@ -54,7 +38,6 @@ data class ImageInfo(
5438
null,
5539
JobState.Ready,
5640
false,
57-
Shader.TileMode.REPEAT.ordinal,
5841
0.5f,
5942
0.5f
6043
)

app/src/main/java/me/rosuh/easywatermark/data/model/WaterMark.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package me.rosuh.easywatermark.data.model
22

3+
import android.graphics.Shader
34
import android.net.Uri
5+
import android.os.Build
46
import androidx.annotation.Keep
57
import me.rosuh.easywatermark.data.repo.WaterMarkRepository
68

@@ -17,5 +19,10 @@ data class WaterMark(
1719
val vGap: Int,
1820
val iconUri: Uri,
1921
val markMode: WaterMarkRepository.MarkMode,
20-
val enableBounds: Boolean
21-
)
22+
val enableBounds: Boolean,
23+
val tileMode: Shader.TileMode,
24+
) {
25+
fun obtainTileMode(): Shader.TileMode {
26+
return tileMode
27+
}
28+
}

app/src/main/java/me/rosuh/easywatermark/data/repo/WaterMarkRepository.kt

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import me.rosuh.easywatermark.data.repo.WaterMarkRepository.PreferenceKeys.KEY_T
2727
import me.rosuh.easywatermark.data.repo.WaterMarkRepository.PreferenceKeys.KEY_TEXT_SIZE
2828
import me.rosuh.easywatermark.data.repo.WaterMarkRepository.PreferenceKeys.KEY_TEXT_STYLE
2929
import me.rosuh.easywatermark.data.repo.WaterMarkRepository.PreferenceKeys.KEY_TEXT_TYPEFACE
30+
import me.rosuh.easywatermark.data.repo.WaterMarkRepository.PreferenceKeys.KEY_TILE_MODE
3031
import me.rosuh.easywatermark.data.repo.WaterMarkRepository.PreferenceKeys.KEY_VERTICAL_GAP
32+
import me.rosuh.easywatermark.utils.ktx.toTileMode
3133
import java.io.IOException
3234
import javax.inject.Inject
3335
import javax.inject.Named
@@ -83,6 +85,7 @@ class WaterMarkRepository @Inject constructor(
8385
vGap = it[KEY_VERTICAL_GAP] ?: 0,
8486
iconUri = Uri.parse(it[KEY_ICON_URI] ?: ""),
8587
markMode = if (it[KEY_MODE] == MarkMode.Image.value) MarkMode.Image else MarkMode.Text,
88+
tileMode = it[KEY_TILE_MODE].toTileMode(),
8689
enableBounds = it[KEY_ENABLE_BOUNDS] ?: false
8790
)
8891
}
@@ -150,23 +153,10 @@ class WaterMarkRepository @Inject constructor(
150153
}
151154
}
152155

153-
suspend fun updateTileMode(imageInfo: ImageInfo, mode: Shader.TileMode): ImageInfo {
154-
if (imageInfo.tileMode == mode.ordinal) {
155-
Log.i("WaterMarkRepository", "updateTileMode: same mode")
156-
return imageInfo
157-
}
158-
val index = imageInfoMap[imageInfo.uri] ?: kotlin.run {
159-
Log.e("WaterMarkRepository", "updateTileMode: imageInfo not found, uri = ${imageInfo.uri}")
160-
return imageInfo
156+
suspend fun updateTileMode(mode: Shader.TileMode) {
157+
dataStore.edit {
158+
it[KEY_TILE_MODE] = mode.ordinal
161159
}
162-
163-
val info = imageInfo.copy(tileMode = mode.ordinal)
164-
val list = ArrayList(imageInfoList)
165-
list[index] = info
166-
imageInfoMap[info.uri] = index
167-
_imageMapFlow.emit(list)
168-
_selectedImage.emit(info)
169-
return info
170160
}
171161

172162
suspend fun updateOffset(imageInfo: ImageInfo) {

app/src/main/java/me/rosuh/easywatermark/ui/MainActivity.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,7 @@ class MainActivity : AppCompatActivity() {
634634
window.decorView.systemUiVisibility = systemUiVisibilityFlags
635635
}
636636
window.statusBarColor = color
637-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
638-
window.findViewById<View>(android.R.id.content)?.foreground = null
639-
}
637+
window.findViewById<View>(android.R.id.content)?.foreground = null
640638
}
641639

642640

app/src/main/java/me/rosuh/easywatermark/ui/MainViewModel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class MainViewModel @Inject constructor(
322322

323323
layoutPaint.shader = shader?.bitmapShader
324324

325-
if (imageInfo.obtainTileMode() == Shader.TileMode.CLAMP) {
325+
if (tmpConfig.obtainTileMode() == Shader.TileMode.CLAMP) {
326326
canvas.translate(
327327
0 + imageInfo.offsetX * mutableBitmap.width,
328328
0 + imageInfo.offsetY * mutableBitmap.height
@@ -518,10 +518,10 @@ class MainViewModel @Inject constructor(
518518
}
519519
}
520520

521-
fun updateTileMode(imageInfo: ImageInfo, tileMode: Shader.TileMode) {
521+
fun updateTileMode(tileMode: Shader.TileMode) {
522522
launch {
523523
autoScroll = false
524-
waterMarkRepo.updateTileMode(imageInfo, tileMode)
524+
waterMarkRepo.updateTileMode(tileMode)
525525
}
526526
}
527527

app/src/main/java/me/rosuh/easywatermark/ui/about/AboutActivity.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ class AboutActivity : AppCompatActivity() {
5757
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
5858
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
5959
window.statusBarColor = Color.TRANSPARENT
60-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
61-
window.findViewById<View>(android.R.id.content)?.foreground = null
62-
}
60+
window.findViewById<View>(android.R.id.content)?.foreground = null
6361
}
6462

6563

@@ -157,12 +155,8 @@ class AboutActivity : AppCompatActivity() {
157155
return@observe
158156
}
159157

160-
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
161-
applyPaletteForSupportLightStatusIcon(it)
162-
}
163-
164158
else -> {
165-
applyPaletteForNoMatterWhoYouAre(it)
159+
applyPaletteForSupportLightStatusIcon(it)
166160
}
167161
}
168162
}

app/src/main/java/me/rosuh/easywatermark/ui/panel/TileModeFragment.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,24 @@ class TileModeFragment : BaseBindFragment<FragmentTileModeBinding>() {
2323

2424
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
2525
super.onViewCreated(view, savedInstanceState)
26-
shareViewModel.selectedImage.observe(viewLifecycleOwner) {
27-
if (it == null) {
28-
return@observe
29-
}
26+
shareViewModel.waterMark.observe(viewLifecycleOwner) {
3027
val checkedId = when (it.tileMode) {
31-
Shader.TileMode.CLAMP.ordinal -> R.id.rb_tile_mode_decal
28+
Shader.TileMode.CLAMP -> R.id.rb_tile_mode_decal
3229
else -> R.id.rb_tile_mode_repeat
3330
}
3431
binding?.rgTileMode?.setOnCheckedChangeListener(null)
3532
binding?.rgTileMode?.check(checkedId)
3633
binding?.rgTileMode?.setOnCheckedChangeListener { _, id ->
3734
val imageInfo = it
38-
if (id == R.id.rb_tile_mode_decal && imageInfo.tileMode == Shader.TileMode.CLAMP.ordinal) {
35+
if (id == R.id.rb_tile_mode_decal && imageInfo.tileMode == Shader.TileMode.CLAMP) {
3936
return@setOnCheckedChangeListener
4037
}
41-
if (id == R.id.rb_tile_mode_repeat && imageInfo.tileMode == Shader.TileMode.REPEAT.ordinal) {
38+
if (id == R.id.rb_tile_mode_repeat && imageInfo.tileMode == Shader.TileMode.REPEAT) {
4239
return@setOnCheckedChangeListener
4340
}
4441
when(id) {
45-
R.id.rb_tile_mode_decal -> shareViewModel.updateTileMode(imageInfo, Shader.TileMode.CLAMP)
46-
else -> shareViewModel.updateTileMode(imageInfo, Shader.TileMode.REPEAT)
42+
R.id.rb_tile_mode_decal -> shareViewModel.updateTileMode(Shader.TileMode.CLAMP)
43+
else -> shareViewModel.updateTileMode(Shader.TileMode.REPEAT)
4744
}
4845
}
4946
}

0 commit comments

Comments
 (0)