diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7ef8c9cd..0864aea4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,119 +1,126 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ package="net.pokeranalytics.android">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/net/pokeranalytics/android/ui/activity/HomeActivity.kt b/app/src/main/java/net/pokeranalytics/android/ui/activity/HomeActivity.kt
index 719b8249..e0289090 100644
--- a/app/src/main/java/net/pokeranalytics/android/ui/activity/HomeActivity.kt
+++ b/app/src/main/java/net/pokeranalytics/android/ui/activity/HomeActivity.kt
@@ -14,7 +14,6 @@ import kotlinx.android.synthetic.main.activity_home.*
import net.pokeranalytics.android.BuildConfig
import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.realm.Currency
-import net.pokeranalytics.android.ui.activity.FiltersActivity
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity
import net.pokeranalytics.android.ui.adapter.HomePagerAdapter
import timber.log.Timber
diff --git a/app/src/main/java/net/pokeranalytics/android/ui/activity/NewDataMenuActivity.kt b/app/src/main/java/net/pokeranalytics/android/ui/activity/NewDataMenuActivity.kt
new file mode 100644
index 00000000..a5680189
--- /dev/null
+++ b/app/src/main/java/net/pokeranalytics/android/ui/activity/NewDataMenuActivity.kt
@@ -0,0 +1,120 @@
+package net.pokeranalytics.android.ui.activity
+
+import android.animation.Animator
+import android.animation.AnimatorListenerAdapter
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import android.view.View
+import android.view.ViewAnimationUtils
+import kotlinx.android.synthetic.main.activity_new_data.*
+import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity
+import net.pokeranalytics.android.ui.extensions.px
+
+
+class NewDataMenuActivity : PokerAnalyticsActivity() {
+
+ enum class IntentKey(val keyName: String) {
+ CHOICE("CHOICE"),
+ }
+
+ companion object {
+ fun newInstance(context: Context) {
+ val intent = Intent(context, NewDataMenuActivity::class.java)
+ context.startActivity(intent)
+ }
+ }
+
+ private val fabSize = 48.px
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(net.pokeranalytics.android.R.layout.activity_new_data)
+ initUI()
+ }
+
+ override fun onBackPressed() {
+ hideMenu()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ overridePendingTransition(0, 0)
+ }
+
+ /**
+ * Init UI
+ */
+ private fun initUI() {
+
+ overridePendingTransition(0, 0)
+
+ container.viewTreeObserver.addOnGlobalLayoutListener {
+ showMenu()
+ }
+
+ newCashGame.setOnClickListener {
+ finishWithResult(0)
+ }
+
+ newTournament.setOnClickListener {
+ finishWithResult(1)
+ }
+
+ newTransaction.setOnClickListener {
+ finishWithResult(2)
+ }
+
+ container.setOnClickListener {
+ hideMenu()
+ }
+ }
+
+ /**
+ * Set the result and hide menu
+ */
+ private fun finishWithResult(choice: Int) {
+ val intent = Intent()
+ intent.putExtra(IntentKey.CHOICE.keyName, choice)
+ setResult(RESULT_OK, intent)
+ hideMenu(true)
+ }
+
+ /**
+ * Show menu
+ */
+ private fun showMenu() {
+
+ val cx = menuContainer.measuredWidth - fabSize / 2
+ val cy = menuContainer.measuredHeight - fabSize / 2
+ val finalRadius = Math.max(menuContainer.width, menuContainer.height)
+ val anim = ViewAnimationUtils.createCircularReveal(menuContainer, cx, cy, 0f, finalRadius.toFloat())
+ anim.duration = 300
+
+ menuContainer.visibility = View.VISIBLE
+ anim.start()
+ }
+
+ /**
+ * Hide menu
+ */
+ private fun hideMenu(hideQuickly: Boolean = false) {
+
+ val cx = menuContainer.measuredWidth - fabSize / 2
+ val cy = menuContainer.measuredHeight - fabSize / 2
+ val initialRadius = menuContainer.width
+ val anim = ViewAnimationUtils.createCircularReveal(menuContainer, cx, cy, initialRadius.toFloat(), 0f)
+ anim.duration = if (hideQuickly) 150 else 300
+
+ anim.addListener(object : AnimatorListenerAdapter() {
+ override fun onAnimationEnd(animation: Animator?) {
+ super.onAnimationEnd(animation)
+ menuContainer.visibility = View.INVISIBLE
+ finish()
+ }
+ })
+
+ anim.start()
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/HistoryFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/HistoryFragment.kt
index 06319966..89563e44 100644
--- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/HistoryFragment.kt
+++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/HistoryFragment.kt
@@ -1,19 +1,22 @@
package net.pokeranalytics.android.ui.fragment
+import android.app.Activity.RESULT_OK
+import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
+import androidx.core.app.ActivityOptionsCompat
import androidx.core.view.isVisible
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
import io.realm.RealmResults
import io.realm.Sort
import io.realm.kotlin.where
import kotlinx.android.synthetic.main.fragment_history.*
-import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.interfaces.Editable
import net.pokeranalytics.android.model.realm.Session
+import net.pokeranalytics.android.ui.activity.NewDataMenuActivity
import net.pokeranalytics.android.ui.activity.SessionActivity
import net.pokeranalytics.android.ui.adapter.HistorySessionRowRepresentableAdapter
import net.pokeranalytics.android.ui.adapter.LiveRowRepresentableDataSource
@@ -25,9 +28,16 @@ import net.pokeranalytics.android.util.Preferences
import java.text.SimpleDateFormat
import java.util.*
+
+
+
+
class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource, RowRepresentableDelegate {
companion object {
+
+ const val REQUEST_CODE_MENU = 100
+
fun newInstance(): HistoryFragment {
val fragment = HistoryFragment()
val bundle = Bundle()
@@ -37,13 +47,14 @@ class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource
}
private lateinit var historyAdapter: HistorySessionRowRepresentableAdapter
-
private lateinit var realmSessions: RealmResults
+ private lateinit var betaLimitDate: Date
+
private val rows: ArrayList = ArrayList()
private var newSessionCreated: Boolean = false
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- return inflater.inflate(R.layout.fragment_history, container, false)
+ return inflater.inflate(net.pokeranalytics.android.R.layout.fragment_history, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -52,42 +63,48 @@ class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource
initData()
}
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+ super.onActivityResult(requestCode, resultCode, data)
+ if (requestCode == REQUEST_CODE_MENU && resultCode == RESULT_OK && data != null) {
+ when(data.getIntExtra(NewDataMenuActivity.IntentKey.CHOICE.keyName, -1)) {
+ 0 -> createNewSession(false)
+ 1 -> createNewSession(true)
+ 2 -> createNewTransaction()
+ }
+ }
+ }
+
override fun onDestroyView() {
super.onDestroyView()
realmSessions.removeAllChangeListeners()
}
- /**
- * Init UI
- */
- private fun initUI() {
-
- disclaimerContainer.isVisible = Preferences.shouldShowDisclaimer(requireContext())
-
- val sdf = SimpleDateFormat("dd/M/yyyy hh:mm")
- val betaLimitDate = sdf.parse("17/7/2019 10:00")
+ override fun rowRepresentableForPosition(position: Int): RowRepresentable? {
+ return this.rows[position]
+ }
- newCashGame.setOnClickListener {
+ override fun numberOfRows(): Int {
+ return this.rows.size
+ }
- if (Date().after(betaLimitDate)) {
- this.showEndOfBetaMessage()
- return@setOnClickListener
- }
+ override fun viewTypeForPosition(position: Int): Int {
+ return rows[position].viewType
+ }
- SessionActivity.newInstance(requireContext(), false)
- newSessionCreated = true
- }
+ override fun indexForRow(row: RowRepresentable): Int {
+ return this.rows.indexOf(row)
+ }
- newTournament.setOnClickListener {
+ override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) {
+ SessionActivity.newInstance(requireContext(), sessionId = (row as Editable).id)
+ }
- if (Date().after(betaLimitDate)) {
- this.showEndOfBetaMessage()
- return@setOnClickListener
- }
+ /**
+ * Init UI
+ */
+ private fun initUI() {
- SessionActivity.newInstance(requireContext(), true)
- newSessionCreated = true
- }
+ disclaimerContainer.isVisible = Preferences.shouldShowDisclaimer(requireContext())
disclaimerDismiss.setOnClickListener {
Preferences.setStopShowingDisclaimer(requireContext())
@@ -98,11 +115,13 @@ class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource
.start()
}
- }
-
- private fun showEndOfBetaMessage() {
- Toast.makeText(context, "Beta has ended. Please update with the Google Play version", Toast.LENGTH_LONG).show()
-
+ addButton.setOnClickListener {
+ activity?.let {
+ val options = ActivityOptionsCompat.makeSceneTransitionAnimation(it)
+ val intent = Intent(requireContext(), NewDataMenuActivity::class.java)
+ startActivityForResult(intent, REQUEST_CODE_MENU, options.toBundle())
+ }
+ }
}
/**
@@ -110,6 +129,9 @@ class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource
*/
private fun initData() {
+ val sdf = SimpleDateFormat("dd/M/yyyy hh:mm", Locale.getDefault())
+ betaLimitDate = sdf.parse("17/7/2019 10:00")
+
this.realmSessions = getRealm().where().findAll().sort("startDate", Sort.DESCENDING)
this.realmSessions.addChangeListener { _, _ ->
this.historyAdapter.refreshData()
@@ -130,23 +152,37 @@ class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource
}
}
- override fun rowRepresentableForPosition(position: Int): RowRepresentable? {
- return this.rows[position]
- }
+ /**
+ * Create a new cash game
+ */
+ private fun createNewSession(isTournament: Boolean) {
- override fun numberOfRows(): Int {
- return this.rows.size
- }
+ if (Date().after(betaLimitDate)) {
+ this.showEndOfBetaMessage()
+ return
+ }
- override fun viewTypeForPosition(position: Int): Int {
- return rows[position].viewType
+ SessionActivity.newInstance(requireContext(), isTournament)
+ newSessionCreated = true
}
- override fun indexForRow(row: RowRepresentable): Int {
- return this.rows.indexOf(row)
+ /**
+ * Create a new transaction
+ */
+ private fun createNewTransaction() {
+
+ if (Date().after(betaLimitDate)) {
+ this.showEndOfBetaMessage()
+ return
+ }
+
}
- override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) {
- SessionActivity.newInstance(requireContext(), sessionId = (row as Editable).id)
+ /**
+ * Show end of beta message
+ */
+ private fun showEndOfBetaMessage() {
+ Toast.makeText(context, "Beta has ended. Please update with the Google Play version", Toast.LENGTH_LONG).show()
}
+
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_new_data.xml b/app/src/main/res/layout/activity_new_data.xml
new file mode 100644
index 00000000..cc84d52f
--- /dev/null
+++ b/app/src/main/res/layout/activity_new_data.xml
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_history.xml b/app/src/main/res/layout/fragment_history.xml
index 6177771c..b9a5668a 100644
--- a/app/src/main/res/layout/fragment_history.xml
+++ b/app/src/main/res/layout/fragment_history.xml
@@ -7,38 +7,53 @@
android:layout_height="match_parent"
tools:context=".ui.activity.HomeActivity">
-
+ app:layout_constraintTop_toTopOf="parent">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@color/colorPrimary
- @color/white
- @color/white
+ - true
- @style/PokerAnalyticsTheme.BottomNavigationView
- @style/PokerAnalyticsTheme.Toolbar
@@ -23,6 +24,7 @@
+
@@ -241,6 +243,17 @@
+
+