From 94c727abd2b9f9543e01f1d971fd08da23b92fec Mon Sep 17 00:00:00 2001 From: Filip Date: Fri, 25 Jan 2019 22:41:07 +0100 Subject: [PATCH] feat: Release 1.0 --- .../wykopmobilny/models/dataclass/Author.kt | 6 ++ .../mainnavigation/MainNavigationActivity.kt | 77 ++++++++++++++++++- .../utils/preferences/SettingsPreferences.kt | 2 + .../utils/textview/TextViewExtensions.kt | 10 ++- .../main/res/layout/app_about_bottomsheet.xml | 13 ++++ .../main/res/layout/author_header_layout.xml | 2 +- app/src/main/res/layout/comment_list_item.xml | 6 +- .../main/res/layout/link_comment_layout.xml | 6 +- app/src/main/res/layout/patron_list_item.xml | 40 ++++++++++ .../main/res/layout/patrons_bottomsheet.xml | 32 ++++++++ app/src/main/res/values/strings.xml | 2 + app/src/main/res/values/styles.xml | 4 +- build.gradle | 8 +- versions.gradle | 2 +- 14 files changed, 191 insertions(+), 19 deletions(-) create mode 100644 app/src/main/res/layout/patron_list_item.xml create mode 100644 app/src/main/res/layout/patrons_bottomsheet.xml diff --git a/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/models/dataclass/Author.kt b/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/models/dataclass/Author.kt index 45ecfaa58..0f939c43e 100755 --- a/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/models/dataclass/Author.kt +++ b/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/models/dataclass/Author.kt @@ -1,5 +1,6 @@ package io.github.feelfreelinux.wykopmobilny.models.dataclass +import android.content.Context import android.graphics.Color import android.graphics.drawable.GradientDrawable import android.os.Build @@ -8,6 +9,8 @@ import android.os.Parcelable import android.view.View import android.widget.TextView import io.github.feelfreelinux.wykopmobilny.models.pojo.apiv2.patrons.PatronBadge +import io.github.feelfreelinux.wykopmobilny.utils.getActivityContext +import io.github.feelfreelinux.wykopmobilny.utils.openBrowser class Author( val nick: String, @@ -51,6 +54,9 @@ fun PatronBadge.drawBadge(view: TextView) { val shape = GradientDrawable( GradientDrawable.Orientation.LEFT_RIGHT, intArrayOf(Color.parseColor(hexColor), Color.parseColor(hexColor))) + view.setOnClickListener { + view.getActivityContext()?.openBrowser("https://patronite.pl/wykop-mobilny") + } shape.cornerRadius = 30f view.text = text if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { diff --git a/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/ui/modules/mainnavigation/MainNavigationActivity.kt b/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/ui/modules/mainnavigation/MainNavigationActivity.kt index 800cac7c5..9c7e41f60 100644 --- a/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/ui/modules/mainnavigation/MainNavigationActivity.kt +++ b/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/ui/modules/mainnavigation/MainNavigationActivity.kt @@ -1,13 +1,18 @@ package io.github.feelfreelinux.wykopmobilny.ui.modules.mainnavigation +import android.annotation.SuppressLint import android.app.ProgressDialog import android.content.Context import android.content.Intent import android.content.res.Configuration import android.os.Bundle import android.os.Handler +import android.text.SpannableString +import android.text.method.LinkMovementMethod +import android.text.util.Linkify import android.view.MenuItem import android.view.View +import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.widget.Toolbar @@ -17,6 +22,7 @@ import com.github.javiersantos.appupdater.AppUpdater import com.github.javiersantos.appupdater.enums.UpdateFrom import com.google.android.material.internal.NavigationMenuView import io.github.feelfreelinux.wykopmobilny.R +import io.github.feelfreelinux.wykopmobilny.api.patrons.PatronsApi import io.github.feelfreelinux.wykopmobilny.base.BaseActivity import io.github.feelfreelinux.wykopmobilny.base.BaseNavigationView import io.github.feelfreelinux.wykopmobilny.models.pojo.apiv2.WykopMobilnyUpdate @@ -46,11 +52,15 @@ import io.github.feelfreelinux.wykopmobilny.utils.preferences.BlacklistPreferenc import io.github.feelfreelinux.wykopmobilny.utils.preferences.SettingsPreferencesApi import io.github.feelfreelinux.wykopmobilny.utils.printout import io.github.feelfreelinux.wykopmobilny.utils.usermanager.UserManagerApi +import io.github.feelfreelinux.wykopmobilny.utils.wykop_link_handler.WykopLinkHandlerApi import kotlinx.android.synthetic.main.activity_navigation.* import kotlinx.android.synthetic.main.app_about_bottomsheet.view.* import kotlinx.android.synthetic.main.drawer_header_view_layout.view.* import kotlinx.android.synthetic.main.navigation_header.view.* +import kotlinx.android.synthetic.main.patron_list_item.view.* +import kotlinx.android.synthetic.main.patrons_bottomsheet.view.* import kotlinx.android.synthetic.main.toolbar.* +import java.net.URLDecoder import javax.inject.Inject interface MainNavigationInterface { @@ -78,7 +88,10 @@ class MainNavigationActivity : BaseActivity(), MainNavigationView, } } + @Inject lateinit var patronsApi: PatronsApi + @Inject lateinit var blacklistPreferencesApi: BlacklistPreferencesApi + @Inject lateinit var settingsPreferencesApi: SettingsPreferencesApi override val activityToolbar: Toolbar get() = toolbar var tapDoubleClickedMillis = 0L @@ -103,6 +116,7 @@ class MainNavigationActivity : BaseActivity(), MainNavigationView, @Inject lateinit var settingsApi: SettingsPreferencesApi @Inject lateinit var navigator: NewNavigatorApi @Inject lateinit var userManagerApi: UserManagerApi + @Inject lateinit var linkHandler: WykopLinkHandlerApi override fun onNavigationItemSelected(item: MenuItem): Boolean { when (item.itemId) { @@ -156,6 +170,7 @@ class MainNavigationActivity : BaseActivity(), MainNavigationView, return true } + @SuppressLint("RestrictedApi") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_navigation) @@ -174,10 +189,10 @@ class MainNavigationActivity : BaseActivity(), MainNavigationView, }, 333) JobUtil.hasBootPermission(this) - + showFullReleaseDialog() (navigationView.getChildAt(0) as NavigationMenuView).isVerticalScrollBarEnabled = false //Setup AppUpdater - AppUpdater(this) + /*AppUpdater(this) .setUpdateFrom(UpdateFrom.GITHUB) .setGitHubUserAndRepo("feelfreelinux", "WykopMobilny") .setTitleOnUpdateAvailable(R.string.update_available) @@ -185,7 +200,7 @@ class MainNavigationActivity : BaseActivity(), MainNavigationView, .setButtonDismiss(R.string.cancel) .setButtonDoNotShowAgain(R.string.do_not_show_again) .setButtonUpdate(R.string.update) - .start() + .start()*/ //presenter.checkUpdates() checkBlacklist() @@ -385,7 +400,41 @@ class MainNavigationActivity : BaseActivity(), MainNavigationView, dialog.dismiss() } + app_patrons.setOnClickListener { + dialog.dismiss() + val dialog2 = com.google.android.material.bottomsheet.BottomSheetDialog(context) + val badgesDialogView2 = layoutInflater.inflate(R.layout.patrons_bottomsheet, null) + dialog2.setContentView(badgesDialogView2) + + val headerItem = layoutInflater.inflate(R.layout.patron_list_item, null) + headerItem.setOnClickListener { + _ -> + dialog.dismiss() + linkHandler.handleUrl("https://patronite.pl/wykop-mobilny") + } + headerItem.nickname.text = context.getString(R.string.support_app) + headerItem.tierTextView.text = context.getString(R.string.became_patron) + badgesDialogView2.patronsList.addView(headerItem) + for (badge in patronsApi.patrons.filter { patron -> patron.listMention }) { + val item = layoutInflater.inflate(R.layout.patron_list_item, null) + item.setOnClickListener { + _ -> + dialog.dismiss() + linkHandler.handleUrl("https://wykop.pl/ludzie/" + badge.username) + } + item.nickname.text = badge.username + item.tierTextView.text = when (badge.tier) { + "patron50" -> "Patron próg \"Białkowy\"" + "patron25" -> "Patron próg \"Bordowy\"" + "patron10" -> "Patron próg \"Pomaranczowy\"" + "patron5" -> "Patron próg \"Zielony\"" + else -> "Patron" + } + badgesDialogView2.patronsList.addView(item) + } + dialog2.show() + } license.setOnClickListener { openBrowser("https://github.com/feelfreelinux/WykopMobilny/blob/master/LICENSE") @@ -404,6 +453,28 @@ class MainNavigationActivity : BaseActivity(), MainNavigationView, presenter.checkNotifications(true) } + + fun showFullReleaseDialog() { + if (!settingsPreferencesApi.dialogShown) { + val s = SpannableString("Po prawie dwóch latach pracy publikuję wersję 1.0 aplikacji. Jestem wdzięczny wszystkim osobom zaangażowanym w projekt. Aplikacja nadal pozostaje całkowicie darmowa i wolna od reklam. Jeżeli chcesz, możesz wesprzeć rozwój aplikacji na https://patronite.pl/wykop-mobilny \nDziękuję :)") + Linkify.addLinks(s, Linkify.WEB_URLS) + createAlertBuilder().apply { + setTitle("Wersja 1.0") + setMessage(s) + setPositiveButton(android.R.string.ok) { _, _ -> + settingsPreferencesApi.dialogShown = true + } + + val d = create() + d.setOnDismissListener { + settingsPreferencesApi.dialogShown = true + } + d.show() + d.findViewById(android.R.id.message)?.movementMethod = LinkMovementMethod.getInstance() + } + } + } + override fun checkUpdate(wykopMobilnyUpdate: WykopMobilnyUpdate) { val pInfo = this.packageManager.getPackageInfo(packageName, 0) val owmVersion = if (wykopMobilnyUpdate.tagName.contains("untagged")) wykopMobilnyUpdate.name else wykopMobilnyUpdate.tagName diff --git a/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/utils/preferences/SettingsPreferences.kt b/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/utils/preferences/SettingsPreferences.kt index f6b300e04..77a8570de 100644 --- a/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/utils/preferences/SettingsPreferences.kt +++ b/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/utils/preferences/SettingsPreferences.kt @@ -30,6 +30,7 @@ interface SettingsPreferencesApi { var useBuiltInBrowser: Boolean var groupNotifications: Boolean var disableExitConfirmation: Boolean + var dialogShown: Boolean } class SettingsPreferences(context: Context) : Preferences(context, true), SettingsPreferencesApi { @@ -60,5 +61,6 @@ class SettingsPreferences(context: Context) : Preferences(context, true), Settin override var useBuiltInBrowser by booleanPref(defaultValue = true) override var groupNotifications by booleanPref(defaultValue = true) override var disableExitConfirmation by booleanPref(defaultValue = false) + override var dialogShown by booleanPref(defaultValue = false) } \ No newline at end of file diff --git a/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/utils/textview/TextViewExtensions.kt b/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/utils/textview/TextViewExtensions.kt index 6de17c72f..c5404613e 100644 --- a/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/utils/textview/TextViewExtensions.kt +++ b/app/src/main/kotlin/io/github/feelfreelinux/wykopmobilny/utils/textview/TextViewExtensions.kt @@ -4,7 +4,9 @@ import android.text.ParcelableSpan import android.text.Spannable import android.text.SpannableString import android.text.SpannableStringBuilder +import android.text.method.LinkMovementMethod import android.text.style.ClickableSpan +import android.text.util.Linkify import android.widget.TextView import io.github.feelfreelinux.wykopmobilny.ui.dialogs.createAlertBuilder import io.github.feelfreelinux.wykopmobilny.utils.api.convertMarkdownToHtml @@ -32,11 +34,15 @@ fun TextView.prepareBody(html: String, urlClickListener: (String) -> Unit, click if (!shouldOpenSpoilerDialog) { openSpoilers(url.span(), url.text()) } else { + val s = SpannableString(URLDecoder.decode(url.text().substringAfter("spoiler:"), "UTF-8")) + Linkify.addLinks(s, Linkify.WEB_URLS) context.createAlertBuilder().apply { setTitle("Spoiler") - setMessage(URLDecoder.decode(url.text().substringAfter("spoiler:"), "UTF-8")) + setMessage(s) setPositiveButton(android.R.string.ok, null) - create().show() + val d = create() + d.show() + d.findViewById(android.R.id.message)?.movementMethod = LinkMovementMethod.getInstance() } } } else urlClickListener(url.text()) diff --git a/app/src/main/res/layout/app_about_bottomsheet.xml b/app/src/main/res/layout/app_about_bottomsheet.xml index 652963a1f..e82d62057 100644 --- a/app/src/main/res/layout/app_about_bottomsheet.xml +++ b/app/src/main/res/layout/app_about_bottomsheet.xml @@ -24,6 +24,7 @@ android:layout_height="@dimen/separator_line_height" android:background="?attr/lineColor"/> + @@ -37,6 +38,18 @@ + + + + + diff --git a/app/src/main/res/layout/author_header_layout.xml b/app/src/main/res/layout/author_header_layout.xml index 7a5a08833..e812ddfe3 100644 --- a/app/src/main/res/layout/author_header_layout.xml +++ b/app/src/main/res/layout/author_header_layout.xml @@ -49,7 +49,7 @@ android:textStyle="bold" app:layout_constraintStart_toEndOf="@id/userNameTextView" app:layout_constraintBottom_toBottomOf="@+id/userNameTextView" - app:layout_constraintTop_toTopOf="parent" + app:layout_constraintTop_toTopOf="@id/userNameTextView" tools:background="@drawable/patron_badge" tools:layout_editor_absoluteX="85dp" tools:text="PATRON" /> diff --git a/app/src/main/res/layout/comment_list_item.xml b/app/src/main/res/layout/comment_list_item.xml index 107e62532..cc7bd0529 100644 --- a/app/src/main/res/layout/comment_list_item.xml +++ b/app/src/main/res/layout/comment_list_item.xml @@ -24,12 +24,11 @@ android:id="@+id/patronBadgeTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/margin_dp_mini" - android:layout_marginRight="@dimen/margin_dp_mini" + android:layout_marginLeft="@dimen/margin_dp_tiny" + android:layout_marginRight="0dp" android:ellipsize="end" android:lines="1" android:paddingLeft="@dimen/margin_dp_mini" - android:visibility="gone" android:paddingRight="@dimen/margin_dp_mini" android:maxLines="1" android:textColor="@color/white" @@ -38,6 +37,7 @@ app:layout_constraintLeft_toRightOf="@id/authorTextView" app:layout_constraintRight_toLeftOf="@id/dotTextView" app:layout_constraintBottom_toBottomOf="@+id/authorTextView" + app:layout_constraintTop_toTopOf="@+id/authorTextView" tools:background="@drawable/patron_badge" tools:text="PATRON" /> + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/patrons_bottomsheet.xml b/app/src/main/res/layout/patrons_bottomsheet.xml new file mode 100644 index 000000000..70cdfbfda --- /dev/null +++ b/app/src/main/res/layout/patrons_bottomsheet.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 254a09f51..c97acc3f9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -218,5 +218,7 @@ Skopiowano do schowka Wpis Zrób zdjęcie aparatem + Wesprzyj rozwój aplikacji + Zostań patronem na patronite.pl \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ec5b220fa..543cfafcf 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -309,7 +309,7 @@ 0dp wrap_content @dimen/margin_dp_normal - @dimen/padding_dp_small + @dimen/padding_dp_small ?attr/textSizeSmall 1 1 @@ -332,7 +332,7 @@