Skip to content

Commit

Permalink
Disable bottom nav menu items on click
Browse files Browse the repository at this point in the history
- Closes #301
  • Loading branch information
ndegwamartin committed Jun 16, 2022
1 parent 20f219e commit 1cde313
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.8.1-ALPHA9-SNAPSHOT
VERSION_NAME=0.8.6-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Child Library
Expand Down
2 changes: 1 addition & 1 deletion opensrp-child/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-v4'
}

api('org.smartregister:opensrp-client-native-form:2.1.15-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-native-form:2.1.16-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.google.android.gms.vision.barcode.Barcode;
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.domain.Form;

import org.json.JSONObject;
import org.smartregister.AllConstants;
Expand All @@ -27,6 +26,7 @@
import org.smartregister.child.util.ChildJsonFormUtils;
import org.smartregister.child.util.Constants;
import org.smartregister.child.util.Utils;
import org.smartregister.client.utils.domain.Form;
import org.smartregister.helper.BottomNavigationHelper;
import org.smartregister.view.activity.BaseRegisterActivity;

Expand All @@ -46,6 +46,7 @@ public abstract class BaseChildRegisterActivity extends BaseRegisterActivity imp

protected boolean isAdvancedSearch = false;
protected HashMap<String, String> advancedSearchFormData = new HashMap<>();
private int disabledMenuId;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -205,6 +206,9 @@ public void onResume() {
}

protected void onChildRegisterResumption() {

reEnableMenuItem();

if (isAdvancedSearch) {
refreshAdvancedSearchFormValues();
switchToAdvancedSearchFromRegister();
Expand All @@ -214,6 +218,11 @@ protected void onChildRegisterResumption() {
}
}

private void reEnableMenuItem() {
if (disabledMenuId != 0)
bottomNavigationView.getMenu().findItem(disabledMenuId).setEnabled(true);
}

protected void refreshAdvancedSearchFormValues() {
setFormData(this.advancedSearchFormData);
((BaseAdvancedSearchFragment) findFragmentByPosition(ADVANCED_SEARCH_POSITION)).assignedValuesBeforeBarcode();
Expand Down Expand Up @@ -289,4 +298,9 @@ public void saveForm(String jsonString, UpdateRegisterParams updateRegisterParam
public void dissmissProgressDialog() {
hideProgressDialog();
}

@Override
public void setActiveMenuItem(int menuItemId) {
disabledMenuId = menuItemId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public interface ChildRegisterContract {

interface View extends BaseRegisterContract.View {
ChildRegisterContract.Presenter presenter();

void setActiveMenuItem(int menuItemId);
}

interface Presenter extends BaseRegisterContract.Presenter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public void run() {
// For overdue count
// FIXME: Count generated on first sync is not correct
String sqlOverdueCount = Utils.metadata().getRegisterQueryProvider()
.getCountExecuteQuery(filterSelectionCondition(true),"");
.getCountExecuteQuery(filterSelectionCondition(true), "");
Timber.i(sqlOverdueCount);
overDueCount = commonRepository().countSearchIds(sqlOverdueCount);
Timber.i("Total Overdue Count %d ", overDueCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public ChildBottomNavigationListener(BaseChildRegisterActivity context) {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {

item.setEnabled(false);//Disable menu item
if (item.getItemId() == R.id.action_home) {
getBaseRegisterActivityReference().switchToBaseFragment();
} else if (item.getItemId() == R.id.action_scan_qr) {
getBaseRegisterActivityReference().startQrCodeScanner();
} else if (item.getItemId() == R.id.action_search) {
getBaseRegisterActivityReference().switchToFragment(1);
item.setEnabled(true);//Fragment switch - reset immediately
} else if (item.getItemId() == R.id.action_register) {
getBaseRegisterActivityReference().startRegistration();
}
if (this.baseRegisterActivity.get() != null)
this.baseRegisterActivity.get().setActiveMenuItem(item.getItemId());

return true;
}
Expand Down

0 comments on commit 1cde313

Please sign in to comment.