diff --git a/OsmAnd/res/layout/center_button_container.xml b/OsmAnd/res/layout/center_button_container.xml
new file mode 100644
index 0000000000..8c8fdf1617
--- /dev/null
+++ b/OsmAnd/res/layout/center_button_container.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/custom_radio_buttons.xml b/OsmAnd/res/layout/custom_radio_buttons.xml
index d768e58004..d4bd1c8082 100644
--- a/OsmAnd/res/layout/custom_radio_buttons.xml
+++ b/OsmAnd/res/layout/custom_radio_buttons.xml
@@ -1,6 +1,5 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/gpx_list_item_tab_content.xml b/OsmAnd/res/layout/gpx_list_item_tab_content.xml
index d2ce779b8b..fbe7bf5e1c 100644
--- a/OsmAnd/res/layout/gpx_list_item_tab_content.xml
+++ b/OsmAnd/res/layout/gpx_list_item_tab_content.xml
@@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
-
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/right_button_container.xml b/OsmAnd/res/layout/right_button_container.xml
new file mode 100644
index 0000000000..bb618949af
--- /dev/null
+++ b/OsmAnd/res/layout/right_button_container.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java
index 94bd3c4bcb..7c9546d93d 100644
--- a/OsmAnd/src/net/osmand/plus/UiUtilities.java
+++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java
@@ -90,6 +90,12 @@ public class UiUtilities {
END,
}
+ public enum CustomRadioButtonTypeGroup {
+ START,
+ CENTER,
+ END,
+ }
+
public UiUtilities(OsmandApplication app) {
this.app = app;
}
@@ -484,6 +490,87 @@ public class UiUtilities {
}
}
+ public static void updateCustomRadioButtonsGroup(Context app, View buttonsView, boolean nightMode,
+ CustomRadioButtonTypeGroup buttonType) {
+ int activeColor = ContextCompat.getColor(app, nightMode
+ ? R.color.active_color_primary_dark
+ : R.color.active_color_primary_light);
+ int inActiveColor = ContextCompat.getColor(app, nightMode
+ ? R.color.text_color_secondary_dark
+ : R.color.text_color_secondary_light);
+ int textColor = ContextCompat.getColor(app, nightMode
+ ? R.color.text_color_primary_dark
+ : R.color.text_color_primary_light);
+ int roundedCorner = AndroidUtils.dpToPx(app, 4);
+ boolean isLayoutRtl = AndroidUtils.isLayoutRtl(app);
+
+ TextView startButtonText = buttonsView.findViewById(R.id.left_button);
+ View startButtonContainer = buttonsView.findViewById(R.id.left_button_container);
+ TextView centerButtonText = buttonsView.findViewById(R.id.center_button);
+ View centerButtonContainer = buttonsView.findViewById(R.id.center_button_container);
+ TextView endButtonText = buttonsView.findViewById(R.id.right_button);
+ View endButtonContainer = buttonsView.findViewById(R.id.right_button_container);
+ GradientDrawable background = new GradientDrawable();
+ background.setColor(UiUtilities.getColorWithAlpha(activeColor, 0.1f));
+ background.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(activeColor, 0.5f));
+ GradientDrawable startButtonSharpCorner = new GradientDrawable();
+ startButtonSharpCorner.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(inActiveColor, 0.5f));
+ GradientDrawable endButtonRoundedCorner = new GradientDrawable();
+ endButtonRoundedCorner.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(inActiveColor, 0.5f));
+ GradientDrawable centerButtonSharpCorner = new GradientDrawable();
+ centerButtonSharpCorner.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(inActiveColor, 0.5f));
+ setStartEndCenterRoundedCorner(roundedCorner, isLayoutRtl, startButtonSharpCorner, endButtonRoundedCorner, centerButtonSharpCorner);
+
+ if (buttonType == CustomRadioButtonTypeGroup.START) {
+ if (isLayoutRtl) {
+ background.setCornerRadii(new float[]{0, 0, roundedCorner, roundedCorner, roundedCorner, roundedCorner, 0, 0});
+ } else {
+ background.setCornerRadii(new float[]{roundedCorner, roundedCorner, 0, 0, 0, 0, roundedCorner, roundedCorner});
+ }
+ endButtonContainer.setBackground(endButtonRoundedCorner);
+ endButtonText.setTextColor(activeColor);
+ centerButtonContainer.setBackground(centerButtonSharpCorner);
+ centerButtonText.setTextColor(activeColor);
+ endButtonText.setTextColor(activeColor);
+ startButtonContainer.setBackgroundDrawable(background);
+ startButtonText.setTextColor(textColor);
+ } else if (buttonType == CustomRadioButtonTypeGroup.CENTER){
+ endButtonContainer.setBackground(endButtonRoundedCorner);
+ endButtonText.setTextColor(activeColor);
+ startButtonContainer.setBackground(startButtonSharpCorner);
+ startButtonText.setTextColor(activeColor);
+ endButtonText.setTextColor(activeColor);
+ centerButtonContainer.setBackgroundDrawable(background);
+ centerButtonText.setTextColor(textColor);
+ } else {
+ if (isLayoutRtl) {
+ background.setCornerRadii(new float[]{roundedCorner, roundedCorner, 0, 0, 0, 0, roundedCorner, roundedCorner});
+ } else {
+ background.setCornerRadii(new float[]{0, 0, roundedCorner, roundedCorner, roundedCorner, roundedCorner, 0, 0});
+ }
+ endButtonContainer.setBackgroundDrawable(background);
+ endButtonText.setTextColor(textColor);
+ startButtonContainer.setBackground(startButtonSharpCorner);
+ startButtonText.setTextColor(activeColor);
+ centerButtonContainer.setBackground(centerButtonSharpCorner);
+ centerButtonText.setTextColor(activeColor);
+ }
+ }
+
+ private static void setStartEndCenterRoundedCorner(int roundedCorner, boolean isLayoutRtl, GradientDrawable startButtonRoundedCorner, GradientDrawable endButtonRoundedCorner, GradientDrawable centerButtonSharpCorner) {
+ if (isLayoutRtl) {
+ startButtonRoundedCorner.setCornerRadii(new float[]{0, 0, roundedCorner, roundedCorner, roundedCorner, roundedCorner, 0, 0});
+ } else {
+ startButtonRoundedCorner.setCornerRadii(new float[]{roundedCorner, roundedCorner, 0, 0, 0, 0, roundedCorner, roundedCorner});
+ }
+ if (isLayoutRtl) {
+ endButtonRoundedCorner.setCornerRadii(new float[]{roundedCorner, roundedCorner, 0, 0, 0, 0, roundedCorner, roundedCorner});
+ } else {
+ endButtonRoundedCorner.setCornerRadii(new float[]{0, 0, roundedCorner, roundedCorner, roundedCorner, roundedCorner, 0, 0});
+ }
+ centerButtonSharpCorner.setCornerRadii(new float[]{0, 0, 0, 0, 0, 0, 0, 0});
+ }
+
public static void setupCompoundButtonDrawable(Context ctx, boolean nightMode, @ColorInt int activeColor, Drawable drawable) {
int inactiveColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light);
int[][] states = new int[][]{
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java
index 81d9ee9d72..8cd70de903 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java
@@ -13,6 +13,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat;
import androidx.viewpager.widget.PagerAdapter;
+import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.data.Entry;
@@ -23,6 +24,7 @@ import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture;
import com.github.mikephil.charting.listener.OnChartGestureListener;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
+import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.GPXTrackAnalysis;
@@ -78,7 +80,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
private boolean chartClicked;
- public GPXItemPagerAdapter(@NonNull PagerSlidingTabStrip tabs,
+ public GPXItemPagerAdapter(@NonNull final PagerSlidingTabStrip tabs,
@NonNull GpxDisplayItem gpxItem,
@NonNull TrackDisplayHelper displayHelper,
@NonNull SegmentActionsListener actionsListener) {
@@ -89,6 +91,34 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
this.actionsListener = actionsListener;
app = (OsmandApplication) tabs.getContext().getApplicationContext();
iconsCache = app.getUIUtilities();
+
+ tabs.setOnPageChangeListener(new OnPageChangeListener() {
+
+ @Override
+ public void onPageSelected(int arg0) {
+ UiUtilities.CustomRadioButtonTypeGroup type;
+ if (arg0 == 0) {
+ type = UiUtilities.CustomRadioButtonTypeGroup.START;
+ } else if (arg0 == 1) {
+ type = UiUtilities.CustomRadioButtonTypeGroup.CENTER;
+ } else {
+ type = UiUtilities.CustomRadioButtonTypeGroup.END;
+ }
+
+ View parent = (View) tabs.getChildAt(0);
+ UiUtilities.updateCustomRadioButtonsGroup(app, parent, false, type);
+ }
+
+ @Override
+ public void onPageScrolled(int arg0, float arg1, int arg2) {
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int arg0) {
+
+ }
+ });
+
fetchTabTypes();
}
@@ -588,7 +618,15 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
@Override
public View getCustomTabView(@NonNull ViewGroup parent, int position) {
- View tab = LayoutInflater.from(parent.getContext()).inflate(R.layout.gpx_tab, parent, false);
+ int layoutId;
+ if (position == 0) {
+ layoutId = R.layout.left_button_container;
+ } else if (position == 1) {
+ layoutId = R.layout.center_button_container;
+ } else {
+ layoutId = R.layout.right_button_container;
+ }
+ View tab = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
tab.setTag(tabTypes[position].name());
deselect(tab);
return tab;
@@ -597,29 +635,25 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
@Override
public void select(View tab) {
GPXTabItemType tabType = GPXTabItemType.valueOf((String) tab.getTag());
- ImageView img = tab.findViewById(R.id.tab_image);
- switch (tabs.getTabSelectionType()) {
- case ALPHA:
- img.setAlpha(tabs.getTabTextSelectedAlpha());
- break;
- case SOLID_COLOR:
- img.setImageDrawable(iconsCache.getPaintedIcon(tabType.getIconId(), tabs.getTextColor()));
- break;
+ UiUtilities.CustomRadioButtonTypeGroup type;
+ if (tabType == GPXTabItemType.GPX_TAB_ITEM_GENERAL) {
+ type = UiUtilities.CustomRadioButtonTypeGroup.START;
+ } else if (tabType == GPXTabItemType.GPX_TAB_ITEM_ALTITUDE) {
+ type = UiUtilities.CustomRadioButtonTypeGroup.CENTER;
+ } else {
+ type = UiUtilities.CustomRadioButtonTypeGroup.END;
}
+ View parent = (View) tab.getParent();
+ UiUtilities.updateCustomRadioButtonsGroup(app,parent , false, type);
+
+ ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) parent.getLayoutParams();
+ int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
+ int containerMargin = app.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_content_margin_small);
+ AndroidUtils.setMargins(params, contentPadding, containerMargin, contentPadding, containerMargin);
}
@Override
public void deselect(View tab) {
- GPXTabItemType tabType = GPXTabItemType.valueOf((String) tab.getTag());
- ImageView img = tab.findViewById(R.id.tab_image);
- switch (tabs.getTabSelectionType()) {
- case ALPHA:
- img.setAlpha(tabs.getTabTextAlpha());
- break;
- case SOLID_COLOR:
- img.setImageDrawable(iconsCache.getPaintedIcon(tabType.getIconId(), tabs.getTabInactiveTextColor()));
- break;
- }
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java
index a92d2c5e0a..e38a8619b0 100644
--- a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java
+++ b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java
@@ -352,13 +352,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
tab_title.setTextColor(pager.getCurrentItem() == i ? tabTextColor : tabInactiveTextColor);
break;
}
- if (pager.getAdapter() instanceof CustomTabProvider) {
- if (pager.getCurrentItem() == i) {
- ((CustomTabProvider) pager.getAdapter()).select(v);
- } else {
- ((CustomTabProvider) pager.getAdapter()).deselect(v);
- }
- }
// setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
// pre-ICS-build
@@ -370,6 +363,13 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
}
}
}
+ if (pager.getAdapter() instanceof CustomTabProvider) {
+ if (pager.getCurrentItem() == i) {
+ ((CustomTabProvider) pager.getAdapter()).select(v);
+ } else {
+ ((CustomTabProvider) pager.getAdapter()).deselect(v);
+ }
+ }
}
}