add settings activity
git-svn-id: https://osmand.googlecode.com/svn/trunk@28 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
d786dcdd60
commit
22f0ebcdef
7 changed files with 83 additions and 12 deletions
|
@ -5,13 +5,14 @@
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
|
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
|
||||||
<activity android:name=".MapActivity"
|
<activity android:name=".MapActivity"
|
||||||
android:label="@string/app_name" android:launchMode="singleTop">
|
android:label="@string/app_name" android:launchMode="standard">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name="SettingsActivity" android:label="@string/settings_activity"></activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,11 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent">
|
||||||
>
|
<com.osmand.OsmandMapTileView android:id="@+id/MapView" android:layout_width="wrap_content" android:layout_height="wrap_content"></com.osmand.OsmandMapTileView>
|
||||||
<com.osmand.OsmandMapTileView android:id="@+id/View01" android:layout_width="wrap_content" android:layout_height="wrap_content"></com.osmand.OsmandMapTileView>
|
|
||||||
<com.osmand.PointOfView android:id="@+id/PointOfView" android:layout_width="wrap_content" android:layout_height="wrap_content"></com.osmand.PointOfView>
|
<com.osmand.PointOfView android:id="@+id/PointOfView" android:layout_width="wrap_content" android:layout_height="wrap_content"></com.osmand.PointOfView>
|
||||||
<ZoomControls android:id="@+id/ZoomControls01"
|
<ZoomControls android:id="@+id/ZoomControls01"
|
||||||
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right"></ZoomControls>
|
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right"></ZoomControls>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|right" android:id="@+id/BackToLocation" android:background="@drawable/icon"></ImageButton>
|
<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|right" android:id="@+id/BackToLocation" android:background="@drawable/icon"></ImageButton>
|
||||||
|
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/settings_activity" android:layout_gravity="top|left" android:id="@+id/GoToSettingsButton" ></Button>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
17
OsmAnd/res/layout/settings.xml
Normal file
17
OsmAnd/res/layout/settings.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<CheckBox android:id="@+id/use_internet_to_download_tile" android:layout_height="wrap_content" android:text="@string/use_internet_to_download_tile" android:layout_width="wrap_content"></CheckBox>
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dip" android:background="#FFFFFFFF" />
|
||||||
|
|
||||||
|
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/show_gps_coordinates_text" android:id="@+id/show_gps_coordinates_text"></CheckBox>
|
||||||
|
</LinearLayout>
|
|
@ -1,5 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="settings_activity">Settings</string>
|
||||||
|
<string name="show_gps_coordinates_text">Show gps coordinates on map</string>
|
||||||
|
<string name="use_internet_to_download_tile">Use internet to download missing tiles</string>
|
||||||
<string name="hello">Hello World, StartActivity!</string>
|
<string name="hello">Hello World, StartActivity!</string>
|
||||||
<string name="app_name">OsmAnd</string>
|
<string name="app_name">OsmAnd</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.osmand;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.location.LocationListener;
|
import android.location.LocationListener;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
|
@ -11,6 +12,7 @@ import android.os.Environment;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ZoomControls;
|
import android.widget.ZoomControls;
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
|
|
||||||
|
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
mapView = (OsmandMapTileView) findViewById(R.id.View01);
|
mapView = (OsmandMapTileView) findViewById(R.id.MapView);
|
||||||
mapView.setFileWithTiles(new File(Environment.getExternalStorageDirectory(), "osmand/tiles/"));
|
mapView.setFileWithTiles(new File(Environment.getExternalStorageDirectory(), "osmand/tiles/"));
|
||||||
mapView.addMapLocationListener(this);
|
mapView.addMapLocationListener(this);
|
||||||
|
|
||||||
|
@ -75,8 +77,18 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Button goToSettings = (Button)findViewById(R.id.GoToSettingsButton);
|
||||||
|
goToSettings.setOnClickListener(new OnClickListener(){
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final Intent settings = new Intent(MapActivity.this, SettingsActivity.class);
|
||||||
|
startActivity(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
|
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||||
// service.get
|
|
||||||
service.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
|
service.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ public class OsmandMapTileView extends View implements IMapDownloaderCallback {
|
||||||
protected final int emptyTileDivisor = DefaultLauncherConstants.MAP_divNonLoadedImage;
|
protected final int emptyTileDivisor = DefaultLauncherConstants.MAP_divNonLoadedImage;
|
||||||
protected final int maxImgCacheSize = 512;
|
protected final int maxImgCacheSize = 512;
|
||||||
|
|
||||||
|
protected int drawCoordinatesX = 0;
|
||||||
|
protected int drawCoordinatesY = 55;
|
||||||
|
|
||||||
protected static final Log log = LogFactory.getLog(OsmandMapTileView.class);
|
protected static final Log log = LogFactory.getLog(OsmandMapTileView.class);
|
||||||
/**
|
/**
|
||||||
* file or directory with tiles
|
* file or directory with tiles
|
||||||
|
@ -188,7 +191,8 @@ public class OsmandMapTileView extends View implements IMapDownloaderCallback {
|
||||||
canvas.drawCircle(getWidth()/2, getHeight()/2, 3, paintBlack);
|
canvas.drawCircle(getWidth()/2, getHeight()/2, 3, paintBlack);
|
||||||
canvas.drawCircle(getWidth()/2, getHeight()/2, 6, paintBlack);
|
canvas.drawCircle(getWidth()/2, getHeight()/2, 6, paintBlack);
|
||||||
if (DefaultLauncherConstants.showGPSCoordinates) {
|
if (DefaultLauncherConstants.showGPSCoordinates) {
|
||||||
canvas.drawText(MessageFormat.format("Lat : {0}, lon : {1}, zoom : {2}", latitude, longitude, zoom), 0, 15, paintBlack);
|
canvas.drawText(MessageFormat.format("Lat : {0}, lon : {1}, zoom : {2}", latitude, longitude, zoom),
|
||||||
|
drawCoordinatesX, drawCoordinatesY, paintBlack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
OsmAnd/src/com/osmand/SettingsActivity.java
Normal file
36
OsmAnd/src/com/osmand/SettingsActivity.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package com.osmand;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
|
public class SettingsActivity extends Activity {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.settings);
|
||||||
|
|
||||||
|
final CheckBox useInternet = (CheckBox)findViewById(R.id.use_internet_to_download_tile);
|
||||||
|
useInternet.setOnClickListener(new OnClickListener(){
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
DefaultLauncherConstants.loadMissingImages = useInternet.isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
useInternet.setChecked(DefaultLauncherConstants.loadMissingImages);
|
||||||
|
|
||||||
|
final CheckBox showGPSText = (CheckBox)findViewById(R.id.show_gps_coordinates_text);
|
||||||
|
showGPSText.setOnClickListener(new OnClickListener(){
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
DefaultLauncherConstants.showGPSCoordinates = showGPSText.isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
showGPSText.setChecked(DefaultLauncherConstants.showGPSCoordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue