Skip to content

Commit

Permalink
feat: Release 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Jan 25, 2019
1 parent 679e506 commit 94c727a
Show file tree
Hide file tree
Showing 14 changed files with 191 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -174,18 +189,18 @@ 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)
.setContentOnUpdateAvailable(R.string.update_app)
.setButtonDismiss(R.string.cancel)
.setButtonDoNotShowAgain(R.string.do_not_show_again)
.setButtonUpdate(R.string.update)
.start()
.start()*/
//presenter.checkUpdates()
checkBlacklist()

Expand Down Expand Up @@ -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")
Expand All @@ -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<TextView>(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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<TextView>(android.R.id.message)?.movementMethod = LinkMovementMethod.getInstance()
}
}
} else urlClickListener(url.text())
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res/layout/app_about_bottomsheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
android:layout_height="@dimen/separator_line_height"
android:background="?attr/lineColor"/>


<LinearLayout
android:id="@+id/app_version"
style="@style/BottomSheetMenuItem">
Expand All @@ -37,6 +38,18 @@

</LinearLayout>

<LinearLayout
android:id="@+id/app_patrons"
style="@style/BottomSheetMenuItem">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/app_patrons_textview"
android:layout_gravity="center"
android:text="Patroni"/>
</LinearLayout>

<LinearLayout
android:id="@+id/app_observe_tag"
style="@style/BottomSheetMenuItem">
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/author_header_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/comment_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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" />
<TextView
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/link_comment_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
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:maxLines="1"
android:paddingLeft="@dimen/margin_dp_mini"
android:paddingLeft="@dimen/margin_dp_tiny"
android:paddingRight="@dimen/margin_dp_mini"
android:textColor="@color/white"
android:textSize="?attr/textSizeTiny"
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/res/layout/patron_list_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<androidx.constraintlayout.widget.ConstraintLayout
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:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:addStatesFromChildren="true"
android:paddingRight="@dimen/bottomsheet_item_padding_horizontal"
android:paddingLeft="@dimen/bottomsheet_item_padding_horizontal"
android:paddingTop="@dimen/bottomsheet_item_padding_vertical"
android:paddingBottom="@dimen/bottomsheet_item_padding_vertical">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">

<TextView
android:id="@+id/nickname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
tools:text="feelfree"/>

<TextView
android:id="@+id/tierTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/authorHeader_date_color"
android:textSize="12sp"
tools:text="Patron próg Zielony"/>

</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
32 changes: 32 additions & 0 deletions app/src/main/res/layout/patrons_bottomsheet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

<LinearLayout

android:id="@+id/patronsList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/backgroundColor"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/bottomsheet_item_padding_vertical"
android:paddingLeft="@dimen/bottomsheet_item_padding_horizontal"
android:paddingRight="@dimen/bottomsheet_item_padding_horizontal"
android:paddingTop="@dimen/bottomsheet_item_padding_vertical"
android:text="Patroni"
android:textSize="@dimen/bottomsheet_item_title_text_size" />

<View
android:layout_width="match_parent"
android:layout_height="@dimen/separator_line_height"
android:background="?attr/lineColor" />

</LinearLayout>
</androidx.core.widget.NestedScrollView>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,7 @@
<string name="text_copied">Skopiowano do schowka</string>
<string name="entry">Wpis</string>
<string name="insert_photo_camera">Zrób zdjęcie aparatem</string>
<string name="support_app">Wesprzyj rozwój aplikacji</string>
<string name="became_patron">Zostań patronem na patronite.pl</string>

</resources>
Loading

0 comments on commit 94c727a

Please sign in to comment.