Fix icons, fix options menu on different devices, update imports

This commit is contained in:
Victor Shcherb 2013-05-17 01:38:25 +02:00
parent 08bf284fff
commit 52f7df8677
120 changed files with 325 additions and 313 deletions

View file

@ -1414,6 +1414,10 @@ public class OsmandSettings {
return OSMAND_THEME.get() == OSMAND_LIGHT_THEME;
}
public boolean isLightContent(){
return OSMAND_THEME.get() != OSMAND_DARK_THEME;
}
public final CommonPreference<Boolean> FLUORESCENT_OVERLAYS =
new BooleanPreference("fluorescent_overlays", false).makeGlobal().cache();

View file

@ -21,7 +21,7 @@
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<!-- android:theme="@style/OsmandLightDarkActionBarTheme" -->
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true" android:name="net.osmand.plus.OsmandApplication"
android:debuggable="true" android:name="net.osmand.plus.OsmandApplication" android:configChanges="locale"
android:theme="@style/OsmandDarkTheme"
android:backupAgent="net.osmand.plus.OsmandBackupAgent" android:restoreAnyVersion="true">

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dip"
android:layout_marginTop="12dip"
android:layout_marginBottom="12dip"
android:gravity="center_vertical"
android:text="@string/layer_poi"
android:textSize="18sp"
android:layout_weight="1"/>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="fill_parent">
<CheckBox
android:id="@+id/check_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dip"
android:layout_marginRight="2dip"
android:button="@drawable/ic_btn_wocheckbox"
android:focusable="false"
android:gravity="center_vertical" />
</LinearLayout>
</LinearLayout>

View file

@ -64,7 +64,7 @@
\n\tЧтобы получить достоверные данные необходимо загрузить WW15MGH.DAC через менеджер загрузок (оригинал - http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/binary/WW15MGH.DAC).
</string>
<string name="no_buildings_found">Здания не найдены.</string>
<string name="no_buildings_found">Здания не найдены</string>
<string name="incremental_search_city">Выберите город</string>
<string name="search_villages_and_postcodes">Поиск по деревням и почт. индексу</string>
<string name="rendering_attr_showRoadMaps_description">Выберите как отображать только дорожные карты:</string>
@ -707,8 +707,8 @@
<string name="map_specify_point">Координаты</string>
<string name="show_view_angle_descr">Показывать угол обзора в соответствии с компасом</string>
<string name="show_view_angle">Угол обзора</string>
<string name="stop_navigation">Снять отметку.</string>
<string name="navigate_to_point">Отметить точку.</string>
<string name="stop_navigation">Снять отметку</string>
<string name="navigate_to_point">Отметить точку</string>
<string name="map_view_3d_descr">Включить 3D вид для карты</string>
<string name="map_view_3d">3D вид</string>
<string name="show_poi_over_map_description">Показывать слой POI</string>

View file

@ -1,7 +1,6 @@
package net.osmand.access;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import android.content.Context;
import android.text.Layout;
import android.text.method.ArrowKeyMovementMethod;

View file

@ -1,6 +1,5 @@
package net.osmand.access;
import net.osmand.access.AccessibilityActionsProvider;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.OsmandMapTileView;
import android.os.Build;

View file

