Add Translators to About
This commit is contained in:
parent
6109001a54
commit
eabf6f40dc
17 changed files with 224 additions and 18 deletions
|
@ -123,6 +123,11 @@
|
|||
|
||||
<activity
|
||||
android:name="dev.lucasnlm.antimine.about.thirds.ThirdPartiesActivity"
|
||||
android:label="@string/licenses"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
<activity
|
||||
android:name="dev.lucasnlm.antimine.about.translators.TranslatorsActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
<activity
|
||||
|
|
|
@ -9,6 +9,7 @@ import dev.lucasnlm.antimine.BuildConfig
|
|||
import dev.lucasnlm.antimine.R
|
||||
|
||||
import dev.lucasnlm.antimine.about.thirds.ThirdPartiesActivity
|
||||
import dev.lucasnlm.antimine.about.translators.TranslatorsActivity
|
||||
import kotlinx.android.synthetic.main.activity_about.*
|
||||
|
||||
class AboutActivity : AppCompatActivity() {
|
||||
|
@ -24,6 +25,7 @@ class AboutActivity : AppCompatActivity() {
|
|||
|
||||
thirdsParties.setOnClickListener { openThirdParties() }
|
||||
sourceCode.setOnClickListener { openSourceCode() }
|
||||
translation.setOnClickListener { openTranslation() }
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||
|
@ -47,7 +49,15 @@ class AboutActivity : AppCompatActivity() {
|
|||
startActivity(Intent(this, ThirdPartiesActivity::class.java))
|
||||
}
|
||||
|
||||
private fun openTranslation() {
|
||||
startActivity(Intent(this, TranslatorsActivity::class.java))
|
||||
}
|
||||
|
||||
private fun openSourceCode() {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/lucasnlm/antimine-android")))
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(SOURCE_CODE)))
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val SOURCE_CODE = "https://github.com/lucasnlm/antimine-android"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,10 +25,10 @@ class ThirdPartiesActivity : AppCompatActivity() {
|
|||
layoutManager = LinearLayoutManager(context)
|
||||
}
|
||||
|
||||
loadLicenses()
|
||||
bindLicenses()
|
||||
}
|
||||
|
||||
private fun loadLicenses() {
|
||||
private fun bindLicenses() {
|
||||
licenses.adapter = ThirdPartyAdapter(
|
||||
listOf(
|
||||
ThirdParty(
|
||||
|
|
|
@ -12,18 +12,18 @@ import dev.lucasnlm.antimine.about.thirds.data.ThirdParty
|
|||
|
||||
internal class ThirdPartyAdapter(
|
||||
private val thirdParties: List<ThirdParty>
|
||||
) : RecyclerView.Adapter<ThirdPartyItemHolder>() {
|
||||
) : RecyclerView.Adapter<ThirdPartyViewHolder>() {
|
||||
|
||||
override fun getItemCount(): Int = thirdParties.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ThirdPartyItemHolder {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ThirdPartyViewHolder {
|
||||
val view = LayoutInflater
|
||||
.from(parent.context)
|
||||
.inflate(R.layout.view_third_party, parent, false)
|
||||
return ThirdPartyItemHolder(view)
|
||||
return ThirdPartyViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ThirdPartyItemHolder, position: Int) {
|
||||
override fun onBindViewHolder(holder: ThirdPartyViewHolder, position: Int) {
|
||||
val thirdParty = thirdParties[position]
|
||||
holder.title.text = thirdParty.name
|
||||
holder.itemView.setOnClickListener { view ->
|
||||
|
|
|
@ -6,6 +6,6 @@ import android.widget.TextView
|
|||
|
||||
import dev.lucasnlm.antimine.R
|
||||
|
||||
internal class ThirdPartyItemHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
internal class ThirdPartyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val title: TextView = view.findViewById(R.id.third_name)
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package dev.lucasnlm.antimine.about.translators
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import dev.lucasnlm.antimine.R
|
||||
import dev.lucasnlm.antimine.about.translators.model.TranslationInfo
|
||||
import dev.lucasnlm.antimine.about.translators.view.TranslatorsAdapter
|
||||
import kotlinx.android.synthetic.main.activity_translators.*
|
||||
|
||||
class TranslatorsActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_translators)
|
||||
bindToolbar()
|
||||
|
||||
translators.apply {
|
||||
addItemDecoration(
|
||||
DividerItemDecoration(context, DividerItemDecoration.VERTICAL)
|
||||
)
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
}
|
||||
|
||||
bindTranslationInfo()
|
||||
}
|
||||
|
||||
private fun bindTranslationInfo() {
|
||||
translators.adapter = TranslatorsAdapter(
|
||||
listOf(
|
||||
TranslationInfo(
|
||||
"Brazilian Portuguese",
|
||||
sequenceOf("Lucas Lima")
|
||||
),
|
||||
TranslationInfo(
|
||||
"Czech",
|
||||
sequenceOf("Lukas Novotny")
|
||||
),
|
||||
TranslationInfo(
|
||||
"Turkish",
|
||||
sequenceOf("Fatih Fırıncı")
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun bindToolbar() {
|
||||
supportActionBar?.apply {
|
||||
setTitle(R.string.licenses)
|
||||
setDisplayHomeAsUpEnabled(true)
|
||||
setHomeButtonEnabled(true)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package dev.lucasnlm.antimine.about.translators.model
|
||||
|
||||
data class TranslationInfo(
|
||||
val language: String,
|
||||
val translators: Sequence<String>
|
||||
)
|
|
@ -0,0 +1,28 @@
|
|||
package dev.lucasnlm.antimine.about.translators.view
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dev.lucasnlm.antimine.R
|
||||
import dev.lucasnlm.antimine.about.translators.model.TranslationInfo
|
||||
|
||||
internal class TranslatorsAdapter(
|
||||
private val translators: List<TranslationInfo>
|
||||
) : RecyclerView.Adapter<TranslatorsViewHolder>() {
|
||||
|
||||
override fun getItemCount(): Int = translators.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TranslatorsViewHolder {
|
||||
val view = LayoutInflater
|
||||
.from(parent.context)
|
||||
.inflate(R.layout.view_translator, parent, false)
|
||||
return TranslatorsViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: TranslatorsViewHolder, position: Int) {
|
||||
with(translators[position]) {
|
||||
holder.language.text = language
|
||||
holder.translators.text = translators.joinToString("\n")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package dev.lucasnlm.antimine.about.translators.view
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dev.lucasnlm.antimine.R
|
||||
|
||||
internal class TranslatorsViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val language: TextView = view.findViewById(R.id.language)
|
||||
val translators: TextView = view.findViewById(R.id.translators)
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:src="@drawable/title"
|
||||
app:srcCompat="@drawable/title"
|
||||
app:layout_constraintBottom_toTopOf="@+id/version"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
|
@ -63,6 +63,17 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/source_code" />
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/translation"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/translation" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -9,14 +9,17 @@
|
|||
tools:context="dev.lucasnlm.antimine.about.thirds.ThirdPartiesActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingBottom="24dp"
|
||||
android:text="@string/translators_text"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:text="@string/used_software_text"
|
||||
android:id="@+id/summary"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/licenses"
|
||||
|
@ -26,6 +29,6 @@
|
|||
android:overScrollMode="never"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/summary" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/description" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
34
app/src/main/res/layout/activity_translators.xml
Normal file
34
app/src/main/res/layout/activity_translators.xml
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="false"
|
||||
tools:context="dev.lucasnlm.antimine.about.translators.TranslatorsActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingBottom="24dp"
|
||||
android:text="@string/translators_text"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/translators"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:clipToPadding="false"
|
||||
android:overScrollMode="never"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/description" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -5,7 +5,8 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:foreground="?android:attr/selectableItemBackground">
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
tools:targetApi="m">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/third_name"
|
||||
|
|
33
app/src/main/res/layout/view_translator.xml
Normal file
33
app/src/main/res/layout/view_translator.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:padding="16dp"
|
||||
tools:targetApi="m">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/language"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:text="Language" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/translators"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:text="Person A\nPerson B" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -22,7 +22,6 @@
|
|||
<color name="text_color">#FFFFFF</color>
|
||||
<color name="highlight">#FFFFFF</color>
|
||||
|
||||
<color name="stroke_cover">#757575</color>
|
||||
<color name="view_cover">#171717</color>
|
||||
<color name="view_clean">#ff424242</color>
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
<color name="text_color">#212121</color>
|
||||
<color name="highlight">#212121</color>
|
||||
|
||||
<color name="stroke_cover">#000</color>
|
||||
<color name="view_cover">#424242</color>
|
||||
<color name="view_clean">#d5d2cc</color>
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<string name="resume">Resume</string>
|
||||
<string name="show_licenses">Show Licenses</string>
|
||||
<string name="source_code">Source Code</string>
|
||||
<string name="translation">Translation</string>
|
||||
<string name="licenses">Licenses</string>
|
||||
<string name="google_play_games">Google Play Games</string>
|
||||
<string name="leaderboards">Leaderboards</string>
|
||||
|
@ -47,6 +48,7 @@
|
|||
<string name="flag_placed">Flag placed!</string>
|
||||
<string name="flag_removed">Flag removed!</string>
|
||||
<string name="used_software_text">This game uses the following third parties software:</string>
|
||||
<string name="translators_text">This game was translated by the following people:</string>
|
||||
<string name="sign_in_failed">Failed to sign in. Please check your network connection and try again.</string>
|
||||
<string name="unknown_error">Unknown error.</string>
|
||||
<string name="retry">Retry</string>
|
||||
|
|
Loading…
Reference in a new issue