1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2025-02-07 20:24:36 +01:00

Add homepage button in about fragment (#280)

This commit is contained in:
Mikołaj Pich 2019-03-16 14:22:51 +01:00 committed by Rafał Borcz
parent be807cb6c8
commit 38aa26a3ff
5 changed files with 48 additions and 19 deletions

View File

@ -1,12 +1,14 @@
package io.github.wulkanowy.ui.modules.about package io.github.wulkanowy.ui.modules.about
import android.content.Intent import android.content.Intent
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.mikepenz.aboutlibraries.LibsBuilder import com.mikepenz.aboutlibraries.LibsBuilder
import com.mikepenz.aboutlibraries.LibsFragmentCompat import com.mikepenz.aboutlibraries.LibsFragmentCompat
import io.github.wulkanowy.BuildConfig
import io.github.wulkanowy.R import io.github.wulkanowy.R
import io.github.wulkanowy.ui.base.BaseFragment import io.github.wulkanowy.ui.base.BaseFragment
import io.github.wulkanowy.ui.modules.main.MainView import io.github.wulkanowy.ui.modules.main.MainView
@ -36,12 +38,12 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
.withAboutVersionShown(true) .withAboutVersionShown(true)
.withAboutIconShown(true) .withAboutIconShown(true)
.withLicenseShown(true) .withLicenseShown(true)
.withAboutSpecial1(getString(R.string.about_source_code)) .withAboutSpecial1(getString(R.string.about_discord_invite))
.withAboutSpecial2(getString(R.string.about_feedback)) .withAboutSpecial2(getString(R.string.about_homepage))
.withAboutSpecial3(getString(R.string.about_feedback))
.withFields(R.string::class.java.fields) .withFields(R.string::class.java.fields)
.withCheckCachedDetection(false) .withCheckCachedDetection(false)
.withExcludedLibraries("fastadapter", "AndroidIconics", "gson", .withExcludedLibraries("fastadapter", "AndroidIconics", "gson", "Jsoup", "Retrofit", "okio", "OkHttp")
"Jsoup", "Retrofit", "okio", "OkHttp")
.withOnExtraListener { presenter.onExtraSelect(it) }) .withOnExtraListener { presenter.onExtraSelect(it) })
}.let { }.let {
fragmentCompat.onCreateView(inflater.context, inflater, container, savedInstanceState, it) fragmentCompat.onCreateView(inflater.context, inflater, container, savedInstanceState, it)
@ -53,13 +55,34 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
fragmentCompat.onViewCreated(view, savedInstanceState) fragmentCompat.onViewCreated(view, savedInstanceState)
} }
override fun openSourceWebView() { override fun openDiscordInviteView() {
startActivity(Intent.parseUri("https://github.com/wulkanowy/wulkanowy", 0)) startActivity(Intent.parseUri("https://discord.gg/vccAQBr", 0))
} }
override fun openIssuesWebView() { override fun openHomepageWebView() {
startActivity(Intent.parseUri("https://wulkanowy.github.io/", 0))
}
override fun openEmailClientView() {
val intent = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse("mailto:")
putExtra(Intent.EXTRA_EMAIL, Array(1) { "wulkanowyinc@gmail.com" })
putExtra(Intent.EXTRA_SUBJECT, "Zgłoszenie błędu")
putExtra(Intent.EXTRA_TEXT,"Tu umieść treść zgłoszenia\n\n" + "-".repeat(40) + "\n" + """
Build: ${BuildConfig.VERSION_CODE}
SDK: ${android.os.Build.VERSION.SDK_INT}
Device: ${android.os.Build.MANUFACTURER} ${android.os.Build.MODEL}
""".trimIndent())
}
context?.let {
if (intent.resolveActivity(it.packageManager) != null) {
startActivity(Intent.createChooser(intent, getString(R.string.about_feedback)))
} else {
startActivity(Intent.parseUri("https://github.com/wulkanowy/wulkanowy/issues", 0)) startActivity(Intent.parseUri("https://github.com/wulkanowy/wulkanowy/issues", 0))
} }
}
}
override fun onDestroyView() { override fun onDestroyView() {
fragmentCompat.onDestroyView() fragmentCompat.onDestroyView()

View File

@ -24,17 +24,19 @@ class AboutPresenter @Inject constructor(
view?.run { view?.run {
when (type) { when (type) {
SPECIAL1 -> { SPECIAL1 -> {
Timber.i("Opening github page") Timber.i("Opening discord invide page")
analytics.logEvent("open_page", "name" to "github") analytics.logEvent("open_page", "name" to "discord")
openSourceWebView() openDiscordInviteView()
} }
SPECIAL2 -> { SPECIAL2 -> {
Timber.i("Opening issues page") Timber.i("Opening home page")
analytics.logEvent("open_page", "name" to "issues") analytics.logEvent("open_page", "name" to "home")
openIssuesWebView() openHomepageWebView()
} }
SPECIAL3 -> { SPECIAL3 -> {
//empty for now Timber.i("Opening email client")
analytics.logEvent("open_page", "name" to "email")
openEmailClientView()
} }
} }
} }

View File

@ -4,7 +4,9 @@ import io.github.wulkanowy.ui.base.BaseView
interface AboutView : BaseView { interface AboutView : BaseView {
fun openSourceWebView() fun openDiscordInviteView()
fun openIssuesWebView() fun openEmailClientView()
fun openHomepageWebView()
} }

View File

@ -207,8 +207,9 @@
<!--About--> <!--About-->
<string name="about_source_code">Kod źródłowy</string> <string name="about_discord_invite">Discord</string>
<string name="about_feedback">Zgłoś błąd</string> <string name="about_feedback">Zgłoś błąd</string>
<string name="about_homepage">Strona domowa</string>
<!--Generic--> <!--Generic-->

View File

@ -192,8 +192,9 @@
<!--About--> <!--About-->
<string name="about_source_code">Source code</string> <string name="about_discord_invite">Discord</string>
<string name="about_feedback">Report a bug</string> <string name="about_feedback">Report a bug</string>
<string name="about_homepage">Homepage</string>
<!--Generic--> <!--Generic-->