From 6c5028b4be274e07f71f520b011144da3552c054 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 11 Feb 2017 22:18:28 +0100 Subject: [PATCH] CPP dismiss info when focus is lost --- .../CircadianPercentageProfileFragment.java | 23 ++++++++++++++----- .../circadianpercentageprofile_fragment.xml | 2 +- app/src/main/res/values/strings.xml | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java index 6dbc27c2c5..0b31f360bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java @@ -43,6 +43,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfileFragment.class); private static CircadianPercentageProfilePlugin circadianPercentageProfilePlugin = new CircadianPercentageProfilePlugin(); + private Object snackbarCaller; public static CircadianPercentageProfilePlugin getPlugin() { return circadianPercentageProfilePlugin; @@ -68,6 +69,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag ImageView isfeditIcon; BasalEditDialog basalEditDialog; LinearLayout ll; + Snackbar mSnackBar; static Boolean percentageViewHint = true; static Boolean timeshiftViewHint = true; @@ -197,12 +199,15 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag @Override public void onFocusChange(View view, boolean hasFocus) { if (!hasFocus) { + if(mSnackBar!=null && snackbarCaller == timeshiftView){ + mSnackBar.dismiss(); + } timeshiftView.clearFocus(); ll.requestFocusFromTouch(); } else { if (timeshiftViewHint) { - customSnackbar(view, getString(R.string.timeshift_hint)); + customSnackbar(view, getString(R.string.timeshift_hint), timeshiftView); } } } @@ -213,12 +218,15 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag @Override public void onFocusChange(View view, boolean hasFocus) { if (!hasFocus) { + if(mSnackBar!=null && snackbarCaller == percentageView){ + mSnackBar.dismiss(); + } percentageView.clearFocus(); ll.requestFocusFromTouch(); } else { if (percentageViewHint) { - customSnackbar(view, getString(R.string.percentagefactor_hint)); + customSnackbar(view, getString(R.string.percentagefactor_hint), percentageView); } } } @@ -312,14 +320,17 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag return layout; } - private void customSnackbar(View view, final String Msg) { + private void customSnackbar(View view, final String Msg, Object snackbarCaller) { + if(mSnackBar!= null) mSnackBar.dismiss(); + + this.snackbarCaller = snackbarCaller; if (timeshiftViewHint || percentageViewHint) { - Snackbar mSnackBar = Snackbar.make(view, + mSnackBar = Snackbar.make(view, Msg, Snackbar.LENGTH_LONG) - .setDuration(7000) + .setDuration(Snackbar.LENGTH_LONG) .setActionTextColor(getResources().getColor(R.color.notificationInfo)) - .setAction(getString(R.string.dismiss), new View.OnClickListener() { + .setAction(getString(R.string.dont_show_again), new View.OnClickListener() { @Override public void onClick(View v) { if (Msg.equals(getString(R.string.percentagefactor_hint))) { diff --git a/app/src/main/res/layout/circadianpercentageprofile_fragment.xml b/app/src/main/res/layout/circadianpercentageprofile_fragment.xml index 99bf9f0235..347695c413 100644 --- a/app/src/main/res/layout/circadianpercentageprofile_fragment.xml +++ b/app/src/main/res/layout/circadianpercentageprofile_fragment.xml @@ -278,7 +278,7 @@ Remote calibration not allowed Calibration sent xDrip is not receiving calibrations + Don\'t show again