Merge pull request #11058 from osmandapp/add_points_list_landscape_plan_route

Add points list landscape plan route
This commit is contained in:
Vitaliy 2021-03-16 11:14:29 +02:00 committed by GitHub
commit 68af232843
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 29 deletions

View file

@ -48,6 +48,11 @@
<include layout="@layout/map_hud_top"
android:id="@+id/MapHudButtonsOverlayTop"/>
<FrameLayout
android:id="@+id/left_side_menu"
android:layout_width="0dp"
android:layout_height="0dp"/>
<include layout="@layout/map_hud_bottom"
android:id="@+id/MapHudButtonsOverlayBottom"/>

View file

@ -11,6 +11,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -18,17 +20,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.snackbar.Snackbar;
import net.osmand.AndroidUtils;
@ -94,6 +85,17 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import static net.osmand.IndexConstants.GPX_FILE_EXT;
import static net.osmand.IndexConstants.GPX_INDEX_DIR;
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode;
@ -126,6 +128,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private RadioItem pointsBtn;
private RadioItem graphBtn;
private View mainView;
private View bottomMapControls;
private ImageView upDownBtn;
private ImageView undoBtn;
private ImageView redoBtn;
@ -245,6 +248,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
public void showProgressBar() {
MeasurementToolFragment.this.showProgressBar();
updateInfoView();
updateCardContainerSize();
}
@Override
@ -257,6 +261,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
((ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar)).setVisibility(View.GONE);
progressBarVisible = false;
updateInfoView();
updateCardContainerSize();
}
@Override
@ -281,8 +286,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
mainView = view.findViewById(R.id.main_view);
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
detailsMenu = new GraphDetailsMenu();
cardsContainer = mainView.findViewById(R.id.cards_container);
if (portrait) {
cardsContainer = mainView.findViewById(R.id.cards_container);
String pointsBtnTitle = getString(R.string.shared_string_gpx_points);
pointsBtn = new RadioItem(pointsBtnTitle);
pointsBtn.setOnClickListener(getInfoTypeBtnListener(InfoType.POINTS));
@ -294,6 +300,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
LinearLayout infoButtonsContainer = mainView.findViewById(R.id.custom_radio_buttons);
infoTypeBtn = new MultiStateToggleButton(app, infoButtonsContainer, nightMode);
infoTypeBtn.setItems(pointsBtn, graphBtn);
} else {
cardsContainer = mapActivity.findViewById(R.id.left_side_menu);
bottomMapControls = mapActivity.findViewById(R.id.bottom_controls_container);
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
updateCardContainerSize();
}
});
}
pointsCard = new PointsCard(mapActivity, this);
graphsCard = new GraphsCard(mapActivity, detailsMenu, this);
@ -328,12 +343,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
upDownRow.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (portrait) {
if (infoExpanded) {
collapseInfoView();
} else if (setInfoType(InfoType.POINTS)) {
infoTypeBtn.setSelectedItem(pointsBtn);
}
if (infoExpanded) {
collapseInfoView();
} else if (setInfoType(InfoType.POINTS) && portrait) {
infoTypeBtn.setSelectedItem(pointsBtn);
}
}
});
@ -608,14 +621,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
private void expandInfoView() {
infoExpanded = true;
if (portrait) {
infoExpanded = true;
cardsContainer.setVisibility(View.VISIBLE);
setMapPosition(portrait
? OsmandSettings.MIDDLE_TOP_CONSTANT
: OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
updateUpDownBtn();
setMapPosition(OsmandSettings.MIDDLE_TOP_CONSTANT);
} else {
shiftBottomMapControls(false);
setMapPosition(OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
}
cardsContainer.setVisibility(View.VISIBLE);
updateUpDownBtn();
}
private void collapseInfoViewIfExpanded() {
@ -625,14 +639,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
private void collapseInfoView() {
cardsContainer.setVisibility(View.GONE);
if (portrait) {
infoExpanded = false;
currentInfoType = null;
infoTypeBtn.setSelectedItem(null);
cardsContainer.setVisibility(View.GONE);
setDefaultMapPosition();
updateUpDownBtn();
} else {
shiftBottomMapControls(true);
}
infoExpanded = false;
currentInfoType = null;
setDefaultMapPosition();
updateUpDownBtn();
}
private void collapseInfoIfNotEnoughPoints() {
@ -659,6 +675,22 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
}
private void updateCardContainerSize() {
View measureModeControls = mainView.findViewById(R.id.measure_mode_controls);
int width = mainView.getWidth() - measureModeControls.getWidth();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(width, -1);
int bottomMargin = measureModeControls.getHeight();
bottomMargin = progressBarVisible ? bottomMargin + mainView.findViewById(R.id.snap_to_road_progress_bar).getHeight() : bottomMargin;
params.setMargins(0, 0, 0, bottomMargin);
cardsContainer.setLayoutParams(params);
}
private void shiftBottomMapControls(boolean toInitialPosition) {
int leftMargin = toInitialPosition ? 0 : cardsContainer.getWidth();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) bottomMapControls.getLayoutParams();
params.setMargins(leftMargin, 0, 0, 0);
}
public boolean isInEditMode() {
return !isPlanRouteMode() && !editingCtx.isNewData() && !isDirectionMode() && !isFollowTrackMode();
}