Create UI for MapillaryMenu

This commit is contained in:
Alexander Sytnyk 2017-06-15 17:53:24 +03:00
parent 73f5c0d0cc
commit 4927ad0d34
6 changed files with 279 additions and 0 deletions

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color">
<Button
android:id="@+id/button_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:background="?attr/selectableItemBackground"
android:text="@string/shared_string_apply"
android:textColor="?attr/color_dialog_buttons" />
<Button
android:id="@+id/button_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="?attr/selectableItemBackground"
android:text="@string/shared_string_clear"
android:textColor="?attr/color_dialog_buttons" />
</RelativeLayout>
<include layout="@layout/card_bottom_divider" />
<View
android:layout_width="match_parent"
android:layout_height="18dp" />
</LinearLayout>

View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical"
android:paddingLeft="56dp"
android:paddingStart="56dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/from_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_weight="1"
android:text="@string/mapillary_menu_date_from"
tools:text="From" />
<android.support.v7.widget.AppCompatTextView
android:id="@+id/to_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_weight="1"
android:text="@string/mapillary_menu_date_to"
tools:text="To" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp">
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/to_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_weight="1" />
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/from_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_weight="1" />
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginTop="16dp"
android:background="?attr/dashboard_divider" />
</LinearLayout>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical"
android:paddingLeft="56dp"
android:paddingStart="56dp">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:hint="@string/mapillary_menu_edit_text_hint"
android:textSize="@dimen/default_list_text_size" />
<View
android:id="@+id/divider"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginTop="12dp"
android:background="?attr/dashboard_divider" />
</LinearLayout>

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="60dp">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
tools:src="@drawable/ic_action_user" />
<LinearLayout
android:id="@+id/text_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:minHeight="60dp"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingTop="10dp">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="Username" />
<android.support.v7.widget.AppCompatTextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:lines="1"
android:textSize="@dimen/default_desc_text_size"
tools:text="View images added by a certain user." />
</LinearLayout>
</LinearLayout>

View file

@ -9,6 +9,14 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="mapillary_menu_date_to">To</string>
<string name="mapillary_menu_date_from">From</string>
<string name="mapillary_menu_descr_dates">View images added in a certain period.</string>
<string name="mapillary_menu_title_dates">Dates</string>
<string name="mapillary_menu_edit_text_hint">Type user name</string>
<string name="mapillary_menu_descr_username">View images added by a certain user.</string>
<string name="mapillary_menu_title_username">Username</string>
<string name="mapillary_menu_filter_description">You can filter images by the name of the user or by the date.</string>
<string name="map_widget_ruler_control_first_mode">Connection mode</string> <string name="map_widget_ruler_control_first_mode">Connection mode</string>
<string name="map_widget_ruler_control_second_mode">Radius mode</string> <string name="map_widget_ruler_control_second_mode">Radius mode</string>
<string name="shared_string_permissions">Permissions</string> <string name="shared_string_permissions">Permissions</string>

View file

@ -1,6 +1,12 @@
package net.osmand.plus.mapillary; package net.osmand.plus.mapillary;
import android.widget.ArrayAdapter;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -9,6 +15,88 @@ public class MapillaryMenu {
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) { public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) {
ContextMenuAdapter adapter = new ContextMenuAdapter(); ContextMenuAdapter adapter = new ContextMenuAdapter();
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu); adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
createLayersItems(adapter, mapActivity);
return adapter; return adapter;
} }
private static void createLayersItems(final ContextMenuAdapter contextMenuAdapter, final MapActivity mapActivity) {
final OsmandApplication app = mapActivity.getMyApplication();
final OsmandSettings settings = app.getSettings();
final MapillaryPlugin plugin = OsmandPlugin.getPlugin(MapillaryPlugin.class);
if (plugin == null) {
return;
}
final boolean selected = settings.SHOW_MAPILLARY.get();
final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled;
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
if (itemId == toggleActionStringId) {
settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
mapActivity.getDashboard().refreshContent(true);
}
return false;
}
};
boolean light = settings.isLightContent();
int toggleIconColorId;
int toggleIconId;
if (selected) {
toggleIconId = R.drawable.ic_action_view;
toggleIconColorId = light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark;
} else {
toggleIconId = R.drawable.ic_action_hide;
toggleIconColorId = light ? R.color.icon_color : 0;
}
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(toggleActionStringId, mapActivity)
.setIcon(toggleIconId)
.setColor(toggleIconColorId)
.setListener(l)
.setSelected(selected)
.createItem());
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.search_poi_filter, mapActivity)
.setDescription(app.getString(R.string.mapillary_menu_filter_description))
.setCategory(true)
.setLayout(R.layout.list_group_title_with_descr)
.createItem());
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.mapillary_menu_title_username, mapActivity)
.setDescription(app.getString(R.string.mapillary_menu_descr_username))
.setIcon(R.drawable.ic_action_user)
.setClickable(false)
.setLayout(R.layout.list_item_icon_with_title_and_descr)
.createItem());
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setLayout(R.layout.list_item_edit_text)
.setClickable(false)
.createItem());
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.mapillary_menu_title_dates, mapActivity)
.setDescription(app.getString(R.string.mapillary_menu_descr_dates))
.setIcon(R.drawable.ic_action_data)
.setClickable(false)
.setLayout(R.layout.list_item_icon_with_title_and_descr)
.createItem());
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setLayout(R.layout.list_item_date_spinners)
.setClickable(false)
.createItem());
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setLayout(R.layout.list_item_buttons)
.setClickable(false)
.createItem());
}
} }