diff --git a/app/src/main/java/org/koitharu/kotatsu/settings/about/AboutSettingsFragment.kt b/app/src/main/java/org/koitharu/kotatsu/settings/about/AboutSettingsFragment.kt index 8e149f83b..985ca0d1a 100644 --- a/app/src/main/java/org/koitharu/kotatsu/settings/about/AboutSettingsFragment.kt +++ b/app/src/main/java/org/koitharu/kotatsu/settings/about/AboutSettingsFragment.kt @@ -36,18 +36,6 @@ class AboutSettingsFragment : BasePreferenceFragment(R.string.about) { openLink(getString(R.string.url_weblate), preference.title) 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) } } diff --git a/app/src/main/java/org/koitharu/kotatsu/settings/utils/AboutLinksPreference.kt b/app/src/main/java/org/koitharu/kotatsu/settings/utils/AboutLinksPreference.kt new file mode 100644 index 000000000..cb4e12834 --- /dev/null +++ b/app/src/main/java/org/koitharu/kotatsu/settings/utils/AboutLinksPreference.kt @@ -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 + } + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/utils/ext/ViewExt.kt b/app/src/main/java/org/koitharu/kotatsu/utils/ext/ViewExt.kt index 586e40eef..56afd7cd1 100644 --- a/app/src/main/java/org/koitharu/kotatsu/utils/ext/ViewExt.kt +++ b/app/src/main/java/org/koitharu/kotatsu/utils/ext/ViewExt.kt @@ -5,6 +5,8 @@ import android.graphics.Rect import android.view.View import android.view.ViewGroup import android.view.inputmethod.InputMethodManager +import androidx.annotation.StringRes +import androidx.appcompat.widget.TooltipCompat import androidx.core.view.children import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -154,4 +156,12 @@ fun ViewGroup.findViewsByType(clazz: Class): Sequence { } } } +} + +inline fun View.setTooltip(@StringRes stringRes: Int) { + setTooltip(context.getString(stringRes)) +} + +inline fun View.setTooltip(text: String) { + TooltipCompat.setTooltipText(this, text) } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_4pda.xml b/app/src/main/res/drawable/ic_4pda.xml new file mode 100644 index 000000000..6ce338a77 --- /dev/null +++ b/app/src/main/res/drawable/ic_4pda.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/drawable/ic_discord.xml b/app/src/main/res/drawable/ic_discord.xml new file mode 100644 index 000000000..ff193346d --- /dev/null +++ b/app/src/main/res/drawable/ic_discord.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/drawable/ic_github.xml b/app/src/main/res/drawable/ic_github.xml new file mode 100644 index 000000000..55a2da656 --- /dev/null +++ b/app/src/main/res/drawable/ic_github.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/drawable/ic_reddit.xml b/app/src/main/res/drawable/ic_reddit.xml new file mode 100644 index 000000000..d56d46d7b --- /dev/null +++ b/app/src/main/res/drawable/ic_reddit.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_twitter.xml b/app/src/main/res/drawable/ic_twitter.xml new file mode 100644 index 000000000..3e51fdce1 --- /dev/null +++ b/app/src/main/res/drawable/ic_twitter.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/layout/preference_about_links.xml b/app/src/main/res/layout/preference_about_links.xml new file mode 100644 index 000000000..475b02f65 --- /dev/null +++ b/app/src/main/res/layout/preference_about_links.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/constants.xml b/app/src/main/res/values/constants.xml index 5132610e6..424125fab 100644 --- a/app/src/main/res/values/constants.xml +++ b/app/src/main/res/values/constants.xml @@ -3,6 +3,8 @@ https://github.com/nv95/Kotatsu/issues https://discord.gg/NNJ5RgVBC5 https://4pda.to/forum/index.php?showtopic=697669 + https://https://twitter.com/kotatsuapp + https://www.reddit.com/user/kotatsuapp/ https://hosted.weblate.org/engage/kotatsu -1 diff --git a/app/src/main/res/xml/pref_about.xml b/app/src/main/res/xml/pref_about.xml index bde3d1904..ab078ac09 100644 --- a/app/src/main/res/xml/pref_about.xml +++ b/app/src/main/res/xml/pref_about.xml @@ -15,31 +15,13 @@ android:summary="@string/show_notification_app_update" android:title="@string/application_update" /> - - - - - - - - - - + +