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
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 com.mikepenz.aboutlibraries.LibsBuilder
import com.mikepenz.aboutlibraries.LibsFragmentCompat
import io.github.wulkanowy.BuildConfig
import io.github.wulkanowy.R
import io.github.wulkanowy.ui.base.BaseFragment
import io.github.wulkanowy.ui.modules.main.MainView
@ -36,12 +38,12 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
.withAboutVersionShown(true)
.withAboutIconShown(true)
.withLicenseShown(true)
.withAboutSpecial1(getString(R.string.about_source_code))
.withAboutSpecial2(getString(R.string.about_feedback))
.withAboutSpecial1(getString(R.string.about_discord_invite))
.withAboutSpecial2(getString(R.string.about_homepage))
.withAboutSpecial3(getString(R.string.about_feedback))
.withFields(R.string::class.java.fields)
.withCheckCachedDetection(false)
.withExcludedLibraries("fastadapter", "AndroidIconics", "gson",
"Jsoup", "Retrofit", "okio", "OkHttp")
.withExcludedLibraries("fastadapter", "AndroidIconics", "gson", "Jsoup", "Retrofit", "okio", "OkHttp")
.withOnExtraListener { presenter.onExtraSelect(it) })
}.let {
fragmentCompat.onCreateView(inflater.context, inflater, container, savedInstanceState, it)
@ -53,13 +55,34 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
fragmentCompat.onViewCreated(view, savedInstanceState)
}
override fun openSourceWebView() {
startActivity(Intent.parseUri("https://github.com/wulkanowy/wulkanowy", 0))
override fun openDiscordInviteView() {
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))
}
}
}
override fun onDestroyView() {
fragmentCompat.onDestroyView()

View File

@ -24,17 +24,19 @@ class AboutPresenter @Inject constructor(
view?.run {
when (type) {
SPECIAL1 -> {
Timber.i("Opening github page")
analytics.logEvent("open_page", "name" to "github")
openSourceWebView()
Timber.i("Opening discord invide page")
analytics.logEvent("open_page", "name" to "discord")
openDiscordInviteView()
}
SPECIAL2 -> {
Timber.i("Opening issues page")
analytics.logEvent("open_page", "name" to "issues")
openIssuesWebView()
Timber.i("Opening home page")
analytics.logEvent("open_page", "name" to "home")
openHomepageWebView()
}
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 {
fun openSourceWebView()
fun openDiscordInviteView()
fun openIssuesWebView()
fun openEmailClientView()
fun openHomepageWebView()
}

View File

@ -207,8 +207,9 @@
<!--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_homepage">Strona domowa</string>
<!--Generic-->

View File

@ -192,8 +192,9 @@
<!--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_homepage">Homepage</string>
<!--Generic-->