Merge pull request #8965 from osmandapp/Fix_8757

Fix #8757
This commit is contained in:
vshcherb 2020-05-14 15:59:50 +02:00 committed by GitHub
commit f5568b931b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 7 deletions

View file

@ -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();

View file

@ -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);
}

View file

@ -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;
}
});

View file

@ -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() {

View file

@ -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;