@@ -29,10 +29,14 @@ import com.jlindemann.science.animations.Anim
2929import com.jlindemann.science.extensions.TableExtension
3030import com.jlindemann.science.model.Element
3131import com.jlindemann.science.model.ElementModel
32+ import com.jlindemann.science.model.HoverFilterMenu
33+ import com.jlindemann.science.model.HoverFilterMenuList
3234import com.jlindemann.science.preferences.ElectronegativityPreference
3335import com.jlindemann.science.preferences.ElementSendAndLoad
36+ import com.jlindemann.science.preferences.ProVersion
3437import com.jlindemann.science.preferences.SearchPreferences
3538import com.jlindemann.science.preferences.ThemePreference
39+ import com.jlindemann.science.preferences.hideNavPreference
3640import com.jlindemann.science.utils.TabUtil
3741import com.jlindemann.science.utils.Utils
3842import com.sothree.slidinguppanel.SlidingUpPanelLayout
@@ -85,19 +89,20 @@ class MainActivity : TableExtension(), ElementAdapter.OnElementClickListener2 {
8589 findViewById<SlidingUpPanelLayout >(R .id.sliding_layout).panelState = PanelState .COLLAPSED
8690 searchFilter(elements, recyclerView)
8791 mediaListeners()
88- hoverListeners(elements)
8992 initName(elements)
9093 findViewById<FloatingActionButton >(R .id.more_btn).setOnClickListener { openHover() }
9194 findViewById<TextView >(R .id.hover_background).setOnClickListener { closeHover() }
9295 findViewById<Button >(R .id.random_btn).setOnClickListener { getRandomItem() }
9396 findViewById<ConstraintLayout >(R .id.view_main).systemUiVisibility = View .SYSTEM_UI_FLAG_LAYOUT_STABLE or View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
9497
9598 // Check if PRO version and if make changes:
96- val proPref = ElectronegativityPreference (this )
99+ val proPref = ProVersion (this )
97100 var proPrefValue = proPref.getValue()
98101 if (proPrefValue== 100 ) {
99102 proChanges()
100103 }
104+ hoverListeners(elements, proPrefValue)
105+
101106
102107 val handler = android.os.Handler ()
103108 handler.postDelayed({
@@ -113,8 +118,8 @@ class MainActivity : TableExtension(), ElementAdapter.OnElementClickListener2 {
113118 mScale + = scale
114119 if (mScale < 1f )
115120 mScale = 1f
116- if (mScale > 12.5f )
117- mScale = 12.5f
121+ if (mScale > 1f ) // temp disabled, 12.5 default
122+ mScale = 1f
118123 val scaleAnimation = ScaleAnimation (
119124 1f / pScale,
120125 1f / mScale,
@@ -140,19 +145,28 @@ class MainActivity : TableExtension(), ElementAdapter.OnElementClickListener2 {
140145 return true
141146 }
142147 })
148+ val hideNavPref = hideNavPreference(this )
143149
144150 findViewById<TwoWayNestedScrollView >(R .id.scrollView).getViewTreeObserver()
145151 .addOnScrollChangedListener(object : OnScrollChangedListener {
146152 var y = 0f
147153 override fun onScrollChanged () {
148- if (findViewById<TwoWayNestedScrollView >(R .id.scrollView).getScrollY() > y) {
149- Utils .fadeOutAnim(findViewById<FrameLayout >(R .id.nav_bar_main), 150 )
150- Utils .fadeOutAnim(findViewById<FloatingActionButton >(R .id.more_btn), 150 )
151- } else {
152- Utils .fadeInAnim(findViewById<FrameLayout >(R .id.nav_bar_main), 150 )
153- Utils .fadeInAnim(findViewById<FloatingActionButton >(R .id.more_btn), 150 )
154+ val hideNavPrefValue = hideNavPref.getValue()
155+
156+ if (hideNavPrefValue == 1 ) {
157+ if (findViewById<TwoWayNestedScrollView >(R .id.scrollView).getScrollY() > y) {
158+ Utils .fadeOutAnim(findViewById<FrameLayout >(R .id.nav_bar_main), 150 )
159+ Utils .fadeOutAnim(
160+ findViewById<FloatingActionButton >(R .id.more_btn),
161+ 150
162+ )
163+ } else {
164+ Utils .fadeInAnim(findViewById<FrameLayout >(R .id.nav_bar_main), 150 )
165+ Utils .fadeInAnim(findViewById<FloatingActionButton >(R .id.more_btn), 150 )
166+ }
167+ y = findViewById<TwoWayNestedScrollView >(R .id.scrollView).getScrollY()
168+ .toFloat()
154169 }
155- y = findViewById<TwoWayNestedScrollView >(R .id.scrollView).getScrollY().toFloat()
156170 }
157171 })
158172
@@ -364,7 +378,7 @@ class MainActivity : TableExtension(), ElementAdapter.OnElementClickListener2 {
364378 }
365379 }
366380
367- private fun hoverListeners (elements : ArrayList <Element >) {
381+ private fun hoverListeners (elements : ArrayList <Element >, proValue : Int ) {
368382 findViewById<TextView >(R .id.h_name_btn).setOnClickListener { initName(elements) }
369383 findViewById<TextView >(R .id.h_group_btn).setOnClickListener { initGroups(elements) }
370384 findViewById<TextView >(R .id.h_electronegativity_btn).setOnClickListener { initElectro(elements) }
@@ -376,6 +390,33 @@ class MainActivity : TableExtension(), ElementAdapter.OnElementClickListener2 {
376390 findViewById<TextView >(R .id.h_fusion_btn).setOnClickListener { initHeat(elements) }
377391 findViewById<TextView >(R .id.h_specific_btn).setOnClickListener { initSpecific(elements) }
378392 findViewById<TextView >(R .id.h_vaporizaton_btn).setOnClickListener { initVape(elements) }
393+ findViewById<TextView >(R .id.h_electrical_type_btn).setOnClickListener { initTableChange(elements, " electrical_type" ) }
394+
395+ // Check if user has PRO version on not and give additional features if.
396+ findViewById<TextView >(R .id.h_poisson_ratio_btn).setOnClickListener {
397+ if (proValue == 1 ) {
398+ val intent = Intent (this , ProActivity ::class .java)
399+ startActivity(intent) }
400+ if (proValue == 100 ) { initTableChange(elements, " poisson_ratio" ) }
401+ }
402+ findViewById<TextView >(R .id.h_young_modulus_btn).setOnClickListener {
403+ if (proValue == 1 ) {
404+ val intent = Intent (this , ProActivity ::class .java)
405+ startActivity(intent) }
406+ if (proValue == 100 ) { initTableChange(elements, " young_modulus" ) }
407+ }
408+ findViewById<TextView >(R .id.h_bulk_modulus_btn).setOnClickListener {
409+ if (proValue == 1 ) {
410+ val intent = Intent (this , ProActivity ::class .java)
411+ startActivity(intent) }
412+ if (proValue == 100 ) { initTableChange(elements, " bulk_modulus" ) }
413+ }
414+ findViewById<TextView >(R .id.h_shear_modulus_btn).setOnClickListener {
415+ if (proValue == 1 ) {
416+ val intent = Intent (this , ProActivity ::class .java)
417+ startActivity(intent) }
418+ if (proValue == 100 ) { initTableChange(elements, " shear_modulus" ) }
419+ }
379420 }
380421
381422 private fun setupNavListeners () {
0 commit comments