diff --git a/android/res/drawable/download_button.xml b/android/res/drawable/download_button.xml
new file mode 100644
index 0000000000..79f527a30b
--- /dev/null
+++ b/android/res/drawable/download_button.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/drawable/myposition_button_found.xml b/android/res/drawable/myposition_button_found.xml
new file mode 100644
index 0000000000..5243512d11
--- /dev/null
+++ b/android/res/drawable/myposition_button_found.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/drawable/myposition_button_normal.xml b/android/res/drawable/myposition_button_normal.xml
new file mode 100644
index 0000000000..d740b65d4d
--- /dev/null
+++ b/android/res/drawable/myposition_button_normal.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/layout/map.xml b/android/res/layout/map.xml
new file mode 100644
index 0000000000..6cb442fc44
--- /dev/null
+++ b/android/res/layout/map.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/menu/main.xml b/android/res/menu/main.xml
index e3ec480b35..b013877ee4 100644
--- a/android/res/menu/main.xml
+++ b/android/res/menu/main.xml
@@ -1,14 +1,6 @@
diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java
index ac1748422e..daec8d4354 100644
--- a/android/src/com/mapswithme/maps/MWMActivity.java
+++ b/android/src/com/mapswithme/maps/MWMActivity.java
@@ -12,23 +12,15 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
-import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
-import android.widget.FrameLayout;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.util.DisplayMetrics;
import android.util.Log;
public class MWMActivity extends NvEventQueueActivity implements
@@ -39,16 +31,6 @@ public class MWMActivity extends NvEventQueueActivity implements
private static String TAG = "MWMActivity";
private final static String PACKAGE_NAME = "com.mapswithme.maps";
- private int m_ic_location;
- private int m_ic_menu_location;
- private int m_ic_download;
- private int m_ic_menu_download;
- private boolean m_locationStarted = false;
-
- private BitmapFactory m_bitmapFactory = null;
- private ImageButton m_btnLocation = null;
- private ImageButton m_btnDownloadMaps = null;
-
private LocationService m_locationService = null;
private BroadcastReceiver m_externalStorageReceiver = null;
@@ -57,11 +39,16 @@ public class MWMActivity extends NvEventQueueActivity implements
private static Context m_context = null;
public static Context getCurrentContext() { return m_context; }
- private String getAppBundlePath() throws NameNotFoundException
+ private String getAppBundlePath()
{
- PackageManager packMgmr = getApplication().getPackageManager();
- ApplicationInfo appInfo = packMgmr.getApplicationInfo(PACKAGE_NAME, 0);
- return appInfo.sourceDir;
+ try
+ {
+ return getApplication().getPackageManager().getApplicationInfo(PACKAGE_NAME, 0).sourceDir;
+ } catch (NameNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ return "";
}
private String getDataStoragePath()
@@ -77,7 +64,6 @@ public class MWMActivity extends NvEventQueueActivity implements
if (!hasMeasurementSystem())
{
// Checking system-default measurement system
-
if (UnitLocale.getCurrent() == UnitLocale.Metric)
{
u = UNITS_METRIC;
@@ -134,98 +120,20 @@ public class MWMActivity extends NvEventQueueActivity implements
private native void setupMeasurementSystem();
- private void updateButtonIcons()
+ public void onMyPositionClicked(View v)
{
- m_btnLocation.setImageBitmap(BitmapFactory.decodeResource(getResources(),
- m_ic_location));
- m_btnDownloadMaps.setImageBitmap(BitmapFactory.decodeResource(
- getResources(), m_ic_download));
- }
-
- private void onLocationClicked()
- {
- if (m_locationStarted)
+ v.setBackgroundResource(R.drawable.myposition_button_normal);
+ final boolean isLocationActive = v.isSelected();
+ if (isLocationActive)
m_locationService.stopUpdate(this);
else
m_locationService.startUpdate(this, this);
- m_locationStarted = !m_locationStarted;
+ v.setSelected(!isLocationActive);
}
- private void onDownloadMapsClicked()
+ public void onDownloadClicked(View v)
{
- m_ic_download = R.drawable.ic_download_highlighted;
- updateButtonIcons();
- Intent intent = new Intent(this, DownloadUI.class);
- startActivity(intent);
- }
-
- public void setupLayout()
- {
- m_bitmapFactory = new BitmapFactory();
-
- FrameLayout mapLayout = new FrameLayout(this);
- LinearLayout mapButtons = new LinearLayout(this);
-
- m_btnLocation = new ImageButton(this);
-
- m_btnLocation.setBackgroundDrawable(null);
- m_btnLocation.setOnClickListener(new View.OnClickListener()
- {
- public void onClick(View view)
- {
- onLocationClicked();
- }
- });
-
- m_ic_location = R.drawable.ic_location;
- m_ic_menu_location = R.drawable.ic_menu_location;
-
- m_btnDownloadMaps = new ImageButton(this);
- m_btnDownloadMaps.setImageBitmap(BitmapFactory.decodeResource(
- getResources(), R.drawable.ic_download));
- m_btnDownloadMaps.setBackgroundDrawable(null);
- m_btnDownloadMaps.setOnClickListener(new View.OnClickListener()
- {
- public void onClick(View v)
- {
- onDownloadMapsClicked();
- }
- });
-
- m_ic_download = R.drawable.ic_download;
- m_ic_menu_download = R.drawable.ic_menu_download;
-
- DisplayMetrics m = new DisplayMetrics();
- getWindowManager().getDefaultDisplay().getMetrics(m);
-
- Log.d(TAG, "screen density koeff is: " + m.density);
-
- LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
-
- p.setMargins((int) (10 * m.density), (int) (10 * m.density),
- (int) (0 * m.density), (int) (5 * m.density));
-
- mapButtons.setGravity(Gravity.BOTTOM);
-
- mapButtons.addView(m_btnLocation, p);
-
- LinearLayout.LayoutParams p1 = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
-
- p1.setMargins((int) (0 * m.density), (int) (10 * m.density),
- (int) (0 * m.density), (int) (5 * m.density));
-
- mapButtons.addView(m_btnDownloadMaps, p1);
-
- mapLayout.addView(view3d);
- mapLayout.addView(mapButtons);
-
- updateButtonIcons();
-
- setContentView(mapLayout);
+ startActivity(new Intent(this, DownloadUI.class));
}
private void setupLanguages()
@@ -249,15 +157,7 @@ public class MWMActivity extends NvEventQueueActivity implements
final File f = new File(storagePath);
f.mkdirs();
- try
- {
- nativeInit(getAppBundlePath(), storagePath);
- } catch (NameNotFoundException e)
- {
- e.printStackTrace();
- }
-
- setupLayout();
+ nativeInit(getAppBundlePath(), storagePath);
setupLanguages();
@@ -268,38 +168,23 @@ public class MWMActivity extends NvEventQueueActivity implements
m_locationService = new LocationService(this);
}
+ // From Location interface
public void onLocationStatusChanged(int newStatus)
{
- switch (newStatus)
- {
- case LocationService.FIRST_EVENT:
- m_ic_location = R.drawable.ic_location_found;
- m_ic_menu_location = R.drawable.ic_menu_location_found;
- break;
- case LocationService.STARTED:
- m_ic_location = R.drawable.ic_location_search;
- m_ic_menu_location = R.drawable.ic_menu_location_search;
- break;
- default:
- m_ic_location = R.drawable.ic_location;
- m_ic_menu_location = R.drawable.ic_menu_location;
- }
-
- updateButtonIcons();
-
+ Log.d("LOCATION", "status: " + newStatus);
+ if (newStatus == LocationService.FIRST_EVENT)
+ findViewById(R.id.map_button_myposition).setBackgroundResource(R.drawable.myposition_button_found);
nativeLocationStatusChanged(newStatus);
}
- // @Override
- public void onLocationUpdated(long time, double lat, double lon,
- float accuracy)
+ // From Location interface
+ public void onLocationUpdated(long time, double lat, double lon, float accuracy)
{
nativeLocationUpdated(time, lat, lon, accuracy);
}
- // @Override
- public void onCompassUpdated(long time, double magneticNorth,
- double trueNorth, float accuracy)
+ // From Location interface
+ public void onCompassUpdated(long time, double magneticNorth, double trueNorth, float accuracy)
{
nativeCompassUpdated(time, magneticNorth, trueNorth, accuracy);
}
@@ -307,16 +192,9 @@ public class MWMActivity extends NvEventQueueActivity implements
@Override
protected void onPause()
{
- int ic_location_old = m_ic_location;
- int ic_menu_location_old = m_ic_menu_location;
-
- if (m_locationStarted)
+ if (findViewById(R.id.map_button_myposition).isSelected())
m_locationService.stopUpdate(this);
- m_ic_location = ic_location_old;
- m_ic_menu_location = ic_menu_location_old;
- updateButtonIcons();
-
stopWatchingExternalStorage();
super.onPause();
@@ -325,12 +203,7 @@ public class MWMActivity extends NvEventQueueActivity implements
@Override
protected void onResume()
{
- m_ic_download = R.drawable.ic_download;
- m_ic_menu_download = R.drawable.ic_menu_download;
-
- updateButtonIcons();
-
- if (m_locationStarted)
+ if (findViewById(R.id.map_button_myposition).isSelected())
m_locationService.startUpdate(this, this);
startWatchingExternalStorage();
@@ -346,27 +219,12 @@ public class MWMActivity extends NvEventQueueActivity implements
return true;
}
- @Override
- public boolean onPrepareOptionsMenu(Menu menu)
- {
- menu.findItem(R.id.my_position).setIcon(m_ic_menu_location);
- return super.onPrepareOptionsMenu(menu);
- }
-
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
- case R.id.my_position:
- onLocationClicked();
- return true;
-
- case R.id.download_maps:
- onDownloadMapsClicked();
- return true;
-
- case R.id.about_dialog:
+ case R.id.menuitem_about_dialog:
onAboutDialogClicked();
return true;
@@ -426,21 +284,21 @@ public class MWMActivity extends NvEventQueueActivity implements
{ // Add local maps to the model
nativeStorageConnected();
// enable downloader button and dismiss blocking popup
- m_btnDownloadMaps.setVisibility(View.VISIBLE);
+ findViewById(R.id.map_button_download).setVisibility(View.VISIBLE);
if (m_storageDisconnectedDialog != null)
m_storageDisconnectedDialog.dismiss();
} else if (available)
{ // Add local maps to the model
nativeStorageConnected();
// disable downloader button and dismiss blocking popup
- m_btnDownloadMaps.setVisibility(View.INVISIBLE);
+ findViewById(R.id.map_button_download).setVisibility(View.INVISIBLE);
if (m_storageDisconnectedDialog != null)
m_storageDisconnectedDialog.dismiss();
} else
{ // Remove local maps from the model
nativeStorageDisconnected();
// enable downloader button and show blocking popup
- m_btnDownloadMaps.setVisibility(View.VISIBLE);
+ findViewById(R.id.map_button_download).setVisibility(View.VISIBLE);
if (m_storageDisconnectedDialog == null)
{
m_storageDisconnectedDialog = new AlertDialog.Builder(this).create();
diff --git a/android/src/com/nvidia/devtech/NvEventQueueActivity.java b/android/src/com/nvidia/devtech/NvEventQueueActivity.java
index adfd797dea..61fa086505 100644
--- a/android/src/com/nvidia/devtech/NvEventQueueActivity.java
+++ b/android/src/com/nvidia/devtech/NvEventQueueActivity.java
@@ -21,6 +21,8 @@
//----------------------------------------------------------------------------------
package com.nvidia.devtech;
+import com.mapswithme.maps.R;
+
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
@@ -38,8 +40,6 @@ import android.view.SurfaceHolder.Callback;
public abstract class NvEventQueueActivity extends Activity
{
- protected SurfaceView view3d = null;
-
// private static final int EGL_RENDERABLE_TYPE = 0x3040;
// private static final int EGL_OPENGL_ES_BIT = 0x0001;
// private static final int EGL_OPENGL_ES2_BIT = 0x0004;
@@ -109,9 +109,10 @@ public abstract class NvEventQueueActivity extends Activity
System.out.println("**** onCreate");
super.onCreate(savedInstanceState);
- view3d = new SurfaceView(this);
+ setContentView(R.layout.map);
+ final SurfaceView surfaceView = (SurfaceView) findViewById(R.id.map_surfaceview);
- SurfaceHolder holder = view3d.getHolder();
+ SurfaceHolder holder = surfaceView.getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
holder.addCallback(new Callback()