Fix intent activity starting

This commit is contained in:
Victor Shcherb 2011-06-25 16:30:23 +02:00
parent 05766453c8
commit fbcfe4d77a
13 changed files with 58 additions and 27 deletions

View file

@ -3,7 +3,7 @@
<ListPreference android:summary="@string/settings_preset_descr" android:title="@string/settings_preset" android:key="application_mode"></ListPreference>
<PreferenceScreen android:title="@string/rendering_settings" android:summary="@string/rendering_settings_descr">
<PreferenceScreen android:key="map_settings" android:title="@string/rendering_settings" android:summary="@string/rendering_settings_descr">
<CheckBoxPreference android:summary="@string/map_vector_data_descr" android:title="@string/map_vector_data"
android:key="map_vector_data"></CheckBoxPreference>
<ListPreference android:title="@string/map_tile_source" android:summary="@string/map_tile_source_descr" android:key="map_tile_sources"></ListPreference>
@ -28,7 +28,7 @@
</PreferenceScreen>
<PreferenceScreen android:title="@string/routing_settings" android:summary="@string/routing_settings_descr">
<PreferenceScreen android:key="routing_settings" android:title="@string/routing_settings" android:summary="@string/routing_settings_descr">
<ListPreference android:title="@string/router_service" android:key="router_service" android:summary="@string/router_service_descr"></ListPreference>
<CheckBoxPreference android:summary="@string/fast_route_mode_descr" android:title="@string/fast_route_mode"
android:key="fast_route_mode"></CheckBoxPreference>
@ -40,7 +40,7 @@
</PreferenceScreen>
<PreferenceScreen android:title="@string/index_settings" android:summary="@string/index_settings_descr">
<PreferenceScreen android:key="index_settings" android:title="@string/index_settings" android:summary="@string/index_settings_descr">
<Preference android:title="@string/reload_indexes" android:key="reload_indexes" android:summary="@string/reload_indexes_descr"></Preference>
<Preference android:title="@string/download_indexes" android:key="download_indexes" android:summary="@string/download_indexes_descr"></Preference>
</PreferenceScreen>
@ -57,7 +57,7 @@
</PreferenceScreen>
<PreferenceScreen android:title="@string/general_settings" android:summary="@string/general_settings_descr">
<PreferenceScreen android:key="general_settings" android:title="@string/general_settings" android:summary="@string/general_settings_descr">
<CheckBoxPreference android:key="use_internet_to_download_tiles" android:title="@string/use_internet" android:summary="@string/use_internet_to_download_tile"></CheckBoxPreference>
<ListPreference android:title="@string/max_level_download_tile" android:summary="@string/max_level_download_tile_descr"
android:key="max_level_download_tile"></ListPreference>
@ -76,7 +76,7 @@
</PreferenceScreen>
<PreferenceScreen android:title="@string/monitor_preferences" android:summary="@string/monitor_preferences_descr">
<PreferenceScreen android:key = "monitor_settings" android:title="@string/monitor_preferences" android:summary="@string/monitor_preferences_descr">
<CheckBoxPreference android:summary="@string/save_track_to_gpx_descrp" android:title="@string/save_track_to_gpx"
android:key="save_track_to_gpx"></CheckBoxPreference>
<ListPreference android:summary="@string/save_track_interval_descr" android:title="@string/save_track_interval"
@ -84,7 +84,7 @@
<Preference android:summary="@string/save_current_track_descr" android:title="@string/save_current_track" android:key="save_current_track"></Preference>
</PreferenceScreen>
<PreferenceScreen android:title="@string/osm_settings" android:summary="@string/osm_settings_descr">
<PreferenceScreen android:key = "osm_settings" android:title="@string/osm_settings" android:summary="@string/osm_settings_descr">
<!--
<CheckBoxPreference android:key="show_osm_bugs" android:title="@string/show_osm_bugs"
android:summary="@string/show_osm_bugs_descr"></CheckBoxPreference>

View file

