mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-11 06:44:18 +00:00
[android] Add switch to enable 3D mode from layers bottomsheet
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
package app.organicmaps.maplayer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import app.organicmaps.MwmApplication;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.sdk.Framework;
|
||||
import app.organicmaps.sdk.maplayer.Mode;
|
||||
import app.organicmaps.sdk.util.SharedPropertiesUtils;
|
||||
import app.organicmaps.util.ThemeSwitcher;
|
||||
@@ -19,6 +23,7 @@ import app.organicmaps.util.Utils;
|
||||
import app.organicmaps.util.bottomsheet.MenuBottomSheetFragment;
|
||||
import app.organicmaps.widget.recycler.SpanningLinearLayoutManager;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.materialswitch.MaterialSwitch;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,6 +41,22 @@ public class ToggleMapLayerFragment extends Fragment
|
||||
{
|
||||
View mRoot = inflater.inflate(R.layout.fragment_toggle_map_layer, container, false);
|
||||
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext());
|
||||
final boolean _3DEnabled = sharedPreferences.getBoolean(ContextCompat.getString(requireContext(), R.string.pref_3d_buildings),true);
|
||||
MaterialSwitch m3DSwitch = mRoot.findViewById(R.id._3d_button);
|
||||
m3DSwitch.setChecked(_3DEnabled);
|
||||
m3DSwitch.setOnClickListener(v -> {
|
||||
if (m3DSwitch.isChecked())
|
||||
{
|
||||
Framework.nativeSet3dMode(true, false);
|
||||
m3DSwitch.setChecked(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Framework.nativeSet3dMode(true, true);
|
||||
m3DSwitch.setChecked(true);
|
||||
}
|
||||
});
|
||||
mMapButtonsController =
|
||||
(MapButtonsController) requireActivity().getSupportFragmentManager().findFragmentById(R.id.map_buttons);
|
||||
MaterialButton mCloseButton = mRoot.findViewById(R.id.close_button);
|
||||
|
||||
@@ -19,6 +19,18 @@
|
||||
android:textAppearance="@style/MwmTextAppearance.Headline6"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/_3d_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_base"
|
||||
android:paddingTop="@dimen/margin_half_plus"
|
||||
android:text="3D"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/close_button"
|
||||
app:layout_constraintStart_toEndOf="@+id/layers_text"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/close_button"
|
||||
style="@style/Widget.Material3.Button.UnelevatedButton"
|
||||
|
||||
Reference in New Issue
Block a user