fix exit button, introduce osmand app

git-svn-id: https://osmand.googlecode.com/svn/trunk@184 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-06-20 11:08:23 +00:00
parent 9b267f8f3b
commit a47753e2d7
14 changed files with 148 additions and 140 deletions

View file

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.osmand" android:versionCode="1" android:versionName="1.0"> package="com.osmand" android:versionCode="1" android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" <application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true"> android:debuggable="true" android:name=".activities.OsmandApplication">
<activity android:name=".activities.MainMenuActivity" <activity android:name=".activities.MainMenuActivity"
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>

View file

@ -48,11 +48,11 @@
</TableRow> </TableRow>
</TableLayout> </TableLayout>
<FrameLayout android:id="@+id/FrameLayout01" android:layout_gravity="bottom|left" <!-- <FrameLayout android:id="@+id/FrameLayout01" android:layout_gravity="bottom|left"
android:layout_height="wrap_content" android:layout_width="fill_parent"> android:layout_height="wrap_content" 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_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> -->
</FrameLayout> </FrameLayout>

View file

@ -49,12 +49,12 @@
</TableRow> </TableRow>
</TableLayout> </TableLayout>
<FrameLayout android:id="@+id/FrameLayout" <!-- <FrameLayout android:id="@+id/FrameLayout"
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_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> -->
</FrameLayout> </FrameLayout>

View file

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="reload_indexes_descr">Перезагрузить индексы с SD</string>
<string name="reload_indexes">Обновить индексы</string>
<string name="use_online_routing_descr">Использовать интернет для расчета маршрута</string> <string name="use_online_routing_descr">Использовать интернет для расчета маршрута</string>
<string name="use_online_routing">Online маршрутизация</string> <string name="use_online_routing">Online маршрутизация</string>
<string name="user_password_descr">Указать пароль для работы с OSM</string> <string name="user_password_descr">Указать пароль для работы с OSM</string>
<string name="user_password">Пароль</string> <string name="user_password">Пароль</string>
<string name="osm_settings_descr">Упраление слоем open street bugs, установка osm логина </string> <string name="osm_settings_descr">Упраление слоем open street bugs, установка osm логина </string>
<string name="monitor_preferences_descr">Включение мониторинга, установка интервала сохранения</string> <string name="monitor_preferences_descr">Включение мониторинга, установка интервала сохранения</string>
<string name="search_settings_descr">Настройка параметров поиска</string> <string name="data_settings_descr">Настройка данных : язык, обновление данных</string>
<string name="map_preferences_descr">Настройка источника, параметров карты, доступа в Интернет</string> <string name="map_preferences_descr">Настройка источника, параметров карты, доступа в Интернет</string>
<string name="search_settings">Поиск</string> <string name="data_settings">Данные</string>
<string name="osm_settings">Osm</string> <string name="osm_settings">Osm</string>
<string name="auto_zoom_map_descr">Автоматически изменять масштаб карты при изменении скорости</string> <string name="auto_zoom_map_descr">Автоматически изменять масштаб карты при изменении скорости</string>
<string name="auto_zoom_map">Масштаб</string> <string name="auto_zoom_map">Масштаб</string>

View file

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="reload_indexes_descr">Reload data indexes from SD</string>
<string name="reload_indexes">Reload indexes</string>
<string name="use_online_routing_descr">Use internet to calculate route</string> <string name="use_online_routing_descr">Use internet to calculate route</string>
<string name="use_online_routing">Use online routing</string> <string name="use_online_routing">Use online routing</string>
<string name="user_password_descr">Input osm password</string> <string name="user_password_descr">Input osm password</string>
<string name="user_password">User password</string> <string name="user_password">User password</string>
<string name="osm_settings_descr">Specify osm settings: show bugs, osm login</string> <string name="osm_settings_descr">Specify osm settings: show bugs, osm login</string>
<string name="monitor_preferences_descr">Specify monitor settings : save track</string> <string name="monitor_preferences_descr">Specify monitor settings : save track</string>
<string name="search_settings_descr">Specify search settings</string> <string name="data_settings_descr">Specify data settings : language, update data</string>
<string name="map_preferences_descr">Specify map settings : rotation, poi filter</string> <string name="map_preferences_descr">Specify map settings : rotation, poi filter</string>
<string name="search_settings">Search</string> <string name="data_settings">Data</string>
<string name="osm_settings">Osm</string> <string name="osm_settings">Osm</string>
<string name="auto_zoom_map_descr">Auto zoom map according to the speed</string> <string name="auto_zoom_map_descr">Auto zoom map according to the speed</string>
<string name="auto_zoom_map">Auto zoom map</string> <string name="auto_zoom_map">Auto zoom map</string>

