Skip to content

Commit

Permalink
Fix crash on earlier Android versions
Browse files Browse the repository at this point in the history
@color/material_dynamic_neutral30 resource is not found on earlier Android versions.
  • Loading branch information
layou233 committed Feb 2, 2024
1 parent 06c2dad commit 9e01f72
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
10 changes: 7 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ android {
applicationId = "com.launium.mcping"
minSdk = 21
targetSdk = 34
versionCode = 7
versionName = "0.3.1"
versionCode = 8
versionName = "0.3.2"
setProperty("archivesBaseName", "MCPing-$versionName")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
debug {
applicationIdSuffix = ".debug"
}
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
Expand Down Expand Up @@ -56,7 +60,7 @@ dependencies {
implementation("androidx.room:room-runtime:2.6.1")
implementation("io.ktor:ktor-network:2.3.5")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("com.alibaba.fastjson2:fastjson2:2.0.45.android4")
implementation("com.alibaba.fastjson2:fastjson2:2.0.46.android5")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ fun parseMinecraftColor(message: String): SpannableStringBuilder {
else -> null
}
if (span != null) {
builder.setSpan(
span,
it.second,
resetSymbols.find { r -> it.second <= r.second }?.second ?: builder.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
)
val endPosition =
resetSymbols.find { r -> it.second <= r.second }?.second ?: builder.length
if (endPosition - it.second > 0) {
builder.setSpan(
span,
it.second,
endPosition,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import kotlinx.coroutines.sync.Semaphore
import java.net.URL
import java.util.Locale

private const val SERVER_LIST_URL = "https://www.jsip.club/api/ajax.php?request=get_line_list"
private const val SERVER_LIST_URL = "https://www.jsip.club/pub-api/line.php"

class DiscoveryFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener {

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/server_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:layout_marginEnd="4dp"
app:layout_constraintEnd_toStartOf="@id/server_sheet_version_card"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/server_sheet_motd_card">
Expand Down Expand Up @@ -157,7 +157,7 @@
android:layout_width="0dp"
android:layout_height="72dp"
android:layout_gravity="center_horizontal"
android:layout_marginStart="8dp"
android:layout_marginStart="4dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
Expand Down Expand Up @@ -288,7 +288,7 @@
android:text="@string/description_share"
android:textColor="@color/white"
android:theme="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
app:backgroundTint="@color/material_dynamic_neutral30"
app:backgroundTint="#454749"
app:icon="@drawable/ic_share_24dp"
app:iconTint="@color/white" />

Expand Down

0 comments on commit 9e01f72

Please sign in to comment.