Change colors and refactor

This commit is contained in:
PavelRatushny 2017-12-06 17:42:13 +02:00
parent ac69c42463
commit 69c08218da
20 changed files with 155 additions and 76 deletions

View file

@ -6,7 +6,7 @@
<item>
<shape>
<solid
android:color="@color/bg_color_dark" />
android:color="@color/ctx_menu_bg_dark" />
</shape>
</item>
</layer-list>

View file

@ -6,7 +6,7 @@
<item>
<shape>
<solid
android:color="@color/bg_color_light" />
android:color="@color/ctx_menu_bg_light" />
</shape>
</item>
</layer-list>

View file

@ -1,13 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#f6eef1" />
<stroke
android:width="1dp"
android:color="#000000" />
<corners android:radius="5dp" />
</shape>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/context_menu_controller_bg_dark_p" android:state_pressed="true"/>
<item android:drawable="@drawable/context_menu_controller_bg_dark_n"/>
</selector>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/ctx_menu_controller_button_bg_color_dark_n" />
<stroke
android:width="1dp"
android:color="@color/ctx_menu_controller_button_outline_color_dark_n" />
<corners android:radius="3dp" />
</shape>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/ctx_menu_controller_button_bg_color_dark_p" />
<stroke
android:width="1dp"
android:color="@color/ctx_menu_controller_button_outline_color_dark_p" />
<corners android:radius="3dp" />
</shape>

View file

@ -1,13 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#f6eef1" />
<stroke
android:width="1dp"
android:color="#000000" />
<corners android:radius="5dp" />
</shape>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/context_menu_controller_bg_light_p" android:state_pressed="true"/>
<item android:drawable="@drawable/context_menu_controller_bg_light_n"/>
</selector>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/ctx_menu_controller_button_bg_color_light_n" />
<stroke
android:width="1dp"
android:color="@color/ctx_menu_controller_button_outline_color_light_n" />
<corners android:radius="3dp" />
</shape>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/ctx_menu_controller_button_bg_color_light_p" />
<stroke
android:width="1dp"
android:color="@color/ctx_menu_controller_button_outline_color_light_p" />
<corners android:radius="3dp" />
</shape>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/ctx_menu_controller_button_text_color_dark_p" android:state_pressed="true"/>
<item android:color="@color/ctx_menu_controller_button_text_color_dark_n"/>
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/ctx_menu_controller_button_text_color_light_p" android:state_pressed="true"/>
<item android:color="@color/ctx_menu_controller_button_text_color_light_n"/>
</selector>

View file

@ -113,7 +113,7 @@
android:layout_gravity="center_vertical"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:textColor="?android:textColorSecondary"
tools:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="100500 km"/>
@ -151,7 +151,7 @@
android:paddingRight="@dimen/context_menu_button_padding_x"
android:textAllCaps="true"
android:text="@string/recording_context_menu_play"
android:textColor="?attr/contextMenuButtonColor"
android:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
@ -186,7 +186,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_delete"
android:textColor="?attr/contextMenuButtonColor"
android:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
@ -222,7 +222,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_download"
android:textColor="?attr/contextMenuButtonColor"
android:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
@ -246,7 +246,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_delete"
android:textColor="?attr/contextMenuButtonColor"
android:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
@ -276,7 +276,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_others"
android:textColor="?attr/contextMenuButtonColor"
android:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>

View file

@ -25,6 +25,7 @@
<attr name="bg_point_editor_view" format="reference" />
<attr name="ctx_menu_info_view_bg" format="reference" />
<attr name="ctx_menu_controller_bg" format="reference" />
<attr name="ctx_menu_controller_text_color" format="reference" />
<attr name="bottom_menu_view_bg" format="reference" />
<attr name="left_menu_view_bg" format="reference" />

View file

@ -311,4 +311,24 @@
<color name="color_osm_edit_modify">#fac403</color>
<color name="color_osm_edit_delete">#ee5622</color>
<color name="ctx_menu_bg_light">#ffffff</color>
<color name="ctx_menu_bg_dark">#17191a</color>
<color name="ctx_menu_title_color_light">#212121</color>
<color name="ctx_menu_title_color_dark">#cccccc</color>
<color name="ctx_menu_subtitle_color">#727272</color>
<color name="ctx_menu_direction_color_light">#536dfe</color>
<color name="ctx_menu_direction_color_dark">#e69122</color>
<color name="ctx_menu_controller_button_text_color_light_n">#536dfe</color>
<color name="ctx_menu_controller_button_text_color_dark_n">#e69122</color>
<color name="ctx_menu_controller_button_text_color_light_p">#ffffff</color>
<color name="ctx_menu_controller_button_text_color_dark_p">#cccccc</color>
<color name="ctx_menu_controller_button_outline_color_light_n">#e6e6e6</color>
<color name="ctx_menu_controller_button_outline_color_light_p">#4c63e6</color>
<color name="ctx_menu_controller_button_outline_color_dark_n">#2d3133</color>
<color name="ctx_menu_controller_button_outline_color_dark_p">#b36a0b</color>
<color name="ctx_menu_controller_button_bg_color_light_n">#fafafa</color>
<color name="ctx_menu_controller_button_bg_color_light_p">#6d82fc</color>
<color name="ctx_menu_controller_button_bg_color_dark_n">#222526</color>
<color name="ctx_menu_controller_button_bg_color_dark_p">#d28521</color>
</resources>