View file

@ -15,8 +15,9 @@
<ListPreference android:key="position_on_map" android:title="@string/position_on_map" android:summary="@string/position_on_map_descr"></ListPreference> <ListPreference android:key="position_on_map" android:title="@string/position_on_map" android:summary="@string/position_on_map_descr"></ListPreference>
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen android:title="@string/search_settings" android:summary="@string/search_settings_descr"> <PreferenceScreen android:title="@string/data_settings" android:summary="@string/data_settings_descr">
<CheckBoxPreference android:summary="@string/use_english_names_descr" android:title="@string/use_english_names" android:key="use_english_names"></CheckBoxPreference> <CheckBoxPreference android:summary="@string/use_english_names_descr" android:title="@string/use_english_names" android:key="use_english_names"></CheckBoxPreference>
<Preference android:title="@string/reload_indexes" android:key="reload_indexes" android:summary="@string/reload_indexes_descr"></Preference>
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen android:title="@string/monitor_preferences" android:summary="@string/monitor_preferences_descr"> <PreferenceScreen android:title="@string/monitor_preferences" android:summary="@string/monitor_preferences_descr">

View file

@ -109,6 +109,8 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public static final String SAVE_CURRENT_TRACK = "save_current_track"; //$NON-NLS-1$ public static final String SAVE_CURRENT_TRACK = "save_current_track"; //$NON-NLS-1$
public static final String RELOAD_INDEXES = "reload_indexes"; //$NON-NLS-1$
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public static final String SAVE_TRACK_TO_GPX = "save_track_to_gpx"; //$NON-NLS-1$ public static final String SAVE_TRACK_TO_GPX = "save_track_to_gpx"; //$NON-NLS-1$

View file

@ -174,6 +174,15 @@ public class ResourceManager {
} }
////////////////////////////////////////////// Working with indexes //////////////////////////////////////////////// ////////////////////////////////////////////// Working with indexes ////////////////////////////////////////////////
public List<String> reloadIndexes(IProgress progress){
close();
List<String> warnings = new ArrayList<String>();
warnings.addAll(indexingPoi(progress));
warnings.addAll(indexingAddresses(progress));
return warnings;
}
// POI INDEX // // POI INDEX //
public List<String> indexingPoi(final IProgress progress) { public List<String> indexingPoi(final IProgress progress) {
File file = new File(Environment.getExternalStorageDirectory(), POI_PATH); File file = new File(Environment.getExternalStorageDirectory(), POI_PATH);

View file

@ -46,6 +46,7 @@ import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import com.osmand.AmenityIndexRepository; import com.osmand.AmenityIndexRepository;
import com.osmand.Base64;
import com.osmand.LogUtil; import com.osmand.LogUtil;
import com.osmand.OsmandSettings; import com.osmand.OsmandSettings;
import com.osmand.R; import com.osmand.R;
@ -58,7 +59,6 @@ import com.osmand.osm.EntityInfo;
import com.osmand.osm.Node; import com.osmand.osm.Node;
import com.osmand.osm.OSMSettings.OSMTagKey; import com.osmand.osm.OSMSettings.OSMTagKey;
import com.osmand.osm.io.OsmBaseStorage; import com.osmand.osm.io.OsmBaseStorage;
import com.osmand.util.Base64;
import com.osmand.views.OsmandMapTileView; import com.osmand.views.OsmandMapTileView;
public class EditingPOIActivity { public class EditingPOIActivity {

View file

@ -7,14 +7,10 @@ import java.io.FileWriter;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.Thread.UncaughtExceptionHandler; import java.lang.Thread.UncaughtExceptionHandler;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.content.Intent; import android.content.Intent;
@ -33,7 +29,6 @@ import com.osmand.LogUtil;
import com.osmand.ProgressDialogImplementation; import com.osmand.ProgressDialogImplementation;
import com.osmand.R; import com.osmand.R;
import com.osmand.ResourceManager; import com.osmand.ResourceManager;
import com.osmand.Version;
import com.osmand.activities.search.SearchActivity; import com.osmand.activities.search.SearchActivity;
public class MainMenuActivity extends Activity { public class MainMenuActivity extends Activity {
@ -43,12 +38,11 @@ public class MainMenuActivity extends Activity {
private static final String EXCEPTION_FILE_SIZE = "/osmand/exception.log"; //$NON-NLS-1$ private static final String EXCEPTION_FILE_SIZE = "/osmand/exception.log"; //$NON-NLS-1$
private Button showMap; private Button showMap;
private Button exitButton;
private Button settingsButton; private Button settingsButton;
private Button searchButton; private Button searchButton;
private Button favouritesButton; private Button favouritesButton;
private NotificationManager mNotificationManager;
private int APP_NOTIFICATION_ID;
@ -61,9 +55,7 @@ public class MainMenuActivity extends Activity {
@Override @Override
public void run() { public void run() {
try { try {
List<String> warnings = new ArrayList<String>(); List<String> warnings = ResourceManager.getResourceManager().reloadIndexes(impl);
warnings.addAll(ResourceManager.getResourceManager().indexingPoi(impl));
warnings.addAll(ResourceManager.getResourceManager().indexingAddresses(impl));
SavingTrackHelper helper = new SavingTrackHelper(MainMenuActivity.this); SavingTrackHelper helper = new SavingTrackHelper(MainMenuActivity.this);
if (helper.hasDataToSave()) { if (helper.hasDataToSave()) {
impl.startTask("Saving gpx tracks to SD...", -1); impl.startTask("Saving gpx tracks to SD...", -1);
@ -107,17 +99,6 @@ public class MainMenuActivity extends Activity {
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.menu); setContentView(R.layout.menu);
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Intent notificationIndent = new Intent(MainMenuActivity.this, MapActivity.class);
notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Notification notification = new Notification(R.drawable.icon, "", //$NON-NLS-1$
System.currentTimeMillis());
notification.setLatestEventInfo(MainMenuActivity.this, Version.APP_NAME,
"OsmAnd is running in background", PendingIntent.getActivity(
this.getBaseContext(), 0, notificationIndent,
PendingIntent.FLAG_UPDATE_CURRENT));
mNotificationManager.notify(APP_NOTIFICATION_ID, notification);
showMap = (Button) findViewById(R.id.MapButton); showMap = (Button) findViewById(R.id.MapButton);
showMap.setOnClickListener(new OnClickListener() { showMap.setOnClickListener(new OnClickListener() {
@ -156,14 +137,14 @@ public class MainMenuActivity extends Activity {
}); });
exitButton = (Button) findViewById(R.id.ExitButton); // exitButton = (Button) findViewById(R.id.ExitButton);
// exitButton.setVisibility(View.INVISIBLE); // exitButton.setVisibility(View.INVISIBLE);
exitButton.setOnClickListener(new OnClickListener() { // exitButton.setOnClickListener(new OnClickListener() {
@Override // @Override
public void onClick(View v) { // public void onClick(View v) {
finishApplication(); // finishApplication();
} // }
}); // });
startApplication(); startApplication();
} }
@ -191,7 +172,6 @@ public class MainMenuActivity extends Activity {
} }
protected void finishApplication(){ protected void finishApplication(){
mNotificationManager.cancel(APP_NOTIFICATION_ID);
ResourceManager.getResourceManager().close(); ResourceManager.getResourceManager().close();
applicationAlreadyStarted = false; applicationAlreadyStarted = false;
MainMenuActivity.this.finish(); MainMenuActivity.this.finish();

View file

@ -4,6 +4,9 @@ import java.text.MessageFormat;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@ -39,6 +42,7 @@ import com.osmand.LogUtil;
import com.osmand.OsmandSettings; import com.osmand.OsmandSettings;
import com.osmand.R; import com.osmand.R;
import com.osmand.ResourceManager; import com.osmand.ResourceManager;
import com.osmand.Version;
import com.osmand.activities.FavouritesActivity.FavouritePoint; import com.osmand.activities.FavouritesActivity.FavouritePoint;
import com.osmand.activities.FavouritesActivity.FavouritesDbHelper; import com.osmand.activities.FavouritesActivity.FavouritesDbHelper;
import com.osmand.activities.search.SearchActivity; import com.osmand.activities.search.SearchActivity;
@ -77,6 +81,8 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
private MenuItem navigateToPointMenu; private MenuItem navigateToPointMenu;
private NotificationManager mNotificationManager;
private int APP_NOTIFICATION_ID;
@ -85,6 +91,18 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
return OsmandSettings.isMapSyncToGpsLocation(this); return OsmandSettings.isMapSyncToGpsLocation(this);
} }
private Notification getNotification(){
Intent notificationIndent = new Intent(this, MapActivity.class);
notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Notification notification = new Notification(R.drawable.icon, "", //$NON-NLS-1$
System.currentTimeMillis());
notification.setLatestEventInfo(this, Version.APP_NAME,
"Go back to OsmAnd map", PendingIntent.getActivity(
this.getBaseContext(), 0, notificationIndent,
PendingIntent.FLAG_UPDATE_CURRENT));
return notification;
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -94,6 +112,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
// WindowManager.LayoutParams.FLAG_FULLSCREEN); // WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main); setContentView(R.layout.main);
mapView = (OsmandMapTileView) findViewById(R.id.MapView); mapView = (OsmandMapTileView) findViewById(R.id.MapView);
MapTileDownloader.getInstance().addDownloaderCallback(mapView); MapTileDownloader.getInstance().addDownloaderCallback(mapView);
mapView.setMapLocationListener(this); mapView.setMapLocationListener(this);
@ -231,10 +250,24 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
return super.onTrackballEvent(event); return super.onTrackballEvent(event);
} }
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onStop() {
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.notify(APP_NOTIFICATION_ID, getNotification());
super.onStop();
}
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
savingTrackHelper.close(); savingTrackHelper.close();
mNotificationManager.cancel(APP_NOTIFICATION_ID);
MapTileDownloader.getInstance().removeDownloaderCallback(mapView); MapTileDownloader.getInstance().removeDownloaderCallback(mapView);
} }

View file

@ -0,0 +1,14 @@
package com.osmand.activities;
import android.app.Application;
public class OsmandApplication extends Application {
@Override
public void onLowMemory() {
super.onLowMemory();
}
}

View file

@ -2,6 +2,7 @@ package com.osmand.activities;
import java.util.List; import java.util.List;
import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
@ -14,14 +15,18 @@ import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.widget.Toast;
import com.osmand.OsmandSettings; import com.osmand.OsmandSettings;
import com.osmand.ProgressDialogImplementation;
import com.osmand.R; import com.osmand.R;
import com.osmand.ResourceManager;
import com.osmand.OsmandSettings.ApplicationMode; import com.osmand.OsmandSettings.ApplicationMode;
import com.osmand.map.TileSourceManager; import com.osmand.map.TileSourceManager;
import com.osmand.map.TileSourceManager.TileSourceTemplate; import com.osmand.map.TileSourceManager.TileSourceTemplate;
public class SettingsActivity extends PreferenceActivity implements OnPreferenceChangeListener { public class SettingsActivity extends PreferenceActivity implements OnPreferenceChangeListener, OnPreferenceClickListener {
private CheckBoxPreference showPoiOnMap; private CheckBoxPreference showPoiOnMap;
private CheckBoxPreference useInternetToDownloadTiles; private CheckBoxPreference useInternetToDownloadTiles;
@ -39,6 +44,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
private CheckBoxPreference autoZoom; private CheckBoxPreference autoZoom;
private EditTextPreference userPassword; private EditTextPreference userPassword;
private CheckBoxPreference useInternetToCalculateRoute; private CheckBoxPreference useInternetToCalculateRoute;
private Preference reloadIndexes;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -66,6 +72,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
useEnglishNames =(CheckBoxPreference) screen.findPreference(OsmandSettings.USE_ENGLISH_NAMES); useEnglishNames =(CheckBoxPreference) screen.findPreference(OsmandSettings.USE_ENGLISH_NAMES);
useEnglishNames.setOnPreferenceChangeListener(this); useEnglishNames.setOnPreferenceChangeListener(this);
reloadIndexes =(Preference) screen.findPreference(OsmandSettings.RELOAD_INDEXES);
reloadIndexes.setOnPreferenceClickListener(this);
userName = (EditTextPreference) screen.findPreference(OsmandSettings.USER_NAME); userName = (EditTextPreference) screen.findPreference(OsmandSettings.USER_NAME);
userName.setOnPreferenceChangeListener(this); userName.setOnPreferenceChangeListener(this);
userPassword = (EditTextPreference) screen.findPreference(OsmandSettings.USER_PASSWORD); userPassword = (EditTextPreference) screen.findPreference(OsmandSettings.USER_PASSWORD);
@ -76,7 +85,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
saveTrackInterval =(ListPreference) screen.findPreference(OsmandSettings.SAVE_TRACK_INTERVAL); saveTrackInterval =(ListPreference) screen.findPreference(OsmandSettings.SAVE_TRACK_INTERVAL);
saveTrackInterval.setOnPreferenceChangeListener(this); saveTrackInterval.setOnPreferenceChangeListener(this);
saveCurrentTrack =(Preference) screen.findPreference(OsmandSettings.SAVE_CURRENT_TRACK); saveCurrentTrack =(Preference) screen.findPreference(OsmandSettings.SAVE_CURRENT_TRACK);
saveCurrentTrack.setOnPreferenceChangeListener(this); saveCurrentTrack.setOnPreferenceClickListener(this);
positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP); positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP);
positionOnMap.setOnPreferenceChangeListener(this); positionOnMap.setOnPreferenceChangeListener(this);
@ -181,10 +191,6 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
} else if(preference == saveTrackToGpx){ } else if(preference == saveTrackToGpx){
edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, (Boolean) newValue); edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, (Boolean) newValue);
edit.commit(); edit.commit();
} else if(preference == saveCurrentTrack){
SavingTrackHelper helper = new SavingTrackHelper(this);
helper.saveDataToGpx();
helper.close();
} else if(preference == saveTrackInterval){ } else if(preference == saveTrackInterval){
edit.putInt(OsmandSettings.SAVE_TRACK_INTERVAL, Integer.parseInt(newValue.toString())); edit.putInt(OsmandSettings.SAVE_TRACK_INTERVAL, Integer.parseInt(newValue.toString()));
edit.commit(); edit.commit();
@ -217,6 +223,44 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
return true; return true;
} }
public void reloadIndexes(){
final ProgressDialog dlg = ProgressDialog.show(this, "Loading data", "Reading indices...", true);
final ProgressDialogImplementation impl = new ProgressDialogImplementation(dlg);
impl.setRunnable("Initializing app", new Runnable(){ //$NON-NLS-1$
@Override
public void run() {
try {
showWarnings(ResourceManager.getResourceManager().reloadIndexes(impl));
} finally {
dlg.dismiss();
}
}
});
impl.run();
}
protected void showWarnings(List<String> warnings) {
if (!warnings.isEmpty()) {
final StringBuilder b = new StringBuilder();
boolean f = true;
for (String w : warnings) {
if(f){
f = false;
} else {
b.append('\n');
}
b.append(w);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(SettingsActivity.this, b.toString(), Toast.LENGTH_LONG).show();
}
});
}
}
public void setAppMode(ApplicationMode preset, Editor edit){ public void setAppMode(ApplicationMode preset, Editor edit){
if(preset == ApplicationMode.CAR){ if(preset == ApplicationMode.CAR){
edit.putBoolean(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES, true); edit.putBoolean(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES, true);
@ -279,4 +323,18 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
} }
} }
@Override
public boolean onPreferenceClick(Preference preference) {
if(preference == reloadIndexes){
reloadIndexes();
return true;
} else if(preference == saveCurrentTrack){
SavingTrackHelper helper = new SavingTrackHelper(this);
helper.saveDataToGpx();
helper.close();
return true;
}
return false;
}
} }

View file

@ -1,93 +0,0 @@
package com.osmand.util;
/**
* @source http://www.javaworld.com/javaworld/javatips/jw-javatip47.html -- 24.11.2008, (mb)
*/
public class Base64 {
/*******************************************************************************************************************
* BASE 64 encoding of a String or an array of bytes. See also RFC 1421.
*
* @author Unknown
* @author David W. Croft
* @version 1998-06-08
******************************************************************************************************************/
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
public static final char[] alphabet = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47
'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55
'4', '5', '6', '7', '8', '9', '+', '/' }; // 56 to 63
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
public static String encode(final String s)
//////////////////////////////////////////////////////////////////////
{
return encode(s.getBytes());
}
public static String encode(final byte[] octetString)
//////////////////////////////////////////////////////////////////////
{
int bits24;
int bits6;
final char[] out = new char[((octetString.length - 1) / 3 + 1) * 4];
int outIndex = 0;
int i = 0;
while ((i + 3) <= octetString.length) {
// store the octets
bits24 = (octetString[i++] & 0xFF) << 16;
bits24 |= (octetString[i++] & 0xFF) << 8;
bits24 |= (octetString[i++] & 0xFF) << 0;
bits6 = (bits24 & 0x00FC0000) >> 18;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x0003F000) >> 12;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x00000FC0) >> 6;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x0000003F);
out[outIndex++] = alphabet[bits6];
}
if (octetString.length - i == 2) {
// store the octets
bits24 = (octetString[i] & 0xFF) << 16;
bits24 |= (octetString[i + 1] & 0xFF) << 8;
bits6 = (bits24 & 0x00FC0000) >> 18;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x0003F000) >> 12;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x00000FC0) >> 6;
out[outIndex++] = alphabet[bits6];
// padding
out[outIndex++] = '=';
} else if (octetString.length - i == 1) {
// store the octets
bits24 = (octetString[i] & 0xFF) << 16;
bits6 = (bits24 & 0x00FC0000) >> 18;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x0003F000) >> 12;
out[outIndex++] = alphabet[bits6];
// padding
out[outIndex++] = '=';
out[outIndex++] = '=';
}
return new String(out);
}
}