Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .idea/deviceManager.xml

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

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

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

26 changes: 15 additions & 11 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.application")
kotlin("android")
Expand All @@ -14,10 +16,10 @@ android {

defaultConfig {
applicationId = "de.dertyp7214.rboardpatcher"
minSdk = 23
minSdk = 26
targetSdk = 36
versionCode = 3406
versionName = "3.4"
versionCode = 3500
versionName = "3.5"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -37,16 +39,18 @@ android {
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.current()
targetCompatibility = JavaVersion.current()
}

kotlinOptions {
jvmTarget = JavaVersion.current().toString()
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"
)
kotlin {
compilerOptions {
freeCompilerArgs = freeCompilerArgs.get() + listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true",
"-Xsuppress-version-warnings"
)
jvmToolchain(23)
jvmTarget.set(JvmTarget.JVM_23)
}
}

packaging {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.card.MaterialCardView
import de.dertyp7214.rboardcomponents.core.dpToPxRounded
import de.dertyp7214.rboardpatcher.R
import de.dertyp7214.rboardpatcher.screens.types.MainOption

Expand All @@ -30,6 +31,22 @@ class MainOptionAdapter(
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = list[position]

when (position) {
0 -> {
if (list.size == 1){
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_rounded)
}
else{
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_top)
}
}
list.lastIndex -> {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_bottom)
}
else -> {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background)
}
}
holder.icon.setImageResource(item.icon)
holder.title.text = item.title

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Color
import android.graphics.Typeface
import android.os.Build
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.card.MaterialCardView
import de.dertyp7214.rboardcomponents.core.dpToPxRounded
import de.dertyp7214.rboardpatcher.R
import de.dertyp7214.rboardpatcher.api.types.PatchMeta
import de.dertyp7214.rboardpatcher.core.getAttr
Expand Down Expand Up @@ -100,7 +102,36 @@ class PatchAdapter(

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val patchMeta = list[position]

when (position) {
0 -> {
if (list.size == 1){
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_rounded)
val param = holder.root.layoutParams as ViewGroup.MarginLayoutParams
param.setMargins(16.dpToPxRounded(context), 4.dpToPxRounded(context), 16.dpToPxRounded(context), 0.dpToPxRounded(context))
holder.root.layoutParams = param

}
else{
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_top)
val param = holder.root.layoutParams as ViewGroup.MarginLayoutParams
param.setMargins(16.dpToPxRounded(context), 4.dpToPxRounded(context), 16.dpToPxRounded(context), 0.dpToPxRounded(context))
holder.root.layoutParams = param

}
}
list.lastIndex -> {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_bottom)
val param = holder.root.layoutParams as ViewGroup.MarginLayoutParams
param.setMargins(16.dpToPxRounded(context), 0.dpToPxRounded(context), 16.dpToPxRounded(context), 4.dpToPxRounded(context))
holder.root.layoutParams = param
}
else -> {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background)
val param = holder.root.layoutParams as ViewGroup.MarginLayoutParams
param.setMargins(16.dpToPxRounded(context), 0.dpToPxRounded(context), 16.dpToPxRounded(context), 0.dpToPxRounded(context))
holder.root.layoutParams = param
}
}
if (selected[patchMeta]) holder.root.setCardBackgroundColor(selectedColor)
else holder.root.setCardBackgroundColor(Color.TRANSPARENT)

Expand All @@ -122,8 +153,43 @@ class PatchAdapter(
if (isEnabled) {
selected[patchMeta] = !selected[patchMeta]

if (selected[patchMeta]) holder.root.setCardBackgroundColor(selectedColor)
else holder.root.setCardBackgroundColor(Color.TRANSPARENT)
if (selected[patchMeta]) {
when (position) {
0 -> {
if (list.size == 1) {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_rounded_colored)
} else {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_top_colored)
}
}

list.lastIndex -> {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_bottom_colored)
}

else -> {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_colored)
}
}
}
else
when (position) {
0 -> {
if (list.size == 1) {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_rounded)
} else {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_top)
}
}

list.lastIndex -> {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background_bottom)
}

