add settings activity

git-svn-id: https://osmand.googlecode.com/svn/trunk@28 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-05-02 11:31:19 +00:00
parent d786dcdd60
commit 22f0ebcdef
7 changed files with 83 additions and 12 deletions

View file

@ -5,14 +5,15 @@
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
<activity android:name=".MapActivity"
android:label="@string/app_name" android:launchMode="singleTop">
android:label="@string/app_name" android:launchMode="standard">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<activity android:name="SettingsActivity" android:label="@string/settings_activity"></activity>
</application>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>

View file

@ -2,14 +2,11 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.osmand.OsmandMapTileView android:id="@+id/View01" android:layout_width="wrap_content" android:layout_height="wrap_content"></com.osmand.OsmandMapTileView>
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.PointOfView android:id="@+id/PointOfView" android:layout_width="wrap_content" android:layout_height="wrap_content"></com.osmand.PointOfView>
<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>
<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>

View 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>

View file

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<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="app_name">OsmAnd</string>
</resources>

View file

@ -3,6 +3,7 @@ package com.osmand;
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
@ -11,6 +12,7 @@ import android.os.Environment;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ZoomControls;
@ -39,7 +41,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
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.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);
// service.get
service.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
}

View file

@ -34,6 +34,9 @@ public class OsmandMapTileView extends View implements IMapDownloaderCallback {
protected final int emptyTileDivisor = DefaultLauncherConstants.MAP_divNonLoadedImage;
protected final int maxImgCacheSize = 512;
protected int drawCoordinatesX = 0;
protected int drawCoordinatesY = 55;
protected static final Log log = LogFactory.getLog(OsmandMapTileView.class);
/**
* 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, 6, paintBlack);
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);
}
}

View 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);
}
}