fix first menu opening in header-only state;

minor fixes
This commit is contained in:
Skalii 2021-01-23 17:45:42 +02:00
parent 431c7b30e7
commit bbbfe66004

View file

@ -117,6 +117,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
private TrackChartPoints trackChartPoints; private TrackChartPoints trackChartPoints;
private int menuTitleHeight; private int menuTitleHeight;
private String gpxTitle;
public enum TrackMenuType { public enum TrackMenuType {
OVERVIEW(R.id.action_overview, R.string.shared_string_overview), OVERVIEW(R.id.action_overview, R.string.shared_string_overview),
@ -162,6 +163,11 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN; return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
} }
@Override
public int getInitialMenuState() {
return MenuState.HEADER_ONLY;
}
public TrackDisplayHelper getDisplayHelper() { public TrackDisplayHelper getDisplayHelper() {
return displayHelper; return displayHelper;
} }
@ -186,6 +192,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath);
} }
displayHelper.setGpx(selectedGpxFile.getGpxFile()); displayHelper.setGpx(selectedGpxFile.getGpxFile());
String fileName = Algorithms.getFileWithoutDirs(getGpx().path);
gpxTitle = GpxUiHelper.getGpxTitle(fileName);
} }
} }
@ -203,7 +211,11 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
headerIcon = view.findViewById(R.id.icon_view); headerIcon = view.findViewById(R.id.icon_view);
if (isPortrait()) { if (isPortrait()) {
updateCardsLayout(); View mainView = getMainView();
View topShadow = getTopShadow();
FrameLayout bottomContainer = getBottomContainer();
topShadow.setVisibility(View.VISIBLE);
AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
} else { } else {
int widthNoShadow = getLandscapeNoShadowWidth(); int widthNoShadow = getLandscapeNoShadowWidth();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -220,19 +232,15 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
return view; return view;
} }
private void setHeaderTitle(String text, boolean iconVisibility) {
headerTitle.setText(text);
AndroidUiHelper.updateVisibility(headerIcon, iconVisibility);
}
private void updateHeader() { private void updateHeader() {
ViewGroup headerContainer = (ViewGroup) routeMenuTopShadowAll; ViewGroup headerContainer = (ViewGroup) routeMenuTopShadowAll;
if (overviewCard != null && overviewCard.getView() != null) {
headerContainer.removeView(overviewCard.getView());
}
if (menuType == TrackMenuType.OPTIONS) {
headerTitle.setText(menuType.titleId);
AndroidUiHelper.updateVisibility(headerIcon, false);
} else {
String fileName = Algorithms.getFileWithoutDirs(getGpx().path);
headerTitle.setText(GpxUiHelper.getGpxTitle(fileName));
AndroidUiHelper.updateVisibility(headerIcon, true);
if (menuType == TrackMenuType.OVERVIEW) { if (menuType == TrackMenuType.OVERVIEW) {
setHeaderTitle(gpxTitle, true);
if (overviewCard != null && overviewCard.getView() != null) { if (overviewCard != null && overviewCard.getView() != null) {
ViewGroup parent = ((ViewGroup) overviewCard.getView().getParent()); ViewGroup parent = ((ViewGroup) overviewCard.getView().getParent());
if (parent != null) { if (parent != null) {
@ -244,15 +252,13 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
overviewCard.setListener(this); overviewCard.setListener(this);
headerContainer.addView(overviewCard.build(getMapActivity())); headerContainer.addView(overviewCard.build(getMapActivity()));
} }
} else {
if (overviewCard != null && overviewCard.getView() != null) {
headerContainer.removeView(overviewCard.getView());
} }
boolean isOptions = menuType == TrackMenuType.OPTIONS;
setHeaderTitle(isOptions ? app.getString(menuType.titleId) : gpxTitle, !isOptions);
} }
runLayoutListener();
headerContainer.post(new Runnable() {
@Override
public void run() {
openMenuScreen(menuType == TrackMenuType.OVERVIEW ? MenuState.HEADER_ONLY : MenuState.HALF_SCREEN, false);
}
});
} }
private void setupCards() { private void setupCards() {
@ -573,7 +579,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
} }
} }
private void updateCardsLayout() { /*private void updateCardsLayout() {
View mainView = getMainView(); View mainView = getMainView();
if (mainView != null) { if (mainView != null) {
View topShadow = getTopShadow(); View topShadow = getTopShadow();
@ -586,7 +592,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark); AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
} }
} }
} }*/
private void setupButtons(View view) { private void setupButtons(View view) {
ColorStateList navColorStateList = AndroidUtils.createBottomNavColorStateList(getContext(), isNightMode()); ColorStateList navColorStateList = AndroidUtils.createBottomNavColorStateList(getContext(), isNightMode());
@ -814,7 +820,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString(TRACK_FILE_NAME, path); args.putString(TRACK_FILE_NAME, path);
args.putBoolean(CURRENT_RECORDING, showCurrentTrack); args.putBoolean(CURRENT_RECORDING, showCurrentTrack);
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HALF_SCREEN); args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);
TrackMenuFragment fragment = new TrackMenuFragment(); TrackMenuFragment fragment = new TrackMenuFragment();
fragment.setArguments(args); fragment.setArguments(args);