else -> {
holder.root.setBackgroundResource(R.drawable.color_surface_overlay_background)
}
}
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/java/de/dertyp7214/rboardpatcher/core/String.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ import java.util.Locale
fun String.downloadFile(path: File): File {
if (path.exists()) path.deleteRecursively()
path.parentFile?.let { if (!it.exists()) it.mkdirs() }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Files.copy(URL(this).openStream(), path.toPath(), StandardCopyOption.REPLACE_EXISTING)
} else {
URL(this).openStream()
.use { Files.copy(it, path.toPath()) }
}
Files.copy(URL(this).openStream(), path.toPath(), StandardCopyOption.REPLACE_EXISTING)
return path
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class LoadThemeActivity : AppCompatActivity() {
recyclerView.adapter = adapter
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.setHasFixedSize(true)
recyclerView.addItemDecoration(MarginItemDecoration(2.dp(this), all = true))
recyclerView.addItemDecoration(MarginItemDecoration(2.dp(this)))

when {
scheme != "content" && data != null && data.scheme == "file" -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.google.android.material.progressindicator.CircularProgressIndicator
import com.google.android.material.progressindicator.LinearProgressIndicator
import com.google.gson.Gson
import de.dertyp7214.rboardcomponents.components.SearchBar
import de.dertyp7214.rboardcomponents.core.dpToPxRounded
import de.dertyp7214.rboardpatcher.Application
import de.dertyp7214.rboardpatcher.R
import de.dertyp7214.rboardpatcher.adapter.PatchAdapter
Expand All @@ -42,6 +43,7 @@ import de.dertyp7214.rboardpatcher.api.types.KeyValue
import de.dertyp7214.rboardpatcher.api.types.PatchMeta
import de.dertyp7214.rboardpatcher.components.BaseActivity
import de.dertyp7214.rboardpatcher.components.ChipContainer
import de.dertyp7214.rboardpatcher.components.MarginItemDecoration
import de.dertyp7214.rboardpatcher.core.Observe
import de.dertyp7214.rboardpatcher.core.app
import de.dertyp7214.rboardpatcher.core.decodeBitmap
Expand Down Expand Up @@ -332,6 +334,7 @@ class PatchActivity : BaseActivity() {
recyclerView.adapter = adapter
recyclerView.setHasFixedSize(true)
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.addItemDecoration(MarginItemDecoration(2.dpToPxRounded(this)))

doAsync({
val patches: List<PatchMeta> = GitHub.GboardThemes.Patches["patches.json"]
Expand Down Expand Up @@ -424,11 +427,7 @@ class PatchActivity : BaseActivity() {
progress = { progress, stage ->
CoroutineScope(Dispatchers.Main).launch {
patchTheme.text = "Applying: $stage"
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {
progressBar.setProgress(progress.roundToInt(), true)
} else {
progressBar.progress = progress.roundToInt()
}
}
}) {
patchTheme.isEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class PickThemeActivity : AppCompatActivity() {
recyclerView.adapter = adapter
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.setHasFixedSize(true)
recyclerView.addItemDecoration(MarginItemDecoration(2.dp(this), all = true))
recyclerView.addItemDecoration(MarginItemDecoration(2.dp(this)))

Application.rboardService?.apply {
doAsync({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package de.dertyp7214.rboardpatcher.screens.types
import androidx.annotation.DrawableRes

data class MainOption(
@DrawableRes val icon: Int,
@param:DrawableRes val icon: Int,
val title: String,
val action: () -> Unit
)
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/color_surface_overlay_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="?attr/colorSurface" />
<corners android:radius="5dp"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/color_primary_0_10_overlay" />
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="?attr/colorSurface" />
<corners android:topLeftRadius="5dp" android:topRightRadius="5dp"
android:bottomLeftRadius="20dp" android:bottomRightRadius="20dp"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/color_primary_0_10_overlay" />
<corners android:topLeftRadius="5dp" android:topRightRadius="5dp"
android:bottomLeftRadius="20dp" android:bottomRightRadius="20dp"/>
</shape>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="?attr/colorSurfaceContainerHighest" />
<corners android:topLeftRadius="5dp" android:topRightRadius="5dp"
android:bottomLeftRadius="20dp" android:bottomRightRadius="20dp"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/color_primary_0_10_overlay" />
<corners android:topLeftRadius="5dp" android:topRightRadius="5dp"
android:bottomLeftRadius="20dp" android:bottomRightRadius="20dp"/>
</shape>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="?attr/colorSurfaceContainerHighest" />
<corners android:radius="5dp"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/color_primary_0_10_overlay" />
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="?attr/colorSurface" />
<corners android:radius="20dp"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/color_primary_0_10_overlay" />
<corners android:radius="20dp"/>
</shape>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="?attr/colorSurfaceContainerHighest" />
<corners android:radius="20dp"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/color_primary_0_10_overlay" />
<corners android:radius="20dp"/>
</shape>
</item>
</layer-list>
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/color_surface_overlay_background_top.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="?attr/colorSurface" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp" android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/color_primary_0_10_overlay" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp" android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"/>
</shape>
</item>
</layer-list>
Loading
Loading