Fix edit fav/wpt, share. multi-menu dark theme

This commit is contained in:
Alexey Kulish 2015-12-15 16:48:24 +03:00
parent 942cdd8bc4
commit 4f307c70a2
10 changed files with 108 additions and 7 deletions

View file

@ -50,6 +50,7 @@
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>
<ScrollView <ScrollView
android:id="@+id/editor_scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/ctx_menu_info_view_bg" android:background="?attr/ctx_menu_info_view_bg"
@ -211,6 +212,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:id="@+id/description_info_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:baselineAligned="false" android:baselineAligned="false"

View file

@ -3,13 +3,14 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp" android:layout_width="350dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/left_menu_view_bg"> android:background="@android:color/transparent">
<LinearLayout <LinearLayout
android:id="@+id/main_view" android:id="@+id/main_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="?attr/left_menu_view_bg"
android:clickable="true" android:clickable="true"
android:orientation="vertical"> android:orientation="vertical">

View file

@ -208,6 +208,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:id="@+id/description_info_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:baselineAligned="false" android:baselineAligned="false"

View file

@ -96,4 +96,11 @@ public class AndroidUtils {
ctx.getResources().getColor(R.color.secondary_text_dark) ctx.getResources().getColor(R.color.secondary_text_dark)
: ctx.getResources().getColor(R.color.secondary_text_light)); : ctx.getResources().getColor(R.color.secondary_text_light));
} }
public static void setHintTextSecondaryColor(Context ctx, TextView textView, boolean night) {
textView.setHintTextColor(night ?
ctx.getResources().getColor(R.color.secondary_text_dark)
: ctx.getResources().getColor(R.color.secondary_text_light));
}
} }

View file

