changing layout
git-svn-id: https://osmand.googlecode.com/svn/trunk@41 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
eb744a6e34
commit
92a6ef78ba
6 changed files with 61 additions and 115 deletions
28
OsmAnd/res/layout-port/menu.xml
Normal file
28
OsmAnd/res/layout-port/menu.xml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent" android:orientation="vertical"
|
||||||
|
android:layout_height="fill_parent" android:background="@color/menu_background">
|
||||||
|
|
||||||
|
<Button android:layout_height="85dp"
|
||||||
|
android:layout_gravity="center" android:id="@+id/MapButton"
|
||||||
|
android:text="@string/map_Button" android:layout_width="200dp" android:layout_marginTop="30dp"></Button>
|
||||||
|
|
||||||
|
<Button android:layout_height="85dp" android:id="@+id/SearchButton" android:text="@string/search_button"
|
||||||
|
android:layout_width="200dp" android:layout_gravity="center" android:layout_marginTop="20dp"></Button>
|
||||||
|
|
||||||
|
<Button android:layout_height="85dp"
|
||||||
|
android:layout_gravity="center" android:id="@+id/SettingsButton"
|
||||||
|
android:text="@string/settings_Button" android:layout_width="200dp" android:layout_marginTop="20dp"></Button>
|
||||||
|
<FrameLayout android:id="@+id/FrameLayout01"
|
||||||
|
android:layout_height="fill_parent" android:layout_width="fill_parent">
|
||||||
|
<Button android:layout_width="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp" android:layout_marginBottom ="5dp"
|
||||||
|
android:layout_height="wrap_content" android:layout_gravity="bottom|left"
|
||||||
|
android:id="@+id/ExitButton" android:background="@drawable/exit"></Button>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -3,21 +3,21 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent" android:orientation="vertical"
|
android:layout_width="fill_parent" android:orientation="vertical"
|
||||||
android:layout_height="fill_parent" android:background="@color/menu_background">
|
android:layout_height="fill_parent" android:background="@color/menu_background">
|
||||||
<ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="top|right" android:id="@+id/LoadProgressBar" ></ProgressBar>
|
|
||||||
|
|
||||||
<Button android:layout_height="wrap_content"
|
<Button android:layout_height="55dp"
|
||||||
android:layout_gravity="center" android:id="@+id/MapButton"
|
android:layout_gravity="center" android:id="@+id/MapButton"
|
||||||
android:text="@string/map_Button" android:layout_width="200px" android:layout_marginTop="5px"></Button>
|
android:text="@string/map_Button" android:layout_width="300dp" android:layout_marginTop="10dp"></Button>
|
||||||
|
|
||||||
<Button android:layout_height="wrap_content"
|
<Button android:layout_height="55dp" android:id="@+id/SearchButton" android:text="@string/search_button"
|
||||||
|
android:layout_width="300dp" android:layout_gravity="center" android:layout_marginTop="20dp"></Button>
|
||||||
|
|
||||||
|
<Button android:layout_height="55dp"
|
||||||
android:layout_gravity="center" android:id="@+id/SettingsButton"
|
android:layout_gravity="center" android:id="@+id/SettingsButton"
|
||||||
android:text="@string/settings_Button" android:layout_width="200px" android:layout_marginTop="15px"></Button>
|
android:text="@string/settings_Button" android:layout_width="300dp" android:layout_marginTop="20dp"></Button>
|
||||||
|
<FrameLayout android:id="@+id/FrameLayout01"
|
||||||
|
|
||||||
<Button android:layout_height="wrap_content" android:id="@+id/SearchButton" android:text="@string/search_button" android:layout_width="200px" android:layout_gravity="center_horizontal" android:layout_marginTop="15px"></Button><FrameLayout android:id="@+id/FrameLayout01"
|
|
||||||
android:layout_height="fill_parent" android:layout_width="fill_parent">
|
android:layout_height="fill_parent" android:layout_width="fill_parent">
|
||||||
<Button android:layout_width="wrap_content"
|
<Button android:layout_width="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp" android:layout_marginBottom ="5dp"
|
||||||
android:layout_height="wrap_content" android:layout_gravity="bottom|left"
|
android:layout_height="wrap_content" android:layout_gravity="bottom|left"
|
||||||
android:id="@+id/ExitButton" android:background="@drawable/exit"></Button>
|
android:id="@+id/ExitButton" android:background="@drawable/exit"></Button>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.tools.bzip2.CBZip2InputStream;
|
import org.apache.tools.bzip2.CBZip2InputStream;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
@ -191,7 +192,7 @@ public class ResourceManager {
|
||||||
|
|
||||||
|
|
||||||
// POI INDEX //
|
// POI INDEX //
|
||||||
public void indexingPoi(){
|
public void indexingPoi(ProgressDialog dlg){
|
||||||
if (poiIndex == null) {
|
if (poiIndex == null) {
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), POI_PATH);
|
File file = new File(Environment.getExternalStorageDirectory(), POI_PATH);
|
||||||
poiIndex = new DataTileManager<Amenity>();
|
poiIndex = new DataTileManager<Amenity>();
|
||||||
|
@ -201,6 +202,9 @@ public class ResourceManager {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Starting index POI " + f.getAbsolutePath());
|
log.debug("Starting index POI " + f.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
if(dlg != null){
|
||||||
|
dlg.setMessage("Indexing poi " + f.getName());
|
||||||
|
}
|
||||||
boolean zipped = f.getName().endsWith(".bz2");
|
boolean zipped = f.getName().endsWith(".bz2");
|
||||||
InputStream stream = null;
|
InputStream stream = null;
|
||||||
try {
|
try {
|
||||||
|
@ -240,7 +244,7 @@ public class ResourceManager {
|
||||||
|
|
||||||
public DataTileManager<Amenity> getPoiIndex() {
|
public DataTileManager<Amenity> getPoiIndex() {
|
||||||
if(poiIndex == null){
|
if(poiIndex == null){
|
||||||
indexingPoi();
|
indexingPoi(null);
|
||||||
}
|
}
|
||||||
return poiIndex;
|
return poiIndex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,22 @@
|
||||||
package com.osmand.activities;
|
package com.osmand.activities;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
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.Button;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
|
|
||||||
import com.osmand.R;
|
import com.osmand.R;
|
||||||
import com.osmand.ResourceManager;
|
import com.osmand.ResourceManager;
|
||||||
import com.osmand.services.LongRunningActionCallback;
|
|
||||||
import com.osmand.services.LongRunningActionDispatcher;
|
|
||||||
|
|
||||||
public class MainMenuActivity extends Activity implements
|
public class MainMenuActivity extends Activity {
|
||||||
LongRunningActionCallback {
|
|
||||||
|
|
||||||
private Button showMap;
|
private Button showMap;
|
||||||
private Button exitButton;
|
private Button exitButton;
|
||||||
private Button settingsButton;
|
private Button settingsButton;
|
||||||
private ProgressBar loadProgress;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -30,15 +24,12 @@ public class MainMenuActivity extends Activity implements
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
setContentView(R.layout.menu);
|
setContentView(R.layout.menu);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
showMap = (Button) findViewById(R.id.MapButton);
|
showMap = (Button) findViewById(R.id.MapButton);
|
||||||
showMap.setOnClickListener(new OnClickListener() {
|
showMap.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final Intent mapIndent = new Intent(MainMenuActivity.this,
|
final Intent mapIndent = new Intent(MainMenuActivity.this, MapActivity.class);
|
||||||
MapActivity.class);
|
|
||||||
startActivityForResult(mapIndent, 0);
|
startActivityForResult(mapIndent, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,8 +38,7 @@ public class MainMenuActivity extends Activity implements
|
||||||
settingsButton.setOnClickListener(new OnClickListener() {
|
settingsButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final Intent settings = new Intent(MainMenuActivity.this,
|
final Intent settings = new Intent(MainMenuActivity.this, SettingsActivity.class);
|
||||||
SettingsActivity.class);
|
|
||||||
startActivity(settings);
|
startActivity(settings);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -60,30 +50,20 @@ public class MainMenuActivity extends Activity implements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
loadProgress = (ProgressBar) findViewById(R.id.LoadProgressBar);
|
final ProgressDialog dlg = ProgressDialog.show(this, "Loading data", "Reading indices...");
|
||||||
loadProgress.setHorizontalScrollBarEnabled(true);
|
new Thread(){
|
||||||
|
@Override
|
||||||
// startLongRunningOperation();
|
public void run() {
|
||||||
|
try {
|
||||||
}
|
dlg.setMessage("Indexing poi...");
|
||||||
|
ResourceManager.getResourceManager().indexingPoi(dlg);
|
||||||
private LongRunningActionDispatcher dispatcher;
|
} finally {
|
||||||
|
dlg.dismiss();
|
||||||
@SuppressWarnings("unchecked")
|
}
|
||||||
private void startLongRunningOperation() {
|
|
||||||
this.dispatcher = new LongRunningActionDispatcher(this, this);
|
|
||||||
dispatcher.startLongRunningAction(new Callable() {
|
|
||||||
public Void call() throws Exception {
|
|
||||||
ResourceManager.getResourceManager().indexingPoi();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}, "Dialog Title", "Dialog message");
|
}.start();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLongRunningActionFinished(Exception error) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.osmand.services;
|
|
||||||
|
|
||||||
public interface LongRunningActionCallback {
|
|
||||||
void onLongRunningActionFinished(Exception error);
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
package com.osmand.services;
|
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Handler;
|
|
||||||
|
|
||||||
public class LongRunningActionDispatcher {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
private LongRunningActionCallback callback;
|
|
||||||
|
|
||||||
private ProgressDialog progressDialog;
|
|
||||||
|
|
||||||
private Handler finishedHandler = new Handler();
|
|
||||||
|
|
||||||
public LongRunningActionDispatcher(Context context,
|
|
||||||
|
|
||||||
LongRunningActionCallback callback) {
|
|
||||||
this.context = context;
|
|
||||||
this.callback = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void startLongRunningAction(final Callable callable,
|
|
||||||
|
|
||||||
String progressDialogTitle, String progressDialogMessage) {
|
|
||||||
|
|
||||||
progressDialog = ProgressDialog.show(context, progressDialogTitle,
|
|
||||||
progressDialogMessage, true, false);
|
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
Exception error = null;
|
|
||||||
try {
|
|
||||||
callable.call();
|
|
||||||
} catch (Exception e) {
|
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Exception finalError = error;
|
|
||||||
finishedHandler.post(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
onLongRunningActionFinished(finalError);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}).start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onLongRunningActionFinished(Exception error) {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
callback.onLongRunningActionFinished(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue