Fix edit fav/wpt, share. multi-menu dark theme
This commit is contained in:
parent
942cdd8bc4
commit
4f307c70a2
10 changed files with 108 additions and 7 deletions
|
@ -50,6 +50,7 @@
|
|||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/editor_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/ctx_menu_info_view_bg"
|
||||
|
@ -211,6 +212,7 @@
|
|||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/description_info_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="350dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/left_menu_view_bg">
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?attr/left_menu_view_bg"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@
|
|||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/description_info_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
|
|
|
@ -96,4 +96,11 @@ public class AndroidUtils {
|
|||
ctx.getResources().getColor(R.color.secondary_text_dark)
|
||||
: 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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,16 +7,19 @@ import android.support.v7.app.AlertDialog;
|
|||
import android.support.v7.app.AlertDialog.Builder;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
|
||||
|
@ -35,7 +38,7 @@ import net.osmand.util.MapUtils;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
public class MapContextMenu extends MenuTitleController {
|
||||
public class MapContextMenu extends MenuTitleController implements StateChangedListener<ApplicationMode> {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private MapMultiSelectionMenu mapMultiSelectionMenu;
|
||||
|
@ -55,6 +58,8 @@ public class MapContextMenu extends MenuTitleController {
|
|||
private LatLon myLocation;
|
||||
private Float heading;
|
||||
private boolean inLocationUpdate = false;
|
||||
private boolean appModeChanged;
|
||||
private boolean appModeListenerAdded;
|
||||
|
||||
private int favActionIconId;
|
||||
|
||||
|
@ -67,6 +72,10 @@ public class MapContextMenu extends MenuTitleController {
|
|||
|
||||
public void setMapActivity(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
if (!appModeListenerAdded) {
|
||||
mapActivity.getMyApplication().getSettings().APPLICATION_MODE.addListener(this);
|
||||
appModeListenerAdded = true;
|
||||
}
|
||||
|
||||
if (mapMultiSelectionMenu == null) {
|
||||
mapMultiSelectionMenu = new MapMultiSelectionMenu(mapActivity);
|
||||
|
@ -199,6 +208,7 @@ public class MapContextMenu extends MenuTitleController {
|
|||
}
|
||||
|
||||
boolean needAcquireMenuController = menuController == null
|
||||
|| appModeChanged
|
||||
|| !update
|
||||
|| this.object == null && object != null
|
||||
|| this.object != null && object == null
|
||||
|
@ -208,6 +218,7 @@ public class MapContextMenu extends MenuTitleController {
|
|||
this.object = object;
|
||||
|
||||
active = true;
|
||||
appModeChanged = false;
|
||||
|
||||
if (needAcquireMenuController) {
|
||||
acquireMenuController();
|
||||
|
@ -232,7 +243,11 @@ public class MapContextMenu extends MenuTitleController {
|
|||
|
||||
public void show() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -295,6 +310,11 @@ public class MapContextMenu extends MenuTitleController {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(ApplicationMode change) {
|
||||
appModeChanged = active;
|
||||
}
|
||||
|
||||
private void clearSelectedObject(Object object) {
|
||||
if (object != null) {
|
||||
for (OsmandMapLayer l : mapActivity.getMapView().getLayers()) {
|
||||
|
|
|
@ -16,12 +16,14 @@ public abstract class PointEditor {
|
|||
|
||||
private boolean portraitMode;
|
||||
private boolean largeDevice;
|
||||
private boolean nightMode;
|
||||
|
||||
public PointEditor(MapActivity mapActivity) {
|
||||
this.app = mapActivity.getMyApplication();
|
||||
this.mapActivity = mapActivity;
|
||||
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
|
||||
updateNightMode();
|
||||
}
|
||||
|
||||
public void setMapActivity(MapActivity mapActivity) {
|
||||
|
@ -36,6 +38,14 @@ public abstract class PointEditor {
|
|||
return !portraitMode && !largeDevice;
|
||||
}
|
||||
|
||||
public boolean isLight() {
|
||||
return !nightMode;
|
||||
}
|
||||
|
||||
public void updateNightMode() {
|
||||
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode();
|
||||
}
|
||||
|
||||
public int getSlideInAnimation() {
|
||||
if (isLandscapeLayout()) {
|
||||
return R.anim.slide_in_left;
|
||||
|
|
|
@ -56,6 +56,32 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
|
||||
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.setTitle(getToolbarTitle());
|
||||
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);
|
||||
AndroidUtils.setTextPrimaryColor(view.getContext(), headerCaption, !getEditor().isLight());
|
||||
headerCaption.setText(getHeaderCaption());
|
||||
TextView nameCaption = (TextView) view.findViewById(R.id.name_caption);
|
||||
AndroidUtils.setTextSecondaryColor(view.getContext(), nameCaption, !getEditor().isLight());
|
||||
nameCaption.setText(getNameCaption());
|
||||
TextView categoryCaption = (TextView) view.findViewById(R.id.category_caption);
|
||||
AndroidUtils.setTextSecondaryColor(view.getContext(), categoryCaption, !getEditor().isLight());
|
||||
categoryCaption.setText(getCategoryCaption());
|
||||
|
||||
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());
|
||||
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
|
||||
AndroidUtils.setTextPrimaryColor(view.getContext(), categoryEdit, !getEditor().isLight());
|
||||
categoryEdit.setText(getCategoryInitValue());
|
||||
categoryEdit.setFocusable(false);
|
||||
categoryEdit.setOnTouchListener(new View.OnTouchListener() {
|
||||
|
@ -124,6 +156,8 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
});
|
||||
|
||||
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) {
|
||||
descriptionEdit.setText(getDescriptionInitValue());
|
||||
}
|
||||
|
@ -143,9 +177,8 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
|
||||
public Drawable getRowIcon(int iconId) {
|
||||
IconsCache iconsCache = getMyApplication().getIconsCache();
|
||||
boolean light = getMyApplication().getSettings().isLightContent();
|
||||
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
|
||||
|
|
|
@ -162,6 +162,7 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
|
||||
this.latLon = latLon;
|
||||
createCollection(selectedObjects);
|
||||
updateNightMode();
|
||||
MapMultiSelectionMenuFragment.showInstance(getMapActivity());
|
||||
getMapActivity().refreshMap();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import android.widget.ImageView;
|
|||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -44,6 +45,13 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
|
|||
menu = ((MapActivity) getActivity()).getContextMenu().getMultiSelectionMenu();
|
||||
|
||||
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);
|
||||
listAdapter = createAdapter();
|
||||
|
@ -134,6 +142,7 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
|
|||
|
||||
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();
|
||||
final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
|
||||
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
|
||||
TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);
|
||||
AndroidUtils.setTextPrimaryColor(mapActivity, line1, !menu.isLight());
|
||||
line1.setText(item.getTitleStr());
|
||||
|
||||
// Text line 2
|
||||
TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2);
|
||||
AndroidUtils.setTextSecondaryColor(mapActivity, line2, !menu.isLight());
|
||||
line2.setText(item.getTypeStr());
|
||||
Drawable slIcon = item.getTypeIcon();
|
||||
line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null);
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.widget.ImageView;
|
|||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
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) {
|
||||
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);
|
||||
listAdapter = createAdapter();
|
||||
listView.setAdapter(listAdapter);
|
||||
|
@ -88,11 +101,13 @@ public class ShareMenuFragment extends Fragment implements OnItemClickListener {
|
|||
if (v == 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);
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
icon.setImageDrawable(menu.getMapActivity().getMyApplication()
|
||||
.getIconsCache().getContentIcon(item.getIconResourceId()));
|
||||
.getIconsCache().getContentIcon(item.getIconResourceId(), menu.isLight()));
|
||||
TextView name = (TextView) v.findViewById(R.id.name);
|
||||
AndroidUtils.setTextPrimaryColor(v.getContext(), name, !menu.isLight());
|
||||
name.setText(getContext().getText(item.getTitleResourceId()));
|
||||
return v;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue