diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index bc259e33b1..b2c08b53b3 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -1,64 +1,118 @@ + package="net.osmand.plus" + android:installLocation="auto" + android:versionCode="231" + android:versionName="@string/app_version" > - + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - + - - - - - - + + + + + + + + + + + - - - - - - + - - - - + + + + + + + - - - - - - - - + + + + + - - - - - - - - - + + + + + + + + + + + - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + --> + + + - - + + + + + + - - - - - - + - - - - - + - - - - - - - + + + + + + + + + + + + + + diff --git a/OsmAnd/src/net/osmand/access/AccessibleAlertBuilder.java b/OsmAnd/src/net/osmand/access/AccessibleAlertBuilder.java index b05dcff59a..fc9acc3aae 100644 --- a/OsmAnd/src/net/osmand/access/AccessibleAlertBuilder.java +++ b/OsmAnd/src/net/osmand/access/AccessibleAlertBuilder.java @@ -1,9 +1,10 @@ package net.osmand.access; +import android.content.Context; +import android.support.v7.app.AlertDialog; + import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import android.app.AlertDialog.Builder; -import android.content.Context; // Since usual message in an AlertDialog that is set by // AlertDialog.Builder.setMessage() is spoken only once @@ -17,7 +18,7 @@ import android.content.Context; // or system accessibility service is turned off this class // acts just identical to it's direct parent. // -public class AccessibleAlertBuilder extends Builder { +public class AccessibleAlertBuilder extends AlertDialog.Builder { // The method getContext() is only available // starting from API level 11, so store it here. @@ -33,14 +34,14 @@ public class AccessibleAlertBuilder extends Builder { // Provided setMessage() alternatives. @Override - public Builder setMessage(CharSequence msg) { + public AlertDialog.Builder setMessage(CharSequence msg) { if (((OsmandApplication) context.getApplicationContext()).accessibilityExtensions()) return setView(TextMessage.makeView(context, msg, R.layout.alert)); return super.setMessage(msg); } @Override - public Builder setMessage(int msgid) { + public AlertDialog.Builder setMessage(int msgid) { if (((OsmandApplication) context.getApplicationContext()).accessibilityExtensions()) return setView(TextMessage.makeView(context, msgid, R.layout.alert)); return super.setMessage(msgid); diff --git a/OsmAnd/src/net/osmand/access/NavigationInfo.java b/OsmAnd/src/net/osmand/access/NavigationInfo.java index fd8b288371..a403da14b0 100644 --- a/OsmAnd/src/net/osmand/access/NavigationInfo.java +++ b/OsmAnd/src/net/osmand/access/NavigationInfo.java @@ -1,8 +1,10 @@ package net.osmand.access; -import java.util.ArrayList; -import java.util.List; +import android.content.Context; +import android.content.DialogInterface; +import android.os.SystemClock; +import android.support.v7.app.AlertDialog; import net.osmand.Location; import net.osmand.data.LatLon; @@ -12,10 +14,9 @@ import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.access.RelativeDirectionStyle; -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.SystemClock; + +import java.util.ArrayList; +import java.util.List; public class NavigationInfo { @@ -26,14 +27,14 @@ public class NavigationInfo { private static final int UNKNOWN = -1; - private final int[] direction = { R.string.front, - R.string.front_right, - R.string.right, - R.string.back_right, + private final int[] direction = {R.string.front, + R.string.front_right, + R.string.right, + R.string.back_right, R.string.back, - R.string.back_left, - R.string.left, - R.string.front_left }; + R.string.back_left, + R.string.left, + R.string.front_left}; private RelativeDirectionStyle style; private int value; @@ -107,22 +108,22 @@ public class NavigationInfo { } - private final int[] cardinal = { R.string.north, + private final int[] cardinal = {R.string.north, R.string.north_north_east, - R.string.north_east, + R.string.north_east, R.string.east_north_east, - R.string.east, - R.string.east_south_east, + R.string.east, + R.string.east_south_east, R.string.south_east, R.string.south_south_east, R.string.south, R.string.south_south_west, - R.string.south_west, - R.string.west_south_west, - R.string.west, + R.string.south_west, + R.string.west_south_west, + R.string.west, R.string.west_north_west, - R.string.north_west, - R.string.north_north_west }; + R.string.north_west, + R.string.north_north_west}; private final OsmandApplication context; private final OsmandSettings settings; diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 170ab4e95e..4d7ea00e57 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -1,12 +1,12 @@ package net.osmand.plus; import android.app.Activity; -import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.support.v7.app.AlertDialog; import net.osmand.IProgress; import net.osmand.IndexConstants; diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 02346396f6..d31aebda87 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -1,5 +1,18 @@ package net.osmand.plus; +import android.content.Context; +import android.support.v7.app.AlertDialog; + +import net.osmand.PlatformUtil; +import net.osmand.data.FavouritePoint; +import net.osmand.plus.GPXUtilities.GPXFile; +import net.osmand.plus.GPXUtilities.WptPt; +import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; +import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; +import net.osmand.util.Algorithms; + +import org.apache.tools.bzip2.CBZip2OutputStream; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -12,19 +25,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import net.osmand.PlatformUtil; -import net.osmand.data.FavouritePoint; -import net.osmand.plus.GPXUtilities.GPXFile; -import net.osmand.plus.GPXUtilities.WptPt; -import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; -import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; -import net.osmand.util.Algorithms; - -import org.apache.tools.bzip2.CBZip2OutputStream; - -import android.app.AlertDialog; -import android.content.Context; - public class FavouritesDbHelper { public interface FavoritesUpdatedListener { diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index bad13015bd..48f40a6cbc 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -1,24 +1,5 @@ package net.osmand.plus; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import net.osmand.GeoidAltitudeCorrection; -import net.osmand.PlatformUtil; -import net.osmand.ResultMatcher; -import net.osmand.access.NavigationInfo; -import net.osmand.binary.RouteDataObject; -import net.osmand.data.LatLon; -import net.osmand.data.QuadPoint; -import net.osmand.plus.OsmandSettings.OsmandPreference; -import net.osmand.plus.TargetPointsHelper.TargetPoint; -import net.osmand.plus.routing.RoutingHelper; -import net.osmand.router.RouteSegmentResult; -import net.osmand.util.MapUtils; -import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -36,8 +17,28 @@ import android.location.LocationManager; import android.os.Build; import android.os.Bundle; import android.provider.Settings; +import android.support.v7.app.AlertDialog; import android.util.Log; +import net.osmand.GeoidAltitudeCorrection; +import net.osmand.PlatformUtil; +import net.osmand.ResultMatcher; +import net.osmand.access.NavigationInfo; +import net.osmand.binary.RouteDataObject; +import net.osmand.data.LatLon; +import net.osmand.data.QuadPoint; +import net.osmand.plus.OsmandSettings.OsmandPreference; +import net.osmand.plus.TargetPointsHelper.TargetPoint; +import net.osmand.plus.routing.RoutingHelper; +import net.osmand.router.RouteSegmentResult; +import net.osmand.util.MapUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + public class OsmAndLocationProvider implements SensorEventListener { private static final String SIMULATED_PROVIDER = "OsmAnd"; diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java index 28e7964249..86255733d5 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java @@ -1,18 +1,9 @@ package net.osmand.plus; -import java.util.ArrayList; -import java.util.List; - -import net.osmand.CallbackWithObject; -import net.osmand.Location; -import net.osmand.access.AccessibleToast; -import net.osmand.plus.helpers.GpxUiHelper; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; +import android.support.v7.app.AlertDialog; import android.view.View; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; @@ -22,6 +13,15 @@ import android.widget.SeekBar; import android.widget.TextView; import android.widget.Toast; +import net.osmand.CallbackWithObject; +import net.osmand.Location; +import net.osmand.access.AccessibleToast; +import net.osmand.plus.helpers.GpxUiHelper; +import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; + +import java.util.ArrayList; +import java.util.List; + public class OsmAndLocationSimulation { private Thread routeAnimation; @@ -53,7 +53,7 @@ public class OsmAndLocationSimulation { public void startStopRouteAnimation(final Activity ma, final Runnable runnable) { if (!isRouteAnimating()) { - Builder builder = new AlertDialog.Builder(ma); + AlertDialog.Builder builder = new AlertDialog.Builder(ma); builder.setTitle(R.string.animate_route); final View view = ma.getLayoutInflater().inflate(R.layout.animate_route, null); diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 53e1383f87..2b9b31e887 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -2,8 +2,6 @@ package net.osmand.plus; import android.app.Activity; import android.app.AlarmManager; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.app.Application; import android.app.PendingIntent; import android.content.Context; @@ -16,6 +14,7 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Handler; import android.os.Message; +import android.support.v7.app.AlertDialog; import android.text.format.DateFormat; import android.util.TypedValue; import android.view.View; @@ -342,7 +341,7 @@ public class OsmandApplication extends Application { String voiceProvider = osmandSettings.VOICE_PROVIDER.get(); if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) { if (warningNoneProvider && voiceProvider == null) { - Builder builder = new AccessibleAlertBuilder(uiContext); + AlertDialog.Builder builder = new AccessibleAlertBuilder(uiContext); LinearLayout ll = new LinearLayout(uiContext); ll.setOrientation(LinearLayout.VERTICAL); final TextView tv = new TextView(uiContext); @@ -408,7 +407,7 @@ public class OsmandApplication extends Application { public synchronized void closeApplication(final Activity activity) { if (getNavigationService() != null) { - Builder bld = new AlertDialog.Builder(activity); + AlertDialog.Builder bld = new AlertDialog.Builder(activity); bld.setMessage(R.string.background_service_is_enabled_question); bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java b/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java index 9ed66d56bc..25c174b5bd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java @@ -1,13 +1,9 @@ package net.osmand.plus.activities; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; import android.app.Activity; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.os.Bundle; -import android.preference.PreferenceActivity; import android.support.v4.view.ViewCompat; import android.support.v7.widget.Toolbar; import android.util.TypedValue; @@ -15,7 +11,11 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Spinner; -public abstract class ActionBarPreferenceActivity extends PreferenceActivity { +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; + +public abstract class ActionBarPreferenceActivity extends AppCompatPreferenceActivity { private Toolbar tb; private View shadowView; @@ -26,7 +26,7 @@ public abstract class ActionBarPreferenceActivity extends PreferenceActivity { @Override protected void onCreate(final Bundle savedInstanceState) { //settings needed it's own theme because of check boxes not styled properly - OsmandSettings settings = ((OsmandApplication)getApplication()).getSettings(); + OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings(); int t = R.style.OsmandLightTheme; if (settings.OSMAND_THEME.get() == OsmandSettings.OSMAND_DARK_THEME) { t = R.style.OsmandDarkTheme; @@ -44,7 +44,7 @@ public abstract class ActionBarPreferenceActivity extends PreferenceActivity { shadowView = null; } tb.setClickable(true); - tb.setNavigationIcon(((OsmandApplication)getApplication()).getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha)); + tb.setNavigationIcon(((OsmandApplication) getApplication()).getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha)); tb.setBackgroundColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTabBackground))); tb.setTitleTextColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTextColor))); tb.setNavigationOnClickListener(new View.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/activities/AppCompatPreferenceActivity.java b/OsmAnd/src/net/osmand/plus/activities/AppCompatPreferenceActivity.java new file mode 100644 index 0000000000..2e8e66a679 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/activities/AppCompatPreferenceActivity.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.osmand.plus.activities; +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.support.annotation.LayoutRes; +import android.support.annotation.Nullable; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatDelegate; +import android.support.v7.widget.Toolbar; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; +/** + * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls + * to be used with AppCompat. + * + * This technique can be used with an {@link android.app.Activity} class, not just + * {@link android.preference.PreferenceActivity}. + */ +public abstract class AppCompatPreferenceActivity extends PreferenceActivity { + private AppCompatDelegate mDelegate; + @Override + protected void onCreate(Bundle savedInstanceState) { + getDelegate().installViewFactory(); + getDelegate().onCreate(savedInstanceState); + super.onCreate(savedInstanceState); + } + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + getDelegate().onPostCreate(savedInstanceState); + } + public ActionBar getSupportActionBar() { + return getDelegate().getSupportActionBar(); + } + public void setSupportActionBar(@Nullable Toolbar toolbar) { + getDelegate().setSupportActionBar(toolbar); + } + @Override + public MenuInflater getMenuInflater() { + return getDelegate().getMenuInflater(); + } + @Override + public void setContentView(@LayoutRes int layoutResID) { + getDelegate().setContentView(layoutResID); + } + @Override + public void setContentView(View view) { + getDelegate().setContentView(view); + } + @Override + public void setContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().setContentView(view, params); + } + @Override + public void addContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().addContentView(view, params); + } + @Override + protected void onPostResume() { + super.onPostResume(); + getDelegate().onPostResume(); + } + @Override + protected void onTitleChanged(CharSequence title, int color) { + super.onTitleChanged(title, color); + getDelegate().setTitle(title); + } + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getDelegate().onConfigurationChanged(newConfig); + } + @Override + protected void onStop() { + super.onStop(); + getDelegate().onStop(); + } + @Override + protected void onDestroy() { + super.onDestroy(); + getDelegate().onDestroy(); + } + public void invalidateOptionsMenu() { + getDelegate().invalidateOptionsMenu(); + } + private AppCompatDelegate getDelegate() { + if (mDelegate == null) { + mDelegate = AppCompatDelegate.create(this, null); + } + return mDelegate; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java b/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java index 654b4f822e..72a351919c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java @@ -1,16 +1,19 @@ package net.osmand.plus.activities; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.text.MessageFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import android.app.ProgressDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.app.AlertDialog; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Filterable; +import android.widget.TextView; +import android.widget.Toast; import net.osmand.AndroidUtils; import net.osmand.access.AccessibleToast; @@ -20,21 +23,16 @@ import net.osmand.plus.R; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserFactory; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.app.ProgressDialog; -import android.content.DialogInterface; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Filterable; -import android.widget.TextView; -import android.widget.Toast; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.net.URLConnection; +import java.text.MessageFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; public class ContributionVersionActivity extends OsmandListActivity { @@ -210,7 +208,7 @@ public class ContributionVersionActivity extends OsmandListActivity { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { final OsmAndBuild item = (OsmAndBuild) getListAdapter().getItem(position); - Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(MessageFormat.format(getString(R.string.install_selected_build), item.tag, AndroidUtils.formatDateTime(getMyApplication(), item.date.getTime()), item.size)); builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadTilesDialog.java b/OsmAnd/src/net/osmand/plus/activities/DownloadTilesDialog.java index c7fe89c701..8ab074954f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadTilesDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadTilesDialog.java @@ -1,8 +1,14 @@ package net.osmand.plus.activities; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.support.v7.app.AlertDialog; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.SeekBar; +import android.widget.TextView; +import android.widget.Toast; import net.osmand.PlatformUtil; import net.osmand.access.AccessibleToast; @@ -23,18 +29,8 @@ import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.graphics.Rect; -import android.graphics.RectF; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.SeekBar; -import android.widget.TextView; -import android.widget.Toast; +import java.text.MessageFormat; +import java.util.List; public class DownloadTilesDialog { @@ -67,7 +63,7 @@ public class DownloadTilesDialog { final int zoom = rb.getZoom(); // calculate pixel rectangle - Builder builder = new AlertDialog.Builder(ctx); + AlertDialog.Builder builder = new AlertDialog.Builder(ctx); LayoutInflater inflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.download_tiles, null); diff --git a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java index 3e23a73de3..bad87840e6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java @@ -4,27 +4,10 @@ package net.osmand.plus.activities; -import java.text.Collator; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import net.osmand.osm.PoiCategory; -import net.osmand.osm.PoiType; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.plus.poi.PoiFiltersHelper; -import net.osmand.plus.poi.PoiUIFilter; -import net.osmand.util.Algorithms; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.os.Bundle; import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -35,9 +18,25 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.ListView; -import android.widget.ScrollView; import android.widget.TextView; +import net.osmand.osm.PoiCategory; +import net.osmand.osm.PoiType; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.poi.PoiFiltersHelper; +import net.osmand.plus.poi.PoiUIFilter; +import net.osmand.util.Algorithms; + +import java.text.Collator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + /** * */ @@ -112,7 +111,7 @@ public class EditPOIFilterActivity extends OsmandListActivity { final int index = lv.getFirstVisiblePosition(); View v = lv.getChildAt(0); final int top = (v == null) ? 0 : v.getTop(); - Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); final LinkedHashMap subCategories = new LinkedHashMap(); Set acceptedCategories = filter.getAcceptedSubtypes(poiCategory); if (acceptedCategories != null) { diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index 04d5fc23ed..0592f2714e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -1,16 +1,39 @@ package net.osmand.plus.activities; -import gnu.trove.list.array.TIntArrayList; - -import java.io.File; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import android.app.Activity; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.res.Resources; +import android.graphics.PorterDuff; +import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Handler; +import android.support.v4.app.FragmentActivity; +import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.AlertDialog; +import android.support.v7.view.ActionMode; +import android.support.v7.widget.SearchView; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.AutoCompleteTextView; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.ExpandableListView; +import android.widget.Filter; +import android.widget.Filterable; +import android.widget.ImageView; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; import net.osmand.access.AccessibleToast; import net.osmand.data.FavouritePoint; @@ -32,41 +55,18 @@ import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.res.Resources; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.graphics.drawable.Drawable; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Bundle; -import android.os.Handler; -import android.support.v4.app.FragmentActivity; -import android.support.v4.view.MenuItemCompat; -import android.support.v7.view.ActionMode; -import android.support.v7.widget.SearchView; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.AutoCompleteTextView; -import android.widget.CheckBox; -import android.widget.EditText; -import android.widget.ExpandableListView; -import android.widget.Filter; -import android.widget.Filterable; -import android.widget.ImageView; -import android.widget.Spinner; -import android.widget.TextView; -import android.widget.Toast; + +import java.io.File; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import gnu.trove.list.array.TIntArrayList; public class FavoritesTreeFragment extends OsmandExpandableListFragment { @@ -188,7 +188,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { public static boolean editPoint(final Context ctx, final FavouritePoint point, final Runnable callback) { OsmandApplication app = (OsmandApplication) ctx.getApplicationContext(); - final Builder builder = new AlertDialog.Builder(ctx); + final AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.favourites_context_menu_edit); final View v = LayoutInflater.from(ctx).inflate(R.layout.favorite_edit_dialog, null, false); @@ -247,7 +247,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { private boolean deletePoint(final FavouritePoint point) { final Resources resources = this.getResources(); - Builder builder = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(getString(R.string.favourites_remove_dialog_msg, point.getName())); builder.setNegativeButton(R.string.shared_string_no, null); builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @@ -295,7 +295,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper(); if (targetPointsHelper.getIntermediatePoints().size() > 0) { final FragmentActivity act = getActivity(); - Builder builder = new AlertDialog.Builder(act); + AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle(R.string.new_directions_point_dialog); builder.setItems( new String[] { act.getString(R.string.keep_intermediate_points), @@ -491,7 +491,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { } protected void openChangeGroupDialog(final FavoriteGroup group) { - Builder builder = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.fav_group_edit, null); final EditText nameEditText = (EditText) view.findViewById(R.id.nameEditText); @@ -532,7 +532,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { private void deleteFavoritesAction() { if (groupsToDelete.size() + favoritesSelected.size() > 0) { - Builder b = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); b.setMessage(getString(R.string.favorite_delete_multiple, favoritesSelected.size(), groupsToDelete.size())); b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() { @Override @@ -615,7 +615,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { }; if (tosave.exists()) { - Builder bld = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder bld = new AlertDialog.Builder(getActivity()); bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/OsmAnd/src/net/osmand/plus/activities/IntermediatePointsDialog.java b/OsmAnd/src/net/osmand/plus/activities/IntermediatePointsDialog.java index 8bb1a8423d..24e4ce0f62 100644 --- a/OsmAnd/src/net/osmand/plus/activities/IntermediatePointsDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/IntermediatePointsDialog.java @@ -1,29 +1,12 @@ package net.osmand.plus.activities; -import gnu.trove.list.array.TIntArrayList; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import net.osmand.Location; -import net.osmand.TspAnt; -import net.osmand.access.AccessibleAlertBuilder; -import net.osmand.data.LatLon; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.plus.TargetPointsHelper; -import net.osmand.plus.TargetPointsHelper.TargetPoint; -import net.osmand.util.MapUtils; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.app.Dialog; import android.content.DialogInterface; import android.content.DialogInterface.OnShowListener; import android.graphics.Color; import android.os.AsyncTask; +import android.support.v7.app.AlertDialog; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; @@ -38,6 +21,23 @@ import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; +import net.osmand.Location; +import net.osmand.TspAnt; +import net.osmand.access.AccessibleAlertBuilder; +import net.osmand.data.LatLon; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.TargetPointsHelper; +import net.osmand.plus.TargetPointsHelper.TargetPoint; +import net.osmand.util.MapUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import gnu.trove.list.array.TIntArrayList; + public class IntermediatePointsDialog { public static void openIntermediatePointsDialog(final Activity activity, @@ -86,7 +86,7 @@ public class IntermediatePointsDialog { } }); - Builder builder = new AccessibleAlertBuilder(activity); + AlertDialog.Builder builder = new AccessibleAlertBuilder(activity); builder.setView(contentView); builder.setInverseBackgroundForced(true); lv.setBackgroundColor(Color.WHITE); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 31d2d59694..0caf375378 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -1,14 +1,13 @@ package net.osmand.plus.activities; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; +import android.support.v7.app.AlertDialog; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -20,6 +19,7 @@ import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; + import net.londatiga.android.ActionItem; import net.londatiga.android.QuickAction; import net.osmand.IndexConstants; @@ -69,23 +69,23 @@ public class MapActivityActions implements DialogProvider { public static final String KEY_LONGITUDE = "longitude"; public static final String KEY_LATITUDE = "latitude"; public static final String KEY_NAME = "name"; - + public static final String KEY_ZOOM = "zoom"; private static final int DIALOG_ADD_FAVORITE = 100; private static final int DIALOG_REPLACE_FAVORITE = 101; private static final int DIALOG_ADD_WAYPOINT = 102; private static final int DIALOG_RELOAD_TITLE = 103; - + private static final int DIALOG_SAVE_DIRECTIONS = 106; // make static private static Bundle dialogBundle = new Bundle(); - + private final MapActivity mapActivity; private OsmandSettings settings; private RoutingHelper routingHelper; - public MapActivityActions(MapActivity mapActivity){ + public MapActivityActions(MapActivity mapActivity) { this.mapActivity = mapActivity; settings = mapActivity.getMyApplication().getSettings(); routingHelper = mapActivity.getMyApplication().getRoutingHelper(); @@ -94,14 +94,14 @@ public class MapActivityActions implements DialogProvider { public void showNavigationContextMenuPoint(final double latitude, final double longitude) { final ContextMenuAdapter adapter = new ContextMenuAdapter(mapActivity); - if(!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) { + if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) { adapter.item(R.string.context_menu_item_directions_to).iconColor( R.drawable.ic_action_gdirections_dark).reg(); adapter.item(R.string.context_menu_item_directions_from).iconColor( R.drawable.ic_action_gdirections_dark).reg(); } final TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); - if(targets.getPointToNavigate() != null) { + if (targets.getPointToNavigate() != null) { adapter.item(R.string.context_menu_item_destination_point).iconColor(R.drawable.ic_action_flag_dark).reg(); adapter.item(R.string.context_menu_item_intermediate_point).iconColor(R.drawable.ic_action_flage_dark).reg(); // For button-less search UI @@ -111,9 +111,9 @@ public class MapActivityActions implements DialogProvider { getMyApplication().getAppCustomization().prepareLocationMenu(mapActivity, adapter); - final Builder builder = new AlertDialog.Builder(mapActivity); + final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity); builder.setTitle(R.string.get_directions); - final ArrayAdapter listAdapter = + final ArrayAdapter listAdapter = adapter.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContent()); builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() { @@ -152,7 +152,7 @@ public class MapActivityActions implements DialogProvider { public void addAsWaypoint(double latitude, double longitude) { TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); - boolean destination = (targets.getPointToNavigate() == null); + boolean destination = (targets.getPointToNavigate() == null); targets.navigateToPoint(new LatLon(latitude, longitude), true, destination ? -1 : targets.getIntermediatePoints().size(), @@ -171,7 +171,7 @@ public class MapActivityActions implements DialogProvider { aBundle.putString(KEY_NAME, name); return aBundle; } - + private Bundle enhance(Bundle bundle, double latitude, double longitude, final int zoom) { bundle.putDouble(KEY_LATITUDE, latitude); bundle.putDouble(KEY_LONGITUDE, longitude); @@ -180,7 +180,7 @@ public class MapActivityActions implements DialogProvider { } - public void addWaypoint(final double latitude, final double longitude) { + public void addWaypoint(final double latitude, final double longitude) { String name; PointDescription pointDescription = mapActivity.getContextMenu().getPointDescription(); if (!pointDescription.isWpt() && !mapActivity.getContextMenu().isAddressUnknown()) { @@ -188,12 +188,12 @@ public class MapActivityActions implements DialogProvider { } else { name = ""; } - enhance(dialogBundle,latitude,longitude, name); - mapActivity.showDialog(DIALOG_ADD_WAYPOINT); - } + enhance(dialogBundle, latitude, longitude, name); + mapActivity.showDialog(DIALOG_ADD_WAYPOINT); + } - private Dialog createAddWaypointDialog(final Bundle args) { - Builder builder = new AlertDialog.Builder(mapActivity); + private Dialog createAddWaypointDialog(final Bundle args) { + AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity); builder.setTitle(R.string.add_waypoint_dialog_title); View view = mapActivity.getLayoutInflater().inflate(R.layout.add_gpx_point_dialog, null); final EditText editText = (EditText) view.findViewById(android.R.id.edit); @@ -222,60 +222,60 @@ public class MapActivityActions implements DialogProvider { } }); return alertDialog; - } - - public void reloadTile(final int zoom, final double latitude, final double longitude){ - enhance(dialogBundle,latitude,longitude,zoom); - mapActivity.showDialog(DIALOG_RELOAD_TITLE); - } + } - protected String getString(int res){ - return mapActivity.getString(res); - } - - protected void showToast(final String msg){ - mapActivity.runOnUiThread(new Runnable() { + public void reloadTile(final int zoom, final double latitude, final double longitude) { + enhance(dialogBundle, latitude, longitude, zoom); + mapActivity.showDialog(DIALOG_RELOAD_TITLE); + } + + protected String getString(int res) { + return mapActivity.getString(res); + } + + protected void showToast(final String msg) { + mapActivity.runOnUiThread(new Runnable() { @Override public void run() { AccessibleToast.makeText(mapActivity, msg, Toast.LENGTH_LONG).show(); } }); - } - - - public void aboutRoute() { - Intent intent = new Intent(mapActivity, ShowRouteInfoActivity.class); + } + + + public void aboutRoute() { + Intent intent = new Intent(mapActivity, ShowRouteInfoActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); mapActivity.startActivity(intent); - } - - protected Location getLastKnownLocation() { + } + + protected Location getLastKnownLocation() { return getMyApplication().getLocationProvider().getLastKnownLocation(); } protected OsmandApplication getMyApplication() { return mapActivity.getMyApplication(); } - + public void saveDirections() { mapActivity.showDialog(DIALOG_SAVE_DIRECTIONS); } - - public static Dialog createSaveDirections(Activity activity, RoutingHelper routingHelper) { + + public static Dialog createSaveDirections(Activity activity, RoutingHelper routingHelper) { final OsmandApplication app = ((OsmandApplication) activity.getApplication()); final File fileDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); final Dialog dlg = new Dialog(activity); dlg.setTitle(R.string.shared_string_save_as_gpx); dlg.setContentView(R.layout.save_directions_dialog); final EditText edit = (EditText) dlg.findViewById(R.id.FileNameEdit); - - final GPXRouteParamsBuilder rp = routingHelper.getCurrentGPXRoute(); - final String editText; - if (rp == null || rp.getFile() == null || rp.getFile().path == null) { - editText = "_" + MessageFormat.format("{0,date,yyyy-MM-dd}", new Date()) + "_"; - } else { - editText = new File(rp.getFile().path).getName(); - } + + final GPXRouteParamsBuilder rp = routingHelper.getCurrentGPXRoute(); + final String editText; + if (rp == null || rp.getFile() == null || rp.getFile().path == null) { + editText = "_" + MessageFormat.format("{0,date,yyyy-MM-dd}", new Date()) + "_"; + } else { + editText = new File(rp.getFile().path).getName(); + } edit.setText(editText); ((Button) dlg.findViewById(R.id.Save)).setOnClickListener(new View.OnClickListener() { @@ -298,20 +298,20 @@ public class MapActivityActions implements DialogProvider { } } }); - + ((Button) dlg.findViewById(R.id.Cancel)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dlg.dismiss(); } }); - - + + return dlg; } private static class SaveDirectionsAsyncTask extends AsyncTask { - + private final OsmandApplication app; public SaveDirectionsAsyncTask(OsmandApplication app) { @@ -328,14 +328,14 @@ public class MapActivityActions implements DialogProvider { } return null; } - + @Override protected void onPostExecute(String result) { - if(result != null){ + if (result != null) { AccessibleToast.makeText(app, result, Toast.LENGTH_LONG).show(); } } - + } public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) { @@ -343,9 +343,9 @@ public class MapActivityActions implements DialogProvider { adapter.item(R.string.context_menu_item_search).iconColor(R.drawable.ic_action_search_dark).reg(); OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj); getMyApplication().getAppCustomization().prepareLocationMenu(mapActivity, adapter); - - final Builder builder = new AlertDialog.Builder(mapActivity); - final ArrayAdapter listAdapter = + + final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity); + final ArrayAdapter listAdapter = adapter.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContent()); builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() { @@ -368,9 +368,9 @@ public class MapActivityActions implements DialogProvider { } public void setGPXRouteParams(GPXFile result) { - if(result == null) { + if (result == null) { mapActivity.getRoutingHelper().setGpxParams(null); - settings.FOLLOW_THE_GPX_ROUTE.set(null); + settings.FOLLOW_THE_GPX_ROUTE.set(null); } else { GPXRouteParamsBuilder params = new GPXRouteParamsBuilder(result, mapActivity.getMyApplication() .getSettings()); @@ -396,7 +396,7 @@ public class MapActivityActions implements DialogProvider { } } } - + public void enterRoutePlanningMode(final LatLon from, final PointDescription fromName, boolean useCurrentGPX) { List selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper() .getSelectedGPXFiles(); @@ -410,8 +410,8 @@ public class MapActivityActions implements DialogProvider { } if (gpxFiles.size() > 0 && !useCurrentGPX) { - Builder bld = new AlertDialog.Builder(mapActivity); - if (gpxFiles.size() == 1){ + AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity); + if (gpxFiles.size() == 1) { bld.setMessage(R.string.use_displayed_track_for_navigation); bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override @@ -421,15 +421,15 @@ public class MapActivityActions implements DialogProvider { }); } else { bld.setTitle(R.string.navigation_over_track); - ArrayAdapter adapter =new ArrayAdapter(mapActivity, R.layout.drawer_list_item, gpxFiles){ + ArrayAdapter adapter = new ArrayAdapter(mapActivity, R.layout.drawer_list_item, gpxFiles) { @Override public View getView(int position, View convertView, ViewGroup parent) { - if (convertView == null){ + if (convertView == null) { convertView = mapActivity.getLayoutInflater().inflate(R.layout.drawer_list_item, null); } String path = getItem(position).path; - String name = path.substring(path.lastIndexOf("/") + 1,path.length()); - ((TextView)convertView.findViewById(R.id.title)).setText(name); + String name = path.substring(path.lastIndexOf("/") + 1, path.length()); + ((TextView) convertView.findViewById(R.id.title)).setText(name); convertView.findViewById(R.id.icon).setVisibility(View.GONE); convertView.findViewById(R.id.check_item).setVisibility(View.GONE); return convertView; @@ -454,7 +454,7 @@ public class MapActivityActions implements DialogProvider { enterRoutePlanningModeImpl(useCurrentGPX ? gpxFiles.get(0) : null, from, fromName); } } - + private void enterRoutePlanningModeImpl(GPXFile gpxFile, LatLon from, PointDescription fromName) { OsmandApplication app = mapActivity.getMyApplication(); @@ -474,11 +474,11 @@ public class MapActivityActions implements DialogProvider { setGPXRouteParams(gpxFile); // then update start and destination point targets.updateRouteAndReferesh(true); - + mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode(); mapActivity.getMapView().refreshMap(true); mapActivity.getMapLayers().getMapControlsLayer().showDialog(); - if(targets.hasTooLongDistanceToNavigate()) { + if (targets.hasTooLongDistanceToNavigate()) { app.showToastMessage(R.string.route_is_too_long); } } @@ -494,39 +494,39 @@ public class MapActivityActions implements DialogProvider { from = new LatLon(ll.getLatitude(), ll.getLongitude()); } } - if( selected != ApplicationMode.DEFAULT) { + if (selected != ApplicationMode.DEFAULT) { mode = selected; } else if (mode == ApplicationMode.DEFAULT) { mode = ApplicationMode.CAR; - if(settings.LAST_ROUTING_APPLICATION_MODE != null && + if (settings.LAST_ROUTING_APPLICATION_MODE != null && settings.LAST_ROUTING_APPLICATION_MODE != ApplicationMode.DEFAULT) { mode = settings.LAST_ROUTING_APPLICATION_MODE; } - if(from != null && targets.getPointToNavigate() != null) { + if (from != null && targets.getPointToNavigate() != null) { double dist = MapUtils.getDistance(from, targets.getPointToNavigate().getLatitude(), targets.getPointToNavigate().getLongitude()); - if(dist >= 50000 && mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) { - mode = ApplicationMode.CAR ; - } else if(dist >= 300000 && mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) { - mode = ApplicationMode.CAR ; - } else if(dist < 2000 && mode.isDerivedRoutingFrom(ApplicationMode.CAR)) { - mode = ApplicationMode.PEDESTRIAN ; + if (dist >= 50000 && mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) { + mode = ApplicationMode.CAR; + } else if (dist >= 300000 && mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) { + mode = ApplicationMode.CAR; + } else if (dist < 2000 && mode.isDerivedRoutingFrom(ApplicationMode.CAR)) { + mode = ApplicationMode.PEDESTRIAN; } } } return mode; } - public void contextMenuPoint(final double latitude, final double longitude){ + public void contextMenuPoint(final double latitude, final double longitude) { contextMenuPoint(latitude, longitude, null, null); } - + private Dialog createReloadTitleDialog(final Bundle args) { - Builder builder = new AccessibleAlertBuilder(mapActivity); - builder.setMessage(R.string.context_menu_item_update_map_confirm); - builder.setNegativeButton(R.string.shared_string_cancel, null); - final OsmandMapTileView mapView = mapActivity.getMapView(); - builder.setPositiveButton(R.string.context_menu_item_update_map, new DialogInterface.OnClickListener() { + AlertDialog.Builder builder = new AccessibleAlertBuilder(mapActivity); + builder.setMessage(R.string.context_menu_item_update_map_confirm); + builder.setNegativeButton(R.string.shared_string_cancel, null); + final OsmandMapTileView mapView = mapActivity.getMapView(); + builder.setPositiveButton(R.string.context_menu_item_update_map, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int zoom = args.getInt(KEY_ZOOM); @@ -558,9 +558,8 @@ public class MapActivityActions implements DialogProvider { } }); return builder.create(); - } - - + } + @Override public Dialog onCreateDialog(int id) { @@ -584,21 +583,21 @@ public class MapActivityActions implements DialogProvider { public void onPrepareDialog(int id, Dialog dialog) { Bundle args = dialogBundle; switch (id) { - case DIALOG_ADD_FAVORITE: - FavoriteDialogs.prepareAddFavouriteDialog(mapActivity, dialog, args, - args.getDouble(KEY_LATITUDE), args.getDouble(KEY_LONGITUDE), - new PointDescription(PointDescription.POINT_TYPE_FAVORITE, args.getString(KEY_NAME))); - break; - case DIALOG_ADD_WAYPOINT: - EditText v = (EditText) dialog.getWindow().findViewById(android.R.id.edit); - v.setPadding(5, 0, 5, 0); - if(args.getString(KEY_NAME) != null) { - v.setText(args.getString(KEY_NAME)); - v.selectAll(); - } else { - v.setText(""); - } - break; + case DIALOG_ADD_FAVORITE: + FavoriteDialogs.prepareAddFavouriteDialog(mapActivity, dialog, args, + args.getDouble(KEY_LATITUDE), args.getDouble(KEY_LONGITUDE), + new PointDescription(PointDescription.POINT_TYPE_FAVORITE, args.getString(KEY_NAME))); + break; + case DIALOG_ADD_WAYPOINT: + EditText v = (EditText) dialog.getWindow().findViewById(android.R.id.edit); + v.setPadding(5, 0, 5, 0); + if (args.getString(KEY_NAME) != null) { + v.setText(args.getString(KEY_NAME)); + v.selectAll(); + } else { + v.setText(""); + } + break; } } @@ -650,7 +649,7 @@ public class MapActivityActions implements DialogProvider { LatLon loc = mapActivity.getMapLocation(); newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude()); newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude()); - if(mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation()) { + if (mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation()) { newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true); } newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); @@ -670,7 +669,7 @@ public class MapActivityActions implements DialogProvider { return true; } }).reg(); - + optionsMenuHelper.item(R.string.show_point_options).iconColor(R.drawable.ic_action_marker_dark) .listen(new OnContextMenuClick() { @@ -699,10 +698,10 @@ public class MapActivityActions implements DialogProvider { } }).reg(); String d = getString(R.string.index_settings); - if(app.getDownloadThread().getIndexes().isDownloadedFromInternet) { + if (app.getDownloadThread().getIndexes().isDownloadedFromInternet) { List updt = app.getDownloadThread().getIndexes().getItemsToUpdate(); - if(updt != null && updt.size() > 0) { - d += " ("+updt.size()+")"; + if (updt != null && updt.size() > 0) { + d += " (" + updt.size() + ")"; } } optionsMenuHelper.item(R.string.index_settings).name(d).iconColor(R.drawable.ic_type_archive) @@ -716,7 +715,7 @@ public class MapActivityActions implements DialogProvider { return true; } }).reg(); - + optionsMenuHelper.item(R.string.prefs_plugins).iconColor(R.drawable.ic_extension_dark) .listen(new OnContextMenuClick() { @@ -729,7 +728,7 @@ public class MapActivityActions implements DialogProvider { return true; } }).reg(); - + optionsMenuHelper.item(R.string.shared_string_settings).iconColor(R.drawable.ic_action_settings) .listen(new OnContextMenuClick() { @@ -742,17 +741,17 @@ public class MapActivityActions implements DialogProvider { } }).reg(); optionsMenuHelper.item(R.string.shared_string_help).iconColor(R.drawable.ic_action_help) - .listen(new OnContextMenuClick() { - @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { - mapActivity.startActivity(new Intent(mapActivity, HelpActivity.class)); - return true; - } - }).reg(); + .listen(new OnContextMenuClick() { + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + mapActivity.startActivity(new Intent(mapActivity, HelpActivity.class)); + return true; + } + }).reg(); //////////// Others OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper); - + // optionsMenuHelper.item(R.string.shared_string_exit).iconColor(R.drawable.ic_action_quit_dark ) // .listen(new OnContextMenuClick() { // @Override @@ -773,21 +772,21 @@ public class MapActivityActions implements DialogProvider { return optionsMenuHelper; } - - public void openIntermediatePointsDialog(){ + + public void openIntermediatePointsDialog() { mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); } - public void openIntermediateEditPointsDialog(){ + public void openIntermediateEditPointsDialog() { mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); } private TargetPointsHelper getTargets() { return mapActivity.getMyApplication().getTargetPointsHelper(); } - + public void stopNavigationWithoutConfirm() { - if(getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) { + if (getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) { getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity); } routingHelper.getVoiceRouter().interruptRouteCommands(); @@ -797,9 +796,9 @@ public class MapActivityActions implements DialogProvider { settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get()); mapActivity.updateApplicationModeSettings(); } - + public AlertDialog stopNavigationActionConfirm() { - Builder builder = new AlertDialog.Builder(mapActivity); + AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity); // Stop the navigation builder.setTitle(getString(R.string.cancel_route)); builder.setMessage(getString(R.string.stop_routing_confirm)); @@ -812,9 +811,8 @@ public class MapActivityActions implements DialogProvider { builder.setNegativeButton(R.string.shared_string_no, null); return builder.show(); } - - + public void whereAmIDialog() { final List items = new ArrayList(); items.add(getString(R.string.show_location)); @@ -825,30 +823,27 @@ public class MapActivityActions implements DialogProvider { public void onClick(DialogInterface dialog, int item) { dialog.dismiss(); switch (item) { - case 0: - mapActivity.getMapViewTrackingUtilities().backToLocationImpl(); - break; - case 1: - OsmAndLocationProvider locationProvider = getMyApplication().getLocationProvider(); - locationProvider.showNavigationInfo(mapActivity.getPointToNavigate(), mapActivity); - break; - default: - break; + case 0: + mapActivity.getMapViewTrackingUtilities().backToLocationImpl(); + break; + case 1: + OsmAndLocationProvider locationProvider = getMyApplication().getLocationProvider(); + locationProvider.showNavigationInfo(mapActivity.getPointToNavigate(), mapActivity); + break; + default: + break; } } }); menu.show(); } - - - - + public static void showObjectContextMenu(final ContextMenuAdapter qa, final Activity activity, - final OnClickListener onShow) { + final OnClickListener onShow) { OsmandApplication app = (OsmandApplication) activity.getApplication(); - if(app.accessibilityEnabled()) { - Builder builder = new AlertDialog.Builder(activity); + if (app.accessibilityEnabled()) { + AlertDialog.Builder builder = new AlertDialog.Builder(activity); String[] values = qa.getItemNames(); builder.setItems(values, new DialogInterface.OnClickListener() { @Override @@ -910,5 +905,5 @@ public class MapActivityActions implements DialogProvider { } }); } - + } diff --git a/OsmAnd/src/net/osmand/plus/activities/OpeningHoursView.java b/OsmAnd/src/net/osmand/plus/activities/OpeningHoursView.java index f601005671..7d965c2146 100644 --- a/OsmAnd/src/net/osmand/plus/activities/OpeningHoursView.java +++ b/OsmAnd/src/net/osmand/plus/activities/OpeningHoursView.java @@ -1,20 +1,10 @@ package net.osmand.plus.activities; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.List; - -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule; -import net.osmand.util.OpeningHoursParser.OpeningHoursRule; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnMultiChoiceClickListener; import android.graphics.Typeface; +import android.support.v7.app.AlertDialog; import android.text.format.DateFormat; import android.view.LayoutInflater; import android.view.View; @@ -26,6 +16,16 @@ import android.widget.TextView; import android.widget.TimePicker; import android.widget.TimePicker.OnTimeChangedListener; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule; +import net.osmand.util.OpeningHoursParser.OpeningHoursRule; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; + public class OpeningHoursView { private final Context ctx; @@ -160,7 +160,7 @@ public class OpeningHoursView { } public void showDaysDialog(final BasicOpeningHourRule item, final int positionToAdd) { - Builder b = new AlertDialog.Builder(ctx); + AlertDialog.Builder b = new AlertDialog.Builder(ctx); boolean add = positionToAdd > -1; Calendar inst = Calendar.getInstance(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java index 462607b6d0..02c83a6ddd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java @@ -1,13 +1,25 @@ package net.osmand.plus.activities; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; +import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnMultiChoiceClickListener; +import android.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.EditTextPreference; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.Preference.OnPreferenceClickListener; +import android.preference.PreferenceGroup; +import android.preference.PreferenceScreen; +import android.support.v7.app.AlertDialog; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.TextView; +import android.widget.Toast; import net.osmand.access.AccessibleToast; import net.osmand.plus.ApplicationMode; @@ -18,28 +30,15 @@ import net.osmand.plus.OsmandSettings.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.activities.actions.AppModeDialog; import net.osmand.plus.views.SeekBarPreference; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.Context; -import android.content.DialogInterface; -import android.content.DialogInterface.OnMultiChoiceClickListener; -import android.graphics.Color; -import android.os.Bundle; -import android.preference.CheckBoxPreference; -import android.preference.EditTextPreference; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.Preference.OnPreferenceChangeListener; -import android.preference.Preference.OnPreferenceClickListener; -import android.preference.PreferenceGroup; -import android.preference.PreferenceScreen; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.TextView; -import android.widget.Toast; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity @@ -399,7 +398,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity } protected void profileDialog() { - Builder b = new AlertDialog.Builder(this); + AlertDialog.Builder b = new AlertDialog.Builder(this); final Set selected = new LinkedHashSet(); View v = AppModeDialog.prepareAppModeView(this, selected, false, null, true, new View.OnClickListener() { @@ -538,7 +537,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity public void showBooleanSettings(String[] vals, final OsmandPreference[] prefs) { - Builder bld = new AlertDialog.Builder(this); + AlertDialog.Builder bld = new AlertDialog.Builder(this); boolean[] checkedItems = new boolean[prefs.length]; for (int i = 0; i < prefs.length; i++) { checkedItems[i] = prefs[i].get(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index d8f790db02..49d2444c50 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -1,8 +1,6 @@ package net.osmand.plus.activities; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.app.Dialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; @@ -21,9 +19,11 @@ import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; +import android.support.v7.app.AlertDialog; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.Toast; + import net.osmand.IProgress; import net.osmand.IndexConstants; import net.osmand.access.AccessibleToast; @@ -62,7 +62,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(Bundle savedInstanceState) { ((OsmandApplication) getApplication()).applyTheme(this); super.onCreate(savedInstanceState); getToolbar().setTitle(R.string.global_app_settings); @@ -73,10 +73,9 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { settings = getMyApplication().getSettings(); - ApplicationMode[] appModes = ApplicationMode.values(settings).toArray(new ApplicationMode[0]); entries = new String[appModes.length]; - for(int i=0; i= 19) { - showAppDirDialogV19(); - return; + public void showAppDirDialog() { + if (Build.VERSION.SDK_INT >= 19) { + showAppDirDialogV19(); + return; } AlertDialog.Builder editalert = new AlertDialog.Builder(SettingsGeneralActivity.this); editalert.setTitle(R.string.application_dir); final EditText input = new EditText(SettingsGeneralActivity.this); input.setText(settings.getExternalStorageDirectory().getAbsolutePath()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT); + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT); lp.leftMargin = lp.rightMargin = 5; lp.bottomMargin = lp.topMargin = 5; input.setLayoutParams(lp); @@ -328,16 +325,16 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { editalert.setView(input); editalert.setNegativeButton(R.string.shared_string_cancel, null); editalert.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - warnAboutChangingStorage(input.getText().toString()); - } + public void onClick(DialogInterface dialog, int whichButton) { + warnAboutChangingStorage(input.getText().toString()); + } }); editalert.show(); } private void showAppDirDialogV19() { - Builder bld = new AlertDialog.Builder(this); + AlertDialog.Builder bld = new AlertDialog.Builder(this); ChooseAppDirFragment frg = new DashChooseAppDirFragment.ChooseAppDirFragment(this, (Dialog) null); bld.setView(frg.initView(getLayoutInflater(), null, null)); AlertDialog dlg = bld.show(); @@ -345,7 +342,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { } - private void addMiscPreferences(PreferenceGroup misc) { if (!Version.isBlackberry(getMyApplication())) { applicationDir = new Preference(this); @@ -380,7 +376,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { registerListPreference( settings.OSMAND_THEME, misc, - new String[] { getString(R.string.dark_theme), getString(R.string.light_theme) }, new Integer[] { OsmandSettings.OSMAND_DARK_THEME, + new String[]{getString(R.string.dark_theme), getString(R.string.light_theme)}, new Integer[]{OsmandSettings.OSMAND_DARK_THEME, OsmandSettings.OSMAND_LIGHT_THEME}); misc.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr)); @@ -388,9 +384,8 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { } - private void updateApplicationDirTextAndSummary() { - if(applicationDir != null) { + if (applicationDir != null) { String storageDir = settings.getExternalStorageDirectory().getAbsolutePath(); applicationDir.setSummary(storageDir); } @@ -445,15 +440,14 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { } - private void restartApp() { - Builder bld = new AlertDialog.Builder(this); + AlertDialog.Builder bld = new AlertDialog.Builder(this); bld.setMessage(R.string.restart_is_required); bld.setPositiveButton(R.string.shared_string_ok, new OnClickListener() { - + @Override public void onClick(DialogInterface dialog, int which) { - android.os.Process.killProcess(android.os.Process.myPid()); + android.os.Process.killProcess(android.os.Process.myPid()); // Intent intent = getIntent(); // finish(); // startActivity(intent); @@ -463,12 +457,11 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { } - private void warnAboutChangingStorage(final String newValue) { String newDir = newValue != null ? newValue.trim() : newValue; - if(!newDir.replace('/', ' ').trim(). + if (!newDir.replace('/', ' ').trim(). toLowerCase().endsWith(IndexConstants.APP_DIR.replace('/', ' ').trim())) { - newDir += "/" +IndexConstants.APP_DIR; + newDir += "/" + IndexConstants.APP_DIR; } final File path = new File(newDir); path.mkdirs(); @@ -476,14 +469,14 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { AccessibleToast.makeText(this, R.string.specified_dir_doesnt_exist, Toast.LENGTH_LONG).show(); return; } - Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string.application_dir_change_warning3)); builder.setPositiveButton(R.string.shared_string_yes, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MoveFilesToDifferentDirectory task = new MoveFilesToDifferentDirectory(SettingsGeneralActivity.this, - settings.getExternalStorageDirectory(), path); + settings.getExternalStorageDirectory(), path); task.setRunOnSuccess(new Runnable() { @Override public void run() { @@ -515,7 +508,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { public void reloadIndexes() { setProgressVisibility(true); final CharSequence oldTitle = getToolbar().getTitle(); - getToolbar(). setTitle(getString(R.string.loading_data)); + getToolbar().setTitle(getString(R.string.loading_data)); getToolbar().setSubtitle(getString(R.string.reading_indexes)); new AsyncTask>() { @@ -597,7 +590,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { entrieValues[k] = OsmandSettings.VOICE_PROVIDER_NOT_USE; entries[k++] = getString(R.string.shared_string_do_not_use); for (String s : voiceFiles) { - entries[k] = (s.contains("tts") ? getString(R.string.ttsvoice) +" ":"") + + entries[k] = (s.contains("tts") ? getString(R.string.ttsvoice) + " " : "") + FileNameTranslationHelper.getVoiceName(this, s); entrieValues[k] = s; k++; @@ -621,6 +614,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { } return setFiles; } - - + + } diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index 61b3db4a18..7680ec07e6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -1,9 +1,18 @@ package net.osmand.plus.activities; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import android.app.admin.DevicePolicyManager; +import android.content.ComponentName; +import android.content.DialogInterface; +import android.content.DialogInterface.OnMultiChoiceClickListener; +import android.content.Intent; +import android.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.PreferenceCategory; +import android.preference.PreferenceScreen; +import android.support.v7.app.AlertDialog; import net.osmand.plus.ApplicationMode; import net.osmand.plus.DeviceAdminRecv; @@ -18,19 +27,10 @@ import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter.RoutingParameter; import net.osmand.router.GeneralRouter.RoutingParameterType; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.app.admin.DevicePolicyManager; -import android.content.ComponentName; -import android.content.DialogInterface; -import android.content.DialogInterface.OnMultiChoiceClickListener; -import android.content.Intent; -import android.os.Bundle; -import android.preference.CheckBoxPreference; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.PreferenceCategory; -import android.preference.PreferenceScreen; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; public class SettingsNavigationActivity extends SettingsBaseActivity { @@ -391,7 +391,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { } private void confirmSpeedCamerasDlg() { - Builder bld = new AlertDialog.Builder(this); + AlertDialog.Builder bld = new AlertDialog.Builder(this); bld.setMessage(R.string.confirm_usage_speed_cameras); bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @@ -405,7 +405,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { } public AlertDialog showBooleanSettings(String[] vals, final OsmandPreference[] prefs, final CharSequence title) { - Builder bld = new AlertDialog.Builder(this); + AlertDialog.Builder bld = new AlertDialog.Builder(this); boolean[] checkedItems = new boolean[prefs.length]; for (int i = 0; i < prefs.length; i++) { checkedItems[i] = prefs[i].get(); diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java index 68f62293c3..33e935b224 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java @@ -1,15 +1,6 @@ package net.osmand.plus.activities.actions; -import java.util.ArrayList; -import java.util.List; - -import net.osmand.access.AccessibleAlertBuilder; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.plus.Version; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; @@ -18,10 +9,19 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; +import android.support.v7.app.AlertDialog; import android.text.ClipboardManager; import android.text.Html; import android.widget.Toast; +import net.osmand.access.AccessibleAlertBuilder; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.Version; + +import java.util.ArrayList; +import java.util.List; + public class ShareDialog { private Activity a; @@ -113,7 +113,7 @@ public class ShareDialog { if(type == ACTION) { runnable.run(); } else if(type == VIEW) { - Builder bld = new AlertDialog.Builder(a); + AlertDialog.Builder bld = new AlertDialog.Builder(a); bld.setTitle(title); bld.setMessage(content); bld.show(); @@ -131,7 +131,7 @@ public class ShareDialog { } public void showDialog() { - AlertDialog.Builder builder = new Builder(a); + AlertDialog.Builder builder = new AlertDialog.Builder(a); builder.setTitle(title); String[] shareStrings = new String[share.size()]; for(int i = 0; i < shareStrings.length; i++) { diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java index 2386b769e1..8c762c5037 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java @@ -1,12 +1,6 @@ package net.osmand.plus.activities.actions; -import net.osmand.access.AccessibleAlertBuilder; -import net.osmand.plus.R; -import net.osmand.plus.Version; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.views.OsmandMapTileView; import android.app.Activity; -import android.app.AlertDialog; import android.app.Dialog; import android.content.ActivityNotFoundException; import android.content.DialogInterface; @@ -16,6 +10,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.support.v7.app.AlertDialog; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; @@ -28,6 +23,12 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; +import net.osmand.access.AccessibleAlertBuilder; +import net.osmand.plus.R; +import net.osmand.plus.Version; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.views.OsmandMapTileView; + public class StartGPSStatus extends OsmAndAction { public enum GpsStatusApps { diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java index f1adaf5153..7c8fc394ee 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java @@ -1,12 +1,11 @@ package net.osmand.plus.activities.search; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentActivity; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.PopupMenu; import android.view.LayoutInflater; import android.view.Menu; @@ -36,7 +35,6 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmAndListFragment; import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild; import net.osmand.plus.dashboard.DashLocationFragment; -import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.util.MapUtils; @@ -80,7 +78,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA } private void clearWithConfirmation() { - Builder bld = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder bld = new AlertDialog.Builder(getActivity()); bld.setMessage(R.string.confirmation_to_clear_history); bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index 7647126075..0385561205 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -3,16 +3,37 @@ */ package net.osmand.plus.activities.search; -import gnu.trove.set.hash.TLongHashSet; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.os.AsyncTask; +import android.os.AsyncTask.Status; +import android.os.Bundle; +import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.AlertDialog; +import android.support.v7.widget.PopupMenu; +import android.support.v7.widget.Toolbar; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MenuItem.OnMenuItemClickListener; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.Filter; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; import net.osmand.Location; import net.osmand.ResultMatcher; @@ -43,38 +64,17 @@ import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser.OpeningHours; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.os.AsyncTask; -import android.os.AsyncTask.Status; -import android.os.Bundle; -import android.support.v4.view.MenuItemCompat; -import android.support.v7.widget.PopupMenu; -import android.support.v7.widget.Toolbar; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; -import android.view.MenuItem.OnMenuItemClickListener; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.view.inputmethod.InputMethodManager; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.EditText; -import android.widget.Filter; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.LinearLayout.LayoutParams; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import gnu.trove.set.hash.TLongHashSet; /** * Search poi activity @@ -860,7 +860,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa private void removePoiFilter() { - Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.edit_filter_delete_dialog_title); builder.setNegativeButton(R.string.shared_string_no, null); builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @@ -881,7 +881,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa } public void savePoiFilter() { - Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.edit_filter_save_as_menu_item); final EditText editText = new EditText(this); if(filter.isStandardFilter()) { diff --git a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java index 9258109555..1f9d4bf637 100644 --- a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java +++ b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java @@ -1,32 +1,31 @@ package net.osmand.plus.base; -import java.io.File; -import java.util.ArrayList; +import android.content.DialogInterface; +import android.content.DialogInterface.OnCancelListener; +import android.content.DialogInterface.OnDismissListener; +import android.os.AsyncTask; +import android.os.Handler; +import android.support.v7.app.AlertDialog; +import android.widget.TextView; import net.osmand.PlatformUtil; import net.osmand.access.AccessibleAlertBuilder; import net.osmand.data.LatLon; import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities.GPXFile; -import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; +import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.RoutingHelper; import org.apache.commons.logging.Log; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.DialogInterface; -import android.content.DialogInterface.OnCancelListener; -import android.content.DialogInterface.OnDismissListener; -import android.os.AsyncTask; -import android.os.Handler; -import android.widget.TextView; +import java.io.File; +import java.util.ArrayList; public class FailSafeFuntions { private static boolean quitRouteRestoreDialog = false; @@ -49,7 +48,7 @@ public class FailSafeFuntions { @Override public void run() { - Builder builder = new AccessibleAlertBuilder(ma); + AlertDialog.Builder builder = new AccessibleAlertBuilder(ma); final TextView tv = new TextView(ma); tv.setText(ma.getString(R.string.continue_follow_previous_route_auto, delay + "")); tv.setPadding(7, 5, 7, 5); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java index 71a414fd3b..9be40f2c05 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java @@ -1,6 +1,37 @@ package net.osmand.plus.dashboard; -import gnu.trove.list.array.TIntArrayList; +import android.annotation.TargetApi; +import android.app.Activity; +import android.app.Dialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.os.AsyncTask; +import android.os.Build; +import android.os.Bundle; +import android.os.StatFs; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentActivity; +import android.support.v7.app.AlertDialog; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import net.osmand.IndexConstants; +import net.osmand.ValueHolder; +import net.osmand.access.AccessibleToast; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.ProgressImplementation; +import net.osmand.plus.R; +import net.osmand.util.Algorithms; import java.io.File; import java.io.FileInputStream; @@ -13,37 +44,7 @@ import java.util.HashSet; import java.util.List; import java.util.Locale; -import net.osmand.IndexConstants; -import net.osmand.ValueHolder; -import net.osmand.access.AccessibleToast; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.ProgressImplementation; -import net.osmand.plus.R; -import net.osmand.util.Algorithms; -import android.annotation.TargetApi; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.AsyncTask; -import android.os.Build; -import android.os.Bundle; -import android.os.StatFs; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.widget.Toast; +import gnu.trove.list.array.TIntArrayList; public class DashChooseAppDirFragment { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashNavigationFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashNavigationFragment.java index 693e38ef91..cce745f16c 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashNavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashNavigationFragment.java @@ -1,10 +1,10 @@ package net.osmand.plus.dashboard; -import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java index e971d570b8..6c0cc3e4a8 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java @@ -1,10 +1,9 @@ package net.osmand.plus.dashboard; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.PopupMenu; import android.view.LayoutInflater; import android.view.MenuItem; @@ -195,7 +194,7 @@ public class DashWaypointsFragment extends DashLocationFragment { protected void deletePointConfirm(final TargetPoint point, View view) { final boolean target = point == getMyApplication().getTargetPointsHelper().getPointToNavigate(); - Builder builder = new AlertDialog.Builder(view.getContext()); + AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); // Stop the navigation builder.setTitle(getString(R.string.delete_target_point)); builder.setMessage(PointDescription.getSimpleName(point, getActivity())); diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java index c1aae01d1a..f7487c2e9c 100644 --- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java @@ -2,8 +2,6 @@ package net.osmand.plus.development; import android.annotation.SuppressLint; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.Intent; import android.os.Bundle; import android.os.Debug; @@ -13,6 +11,7 @@ import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; +import android.support.v7.app.AlertDialog; import android.view.View; import net.osmand.plus.ApplicationMode; @@ -207,7 +206,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity { } protected void availableProfileDialog() { - Builder b = new AlertDialog.Builder(this); + AlertDialog.Builder b = new AlertDialog.Builder(this); final List modes = ApplicationMode.allPossibleValues(); modes.remove(ApplicationMode.DEFAULT); final Set selected = new LinkedHashSet(ApplicationMode.values(settings)); diff --git a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java index 194198b8cf..d3678c7c18 100644 --- a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java @@ -1,12 +1,11 @@ package net.osmand.plus.development; import android.app.ActionBar; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.pm.ActivityInfo; import android.os.Build; import android.os.Bundle; +import android.support.v7.app.AlertDialog; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; @@ -106,7 +105,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity { } k++; } - Builder bld = new AlertDialog.Builder(this); + AlertDialog.Builder bld = new AlertDialog.Builder(this); bld.setSingleChoiceItems(entrieValues, selected, new DialogInterface.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/dialogs/DirectionsDialogs.java b/OsmAnd/src/net/osmand/plus/dialogs/DirectionsDialogs.java index c1536626dd..88d60838d5 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/DirectionsDialogs.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/DirectionsDialogs.java @@ -1,9 +1,8 @@ package net.osmand.plus.dialogs; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.PopupMenu; import net.osmand.data.LatLon; @@ -23,7 +22,7 @@ public class DirectionsDialogs { final OsmandApplication ctx = (OsmandApplication) act.getApplication(); final TargetPointsHelper targetPointsHelper = ctx.getTargetPointsHelper(); if (targetPointsHelper.getIntermediatePoints().size() > 0) { - Builder builder = new AlertDialog.Builder(act); + AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle(R.string.new_directions_point_dialog); builder.setItems( new String[] { act.getString(R.string.keep_intermediate_points), @@ -51,7 +50,7 @@ public class DirectionsDialogs { final OsmandApplication ctx = (OsmandApplication) act.getApplication(); final TargetPointsHelper targetPointsHelper = ctx.getTargetPointsHelper(); if (targetPointsHelper.getPointToNavigate() != null) { - Builder builder = new AlertDialog.Builder(act); + AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle(R.string.new_destination_point_dialog); builder.setItems( new String[] { act.getString(R.string.replace_destination_point), diff --git a/OsmAnd/src/net/osmand/plus/dialogs/FavoriteDialogs.java b/OsmAnd/src/net/osmand/plus/dialogs/FavoriteDialogs.java index 72f89f8fce..1abfd26bb1 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/FavoriteDialogs.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/FavoriteDialogs.java @@ -1,8 +1,6 @@ package net.osmand.plus.dialogs; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; @@ -10,6 +8,7 @@ import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnDismissListener; import android.content.res.Resources; import android.os.Bundle; +import android.support.v7.app.AlertDialog; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -98,7 +97,7 @@ public class FavoriteDialogs { } public static Dialog createAddFavouriteDialog(final Activity activity, final Bundle args) { - Builder builder = new AlertDialog.Builder(activity); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.favourites_context_menu_edit); final View v = activity.getLayoutInflater().inflate(R.layout.favorite_edit_dialog, null, false); final FavouritesDbHelper helper = ((OsmandApplication) activity.getApplication()).getFavorites(); @@ -138,7 +137,7 @@ public class FavoriteDialogs { point.setName(editText.getText().toString().trim()); point.setDescription(description.getText().toString().trim()); point.setCategory(categoryStr); - Builder bld = FavouritesDbHelper.checkDuplicates(point, helper, activity); + AlertDialog.Builder bld = FavouritesDbHelper.checkDuplicates(point, helper, activity); if(bld != null) { bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override @@ -172,7 +171,7 @@ public class FavoriteDialogs { final FavouritesAdapter favouritesAdapter, final OnItemClickListener click, final OnDismissListener dismissListener, final Dialog[] dialogHolder, final boolean sortByDist) { ListView listView = new ListView(uiContext); - Builder bld = new AlertDialog.Builder(uiContext); + AlertDialog.Builder bld = new AlertDialog.Builder(uiContext); final Collator inst = Collator.getInstance(); favouritesAdapter.sort(new Comparator() { diff --git a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java index d097c12ee7..4c28d53ede 100644 --- a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java +++ b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java @@ -1,8 +1,6 @@ package net.osmand.plus.distancecalculator; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; @@ -17,6 +15,7 @@ import android.graphics.Paint.Style; import android.graphics.Path; import android.graphics.PointF; import android.os.AsyncTask; +import android.support.v7.app.AlertDialog; import android.text.Editable; import android.text.TextWatcher; import android.view.View; @@ -170,7 +169,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin { } } private void showDialog(final MapActivity activity) { - Builder bld = new AlertDialog.Builder(activity); + AlertDialog.Builder bld = new AlertDialog.Builder(activity); final TIntArrayList list = new TIntArrayList(); if(distanceMeasurementMode == 0) { list.add(R.string.distance_measurement_start_editing); @@ -257,7 +256,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin { } protected void saveGpx(final MapActivity activity) { - Builder b = new AlertDialog.Builder(activity); + AlertDialog.Builder b = new AlertDialog.Builder(activity); final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); LinearLayout ll = new LinearLayout(activity); ll.setOrientation(LinearLayout.VERTICAL); @@ -393,7 +392,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin { final CommonPreference pref = app.getSettings().registerBooleanPreference("show_measurement_help_first_time", true); pref.makeGlobal(); if(pref.get()) { - Builder builder = new AlertDialog.Builder(ctx); + AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(R.string.use_distance_measurement_help); builder.setNegativeButton(R.string.shared_string_do_not_show_again, new OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index f603283be2..0036014865 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -2,7 +2,6 @@ package net.osmand.plus.download; import android.annotation.SuppressLint; import android.app.Activity; -import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -16,6 +15,7 @@ import android.os.AsyncTask.Status; import android.os.Build; import android.os.StatFs; import android.support.annotation.UiThread; +import android.support.v7.app.AlertDialog; import android.support.v7.app.NotificationCompat; import android.support.v7.app.NotificationCompat.Builder; import android.view.View; diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java b/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java index d08f45b066..3a74d29639 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java @@ -1,19 +1,5 @@ package net.osmand.plus.download; -import java.lang.ref.WeakReference; -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Set; - -import net.osmand.access.AccessibleToast; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.Version; -import net.osmand.plus.activities.ActionBarProgressActivity; -import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; -import android.app.Activity; -import android.app.AlertDialog; import android.app.Dialog; import android.content.ActivityNotFoundException; import android.content.Context; @@ -22,12 +8,20 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; -import android.support.annotation.UiThread; import android.support.v4.app.DialogFragment; -import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; +import android.support.v7.app.AlertDialog; import android.widget.Toast; +import net.osmand.access.AccessibleToast; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.Version; +import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; + +import java.text.MessageFormat; + public class DownloadValidationManager { public static final int MAXIMUM_AVAILABLE_FREE_DOWNLOADS = 5; protected OsmandSettings settings; @@ -40,11 +34,11 @@ public class DownloadValidationManager { downloadThread = app.getDownloadThread(); } - + public DownloadIndexesThread getDownloadThread() { return downloadThread; } - + public void startDownload(FragmentActivity activity, IndexItem... items) { downloadFilesWithAllChecks(activity, items); } @@ -82,16 +76,15 @@ public class DownloadValidationManager { downloadFileCheck_Final_Run(activity, items); } } - + private void downloadFileCheck_Final_Run(FragmentActivity activity, IndexItem[] items) { downloadThread.runDownloadFiles(items); - if(activity instanceof DownloadEvents) { + if (activity instanceof DownloadEvents) { ((DownloadEvents) activity).downloadInProgress(); } } - - - + + protected void downloadFilesWithAllChecks(FragmentActivity activity, IndexItem[] items) { downloadFilesCheck_1_FreeVersion(activity, items); } @@ -131,7 +124,6 @@ public class DownloadValidationManager { } } - public void makeSureUserCancelDownload(Context ctx, final IndexItem item) { AlertDialog.Builder bld = new AlertDialog.Builder(ctx); @@ -147,9 +139,10 @@ public class DownloadValidationManager { bld.setNegativeButton(R.string.shared_string_no, null); bld.show(); } - + public static class InstallPaidVersionDialogFragment extends DialogFragment { public static final String TAG = "InstallPaidVersionDialogFragment"; + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ActiveDownloadsDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/ActiveDownloadsDialogFragment.java index 1137650526..067d6d5481 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ActiveDownloadsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ActiveDownloadsDialogFragment.java @@ -1,21 +1,22 @@ package net.osmand.plus.download.ui; -import java.util.ArrayList; -import java.util.List; +import android.app.Dialog; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; import net.osmand.plus.R; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.download.IndexItem; -import android.app.AlertDialog; -import android.app.Dialog; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.DialogFragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; + +import java.util.ArrayList; +import java.util.List; public class ActiveDownloadsDialogFragment extends DialogFragment implements DownloadEvents { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index b0ef9c77e9..7ce7581d5c 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -1,7 +1,6 @@ package net.osmand.plus.download.ui; import android.annotation.SuppressLint; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; @@ -369,7 +368,7 @@ public class ItemViewHolder { : LocalIndexType.VOICE_DATA; } final LocalIndexInfo info = new LocalIndexInfo(tp, fl, false); - Builder confirm = new Builder(context); + AlertDialog.Builder confirm = new AlertDialog.Builder(context); confirm.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index 98fd3d026a..4f915a9967 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -1,20 +1,40 @@ package net.osmand.plus.download.ui; -import java.io.File; -import java.text.Collator; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import android.app.Activity; +import android.content.DialogInterface; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.graphics.PorterDuff; +import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AlertDialog; +import android.support.v7.view.ActionMode; +import android.support.v7.widget.PopupMenu; +import android.util.TypedValue; +import android.view.ContextMenu; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.SubMenu; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.ExpandableListView; +import android.widget.ExpandableListView.ExpandableListContextMenuInfo; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; import net.osmand.IndexConstants; -import net.osmand.PlatformUtil; import net.osmand.access.AccessibleToast; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; @@ -38,42 +58,18 @@ import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdate; import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdateList; import net.osmand.util.Algorithms; -import org.apache.commons.logging.Log; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.DialogInterface; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.graphics.drawable.Drawable; -import android.os.AsyncTask; -import android.os.Bundle; -import android.support.v4.view.MenuItemCompat; -import android.support.v7.app.ActionBar; -import android.support.v7.view.ActionMode; -import android.support.v7.widget.PopupMenu; -import android.util.TypedValue; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.SubMenu; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.CheckBox; -import android.widget.EditText; -import android.widget.ExpandableListView; -import android.widget.ExpandableListView.ExpandableListContextMenuInfo; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; +import java.io.File; +import java.text.Collator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; public class LocalIndexesFragment extends OsmandExpandableListFragment implements DownloadEvents { @@ -170,7 +166,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } private void showContextMenu(final LocalIndexInfo info) { - Builder builder = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final ContextMenuAdapter adapter = new ContextMenuAdapter(getActivity()); basicFileOperation(info, adapter); OsmandPlugin.onContextMenuActivity(getActivity(), null, info, adapter); @@ -224,7 +220,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } else if (resId == R.string.local_index_mi_restore) { new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.RESTORE_OPERATION).execute(info); } else if (resId == R.string.shared_string_delete) { - Builder confirm = new Builder(getActivity()); + AlertDialog.Builder confirm = new AlertDialog.Builder(getActivity()); confirm.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -244,7 +240,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } public static void renameFile(final Activity a, final File f, final Runnable callback) { - Builder b = new AlertDialog.Builder(a); + AlertDialog.Builder b = new AlertDialog.Builder(a); if (f.exists()) { int xt = f.getName().lastIndexOf('.'); final String ext = xt == -1 ? "" : f.getName().substring(xt); @@ -679,7 +675,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement return true; } - Builder builder = new AlertDialog.Builder(getDownloadActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(getDownloadActivity()); builder.setMessage(getString(R.string.local_index_action_do, actionButton.toLowerCase(), selectedItems.size())); builder.setPositiveButton(actionButton, listener); builder.setNegativeButton(R.string.shared_string_cancel, null); diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java index 52594a48c0..98592988bf 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java +++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java @@ -1,8 +1,7 @@ package net.osmand.plus.helpers; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; +import android.support.v7.app.AlertDialog; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; @@ -103,7 +102,7 @@ public class AvoidSpecificRoads { } public void showDialog(final MapActivity mapActivity) { - Builder bld = new AlertDialog.Builder(mapActivity); + AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity); bld.setTitle(R.string.impassable_road); if (getMissingRoads().size() == 0){ bld.setMessage(R.string.avoid_roads_msg); diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java index ad1f25d12d..f2f22ccea4 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java @@ -1,6 +1,5 @@ package net.osmand.plus.helpers; -import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; @@ -9,7 +8,9 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.ParcelFileDescriptor; import android.provider.OpenableColumns; +import android.support.v7.app.AlertDialog; import android.widget.Toast; + import net.osmand.IndexConstants; import net.osmand.access.AccessibleToast; import net.osmand.data.FavouritePoint; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index 5c55a18a07..ce0471711d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -1,10 +1,10 @@ package net.osmand.plus.mapcontextmenu.controllers; -import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.AsyncTask; +import android.support.v7.app.AlertDialog; import net.osmand.binary.BinaryMapDataObject; import net.osmand.data.LatLon; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/EditCategoryDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/EditCategoryDialogFragment.java index b52679ff42..b49969967c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/EditCategoryDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/EditCategoryDialogFragment.java @@ -1,11 +1,11 @@ package net.osmand.plus.mapcontextmenu.editors; -import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; import android.view.View; import android.widget.AdapterView; import android.widget.Button; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java index 9f425f2fe6..5d2a22874e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java @@ -1,11 +1,11 @@ package net.osmand.plus.mapcontextmenu.editors; import android.app.Activity; -import android.app.AlertDialog; import android.content.DialogInterface; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectCategoryDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectCategoryDialogFragment.java index 70548697ad..0986145534 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectCategoryDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectCategoryDialogFragment.java @@ -1,7 +1,6 @@ package net.osmand.plus.mapcontextmenu.editors; import android.app.Activity; -import android.app.AlertDialog; import android.app.Dialog; import android.content.res.Resources; import android.graphics.PorterDuff; @@ -9,6 +8,7 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; import android.util.TypedValue; import android.view.View; import android.widget.Button; diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index 010388f42d..ee15fc88e2 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -1,11 +1,10 @@ package net.osmand.plus.monitoring; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; +import android.support.v7.app.AlertDialog; import android.util.DisplayMetrics; import android.view.View; import android.view.WindowManager; @@ -247,7 +246,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { private void controlDialog(final Activity map) { final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); - Builder bld = new AlertDialog.Builder(map); + AlertDialog.Builder bld = new AlertDialog.Builder(map); final TIntArrayList items = new TIntArrayList(); if(wasTrackMonitored) { items.add(R.string.gpx_monitoring_stop); @@ -381,7 +380,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { public static void showIntervalChooseDialog(final Context uiCtx, final String patternMsg, String title, final int[] seconds, final int[] minutes, final ValueHolder choice, final ValueHolder v, OnClickListener onclick){ - Builder dlg = new AlertDialog.Builder(uiCtx); + AlertDialog.Builder dlg = new AlertDialog.Builder(uiCtx); dlg.setTitle(title); WindowManager mgr = (WindowManager) uiCtx.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 8026e36afa..a0a4a10d9c 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -1,8 +1,6 @@ package net.osmand.plus.myplaces; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -13,6 +11,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.AlertDialog; import android.support.v7.view.ActionMode; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.SearchView; @@ -32,6 +31,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; + import net.osmand.IndexConstants; import net.osmand.access.AccessibleToast; import net.osmand.plus.ContextMenuAdapter; @@ -526,7 +526,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { return true; } - Builder builder = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(getString(R.string.local_index_action_do, actionButton.toLowerCase(), selectedItems.size())); builder.setPositiveButton(actionButton, listener); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java index 4b0b69bacd..28e855de4c 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java @@ -2,8 +2,6 @@ package net.osmand.plus.myplaces; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; @@ -11,7 +9,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.support.v4.view.MenuItemCompat; -import android.support.v7.widget.PopupMenu; +import android.support.v7.app.AlertDialog; import android.text.Html; import android.view.LayoutInflater; import android.view.Menu; @@ -30,7 +28,6 @@ import android.widget.TextView; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; -import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.WptPt; @@ -47,7 +44,6 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmAndListFragment; import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.FavoriteImageDrawable; -import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.util.Algorithms; @@ -206,7 +202,7 @@ public class SelectedGPXFragment extends OsmAndListFragment { } protected void saveAsFavorites(final GpxDisplayItemType gpxDisplayItemType) { - Builder b = new AlertDialog.Builder(getMyActivity()); + AlertDialog.Builder b = new AlertDialog.Builder(getMyActivity()); final EditText editText = new EditText(getMyActivity()); final List gs = filterGroups(gpxDisplayItemType); if (gs.size() == 0) { @@ -280,7 +276,7 @@ public class SelectedGPXFragment extends OsmAndListFragment { ColorDialogs.setupColorSpinner(getActivity(), getGpx().getColor(0), colorSpinner, list); final Spinner sp = (Spinner) view.findViewById(R.id.Spinner); - Builder bld = new AlertDialog.Builder(getMyActivity()); + AlertDialog.Builder bld = new AlertDialog.Builder(getMyActivity()); final List distanceSplit = new ArrayList(); final TIntArrayList timeSplit = new TIntArrayList(); if(groups.size() == 0) { diff --git a/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java b/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java index e62d67931d..5a4a8c1114 100644 --- a/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java @@ -1,11 +1,10 @@ package net.osmand.plus.openseamapsplugin; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; +import android.support.v7.app.AlertDialog; import net.osmand.IndexConstants; import net.osmand.plus.OsmandApplication; @@ -59,7 +58,7 @@ public class NauticalMapsPlugin extends OsmandPlugin { app.getSettings().RENDERER.set(RendererRegistry.NAUTICAL_RENDER); if(!app.getResourceManager().getIndexFileNames().containsKey("World_seamarks"+ IndexConstants.BINARY_MAP_INDEX_EXT)){ - Builder dlg = new AlertDialog.Builder(activity); + AlertDialog.Builder dlg = new AlertDialog.Builder(activity); dlg.setMessage(net.osmand.plus.R.string.nautical_maps_missing); dlg.setPositiveButton(R.string.shared_string_ok, new OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java index 497fc291f0..4847d97b64 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java @@ -1,9 +1,9 @@ package net.osmand.plus.osmedit; -import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index d803c04b21..76aeaf0ac4 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -1,8 +1,6 @@ package net.osmand.plus.osmedit; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.app.Dialog; import android.content.DialogInterface; import android.graphics.Canvas; @@ -10,6 +8,7 @@ import android.graphics.Paint; import android.graphics.PointF; import android.os.AsyncTask; import android.os.Bundle; +import android.support.v7.app.AlertDialog; import android.util.Xml; import android.view.View; import android.widget.EditText; @@ -320,7 +319,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider private Dialog createOpenBugDialog(final Bundle args) { final View openBug = activity.getLayoutInflater().inflate(R.layout.open_bug, null); - Builder builder = new AlertDialog.Builder(activity); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.osb_add_dialog_title); builder.setView(openBug); builder.setNegativeButton(R.string.shared_string_cancel, null); @@ -406,7 +405,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider } private Dialog createCommentBugDialog(final Bundle args) { - Builder builder = new AlertDialog.Builder(activity); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.osb_comment_dialog_title); final View view = activity.getLayoutInflater().inflate(R.layout.open_bug, null); builder.setView(view); @@ -453,7 +452,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider } private Dialog createCloseBugDialog(final Bundle args) { - Builder builder = new AlertDialog.Builder(activity); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.osb_close_dialog_title); builder.setNegativeButton(R.string.shared_string_cancel, null); builder.setPositiveButton(R.string.osb_close_dialog_close_button, new DialogInterface.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 5d4aa42fb2..b90efd6765 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -1,13 +1,12 @@ package net.osmand.plus.osmedit; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.support.v4.app.Fragment; +import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.widget.ArrayAdapter; @@ -285,7 +284,7 @@ public class OsmEditingPlugin extends OsmandPlugin { AccessibleToast.makeText(la, R.string.validate_gpx_upload_name_pwd, Toast.LENGTH_LONG).show(); return false; } - Builder bldr = new AlertDialog.Builder(la); + AlertDialog.Builder bldr = new AlertDialog.Builder(la); LayoutInflater inflater = (LayoutInflater) la.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View view = inflater.inflate(R.layout.send_gpx_osm, null); final EditText descr = (EditText) view.findViewById(R.id.memory_size); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index b915e1c412..4a449f54a4 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -1,6 +1,5 @@ package net.osmand.plus.osmedit; -import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.content.DialogInterface; @@ -11,6 +10,7 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.AlertDialog; import android.support.v7.view.ActionMode; import android.support.v7.widget.PopupMenu; import android.util.Xml; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java index d69075340f..538c16683b 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java @@ -1,11 +1,11 @@ package net.osmand.plus.osmedit.dialogs; -import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; import net.osmand.data.Amenity; import net.osmand.osm.MapPoiTypes; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java index 3344d83f5e..b9f1641914 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java @@ -1,11 +1,11 @@ package net.osmand.plus.osmedit.dialogs; -import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; import net.osmand.data.Amenity; import net.osmand.osm.MapPoiTypes; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java index b56690f40a..8f8acfe96a 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java @@ -1,11 +1,11 @@ package net.osmand.plus.osmedit.dialogs; -import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; import android.view.View; import android.widget.CheckBox; import android.widget.EditText; diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java index 1149434878..0d74a9b47c 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java @@ -3,48 +3,8 @@ */ package net.osmand.plus.osmo; -import gnu.trove.list.array.TIntArrayList; - -import java.text.Collator; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import net.osmand.AndroidUtils; -import net.osmand.Location; -import net.osmand.StateChangedListener; -import net.osmand.access.AccessibleToast; -import net.osmand.data.LatLon; -import net.osmand.data.PointDescription; -import net.osmand.plus.NavigationService; -import net.osmand.plus.OsmAndConstants; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; -import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.R; -import net.osmand.plus.TargetPointsHelper; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; -import net.osmand.plus.activities.OsmandExpandableListActivity; -import net.osmand.plus.activities.actions.ShareDialog; -import net.osmand.plus.base.MapViewTrackingUtilities; -import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.helpers.ColorDialogs; -import net.osmand.plus.osmo.OsMoGroups.OsMoGroupsUIListener; -import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice; -import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoGroup; -import net.osmand.plus.osmo.OsMoService.SessionInfo; -import net.osmand.util.MapUtils; import android.annotation.SuppressLint; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; @@ -67,6 +27,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.AlertDialog; import android.support.v7.view.ActionMode; import android.support.v7.widget.Toolbar; import android.text.Editable; @@ -100,6 +61,44 @@ import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; +import net.osmand.AndroidUtils; +import net.osmand.Location; +import net.osmand.StateChangedListener; +import net.osmand.access.AccessibleToast; +import net.osmand.data.LatLon; +import net.osmand.data.PointDescription; +import net.osmand.plus.NavigationService; +import net.osmand.plus.OsmAndConstants; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; +import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; +import net.osmand.plus.activities.OsmandExpandableListActivity; +import net.osmand.plus.activities.actions.ShareDialog; +import net.osmand.plus.base.MapViewTrackingUtilities; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.helpers.ColorDialogs; +import net.osmand.plus.osmo.OsMoGroups.OsMoGroupsUIListener; +import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice; +import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoGroup; +import net.osmand.plus.osmo.OsMoService.SessionInfo; +import net.osmand.util.MapUtils; + +import java.text.Collator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import gnu.trove.list.array.TIntArrayList; + /** * */ @@ -530,7 +529,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { if (item.getItemId() == DELETE_ACTION_ID) { - Builder bld = new AlertDialog.Builder(OsMoGroupsActivity.this); + AlertDialog.Builder bld = new AlertDialog.Builder(OsMoGroupsActivity.this); String name = ((OsMoGroup) selectedObject).getVisibleName(OsMoGroupsActivity.this); bld.setTitle(getString(R.string.osmo_leave_confirmation_msg, name)); bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @@ -578,7 +577,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements protected void showGroupInfo(final OsMoGroup group) { - Builder bld = new AlertDialog.Builder(this); + AlertDialog.Builder bld = new AlertDialog.Builder(this); bld.setTitle(R.string.osmo_group); StringBuilder sb = new StringBuilder(); if (group != null){ @@ -658,7 +657,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements setSupportProgressBarIndeterminateVisibility(true); signinPost(false); } else { - Builder bld = new AlertDialog.Builder(this); + AlertDialog.Builder bld = new AlertDialog.Builder(this); String text = getString(R.string.logged_as, app.getSettings().OSMO_USER_NAME.get()); bld.setMessage(text); bld.setPositiveButton(R.string.shared_string_ok, null); @@ -822,7 +821,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements } protected void signin() { - Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.osmo_sign_in); String message = ""; if(app.getSettings().OSMO_USER_PWD.get() != null) { @@ -850,7 +849,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements signin(); return; } - final Builder builder = new AlertDialog.Builder(this); + final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.osmo_create_group); final View v = getLayoutInflater().inflate(R.layout.osmo_create_group, getExpandableListView(), false); final EditText policy = (EditText) v.findViewById(R.id.Policy); @@ -918,7 +917,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements } private void connectToDevice() { - Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); final View v = getLayoutInflater().inflate(R.layout.osmo_connect_to_device, getExpandableListView(), false); final TextView labelTracker = (TextView ) v.findViewById(R.id.LabelTrackerId); final TextView labelName = (TextView ) v.findViewById(R.id.LabelName); @@ -1402,7 +1401,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements public static void showSettingsDialog(Context ctx, final OsMoPlugin plugin, final OsMoDevice device) { - Builder bld = new AlertDialog.Builder(ctx); + AlertDialog.Builder bld = new AlertDialog.Builder(ctx); bld.setTitle(R.string.osmo_edit_device); final LayoutInflater inflater = LayoutInflater.from(ctx); View view = inflater.inflate(R.layout.osmo_edit_device, null); @@ -1526,7 +1525,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements } private void showHint() { - Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.anonymous_user); String message = getString(R.string.anonymous_user_hint); builder.setMessage(message); diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java index 8838bd7f2c..8e35c63928 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java @@ -1,13 +1,21 @@ package net.osmand.plus.osmo; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; +import android.app.Activity; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.AsyncTask; +import android.os.Build; +import android.provider.Settings.Secure; +import android.support.v4.app.NotificationCompat; +import android.support.v7.app.AlertDialog; +import android.text.TextUtils; import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; @@ -27,23 +35,14 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.AsyncTask; -import android.os.Build; -import android.provider.Settings.Secure; -import android.support.v4.app.NotificationCompat; -import android.text.TextUtils; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ConcurrentLinkedQueue; public class OsMoService implements OsMoReactor { private static final String HTTP_API_PREPARE = "http://api.osmo.mobi/prepare"; @@ -362,7 +361,7 @@ public class OsMoService implements OsMoReactor { protected void showRegisterAgain(Activity ga, String msg) { - Builder bld = new AlertDialog.Builder(ga); + AlertDialog.Builder bld = new AlertDialog.Builder(ga); bld.setMessage(msg); bld.setPositiveButton(R.string.shared_string_ok, new OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java b/OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java index fac00b51c7..5e7108dda4 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java @@ -1,8 +1,6 @@ package net.osmand.plus.osmo; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; @@ -11,6 +9,7 @@ import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.PreferenceScreen; +import android.support.v7.app.AlertDialog; import android.text.method.LinkMovementMethod; import android.util.TypedValue; import android.widget.ScrollView; @@ -119,7 +118,7 @@ public class SettingsOsMoActivity extends SettingsBaseActivity { final OsMoPlugin plugin = OsMoPlugin.getEnabledPlugin(OsMoPlugin.class); if (preference == debugPref) { updateDebugPref(); - Builder bld = new AlertDialog.Builder(this); + AlertDialog.Builder bld = new AlertDialog.Builder(this); StringBuilder bs = new StringBuilder(); List hs = plugin.getService().getHistoryOfCommands(); if(hs != null) { @@ -173,7 +172,7 @@ public class SettingsOsMoActivity extends SettingsBaseActivity { @Override public void run() { - Builder bld = new AlertDialog.Builder(SettingsOsMoActivity.this); + AlertDialog.Builder bld = new AlertDialog.Builder(SettingsOsMoActivity.this); bld.setMessage(R.string.osmo_regenerate_login_ids_confirm); bld.setPositiveButton(R.string.shared_string_yes, new OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java b/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java index c81b5723f8..43ede2f81c 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java @@ -1,10 +1,10 @@ package net.osmand.plus.parkingpoint; -import android.app.AlertDialog; import android.content.DialogInterface; import android.graphics.Color; import android.graphics.Typeface; import android.os.Bundle; +import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 0a03bfd886..bf5283bd28 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -2,11 +2,10 @@ package net.osmand.plus.parkingpoint; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; +import android.support.v7.app.AlertDialog; import android.text.format.DateFormat; import android.text.format.Time; import android.view.View; @@ -290,7 +289,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { * Method creates confirmation dialog for deletion of a parking location. */ public AlertDialog showDeleteDialog(final Activity activity) { - Builder confirm = new AlertDialog.Builder(activity); + AlertDialog.Builder confirm = new AlertDialog.Builder(activity); confirm.setTitle(activity.getString(R.string.osmand_parking_delete)); confirm.setMessage(activity.getString(R.string.osmand_parking_delete_confirm)); confirm.setCancelable(true); @@ -317,7 +316,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { */ private void showSetTimeLimitDialog(final MapActivity mapActivity, final Dialog choose) { final View setTimeParking = mapActivity.getLayoutInflater().inflate(R.layout.parking_set_time_limit, null); - Builder setTime = new AlertDialog.Builder(mapActivity); + AlertDialog.Builder setTime = new AlertDialog.Builder(mapActivity); setTime.setView(setTimeParking); setTime.setTitle(mapActivity.getString(R.string.osmand_parking_time_limit_title)); setTime.setNegativeButton(R.string.shared_string_cancel, new DialogInterface.OnClickListener() { @@ -407,7 +406,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { */ private void showDeleteEventWarning(final Activity activity) { if (isParkingEventAdded()) { - Builder deleteEventWarning = new AlertDialog.Builder(activity); + AlertDialog.Builder deleteEventWarning = new AlertDialog.Builder(activity); deleteEventWarning.setTitle(activity.getString(R.string.osmand_parking_warning)); deleteEventWarning.setMessage(activity.getString(R.string.osmand_parking_warning_text)); deleteEventWarning.setNeutralButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 0d212b0482..98f0781ba7 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -1,10 +1,9 @@ package net.osmand.plus.rastermaps; import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.os.AsyncTask; +import android.support.v7.app.AlertDialog; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; @@ -150,7 +149,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { final MapActivityLayers layers = activity.getMapLayers(); Map entriesMap = settings.getTileSourceEntries(); final ArrayList keys = new ArrayList(entriesMap.keySet()); - Builder builder = new AlertDialog.Builder(activity); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); final String[] items = new String[entriesMap.size() + 1]; int i = 0; for(String it : entriesMap.values()){ @@ -285,7 +284,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { AccessibleToast.makeText(activity, R.string.shared_string_io_error, Toast.LENGTH_SHORT).show(); return; } - Builder builder = new AlertDialog.Builder(activity); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); String[] names = new String[downloaded.size()]; for (int i = 0; i < names.length; i++) { names[i] = downloaded.get(i).getName(); @@ -339,7 +338,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { TileSourceTemplate ts = new TileSourceTemplate("NewMapnik","http://mapnik.osmand.net/{0}/{1}/{2}.png", "png", 17, 5, 256, 16, 32000); final TileSourceTemplate[] result = new TileSourceTemplate[] { ts }; - Builder bld = new AlertDialog.Builder(activity); + AlertDialog.Builder bld = new AlertDialog.Builder(activity); View view = activity.getLayoutInflater().inflate(R.layout.editing_tile_source, null); final EditText name = (EditText) view.findViewById(R.id.Name); final Spinner existing = (Spinner) view.findViewById(R.id.TileSourceSpinner); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index dbd62b6936..304b0f4caa 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -1,6 +1,5 @@ package net.osmand.plus.views; -import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Canvas; @@ -10,6 +9,7 @@ import android.graphics.PointF; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; +import android.support.v7.app.AlertDialog; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index 78fb223425..50e031b9f5 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -1,9 +1,14 @@ package net.osmand.plus.views; -import java.util.ArrayList; -import java.util.List; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.PointF; +import android.support.v7.app.AlertDialog; +import android.util.DisplayMetrics; +import android.view.WindowManager; +import android.widget.ArrayAdapter; -import net.osmand.access.AccessibleToast; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; @@ -13,16 +18,9 @@ import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.R; import net.osmand.plus.resources.TransportIndexRepository; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.PointF; -import android.util.DisplayMetrics; -import android.view.WindowManager; -import android.widget.ArrayAdapter; -import android.widget.Toast; + +import java.util.ArrayList; +import java.util.List; public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider { private static final int startZoom = 12; @@ -164,7 +162,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa } private void showDescriptionDialog(TransportStop a) { - Builder bs = new AlertDialog.Builder(view.getContext()); + AlertDialog.Builder bs = new AlertDialog.Builder(view.getContext()); bs.setTitle(a.getName(view.getSettings().MAP_PREFERRED_LOCALE.get())); bs.setMessage(getStopDescription(a, true)); bs.show(); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 1670c536f4..66c0336d70 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -1,5 +1,16 @@ package net.osmand.plus.views.mapwidgets; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.support.v7.app.AlertDialog; +import android.util.DisplayMetrics; +import android.view.View; +import android.view.WindowManager; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + import net.osmand.Location; import net.osmand.ValueHolder; import net.osmand.binary.RouteDataObject; @@ -25,17 +36,6 @@ import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.controls.MapRouteInfoControl; import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable; import net.osmand.router.TurnType; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.util.DisplayMetrics; -import android.view.View; -import android.view.WindowManager; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; public class MapInfoWidgetsFactory { @@ -125,7 +125,7 @@ public class MapInfoWidgetsFactory { final ValueHolder vs = new ValueHolder(); vs.value = app.getSettings().SERVICE_OFF_INTERVAL.get(); final AlertDialog[] dlgshow = new AlertDialog[1]; - Builder dlg = new AlertDialog.Builder(map); + AlertDialog.Builder dlg = new AlertDialog.Builder(map); dlg.setTitle(app.getString(R.string.enable_sleep_mode)); WindowManager mgr = (WindowManager) map.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); diff --git a/OsmAnd/src/net/osmand/plus/voice/TTSCommandPlayerImpl.java b/OsmAnd/src/net/osmand/plus/voice/TTSCommandPlayerImpl.java index 728e5c7f68..615ab88cdd 100644 --- a/OsmAnd/src/net/osmand/plus/voice/TTSCommandPlayerImpl.java +++ b/OsmAnd/src/net/osmand/plus/voice/TTSCommandPlayerImpl.java @@ -1,15 +1,15 @@ package net.osmand.plus.voice; -import java.io.File; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import android.app.Activity; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.net.Uri; +import android.speech.tts.TextToSpeech; +import android.speech.tts.TextToSpeech.OnInitListener; +import android.speech.tts.TextToSpeech.OnUtteranceCompletedListener; +import android.support.v7.app.AlertDialog; -import android.app.Notification; -import android.app.PendingIntent; -import android.support.v4.app.NotificationCompat; -import android.support.v4.app.NotificationManagerCompat; import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -21,16 +21,11 @@ import org.apache.commons.logging.Log; import org.json.JSONArray; import org.json.JSONObject; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.net.Uri; -import android.speech.tts.TextToSpeech; -import android.speech.tts.TextToSpeech.OnInitListener; -import android.speech.tts.TextToSpeech.OnUtteranceCompletedListener; +import java.io.File; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer { @@ -161,7 +156,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer { { case TextToSpeech.LANG_MISSING_DATA: if (isSettingsActivity(act)) { - Builder builder = createAlertDialog( + AlertDialog.Builder builder = createAlertDialog( R.string.tts_missing_language_data_title, R.string.tts_missing_language_data, new IntentStarter( @@ -183,7 +178,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer { //maybe weird, but I didn't want to introduce parameter in around 5 methods just to do //this if condition if (isSettingsActivity(act)) { - Builder builder = createAlertDialog( + AlertDialog.Builder builder = createAlertDialog( R.string.tts_language_not_supported_title, R.string.tts_language_not_supported, new IntentStarter( @@ -214,9 +209,9 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer { } } - private Builder createAlertDialog(int titleResID, int messageResID, + private AlertDialog.Builder createAlertDialog(int titleResID, int messageResID, IntentStarter intentStarter, final Activity ctx) { - Builder builder = new AlertDialog.Builder(ctx); + AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setCancelable(true); builder.setNegativeButton(R.string.shared_string_no, null); builder.setPositiveButton(R.string.shared_string_yes, intentStarter); diff --git a/plugins/Osmand-Nautical/src/net/osmand/nautical/NauticalActivity.java b/plugins/Osmand-Nautical/src/net/osmand/nautical/NauticalActivity.java index 3a69fd7a56..6bcffa44de 100644 --- a/plugins/Osmand-Nautical/src/net/osmand/nautical/NauticalActivity.java +++ b/plugins/Osmand-Nautical/src/net/osmand/nautical/NauticalActivity.java @@ -2,7 +2,7 @@ package net.osmand.nautical; import net.osmand.nauticalPlugin.R; import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.DialogInterface; diff --git a/plugins/Osmand-ParkingPlugin/src/net/osmand/parkingPlugin/ParkingPluginActivity.java b/plugins/Osmand-ParkingPlugin/src/net/osmand/parkingPlugin/ParkingPluginActivity.java index 287c120ead..98ed6992b0 100644 --- a/plugins/Osmand-ParkingPlugin/src/net/osmand/parkingPlugin/ParkingPluginActivity.java +++ b/plugins/Osmand-ParkingPlugin/src/net/osmand/parkingPlugin/ParkingPluginActivity.java @@ -1,7 +1,6 @@ package net.osmand.parkingPlugin; import android.app.Activity; -import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.DialogInterface; @@ -10,6 +9,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; +import android.support.v7.app.AlertDialog; public class ParkingPluginActivity extends Activity { private static final String OSMAND_COMPONENT = "net.osmand"; //$NON-NLS-1$ diff --git a/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java b/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java index 46a680781e..f90ce43068 100644 --- a/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java +++ b/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java @@ -1,8 +1,6 @@ package net.osmand.srtmPlugin; -import net.osmand.srtmPlugin.paid.R; import android.app.Activity; -import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.DialogInterface; @@ -11,6 +9,9 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; +import android.support.v7.app.AlertDialog; + +import net.osmand.srtmPlugin.paid.R; public class SRTMPluginActivity extends Activity { private static final String OSMAND_COMPONENT = "net.osmand"; //$NON-NLS-1$ diff --git a/plugins/Osmand-Skimaps/src/net/osmand/skimaps/SkiMapsActivity.java b/plugins/Osmand-Skimaps/src/net/osmand/skimaps/SkiMapsActivity.java index ba6cb48380..beb3d41494 100644 --- a/plugins/Osmand-Skimaps/src/net/osmand/skimaps/SkiMapsActivity.java +++ b/plugins/Osmand-Skimaps/src/net/osmand/skimaps/SkiMapsActivity.java @@ -2,7 +2,7 @@ package net.osmand.skimaps; import net.osmand.skimapsPlugin.R; import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.DialogInterface;