View file

@ -132,6 +132,7 @@
<item name="dashboard_button">@drawable/dashboard_button_light</item>
<item name="ctx_menu_info_view_bg">@color/ctx_menu_info_view_bg_light</item>
<item name="ctx_menu_controller_bg">@drawable/context_menu_controller_bg_light</item>
<item name="ctx_menu_controller_text_color">@drawable/context_menu_controller_text_color_light</item>
<item name="search_background">@color/search_background_dark</item>
<item name="actionModeCloseDrawable">@drawable/ic_action_mode_back</item>
<item name="actionModeStyle">@style/WhiteActionMode</item>
@ -318,6 +319,7 @@
<item name="dashboard_button">@drawable/dashboard_button_dark</item>
<item name="ctx_menu_info_view_bg">@color/ctx_menu_info_view_bg_dark</item>
<item name="ctx_menu_controller_bg">@drawable/context_menu_controller_bg_dark</item>
<item name="ctx_menu_controller_text_color">@drawable/context_menu_controller_text_color_dark</item>
<item name="search_background">@color/color_white</item>
<item name="switch_ex_background">@drawable/switch_ex_background_dark</item>
<item name="switch_ex_text_color">@color/switch_ex_button_text_dark</item>

View file

@ -111,6 +111,12 @@ public abstract class DashLocationFragment extends DashBaseFragment {
}
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int imgColor, TextView txt, int textColor, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx) {
updateLocationView(useCenter, fromLoc, h, arrow, 0, imgColor, txt, textColor, new LatLon(toLat, toLon), screenOrientation, app, ctx, true);
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, TextView txt, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx) {
@ -120,11 +126,17 @@ public abstract class DashLocationFragment extends DashBaseFragment {
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, toLoc, screenOrientation, app, ctx, paint);
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, ctx, paint);
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, int color, TextView txt, LatLon toLoc,
ImageView arrow, int arrowResId, int imgColor, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, ctx, paint);
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, int imgColor, TextView txt, int textColor, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
float[] mes = new float[2];
if (fromLoc != null && toLoc != null) {
@ -142,7 +154,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
} else {
dd = (DirectionDrawable) arrow.getDrawable();
}
dd.setImage(arrowResId, color == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : color);
dd.setImage(arrowResId, imgColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : imgColor);
if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0);
} else {
@ -157,7 +169,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
if (fromLoc != null && toLoc != null) {
if (paint) {
txt.setTextColor(app.getResources().getColor(
useCenter ? R.color.color_distance : R.color.color_myloc_distance));
textColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : textColor));
}
txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app));
} else {

View file

@ -1056,9 +1056,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
public TitleButtonController getTopRightTitleButtonController() {
public TitleButtonController getBottomTitleButtonController() {
if (menuController != null) {
return menuController.getTopRightTitleButtonController();
return menuController.getBottomTitleButtonController();
} else {
return null;
}

View file

@ -9,6 +9,7 @@ import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.LayoutInflater;
@ -193,14 +194,14 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
});
// Top Right title button
final View topRightTitleButton = view.findViewById(R.id.title_button_bottom_view);
topRightTitleButton.setOnClickListener(new View.OnClickListener() {
// Bottom title button
final View bottomTitleButton = view.findViewById(R.id.title_button_bottom_view);
bottomTitleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TitleButtonController topRightTitleButtonController = menu.getTopRightTitleButtonController();
if (topRightTitleButtonController != null) {
topRightTitleButtonController.buttonPressed();
TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController();
if (bottomTitleButtonController != null) {
bottomTitleButtonController.buttonPressed();
}
}
});
@ -340,23 +341,17 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
buildHeader();
AndroidUtils.setTextPrimaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.context_menu_line1), nightMode);
((TextView) view.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(),
nightMode ? R.color.ctx_menu_title_color_dark : R.color.ctx_menu_title_color_light));
View menuLine2 = view.findViewById(R.id.context_menu_line2);
if (menuLine2 != null) {
AndroidUtils.setTextSecondaryColor(getMapActivity(), (TextView) menuLine2, nightMode);
((TextView) menuLine2).setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_subtitle_color));
}
((TextView) view.findViewById(R.id.title_button_bottom))
.setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) : getResources().getColor(R.color.osmand_orange));
AndroidUtils.setTextSecondaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.distance), nightMode);
((TextView) view.findViewById(R.id.distance)).setTextColor(ContextCompat.getColor(getContext(),
nightMode ? R.color.ctx_menu_direction_color_dark : R.color.ctx_menu_direction_color_light));
((TextView) view.findViewById(R.id.title_button))
.setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) : getResources().getColor(R.color.osmand_orange));
AndroidUtils.setTextSecondaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.title_button_right_text), nightMode);
((TextView) view.findViewById(R.id.title_button_right))
.setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) : getResources().getColor(R.color.osmand_orange));
AndroidUtils.setTextSecondaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.progressTitle), nightMode);
@ -660,7 +655,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
if (view != null) {
TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
TitleButtonController topRightTitleButtonController = menu.getTopRightTitleButtonController();
TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController();
TitleButtonController leftDownloadButtonController = menu.getLeftDownloadButtonController();
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
TitleProgressController titleProgressController = menu.getTitleProgressController();
@ -712,18 +707,18 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
rightTitleButtonView.setVisibility(View.INVISIBLE);
}
// Top Right title button
final View topRightTitleButtonView = view.findViewById(R.id.title_button_bottom_view);
final TextView topRightTitleButton = (TextView) view.findViewById(R.id.title_button_bottom);
if (topRightTitleButtonController != null) {
topRightTitleButton.setText(topRightTitleButtonController.caption);
topRightTitleButtonView.setVisibility(topRightTitleButtonController.visible ? View.VISIBLE : View.GONE);
// Bottom title button
final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view);
final TextView bottomTitleButton = (TextView) view.findViewById(R.id.title_button_bottom);
if (bottomTitleButtonController != null) {
bottomTitleButton.setText(bottomTitleButtonController.caption);
bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
Drawable leftIcon = topRightTitleButtonController.getLeftIcon();
topRightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
topRightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
bottomTitleButton.setCompoundDrawablePadding(dpToPx(8f));
} else {
topRightTitleButtonView.setVisibility(View.GONE);
bottomTitleButtonView.setVisibility(View.GONE);
}
// Download buttons
@ -1129,8 +1124,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
TextView distanceText = (TextView) view.findViewById(R.id.distance);
ImageView direction = (ImageView) view.findViewById(R.id.direction);
float myHeading = menu.getHeading() == null ? 0f : menu.getHeading();
DashLocationFragment.updateLocationView(false, menu.getMyLocation(), myHeading, direction, distanceText,
menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, app, activity);
int color = nightMode ? R.color.ctx_menu_direction_color_dark : R.color.ctx_menu_direction_color_light;
DashLocationFragment.updateLocationView(false, menu.getMyLocation(), myHeading, direction, color, distanceText,
color, menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, app, activity);
}
}

