diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 8e343fe5ce..ad98edabbd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -738,7 +738,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return; } QuickActionListFragment quickActionListFragment = getQuickActionListFragment(); - if ( quickActionListFragment != null && quickActionListFragment.isVisible()) { + if (quickActionListFragment != null && quickActionListFragment.isVisible() + && quickActionListFragment.fromDashboard()) { this.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, null); } ImportSettingsFragment importSettingsFragment = getImportSettingsFragment(); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index 7aeceda29f..23eeb0174d 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -50,6 +50,8 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick public static final String TAG = QuickActionListFragment.class.getSimpleName(); + public static final String FROM_DASHBOARD_KEY = "from_dashboard"; + private RecyclerView quickActionRV; private FloatingActionButton fab; @@ -57,8 +59,17 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick private ItemTouchHelper touchHelper; private QuickActionRegistry quickActionRegistry; + private boolean fromDashboard; private boolean isLightContent; + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (savedInstanceState != null) { + fromDashboard = savedInstanceState.getBoolean(FROM_DASHBOARD_KEY, false); + } + } + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -154,6 +165,12 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick quickActionRegistry.setUpdatesListener(null); } + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putBoolean(FROM_DASHBOARD_KEY, fromDashboard); + } + @Override public int getStatusBarColorId() { return isLightContent ? R.color.status_bar_color_light : R.color.status_bar_color_dark; @@ -424,6 +441,14 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick } } + public boolean fromDashboard() { + return fromDashboard; + } + + public void setFromDashboard(boolean fromDashboard) { + this.fromDashboard = fromDashboard; + } + public interface OnStartDragListener { void onStartDrag(RecyclerView.ViewHolder viewHolder); } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java index 7a92bcb4dd..110a2a04ff 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java @@ -19,6 +19,7 @@ import androidx.annotation.StyleRes; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; +import androidx.fragment.app.FragmentManager; import androidx.gridlayout.widget.GridLayout; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; @@ -249,8 +250,15 @@ public class QuickActionsWidget extends LinearLayout { view.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { - CreateEditActionDialog dialog = CreateEditActionDialog.newInstance(action.id); - dialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), AddQuickActionDialog.TAG); + FragmentManager fm = ((AppCompatActivity) getContext()).getSupportFragmentManager(); + if (action instanceof NewAction) { + fm.beginTransaction() + .add(R.id.fragmentContainer, new QuickActionListFragment(), QuickActionListFragment.TAG) + .addToBackStack(QuickActionListFragment.TAG).commitAllowingStateLoss(); + } else { + CreateEditActionDialog dialog = CreateEditActionDialog.newInstance(action.id); + dialog.show(fm, AddQuickActionDialog.TAG); + } return true; } }); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/NewAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/NewAction.java index dc9d03923a..0f2abb3d2b 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/NewAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/NewAction.java @@ -10,9 +10,8 @@ import net.osmand.plus.quickaction.QuickActionType; public class NewAction extends QuickAction { - public static final QuickActionType TYPE = new QuickActionType(1, "new", - NewAction.class). - nonEditable().iconRes(R.drawable.ic_action_plus).nameRes(R.string.quick_action_new_action); + public static final QuickActionType TYPE = new QuickActionType(1, "new", NewAction.class) + .iconRes(R.drawable.ic_action_plus).nameRes(R.string.quick_action_new_action); public NewAction() { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index b1740e4307..ce189d7cfa 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -471,9 +471,11 @@ public class MapWidgetRegistry { int slideInAnim = R.anim.slide_in_bottom; int slideOutAnim = R.anim.slide_out_bottom; + QuickActionListFragment fragment = new QuickActionListFragment(); + fragment.setFromDashboard(true); mapActivity.getSupportFragmentManager().beginTransaction() .setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim) - .add(R.id.fragmentContainer, new QuickActionListFragment(), QuickActionListFragment.TAG) + .add(R.id.fragmentContainer, fragment, QuickActionListFragment.TAG) .addToBackStack(QuickActionListFragment.TAG).commitAllowingStateLoss(); return true;