Skip to content

Commit

Permalink
Fix Back button issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Barashkov committed Jun 5, 2020
1 parent 3f4b6d0 commit 38d9d4a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ android {
applicationId "com.handydev.financier"
minSdkVersion 21
targetSdkVersion 29
versionCode 208
versionName "2.0.8"
versionCode 209
versionName "2.0.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions {
Expand Down
18 changes: 11 additions & 7 deletions app/src/fdroid/java/com/handydev/financier/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ class MainActivity : FragmentActivity() {
val tabPager = findViewById<ViewPager2>(R.id.mainViewPager)
if(tabPager != null) {
val fragment = supportFragmentManager.findFragmentByTag("f" + tabPager.currentItem)
(fragment as? IOnBackPressed)?.onBackPressed()?.not()?.let {
var handled = false
if(fragment is IOnBackPressed) {
handled = fragment.onBackPressed()
}
if(!handled) {
super.onBackPressed()
}
} else {
Expand Down Expand Up @@ -128,12 +132,12 @@ class MainActivity : FragmentActivity() {
}

fun refreshCurrentTab() {
/*val currentActivity: Activity = getLocalActivityManager().getCurrentActivity()
if (currentActivity is RefreshSupportedActivity) {
val activity = currentActivity as RefreshSupportedActivity
activity.recreateCursor()
activity.integrityCheck()
}*/
for(fragment in supportFragmentManager.fragments) {
if(fragment.isVisible && fragment is RefreshSupportedActivity) {
fragment.recreateCursor()
fragment.integrityCheck()
}
}
}

private fun initialLoad() {
Expand Down
19 changes: 12 additions & 7 deletions app/src/googleplay/java/com/handydev/financier/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.api.Scope
import com.google.api.services.drive.DriveScopes
import com.handydev.financier.activity.PreferencesActivity.CHOOSE_ACCOUNT
import com.handydev.financier.activity.RefreshSupportedActivity
import com.handydev.financier.app.FinancierApp
import com.handydev.financier.base.AbstractListFragment
import com.handydev.financier.bus.RefreshData
Expand Down Expand Up @@ -72,7 +73,11 @@ class MainActivity : FragmentActivity() {
val tabPager = findViewById<ViewPager2>(R.id.mainViewPager)
if(tabPager != null) {
val fragment = supportFragmentManager.findFragmentByTag("f" + tabPager.currentItem)
(fragment as? IOnBackPressed)?.onBackPressed()?.not()?.let {
var handled = false
if(fragment is IOnBackPressed) {
handled = fragment.onBackPressed()
}
if(!handled) {
super.onBackPressed()
}
} else {
Expand Down Expand Up @@ -131,12 +136,12 @@ class MainActivity : FragmentActivity() {
}

fun refreshCurrentTab() {
/*val currentActivity: Activity = getLocalActivityManager().getCurrentActivity()
if (currentActivity is RefreshSupportedActivity) {
val activity = currentActivity as RefreshSupportedActivity
activity.recreateCursor()
activity.integrityCheck()
}*/
for(fragment in supportFragmentManager.fragments) {
if(fragment.isVisible && fragment is RefreshSupportedActivity) {
fragment.recreateCursor()
fragment.integrityCheck()
}
}
}

private fun initialLoad() {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/assets/whatsnew.htm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
</head>
<body>

<p><b>2.0.9</b></p>
<p>
[*] Fixed back button issues.<br/>
[*] Fixed accounts list info refresh.<br/>
</p>

<p><b>2.0.8</b></p>
<p>
[*] Fixed refresh of main menu blotter list.<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ open class AccountsFragment: AbstractListFragment(R.layout.account_list) {
integrityCheck()
}

override fun onResume() {
super.onResume()
recreateCursor()
}

private fun setupUi() {
view?.findViewById<View>(R.id.integrity_error)?.setOnClickListener { v: View -> v.visibility = View.GONE }
listView.onItemLongClickListener = AdapterView.OnItemLongClickListener { _, view, _, id ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,9 @@ open class BlotterFragment: AbstractListFragment(R.layout.blotter), IOTransactio
val searchLayout = view?.findViewById<FrameLayout>(R.id.search_text_frame)
return if (searchLayout != null && searchLayout.visibility == View.VISIBLE) {
searchLayout.visibility = View.GONE
false
} else {
true
} else {
false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.os.Bundle;
import android.os.Vibrator;
import androidx.core.content.ContextCompat;

import android.view.View;
import android.view.Window;
import android.widget.Button;
Expand Down

0 comments on commit 38d9d4a

Please sign in to comment.