Fixed few UI bugs. Added three points button to markers dashboard
This commit is contained in:
parent
5cabbc46b5
commit
e475a9a31b
7 changed files with 134 additions and 40 deletions
|
@ -81,14 +81,14 @@
|
|||
android:id="@+id/marker_btn_ok"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_action_done"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/marker_btn_more"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_overflow_menu_white"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -158,14 +158,14 @@
|
|||
android:id="@+id/marker_btn_ok_2dn"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_action_done"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/marker_btn_more_2nd"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_overflow_menu_white"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -214,14 +214,14 @@
|
|||
android:id="@+id/marker_btn_ok"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_action_done"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/marker_btn_more"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_overflow_menu_white"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -295,7 +295,7 @@
|
|||
android:id="@+id/marker_btn_ok_2dn"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_action_done"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:paddingRight="16dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="48dp"
|
||||
|
@ -30,14 +29,28 @@
|
|||
style="@style/DashboardSubHeader"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<include layout="@layout/check_item_rel"/>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="16dp">
|
||||
|
||||
<include layout="@layout/check_item_rel"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/image_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_overflow_menu_white"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/header_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:layout_marginRight="-16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/shared_string_clear"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources>
|
||||
<!--
|
||||
Disclaimer:
|
||||
|
@ -9,6 +9,7 @@
|
|||
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
|
||||
-->
|
||||
<string name="shared_string_reverse_order">Reverse order</string>
|
||||
<string name="show_map_markers">Map Markers</string>
|
||||
<string name="show_map_markers_description">Activate Map Markers feature</string>
|
||||
<string name="clear_active_markers_q">Do you want to delete all active markers?</string>
|
||||
|
|
|
@ -166,6 +166,20 @@ public class MapMarkersHelper {
|
|||
return list;
|
||||
}
|
||||
|
||||
public void reverseActiveMarkersOrder() {
|
||||
cancelAddressRequests();
|
||||
|
||||
List<MapMarker> markers = new ArrayList<>(mapMarkers.size());
|
||||
for (int i = mapMarkers.size() - 1; i >= 0; i--) {
|
||||
MapMarker marker = mapMarkers.get(i);
|
||||
markers.add(marker);
|
||||
}
|
||||
mapMarkers = markers;
|
||||
saveMapMarkers(mapMarkers, mapMarkersHistory);
|
||||
readFromSettings();
|
||||
refresh();
|
||||
}
|
||||
|
||||
public void removeActiveMarkers() {
|
||||
cancelAddressRequests();
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ import net.osmand.plus.AppInitializer.InitEvents;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.BusyIndicator;
|
||||
import net.osmand.plus.FirstUsageFragment;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||
import net.osmand.plus.OsmAndConstants;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -102,7 +105,8 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
||||
ActivityCompat.OnRequestPermissionsResultCallback, IRouteInformationListener {
|
||||
ActivityCompat.OnRequestPermissionsResultCallback, IRouteInformationListener,
|
||||
MapMarkerChangedListener {
|
||||
public static final String INTENT_KEY_PARENT_MAP_ACTIVITY = "intent_parent_map_activity_key";
|
||||
|
||||
private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1;
|
||||
|
@ -557,6 +561,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
|||
}
|
||||
|
||||
routingHelper.addListener(this);
|
||||
app.getMapMarkersHelper().addListener(this);
|
||||
|
||||
getMyApplication().getAppCustomization().resumeActivity(MapActivity.class, this);
|
||||
if (System.currentTimeMillis() - tm > 50) {
|
||||
|
@ -790,6 +795,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
|||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
app.getMapMarkersHelper().removeListener(this);
|
||||
app.getRoutingHelper().removeListener(this);
|
||||
app.getDownloadThread().resetUiActivity(this);
|
||||
if (atlasMapRendererView != null) {
|
||||
|
@ -1145,6 +1151,16 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
|||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapMarkerChanged(MapMarker mapMarker) {
|
||||
refreshMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapMarkersChanged() {
|
||||
refreshMap();
|
||||
}
|
||||
|
||||
private class ScreenOffReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,11 +5,14 @@ import android.graphics.drawable.Drawable;
|
|||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.Shape;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
@ -18,6 +21,7 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -26,6 +30,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.views.DirectionDrawable;
|
||||
import net.osmand.plus.views.controls.ListDividerShape;
|
||||
import net.osmand.plus.views.controls.StableArrayAdapter;
|
||||
|
@ -196,15 +201,15 @@ public class MapMarkerDialogHelper {
|
|||
v.findViewById(R.id.check_item).setVisibility(View.GONE);
|
||||
v.findViewById(R.id.ProgressBar).setVisibility(View.GONE);
|
||||
|
||||
final Button btn = (Button) v.findViewById(R.id.header_button);
|
||||
btn.setTextColor(!nightMode ? mapActivity.getResources().getColor(R.color.map_widget_blue)
|
||||
: mapActivity.getResources().getColor(R.color.osmand_orange));
|
||||
btn.setText(mapActivity.getString(R.string.shared_string_clear));
|
||||
btn.setVisibility(View.VISIBLE);
|
||||
btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (type == MARKERS_HISTORY) {
|
||||
if (type == MARKERS_HISTORY) {
|
||||
final Button btn = (Button) v.findViewById(R.id.header_button);
|
||||
btn.setTextColor(!nightMode ? mapActivity.getResources().getColor(R.color.map_widget_blue)
|
||||
: mapActivity.getResources().getColor(R.color.osmand_orange));
|
||||
btn.setText(mapActivity.getString(R.string.shared_string_clear));
|
||||
btn.setVisibility(View.VISIBLE);
|
||||
btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
builder.setMessage(mapActivity.getString(R.string.clear_markers_history_q))
|
||||
.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
|
@ -221,26 +226,71 @@ public class MapMarkerDialogHelper {
|
|||
})
|
||||
.setNegativeButton(R.string.shared_string_no, null)
|
||||
.show();
|
||||
} else if (type == ACTIVE_MARKERS) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
builder.setMessage(mapActivity.getString(R.string.clear_active_markers_q))
|
||||
.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
listAdapter.notifyDataSetInvalidated();
|
||||
markersHelper.removeActiveMarkers();
|
||||
if (markersHelper.getMapMarkersHistory().size() == 0) {
|
||||
mapActivity.getDashboard().hideDashboard();
|
||||
} else {
|
||||
reloadListAdapter(listAdapter);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_no, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
} else if (type == ACTIVE_MARKERS) {
|
||||
final ImageButton btn = (ImageButton) v.findViewById(R.id.image_button);
|
||||
btn.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_overflow_menu_white, !nightMode));
|
||||
btn.setVisibility(View.VISIBLE);
|
||||
btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
final PopupMenu optionsMenu = new PopupMenu(mapActivity, v);
|
||||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||
MenuItem item;
|
||||
item = optionsMenu.getMenu().add(R.string.shared_string_clear)
|
||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_delete_dark, !nightMode));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
builder.setMessage(mapActivity.getString(R.string.clear_active_markers_q))
|
||||
.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
listAdapter.notifyDataSetInvalidated();
|
||||
markersHelper.removeActiveMarkers();
|
||||
if (markersHelper.getMapMarkersHistory().size() == 0) {
|
||||
mapActivity.getDashboard().hideDashboard();
|
||||
} else {
|
||||
reloadListAdapter(listAdapter);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_no, null)
|
||||
.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
item = optionsMenu.getMenu().add(R.string.shared_string_reverse_order).setIcon(
|
||||
iconsCache.getContentIcon(R.drawable.ic_action_undo_dark, !nightMode));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
markersHelper.reverseActiveMarkersOrder();
|
||||
reloadListAdapter(listAdapter);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
item = optionsMenu.getMenu().add(R.string.shared_string_save_as_gpx).setIcon(
|
||||
iconsCache.getContentIcon(R.drawable.ic_action_save, !nightMode));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
//
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
optionsMenu.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
TextView tv = (TextView) v.findViewById(R.id.header_text);
|
||||
AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode);
|
||||
|
|
Loading…
Reference in a new issue