mark selected tab in treatments

This commit is contained in:
Milos Kozak 2017-05-26 10:05:42 +02:00
parent a066580896
commit 650b792099
3 changed files with 21 additions and 2 deletions

View file

@ -12,6 +12,7 @@ import android.widget.TextView;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsBolusFragment; import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsBolusFragment;
import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsExtendedBolusesFragment; import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsExtendedBolusesFragment;
@ -49,6 +50,7 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
context = getContext(); context = getContext();
setFragment(new TreatmentsBolusFragment()); setFragment(new TreatmentsBolusFragment());
setBackgroundColorOnSelected(treatmentsTab);
return view; return view;
} }
@ -59,15 +61,19 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
switch (v.getId()) { switch (v.getId()) {
case R.id.treatments_treatments: case R.id.treatments_treatments:
setFragment(new TreatmentsBolusFragment()); setFragment(new TreatmentsBolusFragment());
setBackgroundColorOnSelected(treatmentsTab);
break; break;
case R.id.treatments_extendedboluses: case R.id.treatments_extendedboluses:
setFragment(new TreatmentsExtendedBolusesFragment()); setFragment(new TreatmentsExtendedBolusesFragment());
setBackgroundColorOnSelected(extendedBolusesTab);
break; break;
case R.id.treatments_tempbasals: case R.id.treatments_tempbasals:
setFragment(new TreatmentsTemporaryBasalsFragment()); setFragment(new TreatmentsTemporaryBasalsFragment());
setBackgroundColorOnSelected(tempBasalsTab);
break; break;
case R.id.treatments_temptargets: case R.id.treatments_temptargets:
setFragment(new TreatmentsTempTargetFragment()); setFragment(new TreatmentsTempTargetFragment());
setBackgroundColorOnSelected(tempTargetTab);
break; break;
} }
} }
@ -79,4 +85,12 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
ft.addToBackStack(null); ft.addToBackStack(null);
ft.commit(); ft.commit();
} }
private void setBackgroundColorOnSelected(TextView selected) {
treatmentsTab.setBackgroundColor(MainApp.sResources.getColor(R.color.defaultbackground));
extendedBolusesTab.setBackgroundColor(MainApp.sResources.getColor(R.color.defaultbackground));
tempBasalsTab.setBackgroundColor(MainApp.sResources.getColor(R.color.defaultbackground));
tempTargetTab.setBackgroundColor(MainApp.sResources.getColor(R.color.defaultbackground));
selected.setBackgroundColor(MainApp.sResources.getColor(R.color.tabBgColorSelected));
}
} }

View file

@ -23,12 +23,14 @@ import android.util.TypedValue;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
class SlidingTabStrip extends LinearLayout { class SlidingTabStrip extends LinearLayout {
private static final int DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS = 0; private static final int DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS = 0;
private static final byte DEFAULT_BOTTOM_BORDER_COLOR_ALPHA = 0x26; private static final byte DEFAULT_BOTTOM_BORDER_COLOR_ALPHA = 0x26;
private static final int SELECTED_INDICATOR_THICKNESS_DIPS = 3; private static final int SELECTED_INDICATOR_THICKNESS_DIPS = 3;
private static final int DEFAULT_SELECTED_INDICATOR_COLOR = 0xFF33B5E5;
private final int mBottomBorderThickness; private final int mBottomBorderThickness;
private final Paint mBottomBorderPaint; private final Paint mBottomBorderPaint;
@ -60,7 +62,7 @@ class SlidingTabStrip extends LinearLayout {
DEFAULT_BOTTOM_BORDER_COLOR_ALPHA); DEFAULT_BOTTOM_BORDER_COLOR_ALPHA);
mDefaultTabColorizer = new SimpleTabColorizer(); mDefaultTabColorizer = new SimpleTabColorizer();
mDefaultTabColorizer.setIndicatorColors(DEFAULT_SELECTED_INDICATOR_COLOR); mDefaultTabColorizer.setIndicatorColors(MainApp.sResources.getColor(R.color.tabBgColorSelected));
mBottomBorderThickness = (int) (DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density); mBottomBorderThickness = (int) (DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density);
mBottomBorderPaint = new Paint(); mBottomBorderPaint = new Paint();

View file

@ -9,8 +9,11 @@
<color name="high">#FFFF00</color> <color name="high">#FFFF00</color>
<color name="listdelimiter">#505050</color> <color name="listdelimiter">#505050</color>
<color name="tabBgColor">#f0003f59</color> <color name="tabBgColor">#f0003f59</color>
<color name="tabBgColorSelected">#FF33B5E5</color>
<color name="deviations">#FF0000</color> <color name="deviations">#FF0000</color>
<color name="defaultbackground">#424242</color>
<color name="tempTargetBackground">#77dd77</color> <color name="tempTargetBackground">#77dd77</color>
<color name="tempTargetDisabledBackground">#303F9F</color> <color name="tempTargetDisabledBackground">#303F9F</color>