use validation lib in cpp - layout fixes & longer snackbar duration

This commit is contained in:
viktoria 2017-02-12 19:51:56 +01:00
parent e5e5eca37f
commit 0d02f42714
2 changed files with 22 additions and 22 deletions

View file

@ -7,6 +7,7 @@ import android.os.Bundle;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.text.Editable; import android.text.Editable;
import android.text.Html; import android.text.Html;
import android.text.TextWatcher; import android.text.TextWatcher;
@ -68,7 +69,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
ImageView iceditIcon; ImageView iceditIcon;
ImageView isfeditIcon; ImageView isfeditIcon;
BasalEditDialog basalEditDialog; BasalEditDialog basalEditDialog;
LinearLayout ll; FrameLayout fl;
Snackbar mSnackBar; Snackbar mSnackBar;
static Boolean percentageViewHint = true; static Boolean percentageViewHint = true;
@ -78,8 +79,8 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.circadianpercentageprofile_fragment, container, false); View layout = inflater.inflate(R.layout.circadianpercentageprofile_fragment, container, false);
ll = (LinearLayout) layout.findViewById(R.id.circadianpercentageprofile_linearlayout); fl = (FrameLayout) layout.findViewById(R.id.circadianpercentageprofile_framelayout);
ll.requestFocusFromTouch(); fl.requestFocusFromTouch();
diaView = (FormEditText) layout.findViewById(R.id.circadianpercentageprofile_dia); diaView = (FormEditText) layout.findViewById(R.id.circadianpercentageprofile_dia);
mgdlView = (RadioButton) layout.findViewById(R.id.circadianpercentageprofile_mgdl); mgdlView = (RadioButton) layout.findViewById(R.id.circadianpercentageprofile_mgdl);
mmolView = (RadioButton) layout.findViewById(R.id.circadianpercentageprofile_mmol); mmolView = (RadioButton) layout.findViewById(R.id.circadianpercentageprofile_mmol);
@ -203,7 +204,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
mSnackBar.dismiss(); mSnackBar.dismiss();
} }
timeshiftView.clearFocus(); timeshiftView.clearFocus();
ll.requestFocusFromTouch(); fl.requestFocusFromTouch();
} }
else { else {
if (timeshiftViewHint) { if (timeshiftViewHint) {
@ -222,7 +223,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
mSnackBar.dismiss(); mSnackBar.dismiss();
} }
percentageView.clearFocus(); percentageView.clearFocus();
ll.requestFocusFromTouch(); fl.requestFocusFromTouch();
} }
else { else {
if (percentageViewHint) { if (percentageViewHint) {
@ -238,7 +239,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
public void onFocusChange(View view, boolean hasFocus) { public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) { if (!hasFocus) {
diaView.clearFocus(); diaView.clearFocus();
ll.requestFocusFromTouch(); fl.requestFocusFromTouch();
} }
} }
}); });
@ -249,7 +250,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
public void onFocusChange(View view, boolean hasFocus) { public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) { if (!hasFocus) {
targethighView.clearFocus(); targethighView.clearFocus();
ll.requestFocusFromTouch(); fl.requestFocusFromTouch();
} }
} }
}); });
@ -260,7 +261,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
public void onFocusChange(View view, boolean hasFocus) { public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) { if (!hasFocus) {
targetlowView.clearFocus(); targetlowView.clearFocus();
ll.requestFocusFromTouch(); fl.requestFocusFromTouch();
} }
} }
}); });
@ -325,11 +326,9 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
this.snackbarCaller = snackbarCaller; this.snackbarCaller = snackbarCaller;
if (timeshiftViewHint || percentageViewHint) { if (timeshiftViewHint || percentageViewHint) {
mSnackBar = Snackbar.make(view, //noinspection WrongConstant
Msg, mSnackBar = Snackbar.make(view, Msg, 7000)
Snackbar.LENGTH_LONG) .setActionTextColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationInfo))
.setDuration(Snackbar.LENGTH_LONG)
.setActionTextColor(getResources().getColor(R.color.notificationInfo))
.setAction(getString(R.string.dont_show_again), 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) {
@ -344,9 +343,9 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams(); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams();
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
view.setLayoutParams(params); view.setLayoutParams(params);
view.setBackgroundColor(getResources().getColor(R.color.cardview_dark_background)); view.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.cardview_dark_background));
TextView mainTextView = (TextView) (view).findViewById(android.support.design.R.id.snackbar_text); TextView mainTextView = (TextView) (view).findViewById(android.support.design.R.id.snackbar_text);
mainTextView.setTextColor(getResources().getColor(R.color.mdtp_white)); mainTextView.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.mdtp_white));
mSnackBar.show(); mSnackBar.show();
} }
} }
@ -383,7 +382,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
basalEditDialog.dismiss(); basalEditDialog.dismiss();
} }
basalEditDialog = null; basalEditDialog = null;
ll.requestFocusFromTouch(); fl.requestFocusFromTouch();
} }
public static class BasalEditDialog extends DialogFragment { public static class BasalEditDialog extends DialogFragment {
@ -464,7 +463,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
basalEditDialog = null; basalEditDialog = null;
MainApp.bus().unregister(this); MainApp.bus().unregister(this);
ll.requestFocusFromTouch(); fl.requestFocusFromTouch();
} }
@Override @Override
@ -472,7 +471,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
super.onResume(); super.onResume();
MainApp.bus().register(this); MainApp.bus().register(this);
onStatusEvent(null); onStatusEvent(null);
ll.requestFocusFromTouch(); fl.requestFocusFromTouch();
} }
@Subscribe @Subscribe

View file

@ -3,6 +3,10 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/circadianpercentageprofile_framelayout"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
tools:context=".plugins.CircadianPercentageProfile.CircadianPercentageProfileFragment"> tools:context=".plugins.CircadianPercentageProfile.CircadianPercentageProfileFragment">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
@ -13,10 +17,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical">
android:id="@+id/circadianpercentageprofile_linearlayout"
android:focusable="true"
android:focusableInTouchMode="true" >
<TextView <TextView
android:id="@+id/circadianpercentageprofile_profileview" android:id="@+id/circadianpercentageprofile_profileview"