@ -124,8 +124,7 @@ public class FavouritesActivity extends ListActivity {
FavouritePoint point = favouritesAdapter.getItem(position);
OsmandSettings.getOsmandSettings(this).SHOW_FAVORITES.set( true);
OsmandSettings.getOsmandSettings(this).setMapLocationToShow(point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName()); //$NON-NLS-1$
Intent newIntent = new Intent(FavouritesActivity.this, MapActivity.class);
startActivity(newIntent);
MapActivity.launchMapActivityMoveToTop(FavouritesActivity.this);
}
@Override
@ -134,8 +133,7 @@ public class FavouritesActivity extends ListActivity {
final FavouritePoint point = (FavouritePoint) favouritesAdapter.getItem(menuInfo.position);
if (aItem.getItemId() == NAVIGATE_TO) {
OsmandSettings.getOsmandSettings(this).setPointToNavigate(point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName());
Intent newIntent = new Intent(FavouritesActivity.this, MapActivity.class);
startActivity(newIntent);
MapActivity.launchMapActivityMoveToTop(this);
} else if (aItem.getItemId() == EDIT_ITEM) {
Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.favourites_edit_dialog_title);

View file

@ -224,6 +224,7 @@ public class MainMenuActivity extends Activity {
@Override
public void onClick(View v) {
final Intent search = new Intent(activity, SearchActivity.class);
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(search);
}
});
@ -294,6 +295,7 @@ public class MainMenuActivity extends Activity {
if (keyCode == KeyEvent.KEYCODE_SEARCH
&& event.getRepeatCount() == 0) {
final Intent search = new Intent(MainMenuActivity.this, SearchActivity.class);
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(search);
return true;
}

View file

@ -137,7 +137,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
private Notification getNotification(){
Intent notificationIndent = new Intent(this, MapActivity.class);
notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
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,
@ -359,6 +359,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
@Override
public void onClick(View v) {
final Intent search = new Intent(MapActivity.this, SearchActivity.class);
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
MapActivity.this.startActivity(search);
dlg.dismiss();
}
@ -381,6 +382,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
Intent newIntent = new Intent(MapActivity.this, SearchActivity.class);
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(newIntent);
return true;
}
@ -1327,6 +1329,12 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
public static void launchMapActivityMoveToTop(Activity activity){
Intent newIntent = new Intent(activity, MapActivity.class);
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(newIntent);
}
private Location getLocationToStartFrom(final double lat, final double lon) {
Location location = getLastKnownLocation();

View file

@ -68,8 +68,7 @@ public class NavigatePointActivity extends Activity {
if(dlg != null){
dlg.dismiss();
} else {
Intent newIntent = new Intent(this, MapActivity.class);
startActivity(newIntent);
MapActivity.launchMapActivityMoveToTop(this);
}
}

View file

@ -210,7 +210,9 @@ public class OsmandApplication extends Application {
@Override
public void onClick(DialogInterface dialog, int which) {
uiContext.startActivity(new Intent(uiContext, SettingsActivity.class));
Intent intent = new Intent(uiContext, SettingsActivity.class);
intent.putExtra(SettingsActivity.INTENT_KEY_SETTINGS_SCREEN, SettingsActivity.SCREEN_NAVIGATION_SETTINGS);
uiContext.startActivity(intent);
}
});
builder.setTitle(R.string.voice_is_not_available_title);

View file

@ -50,6 +50,12 @@ import android.preference.PreferenceScreen;
import android.widget.Toast;
public class SettingsActivity extends PreferenceActivity implements OnPreferenceChangeListener, OnPreferenceClickListener {
public static final String INTENT_KEY_SETTINGS_SCREEN = "INTENT_KEY_SETTINGS_SCREEN";
public static final int SCREEN_GENERAL_SETTINGS = 1;
public static final int SCREEN_NAVIGATION_SETTINGS = 2;
public static final int SCREEN_MONITORING_SETTINGS = 3;
private static final String MORE_VALUE = "MORE_VALUE";
private Preference saveCurrentTrack;
@ -300,6 +306,26 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
};
registerReceiver(broadcastReceiver, new IntentFilter(NavigationService.OSMAND_STOP_SERVICE_ACTION));
Intent intent = getIntent();
if(intent != null && intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0) != 0){
int s = intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0);
String pref = null;
if(s == SCREEN_GENERAL_SETTINGS){
pref = "general_settings";
} else if(s == SCREEN_NAVIGATION_SETTINGS){
pref = "routing_settings";
} else if(s == SCREEN_MONITORING_SETTINGS){
pref = "monitor_settings";
}
if(pref != null){
Preference toOpen = screen.findPreference(pref);
if(toOpen instanceof PreferenceScreen){
setPreferenceScreen((PreferenceScreen) toOpen);
}
}
}
}
private void updateApplicationDirTextAndSummary() {

View file

@ -82,7 +82,7 @@ public class ShowRouteInfoActivity extends ListActivity {
Location loc = helper.getLocationFromRouteDirection(item);
if(loc != null){
OsmandSettings.getOsmandSettings(this).setMapLocationToShow(loc.getLatitude(),loc.getLongitude());
startActivity(new Intent(this, MapActivity.class));
MapActivity.launchMapActivityMoveToTop(this);
}
}

View file

@ -157,7 +157,7 @@ public class GeoIntentActivity extends ListActivity {
getMyApplication().getSettings().setMapLocationToShow(item.getLocation()
.getLatitude(), item.getLocation().getLongitude(),
getString(R.string.address) + " : " + item.toString()); //$NON-NLS-1$
startActivity(new Intent(this, MapActivity.class));
MapActivity.launchMapActivityMoveToTop(this);
}
@Override

View file

@ -207,7 +207,7 @@ public class SearchAddressActivity extends Activity {
osmandSettings.setMapLocationToShow(l.getLatitude(), l.getLongitude(), zoom, historyName);
}
startActivity(new Intent(SearchAddressActivity.this, MapActivity.class));
MapActivity.launchMapActivityMoveToTop(SearchAddressActivity.this);
}
}