@ -4,8 +4,15 @@ import gnu.trove.list.array.TIntArrayList;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ListAdapter;
import android.widget.TextView;
public class ContextMenuAdapter {
@ -53,6 +60,14 @@ public class ContextMenuAdapter {
registerSelectedItem(stringResId, -1, icon, listener, pos);
}
public void registerItem(int stringResId, int icon, OnContextMenuClick listener) {
registerSelectedItem(stringResId, -1, icon, listener, -1);
}
public void registerItem(int stringResId, OnContextMenuClick listener) {
registerSelectedItem(stringResId, -1, 0, listener, -1);
}
public void registerSelectedItem(int stringResId, int selected, int icon, OnContextMenuClick listener, int pos) {
if(pos >= items.size() || pos < 0) {
@ -81,4 +96,34 @@ public class ContextMenuAdapter {
return itemNames.toArray(new String[itemNames.size()]);
}
public ListAdapter createListAdapter(final Activity activity, final int layoutId) {
final int padding = (int) (12 * activity.getResources().getDisplayMetrics().density + 0.5f);
ListAdapter listadapter = new ArrayAdapter<String>(activity, layoutId, R.id.title,
getItemNames()) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// User super class to create the View
View v = convertView;
if (v == null) {
v = activity.getLayoutInflater().inflate(layoutId, null);
}
TextView tv = (TextView) v.findViewById(R.id.title);
tv.setText(getItemName(position));
// Put the image on the TextView
if (getImageId(position) != 0) {
tv.setCompoundDrawablesWithIntrinsicBounds(getImageId(position), 0, 0, 0);
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.list_activities_transparent, 0, 0, 0);
}
tv.setCompoundDrawablePadding(padding);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
ch.setVisibility(View.GONE);
return v;
}
};
return listadapter;
}
}

View file

@ -5,7 +5,6 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.osmand.GeoidAltitudeCorrection;
import net.osmand.PlatformUtil;
import net.osmand.access.NavigationInfo;
@ -59,7 +58,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
private final boolean USE_KALMAN_FILTER = true;
private final boolean USE_KALMAN_FILTER = false;
private final float KALMAN_COEFFICIENT = 0.02f;
float avgValSin = 0;
@ -321,7 +320,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
float valRad = (float) (val / 180f * Math.PI);
lastValSin = (float) Math.sin(valRad);
lastValCos = (float) Math.cos(valRad);
lastHeadingCalcTime = System.currentTimeMillis();
// lastHeadingCalcTime = System.currentTimeMillis();
if(heading == null && previousCompassIndA == 0) {
Arrays.fill(previousCompassValuesA, lastValSin);
Arrays.fill(previousCompassValuesB, lastValCos);
@ -353,14 +352,13 @@ public class OsmAndLocationProvider implements SensorEventListener {
}
public Float getHeading() {
if (heading != null && lastValSin != avgValSin && System.currentTimeMillis() - lastHeadingCalcTime > 700) {
avgValSin = lastValSin;
avgValCos = lastValCos;
lastHeadingCalcTime = System.currentTimeMillis();
Arrays.fill(previousCompassValuesA, avgValSin);
Arrays.fill(previousCompassValuesB, avgValCos);
updateCompassVal();
}
// if (heading != null && lastValSin != avgValSin && System.currentTimeMillis() - lastHeadingCalcTime > 700) {
// avgValSin = lastValSin;
// avgValCos = lastValCos;
// Arrays.fill(previousCompassValuesA, avgValSin);
// Arrays.fill(previousCompassValuesB, avgValCos);
// updateCompassVal();
// }
return heading;
}

View file

@ -6,12 +6,10 @@ import java.util.List;
import net.osmand.CallbackWithObject;
import net.osmand.Location;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RouteProvider.GPXRouteParams;
import net.osmand.plus.routing.RoutingHelper;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;

View file

@ -11,11 +11,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.SherlockExpandableListActivity;
import com.actionbarsherlock.app.SherlockListActivity;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.PlatformUtil;
@ -63,6 +58,11 @@ import android.os.Message;
import android.text.format.DateFormat;
import android.widget.Toast;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.SherlockExpandableListActivity;
import com.actionbarsherlock.app.SherlockListActivity;
public class OsmandApplication extends Application implements ClientContext {
public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$
@ -717,6 +717,7 @@ public class OsmandApplication extends Application implements ClientContext {
} else if (osmandSettings.OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_DARK_ACTIONBAR_THEME) {
t = R.style.OsmandLightDarkActionBarTheme;
}
setLanguage(c);
c.setTheme(t);
if (osmandSettings.OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_DARK_ACTIONBAR_THEME
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
@ -736,4 +737,17 @@ public class OsmandApplication extends Application implements ClientContext {
}
}
public void setLanguage(Context context) {
if (prefferedLocale != null) {
Configuration config = context.getResources().getConfiguration();
String lang = prefferedLocale.getLanguage();
if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
prefferedLocale = new Locale(lang);
Locale.setDefault(prefferedLocale);
config.locale = prefferedLocale;
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
}
}
}
}

