Fix status bar icons color and description padding

This commit is contained in:
Vitaliy 2021-04-06 00:47:08 +03:00
parent 27fd305e4c
commit 553258c09a
2 changed files with 12 additions and 16 deletions

View file

@ -14,6 +14,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatImageView;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.Metadata; import net.osmand.GPXUtilities.Metadata;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
@ -25,6 +26,7 @@ import net.osmand.plus.myplaces.SegmentActionsListener;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import static net.osmand.AndroidUtils.dpToPx;
import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.getMetadataImageLink; import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.getMetadataImageLink;
import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.isGpxFileSelected; import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.isGpxFileSelected;
import static net.osmand.plus.track.OptionsCard.APPEARANCE_BUTTON_INDEX; import static net.osmand.plus.track.OptionsCard.APPEARANCE_BUTTON_INDEX;
@ -39,6 +41,7 @@ public class OverviewCard extends BaseCard {
private View appearanceButton; private View appearanceButton;
private View editButton; private View editButton;
private View directionsButton; private View directionsButton;
private TextView description;
private final SegmentActionsListener actionsListener; private final SegmentActionsListener actionsListener;
private final SelectedGpxFile selectedGpxFile; private final SelectedGpxFile selectedGpxFile;
private final GpxBlockStatisticsBuilder blockStatisticsBuilder; private final GpxBlockStatisticsBuilder blockStatisticsBuilder;
@ -70,6 +73,7 @@ public class OverviewCard extends BaseCard {
appearanceButton = view.findViewById(R.id.appearance_button); appearanceButton = view.findViewById(R.id.appearance_button);
editButton = view.findViewById(R.id.edit_button); editButton = view.findViewById(R.id.edit_button);
directionsButton = view.findViewById(R.id.directions_button); directionsButton = view.findViewById(R.id.directions_button);
description = view.findViewById(R.id.description);
RecyclerView blocksView = view.findViewById(R.id.recycler_overview); RecyclerView blocksView = view.findViewById(R.id.recycler_overview);
blockStatisticsBuilder.setBlocksView(blocksView); blockStatisticsBuilder.setBlocksView(blocksView);
@ -81,6 +85,10 @@ public class OverviewCard extends BaseCard {
initDirectionsButton(iconColorDef, iconColorPres); initDirectionsButton(iconColorDef, iconColorPres);
} }
blockStatisticsBuilder.initStatBlocks(actionsListener, getActiveColor()); blockStatisticsBuilder.initStatBlocks(actionsListener, getActiveColor());
if (blocksView.getVisibility() == View.VISIBLE && description.getVisibility() == View.VISIBLE) {
AndroidUtils.setPadding(description, 0, 0, 0, dpToPx(app, 12));
}
} }
private GPXFile getGPXFile() { private GPXFile getGPXFile() {
@ -142,7 +150,6 @@ public class OverviewCard extends BaseCard {
gpxFile.metadata = new Metadata(); gpxFile.metadata = new Metadata();
} }
TextView description = view.findViewById(R.id.description);
final String descriptionHtml = gpxFile.metadata.getDescription(); final String descriptionHtml = gpxFile.metadata.getDescription();
if (Algorithms.isBlank(descriptionHtml)) { if (Algorithms.isBlank(descriptionHtml)) {
AndroidUiHelper.updateVisibility(description, false); AndroidUiHelper.updateVisibility(description, false);

View file

@ -746,19 +746,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
@Override @Override
public int getStatusBarColorId() { public int getStatusBarColorId() {
View view = getView(); if (getViewY() <= getFullScreenTopPosY() || !isPortrait()) {
if (view != null) { return isNightMode() ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
boolean nightMode = isNightMode();
if (getViewY() <= getFullScreenTopPosY() || !isPortrait()) {
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
} else {
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
view.setSystemUiVisibility(view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}
} }
return -1; return -1;
} }
@ -827,7 +816,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
segment = segments.get(0); segment = segments.get(0);
} }
} }
GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[]{GpxDisplayItemType.TRACK_SEGMENT}; GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT};
List<GpxDisplayItem> items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)); List<GpxDisplayItem> items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes));
if (segment != null && !Algorithms.isEmpty(items)) { if (segment != null && !Algorithms.isEmpty(items)) {
SplitSegmentDialogFragment.showInstance(fragmentManager, displayHelper, items.get(0), segment); SplitSegmentDialogFragment.showInstance(fragmentManager, displayHelper, items.get(0), segment);
@ -1220,7 +1209,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
@Override @Override
public void gpxSavingFinished(Exception errorMessage) { public void gpxSavingFinished(Exception errorMessage) {
if (selectedGpxFile != null) { if (selectedGpxFile != null) {
List<GpxDisplayGroup> groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[]{GpxDisplayItemType.TRACK_SEGMENT}); List<GpxDisplayGroup> groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT});
selectedGpxFile.setDisplayGroups(groups, app); selectedGpxFile.setDisplayGroups(groups, app);
selectedGpxFile.processPoints(app); selectedGpxFile.processPoints(app);
} }