forked from streetcomplete/StreetComplete
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes streetcomplete#388 by @mnalis, from https://github.com/mnalis/StreetComplete/tree/ui-hamburger-2x3
- Loading branch information
Showing
7 changed files
with
230 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/src/main/java/de/westnordost/streetcomplete/screens/main/controls/MainMenuGridDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package de.westnordost.streetcomplete.screens.main.controls | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.view.LayoutInflater | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.core.view.doOnPreDraw | ||
import de.westnordost.streetcomplete.databinding.DialogMainMenuGridBinding | ||
import de.westnordost.streetcomplete.screens.about.AboutActivity | ||
import de.westnordost.streetcomplete.screens.main.teammode.TeamModeDialog | ||
import de.westnordost.streetcomplete.screens.settings.SettingsActivity | ||
import de.westnordost.streetcomplete.screens.user.UserActivity | ||
|
||
/** Shows a dialog containing the main menu items. | ||
* This is an almost exact copy of MainMenuDialog, because the compiler doesn't like being able to select | ||
* the binding on init. */ | ||
class MainMenuGridDialog( | ||
context: Context, | ||
indexInTeam: Int?, | ||
onClickDownload: () -> Unit, | ||
onEnableTeamMode: (Int, Int) -> Unit, | ||
onDisableTeamMode: () -> Unit, | ||
onClickOverlays: () -> Unit, | ||
) : AlertDialog(context) { | ||
init { | ||
val binding = DialogMainMenuGridBinding.inflate(LayoutInflater.from(context)) | ||
|
||
binding.profileButton.setOnClickListener { | ||
val intent = Intent(context, UserActivity::class.java) | ||
context.startActivity(intent) | ||
dismiss() | ||
} | ||
binding.enableTeamModeButton.setOnClickListener { | ||
TeamModeDialog(context, onEnableTeamMode).show() | ||
dismiss() | ||
} | ||
binding.disableTeamModeButton.setOnClickListener { | ||
onDisableTeamMode() | ||
dismiss() | ||
} | ||
binding.settingsButton.setOnClickListener { | ||
val intent = Intent(context, SettingsActivity::class.java) | ||
context.startActivity(intent) | ||
dismiss() | ||
} | ||
binding.aboutButton.setOnClickListener { | ||
val intent = Intent(context, AboutActivity::class.java) | ||
context.startActivity(intent) | ||
dismiss() | ||
} | ||
binding.downloadButton.setOnClickListener { | ||
onClickDownload() | ||
dismiss() | ||
} | ||
|
||
binding.overlaysButton.setOnClickListener { | ||
onClickOverlays() | ||
dismiss() | ||
} | ||
|
||
if (indexInTeam != null) { | ||
binding.teamModeColorCircle.setIndexInTeam(indexInTeam) | ||
binding.bigMenuItemsContainer.removeView(binding.enableTeamModeButton) | ||
} else { | ||
binding.bigMenuItemsContainer.removeView(binding.disableTeamModeButton) | ||
} | ||
|
||
binding.root.doOnPreDraw { | ||
binding.bigMenuItemsContainer.columnCount = binding.root.width / binding.profileButton.width | ||
} | ||
|
||
setView(binding.root) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<vector | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="48dp" | ||
android:height="48dp" | ||
android:viewportHeight="24.0" | ||
android:viewportWidth="24.0" | ||
android:tint="?attr/colorControlNormal"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M12,5.5A3.5,3.5 0 0,1 15.5,9A3.5,3.5 0 0,1 12,12.5A3.5,3.5 0 0,1 8.5,9A3.5,3.5 0 0,1 12,5.5M5,8C5.56,8 6.08,8.15 6.53,8.42C6.38,9.85 6.8,11.27 7.66,12.38C7.16,13.34 6.16,14 5,14A3,3 0 0,1 2,11A3,3 0 0,1 5,8M19,8A3,3 0 0,1 22,11A3,3 0 0,1 19,14C17.84,14 16.84,13.34 16.34,12.38C17.2,11.27 17.62,9.85 17.47,8.42C17.92,8.15 18.44,8 19,8M5.5,18.25C5.5,16.18 8.41,14.5 12,14.5C15.59,14.5 18.5,16.18 18.5,18.25V20H5.5V18.25M0,20V18.5C0,17.11 1.89,15.94 4.45,15.6C3.86,16.28 3.5,17.22 3.5,18.25V20H0M24,20H20.5V18.25C20.5,17.22 20.14,16.28 19.55,15.6C22.11,15.94 24,17.11 24,18.5V20Z" | ||
/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<GridLayout | ||
android:id="@+id/bigMenuItemsContainer" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerHorizontal="true" | ||
android:layout_gravity="center" | ||
android:columnCount="2" | ||
android:orientation="horizontal"> | ||
|
||
<TextView | ||
android:id="@+id/profileButton" | ||
style="?android:attr/borderlessButtonStyle" | ||
android:layout_width="144dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="fill_vertical" | ||
android:padding="16dp" | ||
android:text="@string/user_profile" | ||
android:textAppearance="@android:style/TextAppearance.Theme.Dialog" | ||
app:drawableTopCompat="@drawable/ic_profile_48dp" /> | ||
|
||
<TextView | ||
android:id="@+id/enableTeamModeButton" | ||
style="?android:attr/borderlessButtonStyle" | ||
android:layout_width="144dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="fill_vertical" | ||
android:padding="16dp" | ||
android:text="@string/team_mode" | ||
android:textAppearance="@android:style/TextAppearance.Theme.Dialog" | ||
app:drawableTopCompat="@drawable/ic_team_mode_48dp" /> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:id="@+id/disableTeamModeButton" | ||
style="?android:attr/borderlessButtonStyle" | ||
android:layout_width="144dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="fill_vertical" | ||
android:padding="16dp"> | ||
|
||
<de.westnordost.streetcomplete.screens.main.teammode.TeamModeColorCircleView | ||
android:id="@+id/teamModeColorCircle" | ||
android:layout_width="40dp" | ||
android:layout_height="40dp" | ||
android:layout_margin="4dp" | ||
app:layout_constraintBottom_toTopOf="@+id/disableTeamModeText" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"/> | ||
|
||
<TextView | ||
android:id="@+id/disableTeamModeText" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/team_mode_exit" | ||
android:textAlignment="center" | ||
android:textAppearance="@android:style/TextAppearance.Theme.Dialog" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
<TextView | ||
android:id="@+id/aboutButton" | ||
style="?android:attr/borderlessButtonStyle" | ||
android:layout_width="144dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="fill_vertical" | ||
android:padding="16dp" | ||
android:text="@string/action_about2" | ||
android:textAppearance="@android:style/TextAppearance.Theme.Dialog" | ||
app:drawableTopCompat="@drawable/ic_info_outline_48dp" /> | ||
|
||
<TextView | ||
android:id="@+id/overlaysButton" | ||
style="?android:attr/borderlessButtonStyle" | ||
android:layout_width="144dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="fill_vertical" | ||
android:padding="16dp" | ||
android:text="@string/action_overlays" | ||
android:textAppearance="@android:style/TextAppearance.Theme.Dialog" | ||
app:drawableTopCompat="@drawable/ic_overlay_48dp" /> | ||
|
||
<TextView | ||
android:id="@+id/settingsButton" | ||
style="?android:attr/borderlessButtonStyle" | ||
android:layout_width="144dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="fill_vertical" | ||
android:padding="16dp" | ||
android:text="@string/action_settings" | ||
android:textAppearance="@android:style/TextAppearance.Theme.Dialog" | ||
app:drawableTopCompat="@drawable/ic_settings_48dp" /> | ||
|
||
<TextView | ||
android:id="@+id/downloadButton" | ||
style="?android:attr/borderlessButtonStyle" | ||
android:layout_width="144dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="fill_vertical" | ||
android:padding="16dp" | ||
android:text="@string/action_download" | ||
android:textAppearance="@android:style/TextAppearance.Theme.Dialog" | ||
app:drawableTopCompat="@drawable/ic_search_48dp" /> | ||
|
||
</GridLayout> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters