Tweak About view

pull/178/head
Zakhar Timoshenko 4 years ago
parent d2f3bfb2e3
commit 0bb090eee6

@ -36,18 +36,6 @@ class AboutSettingsFragment : BasePreferenceFragment(R.string.about) {
openLink(getString(R.string.url_weblate), preference.title) openLink(getString(R.string.url_weblate), preference.title)
true true
} }
AppSettings.KEY_FEEDBACK_4PDA -> {
openLink(getString(R.string.url_forpda), preference.title)
true
}
AppSettings.KEY_FEEDBACK_DISCORD -> {
openLink(getString(R.string.url_discord), preference.title)
true
}
AppSettings.KEY_FEEDBACK_GITHUB -> {
openLink(getString(R.string.url_github_issues), preference.title)
true
}
else -> super.onPreferenceTreeClick(preference) else -> super.onPreferenceTreeClick(preference)
} }
} }

@ -0,0 +1,62 @@
package org.koitharu.kotatsu.settings.utils
import android.content.Context
import android.content.Intent
import android.util.AttributeSet
import androidx.core.content.ContextCompat.startActivity
import androidx.core.net.toUri
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.utils.ext.setTooltip
class AboutLinksPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
Preference(context, attrs) {
init {
layoutResource = R.layout.preference_about_links
isSelectable = false
}
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
holder.findViewById(R.id.btn_4pda).apply {
setTooltip(contentDescription.toString())
setOnClickListener { openLink(resources.getString(R.string.url_forpda), contentDescription.toString()) }
}
holder.findViewById(R.id.btn_discord).apply {
setTooltip(contentDescription.toString())
setOnClickListener { openLink(resources.getString(R.string.url_discord), contentDescription.toString()) }
}
holder.findViewById(R.id.btn_twitter).apply {
setTooltip(contentDescription.toString())
setOnClickListener { openLink(resources.getString(R.string.url_twitter), contentDescription.toString()) }
}
holder.findViewById(R.id.btn_reddit).apply {
setTooltip(contentDescription.toString())
setOnClickListener { openLink(resources.getString(R.string.url_reddit), contentDescription.toString()) }
}
holder.findViewById(R.id.btn_github).apply {
setTooltip(contentDescription.toString())
setOnClickListener {
openLink(
resources.getString(R.string.url_github_issues),
contentDescription.toString()
)
}
}
}
private fun openLink(url: String, title: CharSequence?) {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = url.toUri()
context.startActivity(
if (title != null) {
Intent.createChooser(intent, title)
} else {
intent
}
)
}
}

@ -5,6 +5,8 @@ import android.graphics.Rect
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import androidx.annotation.StringRes
import androidx.appcompat.widget.TooltipCompat
import androidx.core.view.children import androidx.core.view.children
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -155,3 +157,11 @@ fun <T : View> ViewGroup.findViewsByType(clazz: Class<T>): Sequence<T> {
} }
} }
} }
inline fun View.setTooltip(@StringRes stringRes: Int) {
setTooltip(context.getString(stringRes))
}
inline fun View.setTooltip(text: String) {
TooltipCompat.setTooltipText(this, text)
}

@ -0,0 +1,11 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:fillColor="#000000"
android:fillType="evenOdd"
android:pathData="M402,0 L0,555v317h623v152h401L1024,0ZM624,256L624,596L356,596Z" />
</vector>

@ -0,0 +1,11 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M20.349,4.389a0.06,0.06 0,0 0,-0.032 -0.029,19.77 19.77,0 0,0 -4.885,-1.515 0.075,0.075 0,0 0,-0.079 0.037c-0.209,0.375 -0.444,0.865 -0.607,1.249a18.35,18.35 0,0 0,-5.487 0,12.583 12.583,0 0,0 -0.617,-1.249 0.078,0.078 0,0 0,-0.079 -0.037,19.746 19.746,0 0,0 -4.886,1.515 0.06,0.06 0,0 0,-0.031 0.028c-3.111,4.648 -3.964,9.183 -3.545,13.66a0.082,0.082 0,0 0,0.031 0.057,19.912 19.912,0 0,0 5.993,3.03 0.075,0.075 0,0 0,0.084 -0.028c0.461,-0.631 0.873,-1.296 1.226,-1.994a0.076,0.076 0,0 0,-0.042 -0.106,13.172 13.172,0 0,1 -1.872,-0.892 0.077,0.077 0,0 1,-0.007 -0.128c0.125,-0.094 0.251,-0.192 0.371,-0.292a0.078,0.078 0,0 1,0.078 -0.011c3.928,1.794 8.179,1.794 12.062,0a0.073,0.073 0,0 1,0.077 0.01c0.122,0.099 0.247,0.199 0.373,0.293a0.078,0.078 0,0 1,-0.007 0.128c-0.597,0.349 -1.22,0.645 -1.873,0.892a0.075,0.075 0,0 0,-0.04 0.106c0.359,0.697 0.771,1.362 1.225,1.993a0.077,0.077 0,0 0,0.085 0.029,19.842 19.842,0 0,0 6.003,-3.03 0.077,0.077 0,0 0,0.03 -0.056c0.499,-5.177 -0.839,-9.674 -3.549,-13.66zM8.02,15.322c-1.183,0 -2.157,-1.087 -2.157,-2.419 0,-1.334 0.956,-2.42 2.157,-2.42 1.21,0 2.176,1.095 2.157,2.42 0,1.332 -0.955,2.419 -2.157,2.419zM15.995,15.322c-1.184,0 -2.157,-1.087 -2.157,-2.419 0,-1.334 0.955,-2.42 2.157,-2.42 1.211,0 2.175,1.095 2.156,2.42 0,1.332 -0.945,2.419 -2.156,2.419z" />
</vector>

@ -0,0 +1,11 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z" />
</vector>

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M14.5 15.41C14.58 15.5 14.58 15.69 14.5 15.8C13.77 16.5 12.41 16.56 12 16.56C11.61 16.56 10.25 16.5 9.54 15.8C9.44 15.69 9.44 15.5 9.54 15.41C9.65 15.31 9.82 15.31 9.92 15.41C10.38 15.87 11.33 16 12 16C12.69 16 13.66 15.87 14.1 15.41C14.21 15.31 14.38 15.31 14.5 15.41M10.75 13.04C10.75 12.47 10.28 12 9.71 12C9.14 12 8.67 12.47 8.67 13.04C8.67 13.61 9.14 14.09 9.71 14.08C10.28 14.08 10.75 13.61 10.75 13.04M14.29 12C13.72 12 13.25 12.5 13.25 13.05S13.72 14.09 14.29 14.09C14.86 14.09 15.33 13.61 15.33 13.05C15.33 12.5 14.86 12 14.29 12M22 12C22 17.5 17.5 22 12 22S2 17.5 2 12C2 6.5 6.5 2 12 2S22 6.5 22 12M18.67 12C18.67 11.19 18 10.54 17.22 10.54C16.82 10.54 16.46 10.7 16.2 10.95C15.2 10.23 13.83 9.77 12.3 9.71L12.97 6.58L15.14 7.05C15.16 7.6 15.62 8.04 16.18 8.04C16.75 8.04 17.22 7.57 17.22 7C17.22 6.43 16.75 5.96 16.18 5.96C15.77 5.96 15.41 6.2 15.25 6.55L12.82 6.03C12.75 6 12.68 6.03 12.63 6.07C12.57 6.11 12.54 6.17 12.53 6.24L11.79 9.72C10.24 9.77 8.84 10.23 7.82 10.96C7.56 10.71 7.2 10.56 6.81 10.56C6 10.56 5.35 11.21 5.35 12C5.35 12.61 5.71 13.11 6.21 13.34C6.19 13.5 6.18 13.62 6.18 13.78C6.18 16 8.79 17.85 12 17.85C15.23 17.85 17.85 16.03 17.85 13.78C17.85 13.64 17.84 13.5 17.81 13.34C18.31 13.11 18.67 12.6 18.67 12Z"/>
</vector>