View file

@ -98,7 +98,7 @@ public abstract class MenuController extends BaseMenuController {
protected TitleButtonController leftTitleButtonController;
protected TitleButtonController rightTitleButtonController;
protected TitleButtonController topRightTitleButtonController;
protected TitleButtonController bottomTitleButtonController;
protected TitleButtonController leftDownloadButtonController;
protected TitleButtonController rightDownloadButtonController;
@ -318,8 +318,8 @@ public abstract class MenuController extends BaseMenuController {
return rightTitleButtonController;
}
public TitleButtonController getTopRightTitleButtonController() {
return topRightTitleButtonController;
public TitleButtonController getBottomTitleButtonController() {
return bottomTitleButtonController;
}
public TitleButtonController getLeftDownloadButtonController() {

View file

@ -134,7 +134,7 @@ public class MapDataMenuController extends MenuController {
rightDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
rightDownloadButtonController.leftIconId = R.drawable.ic_action_delete_dark;
topRightTitleButtonController = new TitleButtonController() {
bottomTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
getMapActivity().getContextMenu().close();
@ -158,7 +158,7 @@ public class MapDataMenuController extends MenuController {
mapActivity.getContextMenu().getLatLon(), selectedObjects);
}
};
topRightTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types);
bottomTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types);
titleProgressController = new TitleProgressController() {
@Override
@ -350,7 +350,7 @@ public class MapDataMenuController extends MenuController {
}
rightDownloadButtonController.visible = downloaded;
topRightTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0)
bottomTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0)
|| (otherLocalIndexInfos != null && otherLocalIndexInfos.size() > 0);
boolean internetConnectionAvailable =

View file

@ -7,6 +7,7 @@ import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
@ -200,12 +201,13 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
// Text line 1
TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);
AndroidUtils.setTextPrimaryColor(mapActivity, line1, !menu.isLight());
((TextView) view.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(),
!menu.isLight() ? R.color.ctx_menu_title_color_dark : R.color.ctx_menu_title_color_light));
line1.setText(item.getTitleStr());
// Text line 2
TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2);
AndroidUtils.setTextSecondaryColor(mapActivity, line2, !menu.isLight());
((TextView) line2).setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_subtitle_color));
line2.setText(item.getTypeStr());
Drawable slIcon = item.getTypeIcon();
line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null);