View file

@ -159,7 +159,7 @@ public class SearchAddressOnlineActivity extends ListActivity {
super.onListItemClick(l, v, position, id);
Place item = ((PlacesAdapter) getListAdapter()).getItem(position);
OsmandSettings.getOsmandSettings(this).setMapLocationToShow(item.lat, item.lon, getString(R.string.address)+ " : " + item.displayName); //$NON-NLS-1$
startActivity(new Intent(this, MapActivity.class));
MapActivity.launchMapActivityMoveToTop(this);
}
private static class Place {

View file

@ -84,8 +84,7 @@ public class SearchHistoryActivity extends ListActivity {
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setPointToNavigate(entry.getLat(), entry.getLon(), null);
}
Intent newIntent = new Intent(SearchHistoryActivity.this, MapActivity.class);
startActivity(newIntent);
MapActivity.launchMapActivityMoveToTop(SearchHistoryActivity.this);
}
@ -104,7 +103,7 @@ public class SearchHistoryActivity extends ListActivity {
private void selectModel(HistoryEntry model) {
helper.selectEntry(model, this);
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setMapLocationToShow(model.getLat(), model.getLon());
startActivity(new Intent(this, MapActivity.class));
MapActivity.launchMapActivityMoveToTop(this);
}

View file

@ -189,8 +189,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
if(/*searchNearBy && */location != null){
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), 15);
}
Intent newIntent = new Intent(SearchPOIActivity.this, MapActivity.class);
startActivity(newIntent);
MapActivity.launchMapActivityMoveToTop(SearchPOIActivity.this);
}
});
@ -242,8 +241,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
settings.SHOW_POI_OVER_MAP.set(true);
}
Intent newIntent = new Intent(SearchPOIActivity.this, MapActivity.class);
startActivity(newIntent);
MapActivity.launchMapActivityMoveToTop(SearchPOIActivity.this);
}
@ -488,8 +486,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
String poiSimpleFormat = OsmAndFormatter.getPoiSimpleFormat(amenity, this, settings.usingEnglishNames());
settings.setMapLocationToShow( amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(),
Math.max(16, z), getString(R.string.poi)+" : " + poiSimpleFormat); //$NON-NLS-1$
Intent newIntent = new Intent(SearchPOIActivity.this, MapActivity.class);
startActivity(newIntent);
MapActivity.launchMapActivityMoveToTop(SearchPOIActivity.this);
}
class DirectionDrawable extends Drawable {