|
|
|
@ -1,7 +1,9 @@ |
|
|
|
package net.pokeranalytics.android.ui.activity |
|
|
|
package net.pokeranalytics.android.ui.activity |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.KeyguardManager |
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import android.content.Intent |
|
|
|
import android.content.Intent |
|
|
|
|
|
|
|
import android.os.Build |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.view.Menu |
|
|
|
import android.view.Menu |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.MenuItem |
|
|
|
@ -9,7 +11,7 @@ import androidx.appcompat.app.AlertDialog |
|
|
|
import com.google.android.material.bottomnavigation.BottomNavigationView |
|
|
|
import com.google.android.material.bottomnavigation.BottomNavigationView |
|
|
|
import io.realm.RealmResults |
|
|
|
import io.realm.RealmResults |
|
|
|
import kotlinx.android.synthetic.main.activity_home.* |
|
|
|
import kotlinx.android.synthetic.main.activity_home.* |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.BuildConfig |
|
|
|
import net.pokeranalytics.android.model.realm.Currency |
|
|
|
import net.pokeranalytics.android.model.realm.Currency |
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
import net.pokeranalytics.android.ui.adapter.HomePagerAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.HomePagerAdapter |
|
|
|
@ -44,19 +46,19 @@ class HomeActivity : PokerAnalyticsActivity() { |
|
|
|
displayFragment(2) |
|
|
|
displayFragment(2) |
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
R.id.navigation_history -> { |
|
|
|
net.pokeranalytics.android.R.id.navigation_history -> { |
|
|
|
displayFragment(0) |
|
|
|
displayFragment(0) |
|
|
|
} |
|
|
|
} |
|
|
|
R.id.navigation_stats -> { |
|
|
|
net.pokeranalytics.android.R.id.navigation_stats -> { |
|
|
|
displayFragment(1) |
|
|
|
displayFragment(1) |
|
|
|
} |
|
|
|
} |
|
|
|
R.id.navigation_calendar -> { |
|
|
|
net.pokeranalytics.android.R.id.navigation_calendar -> { |
|
|
|
displayFragment(2) |
|
|
|
displayFragment(2) |
|
|
|
} |
|
|
|
} |
|
|
|
R.id.navigation_reports -> { |
|
|
|
net.pokeranalytics.android.R.id.navigation_reports -> { |
|
|
|
displayFragment(3) |
|
|
|
displayFragment(3) |
|
|
|
} |
|
|
|
} |
|
|
|
R.id.navigation_more -> { |
|
|
|
net.pokeranalytics.android.R.id.navigation_more -> { |
|
|
|
displayFragment(4) |
|
|
|
displayFragment(4) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -65,7 +67,17 @@ class HomeActivity : PokerAnalyticsActivity() { |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
setContentView(R.layout.activity_home) |
|
|
|
|
|
|
|
|
|
|
|
if (BuildConfig.DEBUG) { |
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { |
|
|
|
|
|
|
|
setShowWhenLocked(true) |
|
|
|
|
|
|
|
setTurnScreenOn(true) |
|
|
|
|
|
|
|
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager |
|
|
|
|
|
|
|
keyguardManager.requestDismissKeyguard(this, null) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setContentView(net.pokeranalytics.android.R.layout.activity_home) |
|
|
|
|
|
|
|
|
|
|
|
observeRealmObjects() |
|
|
|
observeRealmObjects() |
|
|
|
initUI() |
|
|
|
initUI() |
|
|
|
@ -74,16 +86,16 @@ class HomeActivity : PokerAnalyticsActivity() { |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean { |
|
|
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean { |
|
|
|
menu?.clear() |
|
|
|
menu?.clear() |
|
|
|
menuInflater.inflate(R.menu.toolbar_home, menu) |
|
|
|
menuInflater.inflate(net.pokeranalytics.android.R.menu.toolbar_home, menu) |
|
|
|
this.homeMenu = menu |
|
|
|
this.homeMenu = menu |
|
|
|
//TODO: Change queryWith button visibility |
|
|
|
//TODO: Change queryWith button visibility |
|
|
|
homeMenu?.findItem(R.id.filter)?.isVisible = true |
|
|
|
homeMenu?.findItem(net.pokeranalytics.android.R.id.filter)?.isVisible = true |
|
|
|
return super.onCreateOptionsMenu(menu) |
|
|
|
return super.onCreateOptionsMenu(menu) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem?): Boolean { |
|
|
|
override fun onOptionsItemSelected(item: MenuItem?): Boolean { |
|
|
|
when (item?.itemId) { |
|
|
|
when (item?.itemId) { |
|
|
|
R.id.filter -> manageFilters() |
|
|
|
net.pokeranalytics.android.R.id.filter -> manageFilters() |
|
|
|
} |
|
|
|
} |
|
|
|
return super.onOptionsItemSelected(item) |
|
|
|
return super.onOptionsItemSelected(item) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -113,7 +125,7 @@ class HomeActivity : PokerAnalyticsActivity() { |
|
|
|
setSupportActionBar(toolbar) |
|
|
|
setSupportActionBar(toolbar) |
|
|
|
|
|
|
|
|
|
|
|
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener) |
|
|
|
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener) |
|
|
|
navigation.selectedItemId = R.id.navigation_history |
|
|
|
navigation.selectedItemId = net.pokeranalytics.android.R.id.navigation_history |
|
|
|
|
|
|
|
|
|
|
|
val homePagerAdapter = HomePagerAdapter(supportFragmentManager) |
|
|
|
val homePagerAdapter = HomePagerAdapter(supportFragmentManager) |
|
|
|
viewPager.offscreenPageLimit = 5 |
|
|
|
viewPager.offscreenPageLimit = 5 |
|
|
|
@ -167,24 +179,24 @@ class HomeActivity : PokerAnalyticsActivity() { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
0 -> { |
|
|
|
0 -> { |
|
|
|
toolbar.title = getString(R.string.feed) |
|
|
|
toolbar.title = getString(net.pokeranalytics.android.R.string.feed) |
|
|
|
homeMenu?.findItem(R.id.filter)?.isVisible = true |
|
|
|
homeMenu?.findItem(net.pokeranalytics.android.R.id.filter)?.isVisible = true |
|
|
|
} |
|
|
|
} |
|
|
|
1 -> { |
|
|
|
1 -> { |
|
|
|
toolbar.title = getString(R.string.stats) |
|
|
|
toolbar.title = getString(net.pokeranalytics.android.R.string.stats) |
|
|
|
homeMenu?.findItem(R.id.filter)?.isVisible = true |
|
|
|
homeMenu?.findItem(net.pokeranalytics.android.R.id.filter)?.isVisible = true |
|
|
|
} |
|
|
|
} |
|
|
|
2 -> { |
|
|
|
2 -> { |
|
|
|
toolbar.title = getString(R.string.calendar) |
|
|
|
toolbar.title = getString(net.pokeranalytics.android.R.string.calendar) |
|
|
|
homeMenu?.findItem(R.id.filter)?.isVisible = false |
|
|
|
homeMenu?.findItem(net.pokeranalytics.android.R.id.filter)?.isVisible = false |
|
|
|
} |
|
|
|
} |
|
|
|
3 -> { |
|
|
|
3 -> { |
|
|
|
toolbar.title = getString(R.string.reports) |
|
|
|
toolbar.title = getString(net.pokeranalytics.android.R.string.reports) |
|
|
|
homeMenu?.findItem(R.id.filter)?.isVisible = false |
|
|
|
homeMenu?.findItem(net.pokeranalytics.android.R.id.filter)?.isVisible = false |
|
|
|
} |
|
|
|
} |
|
|
|
4 -> { |
|
|
|
4 -> { |
|
|
|
toolbar.title = getString(R.string.more) |
|
|
|
toolbar.title = getString(net.pokeranalytics.android.R.string.more) |
|
|
|
homeMenu?.findItem(R.id.filter)?.isVisible = false |
|
|
|
homeMenu?.findItem(net.pokeranalytics.android.R.id.filter)?.isVisible = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -197,16 +209,16 @@ class HomeActivity : PokerAnalyticsActivity() { |
|
|
|
val filterSelected = false |
|
|
|
val filterSelected = false |
|
|
|
|
|
|
|
|
|
|
|
val choices = ArrayList<CharSequence>() |
|
|
|
val choices = ArrayList<CharSequence>() |
|
|
|
choices.add(getString(R.string.new_str)) |
|
|
|
choices.add(getString(net.pokeranalytics.android.R.string.new_str)) |
|
|
|
|
|
|
|
|
|
|
|
if (filterSelected) { |
|
|
|
if (filterSelected) { |
|
|
|
choices.add(getString(R.string.modify_current_filter)) |
|
|
|
choices.add(getString(net.pokeranalytics.android.R.string.modify_current_filter)) |
|
|
|
choices.add(getString(R.string.load_from_db)) |
|
|
|
choices.add(getString(net.pokeranalytics.android.R.string.load_from_db)) |
|
|
|
choices.add(getString(R.string.remove_filter)) |
|
|
|
choices.add(getString(net.pokeranalytics.android.R.string.remove_filter)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val builder = AlertDialog.Builder(this) |
|
|
|
val builder = AlertDialog.Builder(this) |
|
|
|
builder.setTitle(R.string.filter_selection) |
|
|
|
builder.setTitle(net.pokeranalytics.android.R.string.filter_selection) |
|
|
|
.setCancelable(true) |
|
|
|
.setCancelable(true) |
|
|
|
.setItems(choices.toTypedArray()) { _, which -> |
|
|
|
.setItems(choices.toTypedArray()) { _, which -> |
|
|
|
Timber.d("Click on $which") |
|
|
|
Timber.d("Click on $which") |
|
|
|
@ -214,7 +226,7 @@ class HomeActivity : PokerAnalyticsActivity() { |
|
|
|
0 -> FiltersActivity.newInstance(this@HomeActivity) |
|
|
|
0 -> FiltersActivity.newInstance(this@HomeActivity) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.setNegativeButton(R.string.cancel) { _, _ -> |
|
|
|
.setNegativeButton(net.pokeranalytics.android.R.string.cancel) { _, _ -> |
|
|
|
Timber.d("Click on cancel") |
|
|
|
Timber.d("Click on cancel") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|