feat: add about page
This commit is contained in:
parent
6842c85614
commit
ba4a2d0b6f
|
@ -12,7 +12,7 @@ android {
|
|||
minSdkVersion 26
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
versionName "1.0.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -43,11 +43,11 @@ dependencies {
|
|||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
// default kotlin android stuff
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.3.1'
|
||||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.3.0'
|
||||
implementation 'androidx.navigation:navigation-ui:2.3.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||
|
@ -80,7 +80,7 @@ dependencies {
|
|||
implementation "androidx.room:room-ktx:$room_version"
|
||||
androidTestImplementation "androidx.room:room-testing:$room_version"
|
||||
// tests
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'junit:junit:4.13'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
}
|
|
@ -250,7 +250,8 @@ class ConnectionService : Service() {
|
|||
|
||||
this.service.handler.post {
|
||||
val vm: MessagesViewModel by this@ConnectionRunner.service.app.viewModels()
|
||||
vm.addSystemMessage("Connected")
|
||||
val text = this@ConnectionRunner.service.app.getString(R.string.messages_connected)
|
||||
vm.addSystemMessage(text)
|
||||
}
|
||||
|
||||
// conn was trusted, so navigate to messages page
|
||||
|
@ -390,7 +391,8 @@ class ConnectionService : Service() {
|
|||
|
||||
this.service.handler.post {
|
||||
val vm: MessagesViewModel by this@ConnectionRunner.service.app.viewModels()
|
||||
vm.addSystemMessage("Disconnected")
|
||||
val text = this@ConnectionRunner.service.app.getString(R.string.messages_disconnected)
|
||||
vm.addSystemMessage(text)
|
||||
}
|
||||
|
||||
// stop the service, removing the notification
|
||||
|
|
|
@ -146,6 +146,7 @@ class MainActivity : AppCompatActivity() {
|
|||
R.id.nav_servers,
|
||||
R.id.nav_messages,
|
||||
R.id.nav_settings,
|
||||
R.id.nav_about,
|
||||
),
|
||||
drawerLayout,
|
||||
)
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package io.annaclemens.xivchat.ui.about
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TableLayout
|
||||
import android.widget.TableRow
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import io.annaclemens.xivchat.R
|
||||
import kotlinx.android.synthetic.main.fragment_about.view.*
|
||||
|
||||
|
||||
class AboutFragment : Fragment() {
|
||||
companion object {
|
||||
private const val KOFI_URL: String = "https://ko-fi.com/ascclemens"
|
||||
private const val PATREON_URL: String = "https://www.patreon.com/ascclemens"
|
||||
private const val LIBERAPAY_URL: String = "https://liberapay.com/ascclemens"
|
||||
}
|
||||
|
||||
private fun openUrl(url: String) {
|
||||
val i = Intent(Intent.ACTION_VIEW)
|
||||
i.data = Uri.parse(url)
|
||||
this.startActivity(i)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
val root = inflater.inflate(R.layout.fragment_about, container, false)
|
||||
|
||||
root.kofi_image.setOnClickListener {
|
||||
this.openUrl(Companion.KOFI_URL)
|
||||
}
|
||||
root.liberapay_image.setOnClickListener {
|
||||
this.openUrl(Companion.LIBERAPAY_URL)
|
||||
}
|
||||
root.patreon_image.setOnClickListener {
|
||||
this.openUrl(Companion.PATREON_URL)
|
||||
}
|
||||
|
||||
val translators = this.resources.getStringArray(R.array.translators)
|
||||
val translatorsLayout = TableLayout(this.context)
|
||||
for (translator in translators) {
|
||||
val split = translator.split('|', limit = 2)
|
||||
|
||||
val langId = when (split[0]) {
|
||||
"en" -> R.string.lang_en
|
||||
"de" -> R.string.lang_de
|
||||
"fr" -> R.string.lang_fr
|
||||
"ja" -> R.string.lang_ja
|
||||
else -> 0
|
||||
}
|
||||
val langName = if (langId != 0) {
|
||||
this.getString(langId)
|
||||
} else {
|
||||
"Unknown"
|
||||
}
|
||||
|
||||
val name = split[1]
|
||||
|
||||
val row = TableRow(this.context)
|
||||
val layoutParams = TableRow.LayoutParams().apply {
|
||||
this.marginEnd = this@AboutFragment.dpToPx(8)
|
||||
}
|
||||
row.addView(TextView(this.context).apply { this.text = langName }, layoutParams)
|
||||
row.addView(TextView(this.context).apply { this.text = name })
|
||||
|
||||
translatorsLayout.addView(row)
|
||||
}
|
||||
|
||||
root.translators_scroll.addView(translatorsLayout)
|
||||
|
||||
return root
|
||||
}
|
||||
|
||||
private fun dpToPx(dp: Int): Int {
|
||||
return (this.resources.displayMetrics.scaledDensity * dp).toInt()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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:layout_gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp"
|
||||
tools:context=".ui.about.AboutFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/about_donate_desc" />
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="16dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/kofi_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:background="#ffffff"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/about_kofi"
|
||||
android:padding="12.5dp"
|
||||
app:srcCompat="@drawable/kofi" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/liberapay_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:background="#f6c915"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/about_liberapay"
|
||||
app:srcCompat="@drawable/liberapay" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/patreon_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:adjustViewBounds="true"
|
||||
android:background="#FF424D"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/about_patreon"
|
||||
android:paddingHorizontal="25dp"
|
||||
android:paddingVertical="12.5dp"
|
||||
android:scaleType="centerInside"
|
||||
app:srcCompat="@drawable/patreon" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/about_thank_translators" />
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/translators_scroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
|
@ -21,4 +21,10 @@
|
|||
android:icon="@drawable/settings_black_24dp"
|
||||
android:title="@string/menu_settings" />
|
||||
</group>
|
||||
<group android:id="@+id/menuAbout" >
|
||||
<item
|
||||
android:id="@+id/nav_about"
|
||||
android:icon="@drawable/info_black_24dp"
|
||||
android:title="@string/menu_about" />
|
||||
</group>
|
||||
</menu>
|
|
@ -16,6 +16,7 @@
|
|||
android:name="io.annaclemens.xivchat.ui.settings.KeyVisualisationFragment"
|
||||
android:label="@string/menu_settings"
|
||||
tools:layout="@layout/fragment_settings" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_servers"
|
||||
android:name="io.annaclemens.xivchat.ui.servers.ServersFragment"
|
||||
|
@ -25,4 +26,10 @@
|
|||
app:destination="@id/nav_messages" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_about"
|
||||
android:name="io.annaclemens.xivchat.ui.about.AboutFragment"
|
||||
android:label="@string/menu_about"
|
||||
tools:layout="@layout/fragment_about" />
|
||||
|
||||
</navigation>
|
|
@ -22,11 +22,14 @@
|
|||
<string name="menu_messages">Messages</string>
|
||||
<string name="menu_servers">Servers</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="menu_about">About</string>
|
||||
<string name="menu_not_logged_in">Not logged in</string>
|
||||
|
||||
<string name="messages_not_connected">Please connect to a server</string>
|
||||
<string name="messages_placeholder">Send a message…</string>
|
||||
<string name="messages_unavailable">Chat is unavailable at this time</string>
|
||||
<string name="messages_connected">Connected</string>
|
||||
<string name="messages_disconnected">Disconnected</string>
|
||||
|
||||
<string name="notif_title">Connected to XIVChat</string>
|
||||
<string name="notif_message">Tap to see messages.</string>
|
||||
|
@ -50,6 +53,17 @@
|
|||
<string name="unexpected_disconnect">Disconnected from server</string>
|
||||
<string name="unexpected_disconnect_desc">Could not read from server.</string>
|
||||
|
||||
<string name="about_donate_desc">XIVChat for Android is developed by me, Anna. If you would like to support me further, please consider supporting me on one of the platforms below. Tap on any image to go to my page.</string>
|
||||
<string name="about_patreon">Patreon</string>
|
||||
<string name="about_kofi">Ko-fi</string>
|
||||
<string name="about_liberapay">Liberapay</string>
|
||||
<string name="about_thank_translators">A big thank you to XIVChat\'s wonderful volunteer translators, who are listed below!</string>
|
||||
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
|
||||
<string name="lang_en">English</string>
|
||||
<string name="lang_de">German</string>
|
||||
<string name="lang_fr">French</string>
|
||||
<string name="lang_ja">Japanese</string>
|
||||
</resources>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="translators">
|
||||
<item>en|ascclemens</item>
|
||||
<item>de|goaaats</item>
|
||||
</string-array>
|
||||
</resources>
|
Loading…
Reference in New Issue