@ -0,0 +1,11 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M22.46,6C21.69,6.35 20.86,6.58 20,6.69C20.88,6.16 21.56,5.32 21.88,4.31C21.05,4.81 20.13,5.16 19.16,5.36C18.37,4.5 17.26,4 16,4C13.65,4 11.73,5.92 11.73,8.29C11.73,8.63 11.77,8.96 11.84,9.27C8.28,9.09 5.11,7.38 3,4.79C2.63,5.42 2.42,6.16 2.42,6.94C2.42,8.43 3.17,9.75 4.33,10.5C3.62,10.5 2.96,10.3 2.38,10C2.38,10 2.38,10 2.38,10.03C2.38,12.11 3.86,13.85 5.82,14.24C5.46,14.34 5.08,14.39 4.69,14.39C4.42,14.39 4.15,14.36 3.89,14.31C4.43,16 6,17.26 7.89,17.29C6.43,18.45 4.58,19.13 2.56,19.13C2.22,19.13 1.88,19.11 1.54,19.07C3.44,20.29 5.7,21 8.12,21C16,21 20.33,14.46 20.33,8.79C20.33,8.6 20.33,8.42 20.32,8.23C21.16,7.63 21.88,6.87 22.46,6Z" />
</vector>

@ -0,0 +1,64 @@
<?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:gravity="center">
<ImageButton
android:id="@+id/btn_4pda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="4PDA"
android:padding="16dp"
android:src="@drawable/ic_4pda"
app:tint="?attr/colorAccent"
tools:ignore="HardcodedText" />
<ImageButton
android:id="@+id/btn_discord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Discord"
android:padding="16dp"
android:src="@drawable/ic_discord"
app:tint="?attr/colorAccent"
tools:ignore="HardcodedText" />
<ImageButton
android:id="@+id/btn_twitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Twitter"
android:padding="16dp"
android:src="@drawable/ic_twitter"
app:tint="?attr/colorAccent"
tools:ignore="HardcodedText" />
<ImageButton
android:id="@+id/btn_reddit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Reddit"
android:padding="16dp"
android:src="@drawable/ic_reddit"
app:tint="?attr/colorAccent"
tools:ignore="HardcodedText" />
<ImageButton
android:id="@+id/btn_github"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="GitHub"
android:padding="16dp"
android:src="@drawable/ic_github"
app:tint="?attr/colorAccent"
tools:ignore="HardcodedText" />
</LinearLayout>

@ -3,6 +3,8 @@
<string name="url_github_issues">https://github.com/nv95/Kotatsu/issues</string> <string name="url_github_issues">https://github.com/nv95/Kotatsu/issues</string>
<string name="url_discord">https://discord.gg/NNJ5RgVBC5</string> <string name="url_discord">https://discord.gg/NNJ5RgVBC5</string>
<string name="url_forpda">https://4pda.to/forum/index.php?showtopic=697669</string> <string name="url_forpda">https://4pda.to/forum/index.php?showtopic=697669</string>
<string name="url_twitter">https://https://twitter.com/kotatsuapp</string>
<string name="url_reddit">https://www.reddit.com/user/kotatsuapp/</string>
<string name="url_weblate">https://hosted.weblate.org/engage/kotatsu</string> <string name="url_weblate">https://hosted.weblate.org/engage/kotatsu</string>
<string-array name="values_theme" translatable="false"> <string-array name="values_theme" translatable="false">
<item>-1</item> <item>-1</item>

@ -15,31 +15,13 @@
android:summary="@string/show_notification_app_update" android:summary="@string/show_notification_app_update"
android:title="@string/application_update" /> android:title="@string/application_update" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/about_feedback">
<Preference
android:key="about_feedback_github"
android:persistent="false"
android:summary="@string/url_github_issues"
android:title="@string/github" />
<Preference
android:key="about_feedback_4pda"
android:summary="@string/url_forpda"
android:title="@string/about_feedback_4pda" />
<Preference
android:key="about_feedback_discord"
android:summary="@string/url_discord"
android:title="@string/discord" />
<Preference <Preference
android:key="about_app_translation" android:key="about_app_translation"
android:summary="@string/about_app_translation_summary" android:summary="@string/about_app_translation_summary"
android:title="@string/about_app_translation" /> android:title="@string/about_app_translation" />
<org.koitharu.kotatsu.settings.utils.AboutLinksPreference />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

Loading…
Cancel
Save