Skip to content

Commit

Permalink
Merge pull request #452 from lucasnlm/update-deps
Browse files Browse the repository at this point in the history
App update 17.3.0
  • Loading branch information
lucasnlm authored Sep 6, 2023
2 parents b50c001 + fbe707f commit 1236532
Show file tree
Hide file tree
Showing 219 changed files with 6,973 additions and 5,596 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ insert_final_newline=true
max_line_length=120
ij_kotlin_allow_trailing_comma_on_call_site=true
ij_kotlin_allow_trailing_comma=true
ktlint_standard_no-wildcard-imports =disabled
ktlint_standard_no-wildcard-imports=disabled
ktlint_standard_no-empty-first-line-in-class-body=disabled
8 changes: 4 additions & 4 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup JDK 11
- name: Setup JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
- name: Build with Gradle
run: |
./gradlew testFossDebugUnitTest --stacktrace
Expand All @@ -58,11 +58,11 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup JDK 11
- name: Setup JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
- name: Build for F-Droid
run: |
./gradlew assembleFossDebug
16 changes: 8 additions & 8 deletions about/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ plugins {

android {
namespace 'dev.lucasnlm.antimine.about'
compileSdkVersion 33

defaultConfig {
minSdkVersion 21
targetSdkVersion 33
minSdk 21
targetSdk 34
compileSdk 34

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
consumerProguardFiles 'consumer-rules.pro'
Expand All @@ -23,12 +23,12 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '1.8'
kotlin {
jvmToolchain(17)
}

buildFeatures {
Expand Down Expand Up @@ -73,7 +73,7 @@ dependencies {
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'

// Kotlin Lib
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.10'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.10'

// Unit Tests
testImplementation 'junit:junit:4.13.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import android.app.Application
import android.content.Intent
import android.net.Uri
import android.widget.Toast
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.core.audio.GameAudioManager
import dev.lucasnlm.antimine.core.viewmodel.StatelessViewModel
import dev.lucasnlm.antimine.licenses.LicenseActivity
import dev.lucasnlm.antimine.i18n.R as i18n

class AboutViewModel(
private val application: Application,
Expand Down Expand Up @@ -37,33 +37,44 @@ class AboutViewModel(

private fun openLicensesActivity() {
val context = application.applicationContext
val intent = Intent(context, LicenseActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
}
val intent =
Intent(context, LicenseActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
}
context.startActivity(intent)
}

private fun openSourceCode() {
val context = application.applicationContext
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(SOURCE_CODE)).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
val intent =
Intent(Intent.ACTION_VIEW, Uri.parse(SOURCE_CODE)).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
context.startActivity(intent)
} catch (e: Exception) {
Toast.makeText(context.applicationContext, R.string.unknown_error, Toast.LENGTH_SHORT).show()
Toast.makeText(
context.applicationContext,
i18n.string.unknown_error,
Toast.LENGTH_SHORT,
).show()
}
}

private fun openCrowdin() {
val context = application.applicationContext
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(CROWDIN_URL)).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
val intent =
Intent(Intent.ACTION_VIEW, Uri.parse(CROWDIN_URL)).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
context.startActivity(intent)
} catch (e: Exception) {
Toast.makeText(context.applicationContext, R.string.unknown_error, Toast.LENGTH_SHORT).show()
Toast.makeText(
context.applicationContext,
i18n.string.unknown_error,
Toast.LENGTH_SHORT,
).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import android.view.ViewGroup
import android.widget.Toast
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.about.databinding.FragmentAboutInfoBinding
import dev.lucasnlm.antimine.about.viewmodel.AboutEvent
import dev.lucasnlm.antimine.about.viewmodel.AboutViewModel
Expand All @@ -22,6 +21,7 @@ import dev.lucasnlm.antimine.core.models.Analytics
import dev.lucasnlm.external.AnalyticsManager
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
import dev.lucasnlm.antimine.i18n.R as i18n

class AboutInfoFragment : Fragment() {
private lateinit var binding: FragmentAboutInfoBinding
Expand All @@ -30,64 +30,71 @@ class AboutInfoFragment : Fragment() {
private val analyticsManager: AnalyticsManager by inject()
private val unknownVersionName = "?.?.?"

private fun PackageManager.getPackageInfoCompat(packageName: String, flags: Int = 0): PackageInfo? {
return try {
private fun PackageManager.getPackageInfoCompat(
packageName: String,
flags: Int = 0,
): PackageInfo? {
return runCatching {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(flags.toLong()))
} else {
@Suppress("DEPRECATION")
getPackageInfo(packageName, flags)
}
} catch (e: Exception) {
null
}
}.getOrNull()
}

private fun PackageManager.getApplicationInfoCompat(packageName: String, flags: Int = 0): ApplicationInfo? {
return try {
private fun PackageManager.getApplicationInfoCompat(
packageName: String,
flags: Int = 0,
): ApplicationInfo? {
return runCatching {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val applicationInfoFlags = PackageManager.ApplicationInfoFlags.of(flags.toLong())
getApplicationInfo(packageName, applicationInfoFlags)
} else {
@Suppress("DEPRECATION")
getApplicationInfo(packageName, flags)
}
} catch (e: Exception) {
null
}
}.getOrNull()
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
binding = FragmentAboutInfoBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)

val context = view.context
val packageManager = context.packageManager
val packageName = context.packageName
val versionName = packageManager.getPackageInfoCompat(packageName, 0)?.versionName ?: unknownVersionName
binding.version.text = getString(R.string.version_s, versionName)
binding.instant.isVisible = view.context.run {
try {
val info = packageManager.getApplicationInfoCompat(packageName, PackageManager.GET_META_DATA)
val bundle: Bundle? = info?.metaData
val appId = bundle?.getInt(INSTANT_BUILD_FLAVOR, 0) ?: 0
appId > 0
} catch (e: Exception) {
false
binding.version.text = getString(i18n.string.version_s, versionName)
binding.instant.isVisible =
view.context.run {
runCatching {
val info = packageManager.getApplicationInfoCompat(packageName, PackageManager.GET_META_DATA)
val bundle: Bundle? = info?.metaData
val appId = bundle?.getInt(INSTANT_BUILD_FLAVOR, 0) ?: 0
appId > 0
}.getOrNull() ?: false
}
}

binding.musicBy.run {
val composer = audioManager.getComposerData().firstOrNull()

if (composer == null) {
binding.musicCard.isVisible = false
} else {
text = getString(R.string.music_by, composer.composer)
text = getString(i18n.string.music_by, composer.composer)
setOnClickListener {
openComposer(composer.composerLink)
}
Expand All @@ -109,17 +116,22 @@ class AboutInfoFragment : Fragment() {

private fun openComposer(composerLink: String) {
val context = requireContext()
try {
runCatching {
analyticsManager.sentEvent(
Analytics.OpenMusicLink(from = "About"),
)

val intent = Intent(Intent.ACTION_VIEW, Uri.parse(composerLink)).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
val intent =
Intent(Intent.ACTION_VIEW, Uri.parse(composerLink)).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
context.startActivity(intent)
} catch (e: Exception) {
Toast.makeText(context.applicationContext, R.string.unknown_error, Toast.LENGTH_SHORT).show()
}.onFailure {
Toast.makeText(
context.applicationContext,
i18n.string.unknown_error,
Toast.LENGTH_SHORT,
).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.about.databinding.ActivityContainerBinding
import dev.lucasnlm.antimine.licenses.views.LicensesFragment
import dev.lucasnlm.antimine.ui.ext.ThemedActivity
import dev.lucasnlm.antimine.i18n.R as i18n

class LicenseActivity : ThemedActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -14,7 +15,7 @@ class LicenseActivity : ThemedActivity() {
setContentView(binding.root)

bindToolbar(binding.toolbar)
binding.toolbar.setTitle(R.string.licenses)
binding.toolbar.setTitle(i18n.string.licenses)

supportFragmentManager.commit(allowStateLoss = true) {
replace(R.id.content, LicensesFragment())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ package dev.lucasnlm.antimine.licenses.viewmodel
import dev.lucasnlm.antimine.core.viewmodel.IntentViewModel

class LicenseViewModel : IntentViewModel<Void, LicenseState>() {
private fun getLicensesList() = mapOf(
"Antimine" to "https://github.com/lucasnlm/antimine-android/blob/main/LICENSE",
"Android SDK License" to "https://developer.android.com/studio/terms",
"Koin" to "https://github.com/InsertKoinIO/koin/blob/main/LICENSE",
"LibGDX" to "https://github.com/libgdx/libgdx/blob/master/LICENSE",
"Material Design" to "https://github.com/material-components/material-components-android/blob/master/LICENSE",
"Moshi" to "https://github.com/square/moshi/blob/master/LICENSE.txt",
"Mockk" to "https://github.com/mockk/mockk/blob/master/LICENSE",
"Noto Emoji" to "https://github.com/googlefonts/noto-emoji/blob/main/fonts/LICENSE",
"kotlin" to "https://github.com/JetBrains/kotlin/blob/master/license/LICENSE.txt",
"kotlinx.coroutines" to "https://github.com/Kotlin/kotlinx.coroutines/blob/master/LICENSE.txt",
).map {
License(it.key, it.value)
}.sortedBy {
it.name
}.toList()
private fun getLicensesList() =
mapOf(
"Antimine" to "https://github.com/lucasnlm/antimine-android/blob/main/LICENSE",
"Android SDK License" to "https://developer.android.com/studio/terms",
"Koin" to "https://github.com/InsertKoinIO/koin/blob/main/LICENSE",
"LibGDX" to "https://github.com/libgdx/libgdx/blob/master/LICENSE",
"Material Design" to "https://github.com/material-components/material-components-android/",
"Moshi" to "https://github.com/square/moshi/blob/master/LICENSE.txt",
"Mockk" to "https://github.com/mockk/mockk/blob/master/LICENSE",
"Noto Emoji" to "https://github.com/googlefonts/noto-emoji/blob/main/fonts/LICENSE",
"kotlin" to "https://github.com/JetBrains/kotlin/blob/master/license/LICENSE.txt",
"kotlinx.coroutines" to "https://github.com/Kotlin/kotlinx.coroutines/blob/master/LICENSE.txt",
).map {
License(it.key, it.value)
}.sortedBy {
it.name
}.toList()

override fun initialState(): LicenseState {
return LicenseState(licenses = getLicensesList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ internal class LicensesAdapter(

override fun getItemCount(): Int = licenses.size

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ThirdPartyViewHolder {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int,
): ThirdPartyViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
return ThirdPartyViewHolder(
binding = ViewThirdPartyBinding.inflate(layoutInflater, parent, false),
)
}

override fun onBindViewHolder(holder: ThirdPartyViewHolder, position: Int) {
override fun onBindViewHolder(
holder: ThirdPartyViewHolder,
position: Int,
) {
val thirdParty = licenses[position]
holder.apply {
binding.thirdName.text = thirdParty.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ class LicensesFragment : Fragment(R.layout.fragment_licenses) {
private lateinit var binding: FragmentLicensesBinding
private val viewModel: LicenseViewModel by sharedViewModel()

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
binding = FragmentLicensesBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)

lifecycleScope.launchWhenResumed {
Expand Down
2 changes: 1 addition & 1 deletion about/src/main/res/layout/fragment_licenses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
tools:context="dev.lucasnlm.antimine.about.dev.lucasnlm.antimine.licenses.views.LicensesFragment">
tools:context="dev.lucasnlm.antimine.licenses.LicenseActivity">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/licenses"
Expand Down
Loading

0 comments on commit 1236532

Please sign in to comment.