Skip to content

Commit b2bd197

Browse files
Menu enhanced
1 parent eabec11 commit b2bd197

6 files changed

Lines changed: 42 additions & 11 deletions

File tree

app/src/main/java/org/open311/android/MainActivity.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import java.util.List;
3333

34+
import static org.open311.android.fragments.ReportFragment.LOCATION_REQUEST;
3435
import static org.open311.android.helpers.Utils.*;
3536

3637
import io.tus.android.client.TusPreferencesURLStore;
@@ -92,9 +93,9 @@ protected void onCreate(Bundle savedInstanceState) {
9293
public boolean onCreateOptionsMenu(Menu menu) {
9394
final List<Server> servers = new Servers().getCollection();
9495
getMenuInflater().inflate(R.menu.main, menu);
95-
96-
MenuItem actionItem = menu.findItem(R.id.setting_general);
97-
actionItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
96+
MenuItem mapItem = menu.findItem(R.id.setting_map);
97+
MenuItem cityItem = menu.findItem(R.id.setting_general);
98+
cityItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
9899
@Override
99100
public boolean onMenuItemClick(MenuItem item) {
100101
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
@@ -137,6 +138,15 @@ public void onClick(DialogInterface dialog, int id) {
137138
return false;
138139
}
139140
});
141+
mapItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
142+
@Override
143+
public boolean onMenuItemClick(MenuItem menuItem) {
144+
//Show the map
145+
Intent intent = new Intent(MainActivity.this, MapActivity.class);
146+
startActivityForResult(intent, LOCATION_REQUEST);
147+
return false;
148+
}
149+
});
140150
return true;
141151
}
142152

app/src/main/java/org/open311/android/models/Attachment.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@
33
import android.net.Uri;
44
import android.os.Parcel;
55
import android.os.Parcelable;
6-
import android.webkit.MimeTypeMap;
7-
8-
import com.google.gson.annotations.SerializedName;
96

107
import org.open311.android.R;
118

12-
import java.io.Serializable;
13-
149
/**
1510
* Class for attachments that can be part of a open311 report
1611
* Created by milo@dogodigi.net on 11/23/16.
@@ -88,7 +83,7 @@ public String getDescription() {
8883
return uri.toString();
8984
}
9085

91-
public int getIcon(){
86+
public int getIcon() {
9287
switch (type) {
9388
case AUDIO:
9489
return R.drawable.ic_play_arrow;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FFFFFFFF"
8+
android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FFFFFFFF"
8+
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
9+
</vector>

app/src/main/res/menu/main.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
xmlns:app="http://schemas.android.com/apk/res-auto">
44
<item
55
android:id="@+id/setting_general"
6-
android:orderInCategory="100"
6+
android:orderInCategory="1"
7+
android:icon="@drawable/ic_settings_white"
78
android:title="@string/setting_general"
8-
app:showAsAction="never" />
9+
app:showAsAction="ifRoom" />
10+
<item
11+
android:id="@+id/setting_map"
12+
android:orderInCategory="2"
13+
android:icon="@drawable/ic_map_white"
14+
android:title="@string/setting_map"
15+
app:showAsAction="ifRoom" />
916
</menu>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,5 @@
147147
<string name="id">Id</string>
148148
<string name="citiesListUnavailable">Settings not available, missing Cities list.</string>
149149
<string name="report_hint_cities">Select your city</string>
150+
<string name="setting_map">Map</string>
150151
</resources>

0 commit comments

Comments
 (0)