Skip to content

Commit

Permalink
Merge pull request #398 from lucasnlm/improve-theme
Browse files Browse the repository at this point in the history
Update 17.0.0
  • Loading branch information
lucasnlm committed Jan 16, 2023
2 parents 1d07273 + 68cf128 commit 871e544
Show file tree
Hide file tree
Showing 312 changed files with 6,579 additions and 6,151 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ indent_size=4
insert_final_newline=true
max_line_length=120
ij_kotlin_allow_trailing_comma_on_call_site=true
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma=true
ktlint_standard_no-wildcard-imports =disabled
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Feel free to contribute with [issues](https://github.com/lucasnlm/antimine-andro
## Features

- No guessing algorithm
- Multiple Themes (including System and AMOLED)
- Multiple themes colors (including dynamic colors and AMOLED)
- Multiple skins (including the classic)
- Game Levels: Beginner, Intermediate, Expert, Master, Legend, and Custom
- Game Statistics
- Save/Resume state when Quit/Resume game
Expand All @@ -41,7 +42,6 @@ Feel free to contribute with [issues](https://github.com/lucasnlm/antimine-andro
- Game assistant to auto-flag discovered mines
- Split screen
- Zoom out
- Custom appearance (square roundedness, size and divider)

## Technical Details

Expand Down
21 changes: 10 additions & 11 deletions about/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
minSdkVersion 21
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
Expand Down Expand Up @@ -42,12 +42,12 @@ dependencies {
implementation project(':tutorial')

// Google
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.material:material:1.8.0-rc01'

// AndroidX
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.activity:activity-ktx:1.6.0'
implementation 'androidx.fragment:fragment-ktx:1.5.3'
implementation 'androidx.activity:activity-ktx:1.6.1'
implementation 'androidx.fragment:fragment-ktx:1.5.5'

// RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.2.1'
Expand All @@ -56,20 +56,19 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

// Lifecycle
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.lifecycle:viewmodel:1.1.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'

// Koin
implementation 'io.insert-koin:koin-android:3.1.2'
testImplementation 'io.insert-koin:koin-test:3.1.2'

// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'

// Kotlin Lib
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20'

// Unit Tests
testImplementation 'junit:junit:4.13.2'
Expand Down
7 changes: 4 additions & 3 deletions about/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

<application>
<activity
android:name="dev.lucasnlm.antimine.text.TextActivity"
android:name="dev.lucasnlm.antimine.about.AboutActivity"
android:label="@string/about"
android:theme="@style/AppTheme" />

<activity
android:name="dev.lucasnlm.antimine.about.AboutActivity"
android:label="@string/about"
android:name="dev.lucasnlm.antimine.licenses.LicenseActivity"
android:label="@string/licenses"
android:theme="@style/AppTheme" />
</application>

Expand Down
53 changes: 8 additions & 45 deletions about/src/main/java/dev/lucasnlm/antimine/about/AboutActivity.kt
Original file line number Diff line number Diff line change
@@ -1,56 +1,19 @@
package dev.lucasnlm.antimine.about

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import androidx.lifecycle.lifecycleScope
import dev.lucasnlm.antimine.about.viewmodel.AboutEvent
import dev.lucasnlm.antimine.about.viewmodel.AboutViewModel
import dev.lucasnlm.antimine.about.views.info.AboutInfoFragment
import dev.lucasnlm.antimine.about.views.licenses.LicensesFragment
import dev.lucasnlm.antimine.ui.ext.ThematicActivity
import kotlinx.android.synthetic.main.activity_about.*
import org.koin.androidx.viewmodel.ext.android.viewModel

class AboutActivity : ThematicActivity(R.layout.activity_about) {
private val aboutViewModel: AboutViewModel by viewModel()
import androidx.fragment.app.commit
import dev.lucasnlm.antimine.about.views.AboutInfoFragment
import dev.lucasnlm.antimine.ui.ext.ThemedActivity
import kotlinx.android.synthetic.main.activity_container.*

class AboutActivity : ThemedActivity(R.layout.activity_container) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

section.bind(
text = R.string.about,
startButton = R.drawable.back_arrow,
startDescription = R.string.back,
startAction = {
section.bindText(R.string.about)
onBackPressed()
},
)

replaceFragment(AboutInfoFragment(), null)
bindToolbar(toolbar)

lifecycleScope.launchWhenCreated {
aboutViewModel.observeEvent().collect { event ->
when (event) {
AboutEvent.ThirdPartyLicenses -> {
section.bindText(R.string.licenses)
replaceFragment(LicensesFragment(), LicensesFragment.TAG)
}
else -> {
}
}
}
supportFragmentManager.commit(allowStateLoss = true) {
replace(R.id.content, AboutInfoFragment())
}
}

private fun replaceFragment(fragment: Fragment, stackName: String?) {
supportFragmentManager.beginTransaction().apply {
if (stackName != null) {
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
addToBackStack(stackName)
}
replace(R.id.content, fragment)
}.commitAllowingStateLoss()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import android.content.Intent
import android.net.Uri
import android.widget.Toast
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.core.viewmodel.IntentViewModel
import dev.lucasnlm.antimine.core.viewmodel.StatelessViewModel
import dev.lucasnlm.antimine.licenses.LicenseActivity
import dev.lucasnlm.antimine.tutorial.TutorialActivity

class AboutViewModel(
private val application: Application,
) : IntentViewModel<AboutEvent, AboutState>() {
) : StatelessViewModel<AboutEvent>() {

override fun onEvent(event: AboutEvent) {
when (event) {
AboutEvent.ThirdPartyLicenses -> {
openLicensesActivity()
}
AboutEvent.SourceCode -> {
openSourceCode()
}
Expand All @@ -23,22 +27,16 @@ class AboutViewModel(
AboutEvent.Tutorial -> {
openTutorial()
}
else -> { }
}
}

private fun getLicensesList() = mapOf(
"Android SDK License" to R.raw.android_sdk,
"Koin" to R.raw.apache2,
"LibGDX" to R.raw.apache2,
"Material Design" to R.raw.apache2,
"Moshi" to R.raw.apache2,
"Mockk" to R.raw.apache2,
"Noto Emoji" to R.raw.apache2,
"Sounds" to R.raw.sounds,
).map {
License(it.key, it.value)
}.toList()
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
}
context.startActivity(intent)
}

private fun openTutorial() {
val context = application.applicationContext
Expand Down Expand Up @@ -72,11 +70,6 @@ class AboutViewModel(
}
}

override fun initialState(): AboutState =
AboutState(
licenses = getLicensesList(),
)

companion object {
private const val SOURCE_CODE = "https://github.com/lucasnlm/antimine-android"
private const val CROWDIN_URL = "https://crowdin.com/project/antimine-android"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.lucasnlm.antimine.about.views.info
package dev.lucasnlm.antimine.about.views

import android.content.pm.PackageManager
import android.os.Bundle
Expand All @@ -8,19 +8,11 @@ import androidx.fragment.app.Fragment
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.about.viewmodel.AboutEvent
import dev.lucasnlm.antimine.about.viewmodel.AboutViewModel
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import kotlinx.android.synthetic.main.fragment_about_info.*
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.sharedViewModel

class AboutInfoFragment : Fragment(R.layout.fragment_about_info) {
private val aboutViewModel: AboutViewModel by sharedViewModel()
private val themeRepository: IThemeRepository by inject()

override fun onResume() {
super.onResume()
activity?.setTitle(R.string.about)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand All @@ -40,41 +32,21 @@ class AboutInfoFragment : Fragment(R.layout.fragment_about_info) {
}
}

tutorial.bind(
theme = themeRepository.getTheme(),
text = R.string.tutorial,
centralize = true,
onAction = {
aboutViewModel.sendEvent(AboutEvent.Tutorial)
},
)
tutorial.setOnClickListener {
aboutViewModel.sendEvent(AboutEvent.Tutorial)
}

thirdsParties.bind(
theme = themeRepository.getTheme(),
text = R.string.show_licenses,
centralize = true,
onAction = {
aboutViewModel.sendEvent(AboutEvent.ThirdPartyLicenses)
},
)
thirdsParties.setOnClickListener {
aboutViewModel.sendEvent(AboutEvent.ThirdPartyLicenses)
}

translation.bind(
theme = themeRepository.getTheme(),
text = R.string.translation,
centralize = true,
onAction = {
aboutViewModel.sendEvent(AboutEvent.Translators)
},
)
translation.setOnClickListener {
aboutViewModel.sendEvent(AboutEvent.Translators)
}

sourceCode.bind(
theme = themeRepository.getTheme(),
text = R.string.source_code,
centralize = true,
onAction = {
aboutViewModel.sendEvent(AboutEvent.SourceCode)
},
)
sourceCode.setOnClickListener {
aboutViewModel.sendEvent(AboutEvent.SourceCode)
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.lucasnlm.antimine.licenses

import android.os.Bundle
import androidx.fragment.app.commit
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.licenses.views.LicensesFragment
import dev.lucasnlm.antimine.ui.ext.ThemedActivity
import kotlinx.android.synthetic.main.activity_container.*

class LicenseActivity : ThemedActivity(R.layout.activity_container) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

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

supportFragmentManager.commit(allowStateLoss = true) {
replace(R.id.content, LicensesFragment())
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.lucasnlm.antimine.licenses.viewmodel

data class License(
val name: String,
val url: String,
)

data class LicenseState(
val licenses: List<License>,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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()

override fun initialState(): LicenseState {
return LicenseState(licenses = getLicensesList())
}
}
Loading

0 comments on commit 871e544

Please sign in to comment.