Fix track menu visibility

This commit is contained in:
Vitaliy 2021-04-06 01:08:59 +03:00
parent 553258c09a
commit 7775338364
2 changed files with 31 additions and 21 deletions

View file

@ -30,6 +30,21 @@ import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback;
import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentManager.BackStackEntry;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile;
import net.osmand.Location; import net.osmand.Location;
@ -157,21 +172,6 @@ import java.util.TimerTask;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback;
import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentManager.BackStackEntry;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
public class MapActivity extends OsmandActionBarActivity implements DownloadEvents, public class MapActivity extends OsmandActionBarActivity implements DownloadEvents,
@ -2074,7 +2074,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
public void showQuickSearch(double latitude, double longitude) { public void showQuickSearch(double latitude, double longitude) {
hideContextMenu(); hideVisibleMenu();
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
if (fragment != null) { if (fragment != null) {
fragment.dismiss(); fragment.dismiss();
@ -2085,7 +2085,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
public void showQuickSearch(String searchQuery) { public void showQuickSearch(String searchQuery) {
hideContextMenu(); hideVisibleMenu();
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
if (fragment != null) { if (fragment != null) {
fragment.dismiss(); fragment.dismiss();
@ -2096,7 +2096,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
public void showQuickSearch(Object object) { public void showQuickSearch(Object object) {
hideContextMenu(); hideVisibleMenu();
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
if (fragment != null) { if (fragment != null) {
fragment.dismiss(); fragment.dismiss();
@ -2119,7 +2119,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (mode == ShowQuickSearchMode.CURRENT) { if (mode == ShowQuickSearchMode.CURRENT) {
mapContextMenu.close(); mapContextMenu.close();
} else { } else {
hideContextMenu(); hideVisibleMenu();
} }
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
if (mode.isPointSelection()) { if (mode.isPointSelection()) {
@ -2172,7 +2172,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (mode == ShowQuickSearchMode.CURRENT) { if (mode == ShowQuickSearchMode.CURRENT) {
mapContextMenu.close(); mapContextMenu.close();
} else { } else {
hideContextMenu(); hideVisibleMenu();
} }
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
if (mode.isPointSelection()) { if (mode.isPointSelection()) {
@ -2221,11 +2221,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
BaseSettingsFragment.showInstance(this, SettingsScreenType.MAIN_SETTINGS); BaseSettingsFragment.showInstance(this, SettingsScreenType.MAIN_SETTINGS);
} }
private void hideContextMenu() { private void hideVisibleMenu() {
if (mapContextMenu.isVisible()) { if (mapContextMenu.isVisible()) {
mapContextMenu.hide(); mapContextMenu.hide();
} else if (mapContextMenu.getMultiSelectionMenu().isVisible()) { } else if (mapContextMenu.getMultiSelectionMenu().isVisible()) {
mapContextMenu.getMultiSelectionMenu().hide(); mapContextMenu.getMultiSelectionMenu().hide();
} else if (getTrackMenuFragment() != null) {
dismissTrackMenu();
} }
} }
@ -2277,6 +2279,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return getFragment(RouteLineAppearanceFragment.TAG); return getFragment(RouteLineAppearanceFragment.TAG);
} }
public void dismissTrackMenu() {
FragmentManager fragmentManager = getSupportFragmentManager();
if (!fragmentManager.isStateSaved()) {
fragmentManager.popBackStack(TrackMenuFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
}
public void backToConfigureProfileFragment() { public void backToConfigureProfileFragment() {
FragmentManager fragmentManager = getSupportFragmentManager(); FragmentManager fragmentManager = getSupportFragmentManager();
int backStackEntryCount = fragmentManager.getBackStackEntryCount(); int backStackEntryCount = fragmentManager.getBackStackEntryCount();

View file

@ -578,6 +578,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
if (visible) { if (visible) {
mapActivity.dismissCardDialog(); mapActivity.dismissCardDialog();
mapActivity.dismissTrackMenu();
mapActivity.getContextMenu().hideMenues(); mapActivity.getContextMenu().hideMenues();
mapViewLocation = mapActivity.getMapLocation(); mapViewLocation = mapActivity.getMapLocation();
mapRotation = mapActivity.getMapRotate(); mapRotation = mapActivity.getMapRotate();