Small fixes
This commit is contained in:
parent
252319f619
commit
de773909a0
11 changed files with 180 additions and 388 deletions
|
@ -1,19 +1,19 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/center_button_container"
|
android:id="@+id/center_button_container"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/center_button"
|
android:id="@+id/center_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:text="@string/altitude"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
android:text="@string/altitude"/>
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/custom_radio_buttons"
|
android:id="@+id/custom_radio_buttons"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:minHeight="@dimen/dialog_button_height"
|
android:minHeight="@dimen/dialog_button_height"
|
||||||
|
@ -13,58 +12,22 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
tools:showIn="@layout/fragment_route_between_points_bottom_sheet_dialog">
|
tools:showIn="@layout/fragment_route_between_points_bottom_sheet_dialog">
|
||||||
|
|
||||||
<FrameLayout
|
<include
|
||||||
android:id="@+id/left_button_container"
|
layout="@layout/left_button_container"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1" />
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/left_button"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="@string/shared_string_left"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
<include
|
||||||
|
layout="@layout/center_button_container"
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/center_button_container"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1" />
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<include
|
||||||
android:id="@+id/center_button"
|
layout="@layout/right_button_container"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="@string/position_on_map_center"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/right_button_container"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/right_button"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="@string/shared_string_right"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1,68 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/custom_radio_buttons"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
|
||||||
android:layout_marginEnd="@dimen/content_padding"
|
|
||||||
android:background="?attr/btn_bg_border_inactive"
|
|
||||||
android:baselineAligned="false"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/left_button_container"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1">
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/left_button"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="@string/shared_string_left"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/center_button_container"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/center_button"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="@string/position_on_map_center"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/right_button_container"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/right_button"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="@string/shared_string_right"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -1,24 +1,32 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
android:layout_width="match_parent"
|
||||||
android:orientation="vertical"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:orientation="vertical">
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<include layout="@layout/list_item_divider"/>
|
<include layout="@layout/list_item_divider" />
|
||||||
|
|
||||||
<net.osmand.plus.views.controls.PagerSlidingTabStrip
|
<LinearLayout
|
||||||
android:id="@+id/sliding_tabs"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="48dp"
|
android:background="?attr/bg_color"
|
||||||
android:background="?attr/bg_color"/>
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<net.osmand.plus.views.controls.PagerSlidingTabStrip
|
||||||
|
android:id="@+id/sliding_tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:minHeight="@dimen/dialog_button_height"
|
||||||
|
android:paddingTop="@dimen/content_padding" />
|
||||||
|
|
||||||
<net.osmand.plus.views.controls.WrapContentHeightViewPager
|
<net.osmand.plus.views.controls.WrapContentHeightViewPager
|
||||||
android:id="@+id/pager"
|
android:id="@+id/pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/bg_color"
|
android:paddingTop="4dp" />
|
||||||
android:paddingTop="4dp"/>
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/left_button_container"
|
android:id="@+id/left_button_container"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -13,8 +12,8 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:text="@string/shared_string_overview"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
android:text="@string/shared_string_overview" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -12,8 +12,8 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:text="@string/map_widget_speed"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
android:text="@string/map_widget_speed"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -86,11 +86,6 @@ public class UiUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CustomRadioButtonType {
|
public enum CustomRadioButtonType {
|
||||||
START,
|
|
||||||
END,
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CustomRadioButtonTypeGroup {
|
|
||||||
START,
|
START,
|
||||||
CENTER,
|
CENTER,
|
||||||
END,
|
END,
|
||||||
|
@ -462,6 +457,8 @@ public class UiUtilities {
|
||||||
|
|
||||||
TextView startButtonText = buttonsView.findViewById(R.id.left_button);
|
TextView startButtonText = buttonsView.findViewById(R.id.left_button);
|
||||||
View startButtonContainer = buttonsView.findViewById(R.id.left_button_container);
|
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);
|
TextView endButtonText = buttonsView.findViewById(R.id.right_button);
|
||||||
View endButtonContainer = buttonsView.findViewById(R.id.right_button_container);
|
View endButtonContainer = buttonsView.findViewById(R.id.right_button_container);
|
||||||
GradientDrawable background = new GradientDrawable();
|
GradientDrawable background = new GradientDrawable();
|
||||||
|
@ -477,9 +474,27 @@ public class UiUtilities {
|
||||||
endButtonText.setTextColor(activeColor);
|
endButtonText.setTextColor(activeColor);
|
||||||
startButtonContainer.setBackgroundDrawable(background);
|
startButtonContainer.setBackgroundDrawable(background);
|
||||||
startButtonText.setTextColor(textColor);
|
startButtonText.setTextColor(textColor);
|
||||||
|
|
||||||
|
if (centerButtonContainer != null) {
|
||||||
|
centerButtonText.setTextColor(activeColor);
|
||||||
|
centerButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
} else if (buttonType == CustomRadioButtonType.CENTER) {
|
||||||
|
background.setCornerRadii(new float[] {0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
|
centerButtonContainer.setBackgroundDrawable(background);
|
||||||
|
centerButtonText.setTextColor(textColor);
|
||||||
|
|
||||||
|
if (endButtonContainer != null) {
|
||||||
|
endButtonText.setTextColor(activeColor);
|
||||||
|
endButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
if (startButtonContainer != null) {
|
||||||
|
startButtonText.setTextColor(activeColor);
|
||||||
|
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isLayoutRtl) {
|
if (isLayoutRtl) {
|
||||||
background.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius});
|
background.setCornerRadii(new float[] {radius, radius, 0, 0, 0, 0, radius, radius});
|
||||||
} else {
|
} else {
|
||||||
background.setCornerRadii(new float[]{0, 0, radius, radius, radius, radius, 0, 0});
|
background.setCornerRadii(new float[]{0, 0, radius, radius, radius, radius, 0, 0});
|
||||||
}
|
}
|
||||||
|
@ -487,119 +502,14 @@ public class UiUtilities {
|
||||||
endButtonText.setTextColor(textColor);
|
endButtonText.setTextColor(textColor);
|
||||||
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
startButtonText.setTextColor(activeColor);
|
startButtonText.setTextColor(activeColor);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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 startButtonRoundedCorner = new GradientDrawable();
|
|
||||||
startButtonRoundedCorner.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, startButtonRoundedCorner, 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});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endButtonContainer != null && centerButtonContainer != null) {
|
|
||||||
endButtonContainer.setBackground(endButtonRoundedCorner);
|
|
||||||
endButtonText.setTextColor(activeColor);
|
|
||||||
centerButtonContainer.setBackground(centerButtonSharpCorner);
|
|
||||||
centerButtonText.setTextColor(activeColor);
|
|
||||||
startButtonContainer.setBackgroundDrawable(background);
|
|
||||||
startButtonText.setTextColor(textColor);
|
|
||||||
} else if (centerButtonContainer != null) {
|
|
||||||
centerButtonContainer.setBackground(endButtonRoundedCorner);
|
|
||||||
centerButtonText.setTextColor(activeColor);
|
|
||||||
startButtonContainer.setBackgroundDrawable(background);
|
|
||||||
startButtonText.setTextColor(textColor);
|
|
||||||
} else if (endButtonContainer != null) {
|
|
||||||
endButtonContainer.setBackground(endButtonRoundedCorner);
|
|
||||||
endButtonText.setTextColor(activeColor);
|
|
||||||
startButtonContainer.setBackgroundDrawable(background);
|
|
||||||
startButtonText.setTextColor(textColor);
|
|
||||||
} else if (endButtonContainer == null && centerButtonContainer == null) {
|
|
||||||
background.setCornerRadii(new float[]{roundedCorner, roundedCorner, roundedCorner, roundedCorner, roundedCorner, roundedCorner, roundedCorner, roundedCorner});
|
|
||||||
startButtonContainer.setBackgroundDrawable(background);
|
|
||||||
startButtonText.setTextColor(textColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (buttonType == CustomRadioButtonTypeGroup.CENTER) {
|
|
||||||
centerButtonContainer.setBackgroundDrawable(background);
|
|
||||||
centerButtonText.setTextColor(textColor);
|
|
||||||
startButtonContainer.setBackground(startButtonRoundedCorner);
|
|
||||||
startButtonText.setTextColor(activeColor);
|
|
||||||
if (endButtonContainer != null) {
|
|
||||||
endButtonContainer.setBackground(endButtonRoundedCorner);
|
|
||||||
endButtonText.setTextColor(activeColor);
|
|
||||||
} else {
|
|
||||||
endButtonRoundedCorner.setColor(UiUtilities.getColorWithAlpha(activeColor, 0.1f));
|
|
||||||
centerButtonContainer.setBackgroundDrawable(endButtonRoundedCorner);
|
|
||||||
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});
|
|
||||||
}
|
|
||||||
startButtonContainer.setBackground(startButtonRoundedCorner);
|
|
||||||
startButtonText.setTextColor(activeColor);
|
|
||||||
endButtonContainer.setBackgroundDrawable(background);
|
|
||||||
endButtonText.setTextColor(textColor);
|
|
||||||
if (centerButtonContainer != null) {
|
if (centerButtonContainer != null) {
|
||||||
centerButtonContainer.setBackground(centerButtonSharpCorner);
|
|
||||||
centerButtonText.setTextColor(activeColor);
|
centerButtonText.setTextColor(activeColor);
|
||||||
|
centerButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
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 inactiveColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light);
|
||||||
int[][] states = new int[][]{
|
int[][] states = new int[][]{
|
||||||
|
|
|
@ -7,13 +7,13 @@ import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewGroup.MarginLayoutParams;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.viewpager.widget.PagerAdapter;
|
import androidx.viewpager.widget.PagerAdapter;
|
||||||
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
|
|
||||||
|
|
||||||
import com.github.mikephil.charting.charts.LineChart;
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
|
@ -24,7 +24,6 @@ import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture;
|
||||||
import com.github.mikephil.charting.listener.OnChartGestureListener;
|
import com.github.mikephil.charting.listener.OnChartGestureListener;
|
||||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||||
|
@ -37,6 +36,7 @@ import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.UiUtilities.CustomRadioButtonType;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
||||||
|
@ -44,7 +44,6 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.LineGraphType;
|
import net.osmand.plus.helpers.GpxUiHelper.LineGraphType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
||||||
import net.osmand.plus.track.TrackDisplayHelper;
|
import net.osmand.plus.track.TrackDisplayHelper;
|
||||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
|
||||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip.CustomTabProvider;
|
import net.osmand.plus.views.controls.PagerSlidingTabStrip.CustomTabProvider;
|
||||||
import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionInterface;
|
import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionInterface;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -53,6 +52,7 @@ import net.osmand.util.MapUtils;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -74,7 +74,6 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
private GpxDisplayItem gpxItem;
|
private GpxDisplayItem gpxItem;
|
||||||
private GPXTabItemType[] tabTypes;
|
private GPXTabItemType[] tabTypes;
|
||||||
|
|
||||||
private PagerSlidingTabStrip tabs;
|
|
||||||
private SparseArray<View> views = new SparseArray<>();
|
private SparseArray<View> views = new SparseArray<>();
|
||||||
private SegmentActionsListener actionsListener;
|
private SegmentActionsListener actionsListener;
|
||||||
|
|
||||||
|
@ -82,47 +81,17 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
|
|
||||||
|
|
||||||
public GPXItemPagerAdapter(@NonNull final PagerSlidingTabStrip tabs,
|
public GPXItemPagerAdapter(@NonNull OsmandApplication app,
|
||||||
@NonNull GpxDisplayItem gpxItem,
|
@NonNull GpxDisplayItem gpxItem,
|
||||||
@NonNull TrackDisplayHelper displayHelper,
|
@NonNull TrackDisplayHelper displayHelper,
|
||||||
@NonNull SegmentActionsListener actionsListener,
|
boolean nightMode, @NonNull SegmentActionsListener actionsListener) {
|
||||||
final boolean nightMode) {
|
|
||||||
super();
|
super();
|
||||||
this.tabs = tabs;
|
this.app = app;
|
||||||
this.gpxItem = gpxItem;
|
this.gpxItem = gpxItem;
|
||||||
this.displayHelper = displayHelper;
|
|
||||||
this.nightMode = nightMode;
|
this.nightMode = nightMode;
|
||||||
|
this.displayHelper = displayHelper;
|
||||||
this.actionsListener = actionsListener;
|
this.actionsListener = actionsListener;
|
||||||
app = (OsmandApplication) tabs.getContext().getApplicationContext();
|
|
||||||
iconsCache = app.getUIUtilities();
|
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, nightMode, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int arg0, float arg1, int arg2) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int arg0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchTabTypes();
|
fetchTabTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,44 +558,60 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
return view == object;
|
return view == object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int singleTabLayoutId[] = {R.layout.center_button_container};
|
||||||
|
int doubleTabsLayoutIds[] = {R.layout.left_button_container, R.layout.right_button_container};
|
||||||
|
int tripleTabsLayoutIds[] = {R.layout.left_button_container, R.layout.center_button_container, R.layout.right_button_container};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getCustomTabView(@NonNull ViewGroup parent, int position) {
|
public View getCustomTabView(@NonNull ViewGroup parent, int position) {
|
||||||
int layoutId;
|
int layoutId;
|
||||||
if (position == 0) {
|
int count = getCount();
|
||||||
layoutId = R.layout.left_button_container;
|
if (count == 1) {
|
||||||
} else if (position == 1) {
|
layoutId = singleTabLayoutId[position];
|
||||||
layoutId = R.layout.center_button_container;
|
} else if (count == 2) {
|
||||||
|
layoutId = doubleTabsLayoutIds[position];
|
||||||
} else {
|
} else {
|
||||||
layoutId = R.layout.right_button_container;
|
layoutId = tripleTabsLayoutIds[position];
|
||||||
}
|
}
|
||||||
View tab = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
|
View tab = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
|
||||||
tab.setTag(tabTypes[position].name());
|
tab.setTag(tabTypes[position].name());
|
||||||
deselect(tab);
|
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void select(View tab) {
|
public void select(View tab) {
|
||||||
GPXTabItemType tabType = GPXTabItemType.valueOf((String) tab.getTag());
|
GPXTabItemType tabType = GPXTabItemType.valueOf((String) tab.getTag());
|
||||||
UiUtilities.CustomRadioButtonTypeGroup type;
|
int index = Arrays.asList(tabTypes).indexOf(tabType);
|
||||||
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();
|
View parent = (View) tab.getParent();
|
||||||
UiUtilities.updateCustomRadioButtonsGroup(app, parent, nightMode, type);
|
UiUtilities.updateCustomRadioButtons(app, parent, nightMode, getCustomRadioButtonType(index));
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public void deselect(View tab) {
|
public void deselect(View tab) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tabStylesUpdated(View tabsContainer, int currentPosition) {
|
||||||
|
ViewGroup.MarginLayoutParams params = (MarginLayoutParams) tabsContainer.getLayoutParams();
|
||||||
|
params.height = app.getResources().getDimensionPixelSize(R.dimen.dialog_button_height);
|
||||||
|
tabsContainer.setLayoutParams(params);
|
||||||
|
UiUtilities.updateCustomRadioButtons(app, tabsContainer, nightMode, getCustomRadioButtonType(currentPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
private CustomRadioButtonType getCustomRadioButtonType(int index) {
|
||||||
|
int count = getCount();
|
||||||
|
CustomRadioButtonType type = CustomRadioButtonType.CENTER;
|
||||||
|
if (count == 2) {
|
||||||
|
type = index > 0 ? CustomRadioButtonType.END : CustomRadioButtonType.START;
|
||||||
|
} else if (count == 3) {
|
||||||
|
if (index == 0) {
|
||||||
|
type = CustomRadioButtonType.START;
|
||||||
|
} else if (index == 2) {
|
||||||
|
type = CustomRadioButtonType.END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package net.osmand.plus.myplaces;
|
package net.osmand.plus.myplaces;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.GradientDrawable;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
|
@ -22,6 +20,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
public class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
private TrackDisplayHelper displayHelper;
|
private TrackDisplayHelper displayHelper;
|
||||||
private SegmentActionsListener listener;
|
private SegmentActionsListener listener;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
|
@ -31,7 +30,7 @@ public class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
||||||
@NonNull SegmentActionsListener listener,
|
@NonNull SegmentActionsListener listener,
|
||||||
boolean nightMode) {
|
boolean nightMode) {
|
||||||
super(context, R.layout.gpx_list_item_tab_content, items);
|
super(context, R.layout.gpx_list_item_tab_content, items);
|
||||||
OsmandApplication app = (OsmandApplication) context.getApplicationContext();
|
this.app = (OsmandApplication) context.getApplicationContext();
|
||||||
this.displayHelper = displayHelper;
|
this.displayHelper = displayHelper;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.nightMode = nightMode;
|
this.nightMode = nightMode;
|
||||||
|
@ -56,7 +55,7 @@ public class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
||||||
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
||||||
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
|
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
|
||||||
|
|
||||||
pager.setAdapter(new GPXItemPagerAdapter(tabLayout, item, displayHelper, listener, nightMode));
|
pager.setAdapter(new GPXItemPagerAdapter(app, item, displayHelper, nightMode, listener));
|
||||||
if (create) {
|
if (create) {
|
||||||
tabLayout.setViewPager(pager);
|
tabLayout.setViewPager(pager);
|
||||||
} else {
|
} else {
|
||||||
|
@ -72,9 +71,8 @@ public class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
||||||
View row = UiUtilities.getInflater(context, nightMode).inflate(R.layout.gpx_list_item_tab_content, root, false);
|
View row = UiUtilities.getInflater(context, nightMode).inflate(R.layout.gpx_list_item_tab_content, root, false);
|
||||||
|
|
||||||
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
|
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
|
||||||
tabLayout.setTabBackground(R.color.color_transparent);
|
tabLayout.setTabBackground(AndroidUtils.resolveAttribute(context, R.attr.btn_bg_border_inactive));
|
||||||
tabLayout.setIndicatorHeight(AndroidUtils.dpToPx(context, 0));
|
tabLayout.setIndicatorHeight(0);
|
||||||
tabLayout.setTextSize(AndroidUtils.spToPx(context, 12f));
|
|
||||||
tabLayout.setShouldExpand(true);
|
tabLayout.setShouldExpand(true);
|
||||||
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
||||||
pager.setSwipeable(false);
|
pager.setSwipeable(false);
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class SegmentsCard extends BaseCard {
|
||||||
WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager);
|
WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager);
|
||||||
PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs);
|
PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs);
|
||||||
|
|
||||||
pager.setAdapter(new GPXItemPagerAdapter(tabLayout, displayItem, displayHelper, listener, nightMode));
|
pager.setAdapter(new GPXItemPagerAdapter(app, displayItem, displayHelper, nightMode, listener));
|
||||||
tabLayout.setViewPager(pager);
|
tabLayout.setViewPager(pager);
|
||||||
|
|
||||||
container.addView(segmentView);
|
container.addView(segmentView);
|
||||||
|
|
|
@ -68,6 +68,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
public View getCustomTabView(@NonNull ViewGroup parent, int position);
|
public View getCustomTabView(@NonNull ViewGroup parent, int position);
|
||||||
public void select(View tab);
|
public void select(View tab);
|
||||||
public void deselect(View tab);
|
public void deselect(View tab);
|
||||||
|
public void tabStylesUpdated(View tabsContainer, int currentPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnTabReselectedListener {
|
public interface OnTabReselectedListener {
|
||||||
|
@ -307,6 +308,10 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCurrentPosition() {
|
||||||
|
return currentPosition;
|
||||||
|
}
|
||||||
|
|
||||||
private void addTab(final int position, CharSequence title, View tabView) {
|
private void addTab(final int position, CharSequence title, View tabView) {
|
||||||
TextView textView = (TextView) tabView.findViewById(R.id.tab_title);
|
TextView textView = (TextView) tabView.findViewById(R.id.tab_title);
|
||||||
if (textView != null) {
|
if (textView != null) {
|
||||||
|
@ -332,42 +337,32 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
|
|
||||||
private void updateTabStyles() {
|
private void updateTabStyles() {
|
||||||
tabsContainer.setBackgroundResource(tabBackgroundResId);
|
tabsContainer.setBackgroundResource(tabBackgroundResId);
|
||||||
for (int i = 0; i < tabCount; i++) {
|
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||||
View v = tabsContainer.getChildAt(i);
|
((CustomTabProvider) pager.getAdapter()).tabStylesUpdated(tabsContainer, currentPosition);
|
||||||
v.setBackgroundResource(tabBackgroundResId);
|
} else {
|
||||||
v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
|
for (int i = 0; i < tabCount; i++) {
|
||||||
TextView tab_title = (TextView) v.findViewById(R.id.tab_title);
|
View v = tabsContainer.getChildAt(i);
|
||||||
|
v.setBackgroundResource(tabBackgroundResId);
|
||||||
|
v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
|
||||||
|
|
||||||
if (tab_title != null) {
|
TextView tabTitle = v.findViewById(R.id.tab_title);
|
||||||
tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
|
if (tabTitle != null) {
|
||||||
tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
|
tabTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
|
||||||
switch (tabSelectionType) {
|
tabTitle.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
|
||||||
case ALPHA:
|
switch (tabSelectionType) {
|
||||||
float alpha = pager.getCurrentItem() == i ? tabTextSelectedAlpha : tabTextAlpha;
|
case ALPHA:
|
||||||
tab_title.setAlpha(alpha);
|
float alpha = pager.getCurrentItem() == i ? tabTextSelectedAlpha : tabTextAlpha;
|
||||||
tab_title.setTextColor(tabTextColor);
|
tabTitle.setAlpha(alpha);
|
||||||
break;
|
tabTitle.setTextColor(tabTextColor);
|
||||||
case SOLID_COLOR:
|
break;
|
||||||
tab_title.setAlpha(OPAQUE);
|
case SOLID_COLOR:
|
||||||
tab_title.setTextColor(pager.getCurrentItem() == i ? tabTextColor : tabInactiveTextColor);
|
tabTitle.setAlpha(OPAQUE);
|
||||||
break;
|
tabTitle.setTextColor(pager.getCurrentItem() == i ? tabTextColor : tabInactiveTextColor);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
// setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
|
if (textAllCaps) {
|
||||||
// pre-ICS-build
|
tabTitle.setAllCaps(true);
|
||||||
if (textAllCaps) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
|
||||||
tab_title.setAllCaps(true);
|
|
||||||
} else {
|
|
||||||
tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
|
||||||
if (pager.getCurrentItem() == i) {
|
|
||||||
((CustomTabProvider) pager.getAdapter()).select(v);
|
|
||||||
} else {
|
|
||||||
((CustomTabProvider) pager.getAdapter()).deselect(v);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,39 +553,41 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
|
|
||||||
private void notSelected(View tab) {
|
private void notSelected(View tab) {
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
TextView title = (TextView) tab.findViewById(R.id.tab_title);
|
|
||||||
if (title != null) {
|
|
||||||
title.setTypeface(tabTypeface, tabTypefaceStyle);
|
|
||||||
switch (tabSelectionType) {
|
|
||||||
case ALPHA:
|
|
||||||
title.setAlpha(tabTextAlpha);
|
|
||||||
break;
|
|
||||||
case SOLID_COLOR:
|
|
||||||
title.setTextColor(tabInactiveTextColor);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||||
((CustomTabProvider) pager.getAdapter()).deselect(tab);
|
((CustomTabProvider) pager.getAdapter()).deselect(tab);
|
||||||
|
} else {
|
||||||
|
TextView title = tab.findViewById(R.id.tab_title);
|
||||||
|
if (title != null) {
|
||||||
|
title.setTypeface(tabTypeface, tabTypefaceStyle);
|
||||||
|
switch (tabSelectionType) {
|
||||||
|
case ALPHA:
|
||||||
|
title.setAlpha(tabTextAlpha);
|
||||||
|
break;
|
||||||
|
case SOLID_COLOR:
|
||||||
|
title.setTextColor(tabInactiveTextColor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selected(View tab) {
|
private void selected(View tab) {
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
TextView title = (TextView) tab.findViewById(R.id.tab_title);
|
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||||
if (title != null) {
|
((CustomTabProvider) pager.getAdapter()).select(tab);
|
||||||
title.setTypeface(tabTypeface, tabTypefaceSelectedStyle);
|
} else {
|
||||||
switch (tabSelectionType) {
|
TextView title = tab.findViewById(R.id.tab_title);
|
||||||
case ALPHA:
|
if (title != null) {
|
||||||
title.setAlpha(tabTextSelectedAlpha);
|
title.setTypeface(tabTypeface, tabTypefaceSelectedStyle);
|
||||||
break;
|
switch (tabSelectionType) {
|
||||||
case SOLID_COLOR:
|
case ALPHA:
|
||||||
title.setTextColor(tabTextColor);
|
title.setAlpha(tabTextSelectedAlpha);
|
||||||
break;
|
break;
|
||||||
}
|
case SOLID_COLOR:
|
||||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
title.setTextColor(tabTextColor);
|
||||||
((CustomTabProvider) pager.getAdapter()).select(tab);
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue