Add message to duplicate

csv
Laurent 6 years ago
parent 05afd66d73
commit 3bde851bd5
  1. 9
      app/src/main/java/net/pokeranalytics/android/ui/adapter/FeedSessionRowRepresentableAdapter.kt
  2. 17
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FeedFragment.kt
  3. 49
      app/src/main/java/net/pokeranalytics/android/util/Preferences.kt
  4. 6
      app/src/main/res/layout/fragment_feed.xml
  5. 2
      app/src/main/res/values-fr/strings.xml
  6. 4
      app/src/main/res/values/strings.xml

@ -77,14 +77,13 @@ class FeedSessionRowRepresentableAdapter(
val layout = LayoutInflater.from(parent.context).inflate(net.pokeranalytics.android.R.layout.row_header_title, parent, false)
HeaderTitleViewHolder(layout)
}
}
override fun getItemViewType(position: Int): Int {
if (sortedHeaders.containsKey(position)) {
return RowViewType.HEADER_TITLE.ordinal
return if (sortedHeaders.containsKey(position)) {
RowViewType.HEADER_TITLE.ordinal
} else {
return RowViewType.ROW_SESSION.ordinal
RowViewType.ROW_SESSION.ordinal
}
}
@ -187,8 +186,6 @@ class FeedSessionRowRepresentableAdapter(
*/
private fun checkHeaderCondition(currentCalendar: Calendar, previousYear: Int, previousMonth: Int) : Boolean {
return currentCalendar.get(Calendar.YEAR) == previousYear && currentCalendar.get(Calendar.MONTH) < previousMonth || (currentCalendar.get(Calendar.YEAR) < previousYear)
}
}

@ -191,16 +191,23 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
registerForContextMenu(this.recyclerView)
disclaimerContainer.isVisible = Preferences.shouldShowDisclaimer(requireContext())
val messageToShow: Preferences.FeedMessage? = Preferences.feedMessageToShow(requireContext())
disclaimerDismiss.setOnClickListener {
Preferences.setStopShowingDisclaimer(requireContext())
if (messageToShow != null) {
messageBox.isVisible = true
message.text = getString(messageToShow.resId)
disclaimerContainer.animate().translationY(disclaimerContainer.height.toFloat())
messageBoxDismiss.setOnClickListener {
Preferences.setStopShowingMessage(messageToShow, requireContext())
messageBox.animate().translationY(messageBox.height.toFloat())
.setInterpolator(FastOutSlowInInterpolator())
.withEndAction { disclaimerContainer?.isVisible = false }
.withEndAction { messageBox?.isVisible = false }
.start()
}
} else {
messageBox.isVisible = false
}
addButton.setOnClickListener {
activity?.let {

@ -2,6 +2,10 @@ package net.pokeranalytics.android.util
import android.content.Context
import android.preference.PreferenceManager
import io.realm.Realm
import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.util.extensions.count
import java.util.*
class Preferences {
@ -24,6 +28,7 @@ class Preferences {
LOCALE_CODE("LocaleCode"),
FIRST_LAUNCH("firstLaunch"),
STOP_SHOWING_DISCLAIMER("stopShowingDisclaimer"),
STOP_SHOWING_DUPLICATE("stopShowingDuplicate"),
ACTIVE_FILTER_ID("ActiveFilterId"),
LATEST_PURCHASE("latestPurchase"),
PATCH_BREAK("patchBreaks"),
@ -31,6 +36,28 @@ class Preferences {
PATCH_BLINDS_FORMAT("patchBlindFormat")
}
enum class FeedMessage {
DISCLAIMER,
DUPLICATE;
val resId: Int
get() {
return when (this) {
DISCLAIMER -> R.string.disclaimer
DUPLICATE -> R.string.longtap_to_duplicate
}
}
val key: Keys
get() {
return when (this) {
DISCLAIMER -> Keys.STOP_SHOWING_DISCLAIMER
DUPLICATE -> Keys.STOP_SHOWING_DUPLICATE
}
}
}
companion object {
fun setString(key: PreferenceKey, value: String, context: Context) {
@ -103,12 +130,23 @@ class Preferences {
return null
}
fun setStopShowingDisclaimer(context: Context) {
setBoolean(Keys.STOP_SHOWING_DISCLAIMER, true, context)
fun setStopShowingMessage(message: FeedMessage, context: Context) {
setBoolean(message.key,true, context)
}
fun feedMessageToShow(context: Context): FeedMessage? {
if (!getBoolean(Keys.STOP_SHOWING_DISCLAIMER, context)) {
return FeedMessage.DISCLAIMER
}
fun shouldShowDisclaimer(context: Context) : Boolean {
return !getBoolean(Keys.STOP_SHOWING_DISCLAIMER, context)
val realm = Realm.getDefaultInstance()
val sessionCount = realm.count(Session::class.java)
realm.close()
if (sessionCount in 2..10 && !getBoolean(Keys.STOP_SHOWING_DUPLICATE, context)) {
return FeedMessage.DUPLICATE
}
return null
}
fun executeOnce(key: Keys, context: Context, executable: () -> Unit) {
@ -167,7 +205,8 @@ class UserDefaults private constructor(context: Context) {
open class SingletonHolder<out T, in A>(creator: (A) -> T) {
private var creator: ((A) -> T)? = creator
@Volatile private var instance: T? = null
@Volatile
private var instance: T? = null
fun init(context: A): T {
val i = instance

@ -103,7 +103,7 @@
app:layout_constraintEnd_toEndOf="parent" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/disclaimerContainer"
android:id="@+id/messageBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/green_darker"
@ -115,18 +115,18 @@
app:layout_constraintStart_toStartOf="parent">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/disclaimer"
android:textSize="18sp"
android:textColor="@color/white"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/disclaimerDismiss"
android:id="@+id/messageBoxDismiss"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"

@ -60,7 +60,7 @@
<string name="tournament_names">Noms de tournoi</string>
<string name="tournament_features">Propriétés de tournoi</string>
<string name="pending">En attente</string>
<string name="disclaimer">Poker Analytics est un tracker de sessions. Il s\'agit pour l\'instant d\'une version allégée de la version iOS existante. Nous allons ajouter les fonctionnalités au fur et à mesure. L\'app fonctionnera avec un abonnement illimité de 29,99€ par an, mais nous la proposons gratuitement en attendant plus de fonctionnalités</string>
<string name="disclaimer">Poker Analytics est un tracker de sessions. L\'app fonctionne avec un abonnement illimité annuel, mais vous disposez de 10 sessions + un essai limité dans le temps pour la tester.</string>
<string name="iunderstand">C\'est compris !</string>
<string name="tournament_feature_empty_field_error">La propriété doit avoir un nom</string>
<string name="duplicate_tournament_feature_error">Une propriété utilise déjà ce nom</string>

@ -50,7 +50,7 @@
<string name="tournament_feature">Tournament feature</string>
<string name="tournament_features">Tournament features</string>
<string name="pending">Pending</string>
<string name="disclaimer">Poker Analytics is a poker tracking app. We’re currently on our way to reproduce the iOS app and you’re currently using a lighter version. The app will work with a US$29.99 yearly subscription for an unlimited usage, but will be free until reaching the appropriate feature coverage.</string>
<string name="disclaimer">Poker Analytics is a poker tracking app.\nThe app works with a yearly subscription for an unlimited usage, but you get 10 sessions + a free trial to test the app.</string>
<string name="iunderstand">I understand</string>
<string name="tournament_feature_empty_field_error">You need to give a name to this tournament feature</string>
<string name="duplicate_tournament_feature_error">A tournament feature with the same name already exists.</string>
@ -660,7 +660,7 @@
<string name="subscription_text">Subscription terms of use:\n• Payment will be charged to iTunes Account at confirmation of purchase\n• Subscription automatically renews unless auto-renew is turned off at least 24-hours before the end of the current period\n• Account will be charged for renewal within 24-hours prior to the end of the current period, and identify the cost of the renewal\n• Subscriptions may be managed by the user and auto-renewal may be turned off by going to the user\'s Account Settings after purchase\n• Any unused portion of a free trial period, if offered, will be forfeited when the user purchases a subscription to that publication, where applicable</string>
<string name="privacy_policy">Privacy policy</string>
<string name="bug_report_message">We\'re truly sorry, but something is wrong here&#8230;You may be waiting for iCloud sync. Please wait and retry later. Would you mind sending us a report explaining your current state to help us solve this issue?</string>
<string name="longtap_to_duplicate">Tap and hold on a session to duplicate it.</string>
<string name="longtap_to_duplicate">Tap and hold on a session to duplicate it!</string>
<string name="change_statistic">Change statistic</string>
<string name="compare">Compare</string>
<string name="gross_amount">Gross Amount</string>

Loading…
Cancel
Save