View file

@ -1,6 +1,7 @@
package net.osmand.plus;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@ -132,7 +133,7 @@ public abstract class OsmandPlugin {
public void registerMapContextMenuActions(MapActivity mapActivity, double latitude, double longitude, ContextMenuAdapter adapter, Object selectedObj) {}
public void registerOptionsMenuItems(MapActivity mapActivity, OptionsMenuHelper helper) {}
public void registerOptionsMenuItems(MapActivity mapActivity, ContextMenuAdapter helper) {}
public void loadLocalIndexes(List<LocalIndexInfo> result, LoadLocalIndexTask loadTask) {};
@ -243,7 +244,7 @@ public abstract class OsmandPlugin {
}
}
public static void registerOptionsMenu(MapActivity map, OptionsMenuHelper helper) {
public static void registerOptionsMenu(MapActivity map, ContextMenuAdapter helper) {
for (OsmandPlugin plugin : activePlugins) {
plugin.registerOptionsMenuItems(map, helper);
}

View file

@ -24,7 +24,6 @@ import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;

View file

@ -9,7 +9,6 @@ import net.osmand.map.ITileSource;
import net.osmand.map.MapTileDownloader;
import net.osmand.map.MapTileDownloader.DownloadRequest;
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
import net.osmand.util.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.Version;
@ -17,6 +16,7 @@ import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.views.BaseMapLayer;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;

View file

@ -25,7 +25,6 @@ import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.util.MapUtils;

View file

@ -1,7 +1,6 @@
package net.osmand.plus.activities;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.text.TextPaint;
import android.util.AttributeSet;

View file

@ -4,11 +4,11 @@ import java.util.List;
import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.data.LatLon;
import net.osmand.util.MapUtils;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.util.MapUtils;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;

View file

@ -13,8 +13,6 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import com.ibm.icu.text.DateFormat;
import net.osmand.IndexConstants;
import net.osmand.binary.BinaryIndexPart;
import net.osmand.binary.BinaryMapAddressReaderAdapter.AddressRegion;
@ -26,7 +24,6 @@ import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex;
import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.util.MapUtils;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.Track;
@ -40,9 +37,12 @@ import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask;
import net.osmand.plus.voice.MediaCommandPlayerImpl;
import net.osmand.plus.voice.TTSCommandPlayerImpl;
import net.osmand.util.MapUtils;
import android.content.Context;
import android.os.Build;
import com.ibm.icu.text.DateFormat;
public class LocalIndexHelper {
private final OsmandApplication app;

View file

@ -53,8 +53,6 @@ import android.os.Message;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
@ -108,9 +106,12 @@ public class MapActivity extends AccessibleActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = getMyApplication();
settings = app.getSettings();
app.applyTheme(this);
super.onCreate(savedInstanceState);
mapActions = new MapActivityActions(this);
mapLayers = new MapActivityLayers(this);
requestWindowFeature(Window.FEATURE_NO_TITLE);
@ -380,6 +381,9 @@ public class MapActivity extends AccessibleActivity {
uiHandler.sendMessageDelayed(msg, LONG_KEYPRESS_DELAY);
}
return true;
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
mapActions.openOptionsMenuAsList();
return true;
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
Intent newIntent = new Intent(MapActivity.this, OsmandIntents.getSearchActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@ -616,24 +620,6 @@ public class MapActivity extends AccessibleActivity {
return mapViewTrackingUtilities;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return mapActions.onCreateOptionsMenu(menu);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
boolean val = super.onPrepareOptionsMenu(menu);
mapActions.onPrepareOptionsMenu(menu);
return val;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return mapActions.onOptionsItemSelected(item) == true ? true : super.onOptionsItemSelected(item);
}
protected void parseLaunchIntentLocation(){
Intent intent = getIntent();
if (intent != null && intent.getData() != null) {
@ -684,4 +670,5 @@ public class MapActivity extends AccessibleActivity {
}
}

View file

@ -31,8 +31,6 @@ import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OptionsMenuHelper;
import net.osmand.plus.OptionsMenuHelper.OnOptionsMenuClick;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@ -70,11 +68,8 @@ import android.text.ClipboardManager;
import android.text.Html;
import android.util.FloatMath;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
@ -111,7 +106,6 @@ public class MapActivityActions implements DialogProvider {
private final MapActivity mapActivity;
private OsmandSettings settings;
private RoutingHelper routingHelper;
private OptionsMenuHelper optionsMenuHelper;
public MapActivityActions(MapActivity mapActivity){
@ -812,7 +806,7 @@ public class MapActivityActions implements DialogProvider {
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter(mapActivity) : iadapter;
Builder builder = new AlertDialog.Builder(mapActivity);
adapter.registerItem(R.string.context_menu_item_navigate_point, R.drawable.list_activities_set_destination);
final TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
@ -827,34 +821,9 @@ public class MapActivityActions implements DialogProvider {
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
final int padding = (int) (12 * mapActivity.getResources().getDisplayMetrics().density + 0.5f);
ListAdapter listadapter = new ArrayAdapter<String>(mapActivity, R.layout.list_menu_item, R.id.title,
adapter.getItemNames()) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// User super class to create the View
View v = convertView;
if (v == null) {
v = mapActivity.getLayoutInflater().inflate(R.layout.list_menu_item, null);
}
TextView tv = (TextView) v.findViewById(R.id.title);
tv.setText(adapter.getItemName(position));
// Put the image on the TextView
if (adapter.getImageId(position) != 0) {
tv.setCompoundDrawablesWithIntrinsicBounds(adapter.getImageId(position), 0, 0, 0);
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.list_activities_transparent, 0, 0, 0);
}
tv.setCompoundDrawablePadding(padding);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
ch.setVisibility(View.GONE);
return v;
}
};
builder.setAdapter(listadapter, new DialogInterface.OnClickListener() {
final Builder builder = new AlertDialog.Builder(mapActivity);
ListAdapter listAdapter = adapter.createListAdapter(mapActivity, R.layout.list_menu_item);
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -987,112 +956,92 @@ public class MapActivityActions implements DialogProvider {
}
}
public boolean onCreateOptionsMenu(Menu menu) {
public void openOptionsMenuAsList() {
final ContextMenuAdapter cm = createOptionsMenu();
final Builder bld = new AlertDialog.Builder(mapActivity);
ListAdapter listAdapter = cm.createListAdapter(mapActivity, R.layout.list_menu_item_native);
bld.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick click = cm.getClickAdapter(which);
if (click != null) {
click.onContextMenuClick(cm.getItemId(which), which, false, dialog);
}
}
});
bld.show();
}
private ContextMenuAdapter createOptionsMenu() {
final OsmandMapTileView mapView = mapActivity.getMapView();
final OsmandApplication app = mapActivity.getMyApplication();
optionsMenuHelper = new OptionsMenuHelper();
optionsMenuHelper.registerOptionsMenuItem(R.string.where_am_i, R.string.where_am_i, android.R.drawable.ic_menu_mylocation,
new OnOptionsMenuClick() {
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
boolean light = app.getSettings().isLightContent();
optionsMenuHelper.registerItem(R.string.where_am_i,
light ? R.drawable.a_10_device_access_location_found_light : R.drawable.a_10_device_access_location_found_dark,
new OnContextMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
}
@Override
public boolean onClick(MenuItem item) {
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (getMyApplication().getInternalAPI().accessibilityEnabled()) {
whereAmIDialog();
} else {
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
}
return true;
}
});
optionsMenuHelper.registerOptionsMenuItem(R.string.menu_layers, R.string.menu_layers, android.R.drawable.ic_menu_mapmode,
new OnOptionsMenuClick() {
optionsMenuHelper.registerItem(R.string.menu_layers,
light ? R.drawable.a_7_location_map_light : R.drawable.a_7_location_map_dark,
new OnContextMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
}
@Override
public boolean onClick(MenuItem item) {
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
mapActivity.getMapLayers().openLayerSelectionDialog(mapView);
return true;
}
});
optionsMenuHelper.registerOptionsMenuItem(R.string.settings_Button, R.string.settings_Button, android.R.drawable.ic_menu_preferences,
new OnOptionsMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
}
@Override
public boolean onClick(MenuItem item) {
final Intent intentSettings = new Intent(mapActivity, OsmandIntents.getSettingsActivity());
mapActivity.startActivity(intentSettings);
return true;
}
});
optionsMenuHelper.registerOptionsMenuItem(R.string.stop_navigation, R.string.stop_navigation, android.R.drawable.ic_menu_close_clear_cancel, false,
new OnOptionsMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem navigateToPointMenu) {
if (mapActivity.getPointToNavigate() != null) {
navigateToPointMenu.setTitle((routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() ||
routingHelper.isRouteBeingCalculated()) ? R.string.stop_routing : R.string.stop_navigation);
navigateToPointMenu.setVisible(true);
} else {
navigateToPointMenu.setVisible(false);
}
}
@Override
public boolean onClick(MenuItem item) {
stopNavigationActionConfirm(mapView);
return true;
}
});
optionsMenuHelper.registerOptionsMenuItem(R.string.menu_mute_off, R.string.menu_mute_off, false, new OnOptionsMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem muteMenu) {
if (routingHelper.getFinalLocation() != null && routingHelper.isFollowingMode()) {
boolean muteVisible = routingHelper.getFinalLocation() != null && routingHelper.isFollowingMode();
if (muteVisible) {
boolean mute = routingHelper.getVoiceRouter().isMute();
muteMenu.setTitle(mute ? R.string.menu_mute_on : R.string.menu_mute_off);
muteMenu.setIcon(mute ? R.drawable.ic_menu_soundoff : R.drawable.ic_menu_soundon);
muteMenu.setVisible(true);
int t = mute ? R.string.menu_mute_on : R.string.menu_mute_off;
int icon;
if(mute) {
icon = light ? R.drawable.a_10_device_access_volume_muted_light: R.drawable.a_10_device_access_volume_muted_dark;
} else{
muteMenu.setVisible(false);
icon = light ? R.drawable.a_10_device_access_volume_on_light: R.drawable.a_10_device_access_volume_on_dark;
}
}
optionsMenuHelper.registerItem(t, icon, new OnContextMenuClick() {
@Override
public boolean onClick(MenuItem item) {
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute());
return true;
}
});
optionsMenuHelper.registerOptionsMenuItem(R.string.get_directions, R.string.get_directions, android.R.drawable.ic_menu_directions,
new OnOptionsMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem directions) {
if(routingHelper.isRouteCalculated()){
directions.setTitle(R.string.show_route);
} else {
directions.setTitle(R.string.get_directions);
}
}
optionsMenuHelper.registerItem(routingHelper.isRouteCalculated() ? R.string.show_route: R.string.get_directions,
light ? R.drawable.a_7_location_directions_light : R.drawable.a_7_location_directions_dark,
new OnContextMenuClick() {
@Override
public boolean onClick(MenuItem item) {
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (routingHelper.isRouteCalculated()) {
aboutRoute();
} else {
getDirections(null, null, true);
}
return true;
}
});
optionsMenuHelper.registerOptionsMenuItem(R.string.search_button, R.string.search_button, android.R.drawable.ic_menu_search, new OnOptionsMenuClick() {
optionsMenuHelper.registerItem(R.string.settings_Button,
light ? R.drawable.a_ic_menu_settings_light : R.drawable.a_ic_menu_settings_dark,
new OnContextMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
final Intent intentSettings = new Intent(mapActivity, OsmandIntents.getSettingsActivity());
mapActivity.startActivity(intentSettings);
}
});
optionsMenuHelper.registerItem(R.string.search_button,
light ? R.drawable.a_2_action_search_light : R.drawable.a_2_action_search_dark,
new OnContextMenuClick() {
@Override
public boolean onClick(MenuItem item) {
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
Intent newIntent = new Intent(mapActivity, OsmandIntents.getSearchActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
LatLon loc = mapActivity.getMapLocation();
@ -1100,72 +1049,78 @@ public class MapActivityActions implements DialogProvider {
newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mapActivity.startActivity(newIntent);
return true;
}
});
optionsMenuHelper.registerOptionsMenuItem(R.string.target_points, R.string.target_points, new OnOptionsMenuClick() {
optionsMenuHelper.registerItem(R.string.favorites_Button,
light ? R.drawable.a_3_rating_important_light : R.drawable.a_3_rating_important_dark,
new OnContextMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
item.setVisible(getTargets().getIntermediatePoints().size() > 0);
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
Intent newIntent = new Intent(mapActivity, OsmandIntents.getFavoritesActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
}
});
if (mapActivity.getPointToNavigate() != null) {
int nav = (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) ?
R.string.stop_routing : R.string.stop_navigation;
optionsMenuHelper.registerItem(nav,
light ? R.drawable.a_1_navigation_cancel_light : R.drawable.a_1_navigation_cancel_dark,
new OnContextMenuClick() {
@Override
public boolean onClick(MenuItem item) {
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
stopNavigationActionConfirm(mapView);
}
});
}
if (getTargets().getPointToNavigate() != null) {
optionsMenuHelper.registerItem(R.string.target_points,
light ? R.drawable.a_9_av_make_available_offline_light : R.drawable.a_9_av_make_available_offline_dark,
new OnContextMenuClick() {
@Override
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
openIntermediatePointsDialog();
return true;
}
});
if (Version.isGpsStatusEnabled(app) && !Version.isBlackberry(app)) {
optionsMenuHelper.registerOptionsMenuItem(R.string.show_gps_status, R.string.show_gps_status,
android.R.drawable.ic_menu_compass, new OnOptionsMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
}
@Override
public boolean onClick(MenuItem item) {
startGpsStatusIntent();
return false;
}
});
}
optionsMenuHelper.registerOptionsMenuItem(R.string.show_point_options, R.string.show_point_options, new OnOptionsMenuClick() {
optionsMenuHelper.registerItem(R.string.show_point_options,
light ? R.drawable.a_7_location_place_light : R.drawable.a_7_location_place_dark,
new OnContextMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem item) {
}
@Override
public boolean onClick(MenuItem item) {
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
return true;
}
});
final OsmAndLocationProvider loc = app.getLocationProvider();
optionsMenuHelper.registerOptionsMenuItem(R.string.animate_route, R.string.animate_route, false, new OnOptionsMenuClick() {
@Override
public void prepareOptionsMenu(Menu menu, MenuItem animateMenu) {
animateMenu.setTitle(loc.getLocationSimulation().isRouteAnimating() ? R.string.animate_route_off : R.string.animate_route);
animateMenu.setVisible(app.getTargetPointsHelper().getPointToNavigate() != null);
}
if (Version.isGpsStatusEnabled(app) && !Version.isBlackberry(app)) {
optionsMenuHelper.registerItem(R.string.show_gps_status,
light ? R.drawable.a_2_action_about_light : R.drawable.a_2_action_about_dark,
new OnContextMenuClick() {
@Override
public boolean onClick(MenuItem item) {
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
startGpsStatusIntent();
}
});
}
final OsmAndLocationProvider loc = app.getLocationProvider();
if (app.getTargetPointsHelper().getPointToNavigate() != null) {
optionsMenuHelper.registerItem(loc.getLocationSimulation().isRouteAnimating() ? R.string.animate_route_off
: R.string.animate_route,
light ? R.drawable.a_9_av_play_over_video_light : R.drawable.a_9_av_play_over_video_dark,
new OnContextMenuClick() {
@Override
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
// animate moving on route
loc.getLocationSimulation().startStopRouteAnimation(mapActivity);
return true;
}
});
}
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
optionsMenuHelper.registerOptionsMenu(menu);
return true;
}
public void onPrepareOptionsMenu(Menu menu) {
optionsMenuHelper.prepareOptionsMenu(menu);
}
public boolean onOptionsItemSelected(MenuItem item) {
return optionsMenuHelper.onClick(item);
return optionsMenuHelper;
}
public void openIntermediatePointsDialog(){

View file

@ -35,7 +35,6 @@ import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.render.MapVectorLayer;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.FavoritesLayer;
import net.osmand.plus.views.GPXLayer;

View file

@ -16,11 +16,11 @@ import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.Track;
import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import org.apache.commons.logging.Log;

View file

@ -20,7 +20,6 @@ import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
@ -32,8 +31,8 @@ import android.preference.PreferenceScreen;
import android.widget.ArrayAdapter;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
import com.actionbarsherlock.app.SherlockPreferenceActivity;
public abstract class SettingsBaseActivity extends SherlockPreferenceActivity implements OnPreferenceChangeListener, OnPreferenceClickListener {

View file

@ -6,9 +6,9 @@ import java.util.List;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ClientContext;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.ClientContext;
import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.plus.R;
import net.osmand.plus.Version;
@ -29,8 +29,8 @@ import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceScreen;
import android.widget.Toast;
import com.actionbarsherlock.view.Window;

View file

@ -6,8 +6,8 @@ import java.util.List;
import net.osmand.ResultMatcher;
import net.osmand.data.Building;
import net.osmand.data.City;
import net.osmand.data.Street;
import net.osmand.data.LatLon;
import net.osmand.data.Street;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.resources.RegionAddressRepository;

View file

@ -11,11 +11,11 @@ import net.osmand.ResultMatcher;
import net.osmand.data.City;
import net.osmand.data.City.CityType;
import net.osmand.data.LatLon;
import net.osmand.util.MapUtils;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.resources.RegionAddressRepository;
import net.osmand.util.MapUtils;
import android.os.AsyncTask;
import android.os.Message;
import android.view.Gravity;

View file

@ -6,9 +6,6 @@ package net.osmand.plus.activities.search;
import java.util.ArrayList;
import java.util.List;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.app.SherlockListFragment;
import net.osmand.access.AccessibleToast;
import net.osmand.data.LatLon;
import net.osmand.plus.NameFinderPoiFilter;
@ -32,6 +29,9 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.app.SherlockListFragment;
public class SearchPoiFilterActivity extends SherlockListFragment implements SearchActivityChild {

View file

@ -6,11 +6,11 @@ import java.util.ArrayList;
import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.data.LatLon;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routing.RouteProvider.GPXRouteParams;
import android.app.AlertDialog;

View file

@ -1,7 +1,5 @@
package net.osmand.plus.base;
import android.content.Context;
import android.view.WindowManager;
import net.osmand.Location;
import net.osmand.StateChangedListener;
import net.osmand.map.IMapLocationListener;
@ -15,6 +13,8 @@ import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.MapUtils;
import android.content.Context;
import android.view.WindowManager;
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener {
private static final int AUTO_FOLLOW_MSG_ID = 8;

View file

@ -1,8 +1,5 @@
package net.osmand.plus.development;
import net.osmand.plus.OptionsMenuHelper;
import net.osmand.plus.OptionsMenuHelper.OnOptionsMenuClick;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
@ -12,8 +9,6 @@ import android.content.Intent;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.view.Menu;
import android.view.MenuItem;
public class OsmandDevelopmentPlugin extends OsmandPlugin {
private static final String ID = "osmand.development";

View file

@ -3,8 +3,6 @@
*/
package net.osmand.plus.development;
import com.actionbarsherlock.app.SherlockActivity;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
@ -23,6 +21,8 @@ import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity;
/**
* Test Voice activity
*/

View file

@ -6,7 +6,6 @@ import java.util.List;
import net.osmand.access.AccessibleToast;
import net.osmand.data.LatLon;
import net.osmand.util.MapUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
@ -17,6 +16,7 @@ import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import net.osmand.util.MapUtils;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

View file

@ -23,8 +23,6 @@ import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.BaseMapWidget;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;

View file

@ -7,7 +7,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;

Some files were not shown because too many files have changed in this diff Show more