diff --git a/OsmAnd/src/net/osmand/plus/myplaces/MyPlacesActivity.java b/OsmAnd/src/net/osmand/plus/myplaces/MyPlacesActivity.java index 897bb5a9d2d..785d34cdb6b 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/MyPlacesActivity.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/MyPlacesActivity.java @@ -1,6 +1,5 @@ package net.osmand.plus.myplaces; -import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.MenuItem; @@ -12,14 +11,12 @@ import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager.SimpleOnPageChangeListener; -import net.osmand.PlatformUtil; import net.osmand.data.PointDescription; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.TabActivity; import net.osmand.plus.backup.ui.BackupAuthorizationFragment; -import net.osmand.plus.importfiles.ImportHelper; import net.osmand.plus.myplaces.favorites.dialogs.FavoritesTreeFragment; import net.osmand.plus.myplaces.favorites.dialogs.FragmentStateHolder; import net.osmand.plus.myplaces.tracks.dialogs.AvailableTracksFragment; @@ -27,8 +24,6 @@ import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.controls.PagerSlidingTabStrip; -import org.apache.commons.logging.Log; - import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; @@ -38,10 +33,6 @@ */ public class MyPlacesActivity extends TabActivity { - private static final Log LOG = PlatformUtil.getLog(MyPlacesActivity.class); - - public static final int OPEN_GPX_DOCUMENT_REQUEST = 1006; - public static final int IMPORT_FAVOURITES_REQUEST = 1007; public static final String TAB_ID = "selected_tab_id"; @@ -49,7 +40,6 @@ public class MyPlacesActivity extends TabActivity { public static final int FAV_TAB = R.string.shared_string_my_favorites; private OsmandSettings settings; - private ImportHelper importHelper; private ViewPager viewPager; private List> fragmentsStateList = new ArrayList<>(); @@ -61,7 +51,6 @@ public class MyPlacesActivity extends TabActivity { public void onCreate(@Nullable Bundle savedInstanceState) { OsmandApplication app = getMyApplication(); settings = app.getSettings(); - importHelper = new ImportHelper(this); app.applyTheme(this); super.onCreate(savedInstanceState); @@ -95,17 +84,6 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } } - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == IMPORT_FAVOURITES_REQUEST && resultCode == Activity.RESULT_OK) { - if (data != null && data.getData() != null) { - importHelper.handleFavouritesImport(data.getData()); - } - } else { - super.onActivityResult(requestCode, resultCode, data); - } - } - private void setTabs(@NonNull List tabItems) { PagerSlidingTabStrip mSlidingTabLayout = findViewById(R.id.sliding_tabs); Integer tabId = settings.FAVORITES_TAB.get(); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/favorites/dialogs/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/favorites/dialogs/FavoritesTreeFragment.java index b511798b3f2..ea31a511c7c 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/favorites/dialogs/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/favorites/dialogs/FavoritesTreeFragment.java @@ -4,10 +4,9 @@ import static net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import static net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import static net.osmand.plus.myplaces.MyPlacesActivity.FAV_TAB; -import static net.osmand.plus.myplaces.MyPlacesActivity.IMPORT_FAVOURITES_REQUEST; import static net.osmand.plus.myplaces.MyPlacesActivity.TAB_ID; -import static net.osmand.plus.widgets.dialogbutton.DialogButtonType.SECONDARY; +import android.app.Activity; import android.content.Intent; import android.graphics.PorterDuff; import android.graphics.Typeface; @@ -81,17 +80,19 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implements FragmentStateHolder, OsmAndCompassListener, OsmAndLocationListener, ShareFavoritesListener { - public static final int SEARCH_ID = -1; - public static final int DELETE_ID = 2; - public static final int DELETE_ACTION_ID = 3; - public static final int SHARE_ID = 4; - public static final int SELECT_MAP_MARKERS_ID = 5; - public static final int SELECT_MAP_MARKERS_ACTION_MODE_ID = 6; - public static final int IMPORT_FAVOURITES_ID = 7; - public static final String GROUP_EXPANDED_POSTFIX = "_group_expanded"; + private static final int IMPORT_FAVOURITES_REQUEST = 1007; + private static final int SEARCH_ID = -1; + private static final int DELETE_ID = 2; + private static final int DELETE_ACTION_ID = 3; + private static final int SHARE_ID = 4; + private static final int SELECT_MAP_MARKERS_ID = 5; + private static final int SELECT_MAP_MARKERS_ACTION_MODE_ID = 6; + private static final int IMPORT_FAVOURITES_ID = 7; + private static final String GROUP_EXPANDED_POSTFIX = "_group_expanded"; private FavouritesHelper helper; private FavouritesAdapter favouritesAdapter; + private ImportHelper importHelper; private boolean selectionMode; private final LinkedHashMap> favoritesSelected = new LinkedHashMap<>(); @@ -119,6 +120,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); favouritesAdapter = new FavouritesAdapter(); + importHelper = new ImportHelper(requireActivity()); helper = app.getFavoritesHelper(); if (helper.isFavoritesLoaded()) { @@ -179,10 +181,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, boolean nightMode = !app.getSettings().isLightContent(); View searchView = inflater.inflate(R.layout.search_fav_list_item, listView, false); searchView.setBackgroundResource(ColorUtilities.getListBgColorId(nightMode)); + TextView title = searchView.findViewById(R.id.title); - Drawable searchIcon = app.getUIUtilities().getThemedIcon(R.drawable.ic_action_search_dark); + Drawable searchIcon = getContentIcon(R.drawable.ic_action_search_dark); AndroidUtils.setCompoundDrawablesWithIntrinsicBounds(title, searchIcon, null, null, null); - searchView.setOnClickListener(v -> FavoritesSearchFragment.showInstance(getActivity(), "")); + searchView.setOnClickListener(v -> FavoritesSearchFragment.showInstance(requireActivity(), "")); listView.addHeaderView(searchView); View dividerView = inflater.inflate(R.layout.list_item_divider, null, false); boolean proAvailable = InAppPurchaseHelper.isOsmAndProAvailable(app); @@ -594,6 +597,17 @@ private void importFavourites() { AndroidUtils.startActivityForResultIfSafe(this, intent, IMPORT_FAVOURITES_REQUEST); } + @Override + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + if (requestCode == IMPORT_FAVOURITES_REQUEST && resultCode == Activity.RESULT_OK) { + if (data != null && data.getData() != null) { + importHelper.handleFavouritesImport(data.getData()); + } + } else { + super.onActivityResult(requestCode, resultCode, data); + } + } + public void shareFavorites(@Nullable FavoriteGroup group) { ShareFavoritesAsyncTask shareFavoritesTask = new ShareFavoritesAsyncTask(app, group, this); shareFavoritesTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);