@ -7,16 +7,19 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder; import android.support.v7.app.AlertDialog.Builder;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.StateChangedListener;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState; import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
@ -35,7 +38,7 @@ import net.osmand.util.MapUtils;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
public class MapContextMenu extends MenuTitleController { public class MapContextMenu extends MenuTitleController implements StateChangedListener<ApplicationMode> {
private MapActivity mapActivity; private MapActivity mapActivity;
private MapMultiSelectionMenu mapMultiSelectionMenu; private MapMultiSelectionMenu mapMultiSelectionMenu;
@ -55,6 +58,8 @@ public class MapContextMenu extends MenuTitleController {
private LatLon myLocation; private LatLon myLocation;
private Float heading; private Float heading;
private boolean inLocationUpdate = false; private boolean inLocationUpdate = false;
private boolean appModeChanged;
private boolean appModeListenerAdded;
private int favActionIconId; private int favActionIconId;
@ -67,6 +72,10 @@ public class MapContextMenu extends MenuTitleController {
public void setMapActivity(MapActivity mapActivity) { public void setMapActivity(MapActivity mapActivity) {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
if (!appModeListenerAdded) {
mapActivity.getMyApplication().getSettings().APPLICATION_MODE.addListener(this);
appModeListenerAdded = true;
}
if (mapMultiSelectionMenu == null) { if (mapMultiSelectionMenu == null) {
mapMultiSelectionMenu = new MapMultiSelectionMenu(mapActivity); mapMultiSelectionMenu = new MapMultiSelectionMenu(mapActivity);
@ -199,6 +208,7 @@ public class MapContextMenu extends MenuTitleController {
} }
boolean needAcquireMenuController = menuController == null boolean needAcquireMenuController = menuController == null
|| appModeChanged
|| !update || !update
|| this.object == null && object != null || this.object == null && object != null
|| this.object != null && object == null || this.object != null && object == null
@ -208,6 +218,7 @@ public class MapContextMenu extends MenuTitleController {
this.object = object; this.object = object;
active = true; active = true;
appModeChanged = false;
if (needAcquireMenuController) { if (needAcquireMenuController) {
acquireMenuController(); acquireMenuController();
@ -232,7 +243,11 @@ public class MapContextMenu extends MenuTitleController {
public void show() { public void show() {
if (!isVisible()) { if (!isVisible()) {
if (!MapContextMenuFragment.showInstance(this, mapActivity)) { boolean wasInit = true;
if (appModeChanged) {
wasInit = init(latLon, pointDescription, object);
}
if (wasInit && !MapContextMenuFragment.showInstance(this, mapActivity)) {
active = false; active = false;
} }
} }
@ -295,6 +310,11 @@ public class MapContextMenu extends MenuTitleController {
} }
} }
@Override
public void stateChanged(ApplicationMode change) {
appModeChanged = active;
}
private void clearSelectedObject(Object object) { private void clearSelectedObject(Object object) {
if (object != null) { if (object != null) {
for (OsmandMapLayer l : mapActivity.getMapView().getLayers()) { for (OsmandMapLayer l : mapActivity.getMapView().getLayers()) {

View file

@ -16,12 +16,14 @@ public abstract class PointEditor {
private boolean portraitMode; private boolean portraitMode;
private boolean largeDevice; private boolean largeDevice;
private boolean nightMode;
public PointEditor(MapActivity mapActivity) { public PointEditor(MapActivity mapActivity) {
this.app = mapActivity.getMyApplication(); this.app = mapActivity.getMyApplication();
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity); portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity); largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
updateNightMode();
} }
public void setMapActivity(MapActivity mapActivity) { public void setMapActivity(MapActivity mapActivity) {
@ -36,6 +38,14 @@ public abstract class PointEditor {
return !portraitMode && !largeDevice; return !portraitMode && !largeDevice;
} }
public boolean isLight() {
return !nightMode;
}
public void updateNightMode() {
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode();
}
public int getSlideInAnimation() { public int getSlideInAnimation() {
if (isLandscapeLayout()) { if (isLandscapeLayout()) {
return R.anim.slide_in_left; return R.anim.slide_in_left;

View file

@ -56,6 +56,32 @@ public abstract class PointEditorFragment extends Fragment {
view = inflater.inflate(R.layout.point_editor_fragment, container, false); view = inflater.inflate(R.layout.point_editor_fragment, container, false);
getEditor().updateNightMode();
if (getEditor().isLandscapeLayout()) {
AndroidUtils.setBackground(view.getContext(), view, !getEditor().isLight(),
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} else {
AndroidUtils.setBackground(view.getContext(), view.findViewById(R.id.title_view), !getEditor().isLight(),
R.drawable.bg_point_editor_view_light, R.drawable.bg_point_editor_view_dark);
}
View editorScrollView = view.findViewById(R.id.editor_scroll_view);
if (editorScrollView != null) {
if (getEditor().isLight()) {
editorScrollView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_light));
} else {
editorScrollView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
}
}
View descriptionInfoView = view.findViewById(R.id.description_info_view);
if (descriptionInfoView != null) {
if (getEditor().isLight()) {
descriptionInfoView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_light));
} else {
descriptionInfoView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
}
}
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setTitle(getToolbarTitle()); toolbar.setTitle(getToolbarTitle());
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha)); toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
@ -99,15 +125,21 @@ public abstract class PointEditorFragment extends Fragment {
} }
TextView headerCaption = (TextView) view.findViewById(R.id.header_caption); TextView headerCaption = (TextView) view.findViewById(R.id.header_caption);
AndroidUtils.setTextPrimaryColor(view.getContext(), headerCaption, !getEditor().isLight());
headerCaption.setText(getHeaderCaption()); headerCaption.setText(getHeaderCaption());
TextView nameCaption = (TextView) view.findViewById(R.id.name_caption); TextView nameCaption = (TextView) view.findViewById(R.id.name_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), nameCaption, !getEditor().isLight());
nameCaption.setText(getNameCaption()); nameCaption.setText(getNameCaption());
TextView categoryCaption = (TextView) view.findViewById(R.id.category_caption); TextView categoryCaption = (TextView) view.findViewById(R.id.category_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), categoryCaption, !getEditor().isLight());
categoryCaption.setText(getCategoryCaption()); categoryCaption.setText(getCategoryCaption());
nameEdit = (EditText) view.findViewById(R.id.name_edit); nameEdit = (EditText) view.findViewById(R.id.name_edit);
AndroidUtils.setTextPrimaryColor(view.getContext(), nameEdit, !getEditor().isLight());
AndroidUtils.setHintTextSecondaryColor(view.getContext(), nameEdit, !getEditor().isLight());
nameEdit.setText(getNameInitValue()); nameEdit.setText(getNameInitValue());
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit); AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
AndroidUtils.setTextPrimaryColor(view.getContext(), categoryEdit, !getEditor().isLight());
categoryEdit.setText(getCategoryInitValue()); categoryEdit.setText(getCategoryInitValue());
categoryEdit.setFocusable(false); categoryEdit.setFocusable(false);
categoryEdit.setOnTouchListener(new View.OnTouchListener() { categoryEdit.setOnTouchListener(new View.OnTouchListener() {
@ -124,6 +156,8 @@ public abstract class PointEditorFragment extends Fragment {
}); });
EditText descriptionEdit = (EditText) view.findViewById(R.id.description_edit); EditText descriptionEdit = (EditText) view.findViewById(R.id.description_edit);
AndroidUtils.setTextPrimaryColor(view.getContext(), descriptionEdit, !getEditor().isLight());
AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, !getEditor().isLight());
if (getDescriptionInitValue() != null) { if (getDescriptionInitValue() != null) {
descriptionEdit.setText(getDescriptionInitValue()); descriptionEdit.setText(getDescriptionInitValue());
} }
@ -143,9 +177,8 @@ public abstract class PointEditorFragment extends Fragment {
public Drawable getRowIcon(int iconId) { public Drawable getRowIcon(int iconId) {
IconsCache iconsCache = getMyApplication().getIconsCache(); IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
return iconsCache.getIcon(iconId, return iconsCache.getIcon(iconId,
light ? R.color.icon_color : R.color.icon_color_light); getEditor().isLight() ? R.color.icon_color : R.color.icon_color_light);
} }
@Override @Override

View file

@ -162,6 +162,7 @@ public class MapMultiSelectionMenu extends BaseMenuController {
this.latLon = latLon; this.latLon = latLon;
createCollection(selectedObjects); createCollection(selectedObjects);
updateNightMode();
MapMultiSelectionMenuFragment.showInstance(getMapActivity()); MapMultiSelectionMenuFragment.showInstance(getMapActivity());
getMapActivity().refreshMap(); getMapActivity().refreshMap();
} }

View file

@ -19,6 +19,7 @@ import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -44,6 +45,13 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
menu = ((MapActivity) getActivity()).getContextMenu().getMultiSelectionMenu(); menu = ((MapActivity) getActivity()).getContextMenu().getMultiSelectionMenu();
view = inflater.inflate(R.layout.menu_obj_selection_fragment, container, false); view = inflater.inflate(R.layout.menu_obj_selection_fragment, container, false);
if (menu.isLandscapeLayout()) {
AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(),
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} else {
AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(),
R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
ListView listView = (ListView) view.findViewById(R.id.list); ListView listView = (ListView) view.findViewById(R.id.list);
listAdapter = createAdapter(); listAdapter = createAdapter();
@ -134,6 +142,7 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
private void buildHeader(View view, MenuObject item, MapActivity mapActivity) { private void buildHeader(View view, MenuObject item, MapActivity mapActivity) {
AndroidUtils.setBackground(mapActivity, view, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache(); IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
final View iconLayout = view.findViewById(R.id.context_menu_icon_layout); final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view); final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
@ -152,10 +161,12 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
// Text line 1 // Text line 1
TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1); TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);
AndroidUtils.setTextPrimaryColor(mapActivity, line1, !menu.isLight());
line1.setText(item.getTitleStr()); line1.setText(item.getTitleStr());
// Text line 2 // Text line 2
TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2); TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2);
AndroidUtils.setTextSecondaryColor(mapActivity, line2, !menu.isLight());
line2.setText(item.getTypeStr()); line2.setText(item.getTypeStr());
Drawable slIcon = item.getTypeIcon(); Drawable slIcon = item.getTypeIcon();
line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null); line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null);

View file

@ -14,6 +14,7 @@ import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.other.ShareMenu.ShareItem; import net.osmand.plus.mapcontextmenu.other.ShareMenu.ShareItem;
@ -40,6 +41,18 @@ public class ShareMenuFragment extends Fragment implements OnItemClickListener {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.share_menu_fragment, container, false); View view = inflater.inflate(R.layout.share_menu_fragment, container, false);
View mainView = view.findViewById(R.id.main_view);
if (menu.isLandscapeLayout()) {
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} else {
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
TextView headerCaption = (TextView) view.findViewById(R.id.header_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), headerCaption, !menu.isLight());
ListView listView = (ListView) view.findViewById(R.id.list); ListView listView = (ListView) view.findViewById(R.id.list);
listAdapter = createAdapter(); listAdapter = createAdapter();
listView.setAdapter(listAdapter); listView.setAdapter(listAdapter);
@ -88,11 +101,13 @@ public class ShareMenuFragment extends Fragment implements OnItemClickListener {
if (v == null) { if (v == null) {
v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.share_list_item, null); v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.share_list_item, null);
} }
AndroidUtils.setBackground(v.getContext(), v, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
final ShareItem item = getItem(position); final ShareItem item = getItem(position);
ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageView icon = (ImageView) v.findViewById(R.id.icon);
icon.setImageDrawable(menu.getMapActivity().getMyApplication() icon.setImageDrawable(menu.getMapActivity().getMyApplication()
.getIconsCache().getContentIcon(item.getIconResourceId())); .getIconsCache().getContentIcon(item.getIconResourceId(), menu.isLight()));
TextView name = (TextView) v.findViewById(R.id.name); TextView name = (TextView) v.findViewById(R.id.name);
AndroidUtils.setTextPrimaryColor(v.getContext(), name, !menu.isLight());
name.setText(getContext().getText(item.getTitleResourceId())); name.setText(getContext().getText(item.getTitleResourceId()));
return v; return v;
} }