Implement main screen dropdown menu
This commit is contained in:
@@ -34,9 +34,6 @@ public class AppController {
|
||||
}
|
||||
public AppCompatActivity getActivity() { return appActivity; }
|
||||
public void init() {
|
||||
if (getActivity().getSupportActionBar() != null)
|
||||
getActivity().getSupportActionBar().hide();
|
||||
|
||||
if(map == null) map = new MapComponent(this);
|
||||
if(ui == null) {
|
||||
ui = new UIComponent(this, map);
|
||||
|
||||
@@ -3,6 +3,7 @@ package eu.konggdev.strikemaps.ui;
|
||||
import android.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import eu.konggdev.strikemaps.Component;
|
||||
import eu.konggdev.strikemaps.R;
|
||||
import eu.konggdev.strikemaps.app.AppController;
|
||||
@@ -41,7 +42,8 @@ public class UIComponent implements Component {
|
||||
R.id.mainContentView, new MainContentRegion(map.toFragment(), R.id.mainContentView),
|
||||
R.id.bottomUi, new UIRegion(new FragmentLayoutControls(app, R.id.bottomUi), R.id.bottomUi),
|
||||
R.id.topUi, new UIRegion(new FragmentLayoutSearch(app, R.id.topUi), R.id.topUi)
|
||||
) //TODO: Probably stop referencing layout 3(!) times everytime
|
||||
), //TODO: Probably stop referencing layout 3(!) times everytime
|
||||
null
|
||||
),
|
||||
//Settings screen
|
||||
DefinedScreen.SETTINGS, new Screen(
|
||||
@@ -49,7 +51,8 @@ public class UIComponent implements Component {
|
||||
//Just the settings content fragment
|
||||
Map.of(
|
||||
R.id.mainContentView, new MainContentRegion(new FragmentLayoutContentSettings(), R.id.mainContentView)
|
||||
)
|
||||
),
|
||||
new Toolbar(app.getActivity())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,4 +38,11 @@ public final class AlertDialogFactory {
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static AlertDialog searchSettings(AppController app) {
|
||||
return new AlertDialog.Builder(app.getActivity())
|
||||
.setTitle("Configure Search")
|
||||
.setPositiveButton("OK", null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
+50
-12
@@ -1,29 +1,24 @@
|
||||
package eu.konggdev.strikemaps.ui.fragment.layout;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.PopupWindow;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.PopupMenu;
|
||||
|
||||
import eu.konggdev.strikemaps.R;
|
||||
import eu.konggdev.strikemaps.app.AppController;
|
||||
import eu.konggdev.strikemaps.data.helper.UserPrefsHelper;
|
||||
import eu.konggdev.strikemaps.map.overlay.implementation.LocationOverlay;
|
||||
import eu.konggdev.strikemaps.ui.fragment.popup.FragmentMapChangePopup;
|
||||
import eu.konggdev.strikemaps.ui.factory.AlertDialogFactory;
|
||||
import eu.konggdev.strikemaps.ui.screen.definition.DefinedScreen;
|
||||
|
||||
public class FragmentLayoutSearch extends Fragment implements Layout {
|
||||
AppController app;
|
||||
View rootView;
|
||||
|
||||
private final Integer region;
|
||||
|
||||
public FragmentLayoutSearch(AppController app, Integer region) {
|
||||
@@ -45,7 +40,50 @@ public class FragmentLayoutSearch extends Fragment implements Layout {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
//TODO: Make a floating menu instead of going right in settings
|
||||
setupButton(view, R.id.hamburgerButton, click(() -> app.getUi().swapScreen(DefinedScreen.SETTINGS)));
|
||||
|
||||
setupButton(view, R.id.hamburgerButton, click(() -> {
|
||||
|
||||
View menuView = getLayoutInflater().inflate(R.layout.menu_dropdown, null);
|
||||
|
||||
PopupWindow popupWindow = new PopupWindow(
|
||||
menuView,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
true
|
||||
);
|
||||
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
popupWindow.setFocusable(true);
|
||||
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
|
||||
setupButton(menuView, R.id.menuSearchSettings, click(() -> {
|
||||
app.getUi().alert(AlertDialogFactory.searchSettings(app));
|
||||
}));
|
||||
|
||||
setupButton(menuView, R.id.menuSettings, click(() -> {
|
||||
popupWindow.dismiss();
|
||||
app.getUi().swapScreen(DefinedScreen.SETTINGS);
|
||||
}));
|
||||
|
||||
menuView.findViewById(R.id.menuSearchSettings).setOnClickListener(v -> popupWindow.dismiss());
|
||||
menuView.findViewById(R.id.menuAbout).setOnClickListener(v -> popupWindow.dismiss());
|
||||
|
||||
View anchor = view.findViewById(R.id.searchContainer);
|
||||
|
||||
anchor.post(() -> {
|
||||
|
||||
menuView.measure(
|
||||
View.MeasureSpec.UNSPECIFIED,
|
||||
View.MeasureSpec.UNSPECIFIED
|
||||
);
|
||||
|
||||
int popupWidth = menuView.getMeasuredWidth();
|
||||
int containerWidth = anchor.getWidth();
|
||||
|
||||
int xOffset = containerWidth - popupWidth;
|
||||
popupWindow.showAsDropDown(anchor, xOffset, 1);
|
||||
});
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,25 +2,24 @@ package eu.konggdev.strikemaps.ui.screen;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import eu.konggdev.strikemaps.app.AppController;
|
||||
import eu.konggdev.strikemaps.ui.fragment.ContainerFragment;
|
||||
import eu.konggdev.strikemaps.ui.fragment.FragmentEmptyPlaceholder;
|
||||
import eu.konggdev.strikemaps.ui.fragment.layout.content.main.MainContentLayout;
|
||||
import eu.konggdev.strikemaps.ui.fragment.popup.Popup;
|
||||
import eu.konggdev.strikemaps.ui.element.region.UIRegion;
|
||||
|
||||
public class Screen {
|
||||
@NonNull AppController app;
|
||||
public Screen(AppController app, Map<Integer, UIRegion> regions) {
|
||||
Toolbar supportBar;
|
||||
public Screen(AppController app, Map<Integer, UIRegion> regions, Toolbar supportBar) {
|
||||
this.app = app;
|
||||
this.uiRegions = regions;
|
||||
this.supportBar = supportBar;
|
||||
}
|
||||
|
||||
private MainContentLayout mainContent;
|
||||
|
||||
Map<Integer, UIRegion> uiRegions;
|
||||
public Integer popup;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user