CPP dismiss info when focus is lost

This commit is contained in:
AdrianLxM 2017-02-11 22:18:28 +01:00
parent e4c529fa1f
commit 1f5dd4750a
3 changed files with 19 additions and 7 deletions

View file

@ -43,6 +43,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfileFragment.class); private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfileFragment.class);
private static CircadianPercentageProfilePlugin circadianPercentageProfilePlugin = new CircadianPercentageProfilePlugin(); private static CircadianPercentageProfilePlugin circadianPercentageProfilePlugin = new CircadianPercentageProfilePlugin();
private Object snackbarCaller;
public static CircadianPercentageProfilePlugin getPlugin() { public static CircadianPercentageProfilePlugin getPlugin() {
return circadianPercentageProfilePlugin; return circadianPercentageProfilePlugin;
@ -68,6 +69,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
ImageView isfeditIcon; ImageView isfeditIcon;
BasalEditDialog basalEditDialog; BasalEditDialog basalEditDialog;
LinearLayout ll; LinearLayout ll;
Snackbar mSnackBar;
static Boolean percentageViewHint = true; static Boolean percentageViewHint = true;
static Boolean timeshiftViewHint = true; static Boolean timeshiftViewHint = true;
@ -197,12 +199,15 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
@Override @Override
public void onFocusChange(View view, boolean hasFocus) { public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) { if (!hasFocus) {
if(mSnackBar!=null && snackbarCaller == timeshiftView){
mSnackBar.dismiss();
}
timeshiftView.clearFocus(); timeshiftView.clearFocus();
ll.requestFocusFromTouch(); ll.requestFocusFromTouch();
} }
else { else {
if (timeshiftViewHint) { 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 @Override
public void onFocusChange(View view, boolean hasFocus) { public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) { if (!hasFocus) {
if(mSnackBar!=null && snackbarCaller == percentageView){
mSnackBar.dismiss();
}
percentageView.clearFocus(); percentageView.clearFocus();
ll.requestFocusFromTouch(); ll.requestFocusFromTouch();
} }
else { else {
if (percentageViewHint) { 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; 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) { if (timeshiftViewHint || percentageViewHint) {
Snackbar mSnackBar = Snackbar.make(view, mSnackBar = Snackbar.make(view,
Msg, Msg,
Snackbar.LENGTH_LONG) Snackbar.LENGTH_LONG)
.setDuration(7000) .setDuration(Snackbar.LENGTH_LONG)
.setActionTextColor(getResources().getColor(R.color.notificationInfo)) .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 @Override
public void onClick(View v) { public void onClick(View v) {
if (Msg.equals(getString(R.string.percentagefactor_hint))) { if (Msg.equals(getString(R.string.percentagefactor_hint))) {

View file

@ -278,7 +278,7 @@
<com.andreabaccega.widget.FormEditText <com.andreabaccega.widget.FormEditText
validate:testType="floatNumericRange" validate:testType="floatNumericRange"
validate:floatminNumber="5.0" validate:floatminNumber="4.0"
validate:floatmaxNumber="180.0" validate:floatmaxNumber="180.0"
android:digits="0123456789.," android:digits="0123456789.,"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"

View file

@ -488,4 +488,5 @@
<string name="smscommunicator_remotecalibrationnotallowed">Remote calibration not allowed</string> <string name="smscommunicator_remotecalibrationnotallowed">Remote calibration not allowed</string>
<string name="smscommunicator_calibrationsent">Calibration sent</string> <string name="smscommunicator_calibrationsent">Calibration sent</string>
<string name="smscommunicator_calibrationfailed">xDrip is not receiving calibrations</string> <string name="smscommunicator_calibrationfailed">xDrip is not receiving calibrations</string>
<string name="dont_show_again">Don\'t show again</string>
</resources> </resources>