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.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsBolusFragment;
import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsExtendedBolusesFragment;
@ -49,6 +50,7 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
context = getContext();
setFragment(new TreatmentsBolusFragment());
setBackgroundColorOnSelected(treatmentsTab);
return view;
}
@ -59,15 +61,19 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
switch (v.getId()) {
case R.id.treatments_treatments:
setFragment(new TreatmentsBolusFragment());
setBackgroundColorOnSelected(treatmentsTab);
break;
case R.id.treatments_extendedboluses:
setFragment(new TreatmentsExtendedBolusesFragment());
setBackgroundColorOnSelected(extendedBolusesTab);
break;
case R.id.treatments_tempbasals:
setFragment(new TreatmentsTemporaryBasalsFragment());
setBackgroundColorOnSelected(tempBasalsTab);
break;
case R.id.treatments_temptargets:
setFragment(new TreatmentsTempTargetFragment());
setBackgroundColorOnSelected(tempTargetTab);
break;
}
}
@ -79,4 +85,12 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
ft.addToBackStack(null);
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.widget.LinearLayout;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
class SlidingTabStrip extends LinearLayout {
private static final int DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS = 0;
private static final byte DEFAULT_BOTTOM_BORDER_COLOR_ALPHA = 0x26;
private static final int SELECTED_INDICATOR_THICKNESS_DIPS = 3;
private static final int DEFAULT_SELECTED_INDICATOR_COLOR = 0xFF33B5E5;
private final int mBottomBorderThickness;
private final Paint mBottomBorderPaint;
@ -60,7 +62,7 @@ class SlidingTabStrip extends LinearLayout {
DEFAULT_BOTTOM_BORDER_COLOR_ALPHA);
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);
mBottomBorderPaint = new Paint();

View file

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