From 9bed3254b6a7b9d1fc664102c23ea4f6547d49b7 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Tue, 11 Aug 2020 16:52:54 -0400 Subject: [PATCH] Fix a bunch of deprecations --- .../CacheFragmentStatePagerAdapter.java | 2 +- .../activities/EditPOIFilterActivity.java | 3 +-- .../activities/FavoritesTreeFragment.java | 17 ++++++++--------- .../activities/NavigatePointFragment.java | 3 +-- .../OsmandExpandableListActivity.java | 4 +--- .../plus/activities/OsmandListActivity.java | 4 +--- .../osmand/plus/activities/TabActivity.java | 2 +- .../plus/activities/actions/ShareDialog.java | 2 +- .../search/SearchAddressFragment.java | 7 +++---- .../activities/search/SearchPOIActivity.java | 11 +++++------ ...AudioVideoNoteRecordingMenuFullScreen.java | 3 +-- .../audionotes/AudioVideoNotesPlugin.java | 6 +++--- .../osmand/plus/base/ContextMenuFragment.java | 2 +- .../plus/base/MapViewTrackingUtilities.java | 2 +- .../base/OsmandExpandableListFragment.java | 3 +-- .../plus/dashboard/DashBaseFragment.java | 19 ++++++++++--------- .../plus/dashboard/DashErrorFragment.java | 10 ++++------ .../osmand/plus/dashboard/DashboardOnMap.java | 2 +- .../DashboardSettingsDialogFragment.java | 7 +++---- .../plus/development/TestVoiceActivity.java | 10 +++++----- .../dialogs/HelpArticleDialogFragment.java | 17 +---------------- .../plus/download/DownloadActivity.java | 2 +- .../ui/DownloadResourceGroupFragment.java | 5 ++--- .../download/ui/LocalIndexesFragment.java | 4 ++-- .../plus/liveupdates/OsmLiveActivity.java | 2 +- .../plus/mapcontextmenu/MenuBuilder.java | 2 +- .../mapmarkers/MapMarkersDialogFragment.java | 2 +- .../adapters/MapMarkersActiveAdapter.java | 3 +-- .../adapters/MapMarkersListAdapter.java | 3 +-- .../adapter/MeasurementToolAdapter.java | 3 +-- .../plus/myplaces/AvailableGPXFragment.java | 19 +++++++++---------- .../plus/myplaces/TrackPointFragment.java | 3 +-- .../plus/myplaces/TrackSegmentFragment.java | 10 ++++------ .../plus/osmedit/EditPoiDialogFragment.java | 8 +------- .../plus/poi/RearrangePoiFiltersFragment.java | 3 +-- .../plus/profiles/EditProfilesFragment.java | 3 +-- .../quickaction/QuickActionListFragment.java | 3 +-- .../plus/quickaction/SwitchableAction.java | 3 +-- .../ChooseRouteFragment.java | 2 +- .../search/QuickSearchDialogFragment.java | 2 +- .../fragments/RearrangeMenuItemsAdapter.java | 3 +-- .../plus/views/controls/DynamicListView.java | 2 +- .../views/controls/PagerSlidingTabStrip.java | 9 ++++----- .../SwipeDismissListViewTouchListener.java | 8 ++++---- .../plus/views/layers/MapControlsLayer.java | 4 ++-- .../mapwidgets/MapInfoWidgetsFactory.java | 2 +- .../plus/widgets/InterceptorFrameLayout.java | 4 +--- .../tools/ExtendedBottomSheetBehavior.java | 8 ++++---- .../tools/SwipeDismissTouchListener.java | 4 ++-- .../mapcontextmenu/ContextMenuHelper.java | 19 ++----------------- .../sample1/mapcontextmenu/MenuBuilder.java | 2 +- 51 files changed, 109 insertions(+), 174 deletions(-) diff --git a/OsmAnd/src/com/github/ksoichiro/android/observablescrollview/CacheFragmentStatePagerAdapter.java b/OsmAnd/src/com/github/ksoichiro/android/observablescrollview/CacheFragmentStatePagerAdapter.java index cade4e117e..ae5719d99a 100644 --- a/OsmAnd/src/com/github/ksoichiro/android/observablescrollview/CacheFragmentStatePagerAdapter.java +++ b/OsmAnd/src/com/github/ksoichiro/android/observablescrollview/CacheFragmentStatePagerAdapter.java @@ -43,7 +43,7 @@ public abstract class CacheFragmentStatePagerAdapter extends FragmentStatePagerA private SparseArray mPages; public CacheFragmentStatePagerAdapter(FragmentManager fm) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); mPages = new SparseArray(); mFm = fm; } diff --git a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java index 5daa64977f..336e53aa7d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java @@ -19,7 +19,6 @@ import android.widget.ListView; import android.widget.TextView; import androidx.appcompat.app.AlertDialog; -import androidx.core.view.MenuItemCompat; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiType; @@ -102,7 +101,7 @@ public class EditPOIFilterActivity extends OsmandListActivity { createMenuItem(menu, FILTER, R.string.filter_current_poiButton, R.drawable.ic_action_done, //R.drawable.a_1_navigation_accept_light, R.drawable.a_1_navigation_accept_dark, - MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT | MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS); return super.onCreateOptionsMenu(menu); } diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index f04b727d5f..696f6cc26c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -32,7 +32,6 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.view.ActionMode; import androidx.core.content.ContextCompat; -import androidx.core.view.MenuItemCompat; import net.osmand.AndroidUtils; import net.osmand.Location; @@ -435,7 +434,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); - MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); + MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark, MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { @@ -452,11 +451,11 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen ((FavoritesActivity) getActivity()).updateListViewFooter(footerView); - if (!MenuItemCompat.isActionViewExpanded(mi)) { - createMenuItem(menu, IMPORT_FAVOURITES_ID, R.string.shared_string_add_to_favorites, R.drawable.ic_action_plus, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); - createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS, true); - createMenuItem(menu, SELECT_MAP_MARKERS_ID, R.string.select_map_markers, R.drawable.ic_action_flag, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); - createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + if (!mi.isActionViewExpanded()) { + createMenuItem(menu, IMPORT_FAVOURITES_ID, R.string.shared_string_add_to_favorites, R.drawable.ic_action_plus, MenuItem.SHOW_AS_ACTION_ALWAYS); + createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark, MenuItem.SHOW_AS_ACTION_ALWAYS, true); + createMenuItem(menu, SELECT_MAP_MARKERS_ID, R.string.select_map_markers, R.drawable.ic_action_flag, MenuItem.SHOW_AS_ACTION_ALWAYS); + createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark, MenuItem.SHOW_AS_ACTION_ALWAYS); } } @@ -483,7 +482,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen enableSelectionMode(true); createMenuItem(menu, SELECT_MAP_MARKERS_ACTION_MODE_ID, R.string.select_map_markers, R.drawable.ic_action_flag, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); + MenuItem.SHOW_AS_ACTION_IF_ROOM); favoritesSelected.clear(); groupsToDelete.clear(); favouritesAdapter.notifyDataSetInvalidated(); @@ -546,7 +545,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen enableSelectionMode(true); createMenuItem(menu, DELETE_ACTION_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); + MenuItem.SHOW_AS_ACTION_IF_ROOM); favoritesSelected.clear(); groupsToDelete.clear(); favouritesAdapter.notifyDataSetInvalidated(); diff --git a/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java b/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java index 1fa7cc88b0..0d88642e4b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java @@ -18,7 +18,6 @@ import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; -import androidx.core.view.MenuItemCompat; import androidx.fragment.app.Fragment; import com.jwetherell.openmap.common.LatLonPoint; @@ -106,7 +105,7 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi light = false; } MenuItem menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map); - MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menuItem = menuItem.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_marker_dark, light)); menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/activities/OsmandExpandableListActivity.java b/OsmAnd/src/net/osmand/plus/activities/OsmandExpandableListActivity.java index c1548e4add..a0d46c50e0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/OsmandExpandableListActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/OsmandExpandableListActivity.java @@ -10,8 +10,6 @@ import android.view.MenuItem; import android.view.View; import android.widget.ExpandableListView; -import androidx.core.view.MenuItemCompat; - import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -64,7 +62,7 @@ public abstract class OsmandExpandableListActivity extends return onOptionsItemSelected(item); } }); - MenuItemCompat.setShowAsAction(menuItem, menuItemType); + menuItem.setShowAsAction(menuItemType); return menuItem; } diff --git a/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java b/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java index c601f735a6..0416827447 100644 --- a/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java @@ -10,8 +10,6 @@ import android.widget.HeaderViewListAdapter; import android.widget.ListAdapter; import android.widget.ListView; -import androidx.core.view.MenuItemCompat; - import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -68,7 +66,7 @@ public abstract class OsmandListActivity extends return onOptionsItemSelected(item); } }); - MenuItemCompat.setShowAsAction(menuItem, menuItemType); + menuItem.setShowAsAction(menuItemType); return menuItem; } diff --git a/OsmAnd/src/net/osmand/plus/activities/TabActivity.java b/OsmAnd/src/net/osmand/plus/activities/TabActivity.java index 9dcd547b1e..eca5b2244a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/TabActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/TabActivity.java @@ -39,7 +39,7 @@ public class TabActivity extends ActionBarProgressActivity { private List mTabs; public OsmandFragmentPagerAdapter(FragmentManager fm, List items) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); mTabs = items; } diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java index 5b81f8b505..4858e3ccfe 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java @@ -2,6 +2,7 @@ package net.osmand.plus.activities.actions; import android.app.Activity; import android.content.ActivityNotFoundException; +import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -9,7 +10,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; -import android.text.ClipboardManager; import android.text.Html; import android.widget.Toast; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressFragment.java index 77864a482d..1e0639a5f6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressFragment.java @@ -16,7 +16,6 @@ import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast; -import androidx.core.view.MenuItemCompat; import androidx.fragment.app.Fragment; import net.osmand.data.LatLon; @@ -82,7 +81,7 @@ public class SearchAddressFragment extends Fragment { } if(getActivity() instanceof SearchAddressActivity) { MenuItem menuItem = menu.add(0, SELECT_POINT, 0, ""); - MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); if (getApplication().accessibilityEnabled()) menuItem.setTitle(R.string.shared_string_ok); menuItem = menuItem.setIcon(R.drawable.ic_action_done); @@ -95,7 +94,7 @@ public class SearchAddressFragment extends Fragment { }); } else { MenuItem menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map); - MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menuItem = menuItem.setIcon(R.drawable.ic_action_marker_dark); menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @@ -107,7 +106,7 @@ public class SearchAddressFragment extends Fragment { }); if (ENABLE_ONLINE_ADDRESS) { menuItem = menu.add(0, ONLINE_SEARCH, 0, R.string.search_online_address); - MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menuItem = menuItem.setIcon(R.drawable.ic_world_globe_dark); menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index 727c67ce43..2fe94a5ed9 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -34,7 +34,6 @@ import android.widget.Toast; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.Toolbar; -import androidx.core.view.MenuItemCompat; import androidx.core.view.ViewCompat; import net.osmand.Location; @@ -124,7 +123,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa public boolean onCreateOptionsMenu(Menu omenu) { Menu menu = getClearToolbar(true).getMenu(); searchPOILevel = menu.add(0, SEARCH_MORE, 0, R.string.search_POI_level_btn); - MenuItemCompat.setShowAsAction(searchPOILevel, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + searchPOILevel.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); searchPOILevel.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { @@ -133,7 +132,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa }); showFilterItem = menu.add(0, FILTER, 0, R.string.search_poi_filter); - MenuItemCompat.setShowAsAction(showFilterItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + showFilterItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); showFilterItem = showFilterItem.setIcon(getMyApplication().getUIUtilities().getIcon( R.drawable.ic_action_filter_dark)); showFilterItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @@ -156,7 +155,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa }); showOnMapItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map); - MenuItemCompat.setShowAsAction(showOnMapItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + showOnMapItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); showOnMapItem = showOnMapItem.setIcon(getMyApplication().getUIUtilities().getIcon( R.drawable.ic_show_on_map)); showOnMapItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @@ -176,10 +175,10 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa showOnMapItem.setEnabled(!isNameSearch() || amenityAdapter.getCount() > 0); if (filter != null && !isNameSearch()) { createMenuItem(omenu, SAVE_FILTER, R.string.edit_filter_save_as_menu_item, R.drawable.ic_action_favorite, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); + MenuItem.SHOW_AS_ACTION_IF_ROOM); if (!filter.isStandardFilter()) { createMenuItem(omenu, DELETE_FILTER, R.string.shared_string_delete, R.drawable.ic_action_delete_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); + MenuItem.SHOW_AS_ACTION_IF_ROOM); } } updateButtonState(false); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteRecordingMenuFullScreen.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteRecordingMenuFullScreen.java index 1f6953928d..0a859ed167 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteRecordingMenuFullScreen.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteRecordingMenuFullScreen.java @@ -12,7 +12,6 @@ import android.view.animation.LinearInterpolator; import android.widget.ImageView; import android.widget.ProgressBar; -import androidx.core.view.ViewCompat; import androidx.fragment.app.Fragment; import net.osmand.plus.R; @@ -129,7 +128,7 @@ public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordi stopProgress(); progressBar.setProgress(0); - ViewCompat.setAlpha(progressBar, 1f); + progressBar.setAlpha(1f); progressBar.setVisibility(View.VISIBLE); animatorCompat = ValueAnimator.ofInt(0); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index b62e1152af..e57d86139a 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -1036,11 +1036,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { try { Method m = mr.getClass().getDeclaredMethod("setOrientationHint", Integer.TYPE); Display display = ((WindowManager) mapActivity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); - if (display.getOrientation() == Surface.ROTATION_0) { + if (display.getRotation() == Surface.ROTATION_0) { m.invoke(mr, 90); - } else if (display.getOrientation() == Surface.ROTATION_270) { + } else if (display.getRotation() == Surface.ROTATION_270) { m.invoke(mr, 180); - } else if (display.getOrientation() == Surface.ROTATION_180) { + } else if (display.getRotation() == Surface.ROTATION_180) { m.invoke(mr, 270); } } catch (Exception e) { diff --git a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java index ed85cad88e..de3068cf5a 100644 --- a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java @@ -4,10 +4,10 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.annotation.TargetApi; import android.app.Activity; +import android.content.ClipboardManager; import android.content.Context; import android.os.Build; import android.os.Bundle; -import android.text.ClipboardManager; import android.util.TypedValue; import android.view.GestureDetector; import android.view.LayoutInflater; diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index 47bfce169d..d02aa52492 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -101,7 +101,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc if (mapView != null) { WindowManager wm = (WindowManager) app.getSystemService(Context.WINDOW_SERVICE); if (wm != null) { - int orientation = wm.getDefaultDisplay().getOrientation(); + int orientation = wm.getDefaultDisplay().getRotation(); app.getLocationProvider().updateScreenOrientation(orientation); mapView.setMapLocationListener(this); } diff --git a/OsmAnd/src/net/osmand/plus/base/OsmandExpandableListFragment.java b/OsmAnd/src/net/osmand/plus/base/OsmandExpandableListFragment.java index cc2f0b47af..1db87051fa 100644 --- a/OsmAnd/src/net/osmand/plus/base/OsmandExpandableListFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/OsmandExpandableListFragment.java @@ -13,7 +13,6 @@ import android.widget.ExpandableListView; import android.widget.ExpandableListView.OnChildClickListener; import androidx.annotation.NonNull; -import androidx.core.view.MenuItemCompat; import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; @@ -106,7 +105,7 @@ public abstract class OsmandExpandableListFragment extends BaseOsmAndFragment return onOptionsItemSelected(item); } }); - MenuItemCompat.setShowAsAction(menuItem, menuItemType); + menuItem.setShowAsAction(menuItemType); return menuItem; } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java index 7a48d799ee..837dc99f6e 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java @@ -1,6 +1,7 @@ package net.osmand.plus.dashboard; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.location.Location; import android.os.Bundle; @@ -9,8 +10,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.core.view.ViewCompat; import androidx.fragment.app.Fragment; import com.google.android.material.snackbar.Snackbar; @@ -37,10 +38,10 @@ public abstract class DashBaseFragment extends Fragment { } @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - if (activity instanceof MapActivity) { - dashboard = ((MapActivity) activity).getDashboard(); + public void onAttach(@NonNull Context context) { + super.onAttach(context); + if (context instanceof MapActivity) { + dashboard = ((MapActivity) context).getDashboard(); dashboard.onAttach(this); } } @@ -171,8 +172,8 @@ public abstract class DashBaseFragment extends Fragment { @Override public void onDismiss() { dashboardOnMap.blacklistFragmentByTag(fragmentTag); - ViewCompat.setTranslationX(fragmentView, 0); - ViewCompat.setAlpha(fragmentView, 1); + fragmentView.setTranslationX(0); + fragmentView.setAlpha(1); Snackbar.make(parentView, dashboardOnMap.getMyApplication().getResources() .getString(R.string.shared_string_card_was_hidden), Snackbar.LENGTH_LONG) .setAction(R.string.shared_string_undo, new View.OnClickListener() { @@ -186,8 +187,8 @@ public abstract class DashBaseFragment extends Fragment { public void onUndo() { dashboardOnMap.unblacklistFragmentClass(fragmentTag); - ViewCompat.setTranslationX(fragmentView, 0); - ViewCompat.setAlpha(fragmentView, 1); + fragmentView.setTranslationX(0); + fragmentView.setAlpha(1); } } } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java index bfc835d510..e41659fb24 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java @@ -9,8 +9,6 @@ import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; -import androidx.core.view.ViewCompat; - import com.google.android.material.snackbar.Snackbar; import net.osmand.plus.OsmandApplication; @@ -98,8 +96,8 @@ public class DashErrorFragment extends DashBaseFragment { @Override public void onDismiss() { dashboardOnMap.hideFragmentByTag(fragmentTag); - ViewCompat.setTranslationX(fragmentView, 0); - ViewCompat.setAlpha(fragmentView, 1); + fragmentView.setTranslationX(0); + fragmentView.setAlpha(1); Snackbar.make(parentView, dashboardOnMap.getMyApplication().getResources() .getString(R.string.shared_string_card_was_hidden), Snackbar.LENGTH_LONG) .setAction(R.string.shared_string_undo, new View.OnClickListener() { @@ -113,8 +111,8 @@ public class DashErrorFragment extends DashBaseFragment { public void onUndo() { dashboardOnMap.unhideFragmentByTag(fragmentTag); - ViewCompat.setTranslationX(fragmentView, 0); - ViewCompat.setAlpha(fragmentView, 1); + fragmentView.setTranslationX(0); + fragmentView.setAlpha(1); } } } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 25683f23ce..e1ebc1cc4d 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -1217,7 +1217,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo } private void setTranslationY(View v, int y) { - ViewCompat.setTranslationY(v, y); + v.setTranslationY(y); } @SuppressLint("NewApi") diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java index 8b7e47a941..1689a4e298 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java @@ -1,6 +1,5 @@ package net.osmand.plus.dashboard.tools; -import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; @@ -51,9 +50,9 @@ public class DashboardSettingsDialogFragment extends DialogFragment private static final int DEFAULT_NUMBER_OF_ROWS = 5; @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - mapActivity = (MapActivity) activity; + public void onAttach(@NonNull Context context) { + super.onAttach(context); + mapActivity = (MapActivity) context; mFragmentsData = new ArrayList<>(); for (DashFragmentData fragmentData : mapActivity.getDashboard().getFragmentsData()) { if (fragmentData.canBeDisabled()) mFragmentsData.add(fragmentData); diff --git a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java index 3d29541be4..f1cddde833 100644 --- a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java @@ -65,12 +65,12 @@ public class TestVoiceActivity extends OsmandActionBarActivity { tv.setPadding(0, 5, 0, 7); ScrollView sv = new ScrollView(this); - gl.addView(sv, new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, - android.view.ViewGroup.LayoutParams.FILL_PARENT)); + gl.addView(sv, new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, + android.view.ViewGroup.LayoutParams.MATCH_PARENT)); final LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); - sv.addView(ll, new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, - android.view.ViewGroup.LayoutParams.FILL_PARENT)); + sv.addView(ll, new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, + android.view.ViewGroup.LayoutParams.MATCH_PARENT)); // add buttons setContentView(gl); @@ -271,7 +271,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity { button.setGravity(Gravity.LEFT); button.setTransformationMethod(null); //or else button text is all upper case button.setText(description); - button.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); + button.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); if (!description.startsWith("\u25BA (")) { // Section headline buttons button.setPadding(10, 20, 10, 5); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java index 88bfd6f59d..fc1a917058 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java @@ -6,7 +6,6 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -82,21 +81,7 @@ public class HelpArticleDialogFragment extends DialogFragment { //Scale web view font size with system font size float scale = getActivity().getResources().getConfiguration().fontScale; - if (android.os.Build.VERSION.SDK_INT >= 14) { - webView.getSettings().setTextZoom((int) (scale * 100f)); - } else { - if (scale <= 0.7f) { - webView.getSettings().setTextSize(WebSettings.TextSize.SMALLEST); - } else if (scale <= 0.85f) { - webView.getSettings().setTextSize(WebSettings.TextSize.SMALLER); - } else if (scale <= 1.0f) { - webView.getSettings().setTextSize(WebSettings.TextSize.NORMAL); - } else if (scale <= 1.15f) { - webView.getSettings().setTextSize(WebSettings.TextSize.LARGER); - } else { - webView.getSettings().setTextSize(WebSettings.TextSize.LARGEST); - } - } + webView.getSettings().setTextZoom((int) (scale * 100f)); if (assetName != null) { String fileContents = getAssetAsString(assetName, getActivity()); diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index c11810383d..3ebd06b4b4 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -20,6 +20,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; +import android.widget.Space; import android.widget.TextView; import android.widget.Toast; @@ -32,7 +33,6 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; -import androidx.legacy.widget.Space; import androidx.viewpager.widget.ViewPager; import net.osmand.AndroidUtils; diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java index 9381a50db6..388efca2bb 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java @@ -21,7 +21,6 @@ import android.widget.TextView; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; -import androidx.core.view.MenuItemCompat; import androidx.fragment.app.DialogFragment; import net.osmand.AndroidNetworkUtils; @@ -540,12 +539,12 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow MenuItem itemReload = menu.add(0, RELOAD_ID, 0, R.string.shared_string_refresh); Drawable icReload = app.getUIUtilities().getIcon(R.drawable.ic_action_refresh_dark, colorResId); itemReload.setIcon(icReload); - MenuItemCompat.setShowAsAction(itemReload, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + itemReload.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); MenuItem itemSearch = menu.add(0, SEARCH_ID, 1, R.string.shared_string_search); Drawable icSearch = app.getUIUtilities().getIcon(R.drawable.ic_action_search_dark, colorResId); itemSearch.setIcon(icSearch); - MenuItemCompat.setShowAsAction(itemSearch, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + itemSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } } diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index f920f2dec2..99f5e9b642 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -695,8 +695,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement Drawable icon = getMyApplication().getUIUtilities().getIcon(actionIconId, colorResId); it.setIcon(icon); } - MenuItemCompat.setShowAsAction(it, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | - MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); + it.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | + MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true; } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java index d6e0406904..6014ebbc88 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java @@ -194,7 +194,7 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa private final boolean showSettingsOnly; LiveUpdatesFragmentPagerAdapter(FragmentManager fm, Resources res, boolean showSettingsOnly) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); this.showSettingsOnly = showSettingsOnly; titles = new String[titleIds.length]; for (int i = 0; i < titleIds.length; i++) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 5d3a560ddc..d197ae51e6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -1,6 +1,7 @@ package net.osmand.plus.mapcontextmenu; import android.app.Activity; +import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -11,7 +12,6 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.net.Uri; import android.os.AsyncTask; -import android.text.ClipboardManager; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 4d5dc5d0e3..45c57ed935 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -551,7 +551,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS private final List fragments; MapMarkersViewPagerAdapter(FragmentManager fm) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); fragments = Arrays.asList(activeFragment, groupsFragment, historyFragment); } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index b288a39ffe..4b6eee036b 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -8,7 +8,6 @@ import android.widget.ImageView; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.content.ContextCompat; -import androidx.core.view.MotionEventCompat; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.snackbar.Snackbar; @@ -122,7 +121,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter= Build.VERSION_CODES.JELLY_BEAN) { - obs.removeGlobalOnLayoutListener(this); - } - if (getActivity() != null) { tabLayout.setupWithViewPager(viewPager); } @@ -781,7 +775,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { private final String[] titles; PoiInfoPagerAdapter(FragmentManager fm, String basicTitle, String extendedTitle) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); titles = new String[]{basicTitle, extendedTitle}; } diff --git a/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java b/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java index 97ad08899d..8ddd677be2 100644 --- a/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java +++ b/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java @@ -20,7 +20,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; -import androidx.core.view.MotionEventCompat; import androidx.core.view.ViewCompat; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.FragmentActivity; @@ -642,7 +641,7 @@ public class RearrangePoiFiltersFragment extends DialogFragment implements Selec h.moveIcon.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { - if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { + if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { listener.onDragStarted(holder); } return false; diff --git a/OsmAnd/src/net/osmand/plus/profiles/EditProfilesFragment.java b/OsmAnd/src/net/osmand/plus/profiles/EditProfilesFragment.java index 192357d12c..c20d7f60f1 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/EditProfilesFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/EditProfilesFragment.java @@ -17,7 +17,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; -import androidx.core.view.MotionEventCompat; import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.LinearLayoutManager; @@ -392,7 +391,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment { profileViewHolder.moveButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { - if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { + if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { listener.onDragStarted(holder); } return false; diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index 3e21c21dca..036b60230f 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -23,7 +23,6 @@ import androidx.annotation.Nullable; import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; -import androidx.core.view.MotionEventCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -513,7 +512,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment h.moveButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { - if (MotionEventCompat.getActionMasked(event) == + if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { onStartDragListener.onStartDrag(h); } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java index 3d4c3a9269..526c16a285 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java @@ -16,7 +16,6 @@ import androidx.annotation.ColorRes; import androidx.annotation.DrawableRes; import androidx.annotation.StringRes; import androidx.appcompat.widget.SwitchCompat; -import androidx.core.view.MotionEventCompat; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; @@ -171,7 +170,7 @@ public abstract class SwitchableAction extends QuickAction { holder.handleView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { - if (MotionEventCompat.getActionMasked(event) == + if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { onStartDragListener.onStartDrag(holder); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java index c046cca7f7..c94c6e2968 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java @@ -865,7 +865,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe private int routesCount; RoutesPagerAdapter(FragmentManager fm, int routesCount) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); this.routesCount = routesCount; } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index f8dbd7745d..fb2e32080c 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -2369,7 +2369,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC private final String[] titles; public SearchFragmentPagerAdapter(FragmentManager fm, Resources res) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); titles = new String[titleIds.length]; for (int i = 0; i < titleIds.length; i++) { titles[i] = res.getString(titleIds[i]); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RearrangeMenuItemsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RearrangeMenuItemsAdapter.java index 0f64f93475..3f97398e44 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RearrangeMenuItemsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RearrangeMenuItemsAdapter.java @@ -15,7 +15,6 @@ import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.StringRes; import androidx.core.content.ContextCompat; -import androidx.core.view.MotionEventCompat; import androidx.recyclerview.widget.RecyclerView; import net.osmand.AndroidUtils; @@ -190,7 +189,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter extends CoordinatorLayo @Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { - ViewCompat.setFitsSystemWindows(child, true); + child.setFitsSystemWindows(true); } int savedTop = child.getTop(); // First let the parent lay it out @@ -348,7 +348,7 @@ public class ExtendedBottomSheetBehavior extends CoordinatorLayo @Override public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, - View directTargetChild, View target, int nestedScrollAxes) { + View directTargetChild, View target, int nestedScrollAxes, int type) { mLastNestedScrollDy = 0; mNestedScrolled = false; return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0; @@ -356,7 +356,7 @@ public class ExtendedBottomSheetBehavior extends CoordinatorLayo @Override public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, - int dy, int[] consumed) { + int dy, int[] consumed, int type) { View scrollingChild = mNestedScrollingChildRef.get(); if (target != scrollingChild) { return; @@ -392,7 +392,7 @@ public class ExtendedBottomSheetBehavior extends CoordinatorLayo } @Override - public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) { + public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int type) { if (child.getTop() == mMinOffset) { setStateInternal(STATE_EXPANDED); return; diff --git a/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java b/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java index 6c70bb1943..9b2c659f4a 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java +++ b/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java @@ -227,9 +227,9 @@ public class SwipeDismissTouchListener implements View.OnTouchListener { if (mSwiping) { mTranslationX = deltaX; - ViewCompat.setTranslationX(mView, deltaX - mSwipingSlop); + mView.setTranslationX(deltaX - mSwipingSlop); // TODO: use an ease-out interpolator or such - ViewCompat.setAlpha(mView, Math.max(0f, Math.min(1f, + mView.setAlpha(Math.max(0f, Math.min(1f, 1f - 2f * Math.abs(deltaX) / mViewWidth))); return true; } diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/ContextMenuHelper.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/ContextMenuHelper.java index 273dd86d9e..1b15512e99 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/ContextMenuHelper.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/ContextMenuHelper.java @@ -21,7 +21,6 @@ import android.widget.TextView; import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; -import androidx.core.view.MenuItemCompat; import net.osmand.AndroidUtils; import net.osmand.core.samples.android.sample1.OsmandResources; @@ -91,7 +90,7 @@ public class ContextMenuHelper { return true; } }); - MenuItemCompat.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_ALWAYS); + mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); topBar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { @@ -108,21 +107,7 @@ public class ContextMenuHelper { //Scale web view font size with system font size float scale = ctx.getResources().getConfiguration().fontScale; - if (android.os.Build.VERSION.SDK_INT >= 14) { - settings.setTextZoom((int) (scale * 100f)); - } else { - if (scale <= 0.7f) { - settings.setTextSize(WebSettings.TextSize.SMALLEST); - } else if (scale <= 0.85f) { - settings.setTextSize(WebSettings.TextSize.SMALLER); - } else if (scale <= 1.0f) { - settings.setTextSize(WebSettings.TextSize.NORMAL); - } else if (scale <= 1.15f) { - settings.setTextSize(WebSettings.TextSize.LARGER); - } else { - settings.setTextSize(WebSettings.TextSize.LARGEST); - } - } + settings.setTextZoom((int) (scale * 100f)); wv.loadDataWithBaseURL(null, content, "text/html", "UTF-8", null); // wv.loadUrl(OsMoService.SIGN_IN_URL + app.getSettings().OSMO_DEVICE_KEY.get()); diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/MenuBuilder.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/MenuBuilder.java index 67e48710ca..82294a15ed 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/MenuBuilder.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/MenuBuilder.java @@ -1,13 +1,13 @@ package net.osmand.core.samples.android.sample1.mapcontextmenu; import android.app.Activity; +import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.text.ClipboardManager; import android.text.TextUtils; import android.text.util.Linkify; import android.util.TypedValue;