aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-01-27 08:36:46 +0100
committerBananeweizen <bananeweizen@gmx.de>2013-01-27 08:40:02 +0100
commit81b311085fd92e67676c3e19504b6c92c6d52209 (patch)
tree6f17f780654f7dfdc7fcbdf1015931c4aa66aa47
parentbc070172281b36407d05ed5cbdc4fbcba2d6b529 (diff)
downloadcgeo-81b311085fd92e67676c3e19504b6c92c6d52209.zip
cgeo-81b311085fd92e67676c3e19504b6c92c6d52209.tar.gz
cgeo-81b311085fd92e67676c3e19504b6c92c6d52209.tar.bz2
#1791: refactor live map hint activity into a dialog
-rw-r--r--main/AndroidManifest.xml6
-rw-r--r--main/res/layout/livemapinfo.xml67
-rw-r--r--main/src/cgeo/geocaching/LiveMapInfo.java52
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java6
-rw-r--r--main/src/cgeo/geocaching/ui/dialog/LiveMapInfoDialogBuilder.java43
5 files changed, 66 insertions, 108 deletions
diff --git a/main/AndroidManifest.xml b/main/AndroidManifest.xml
index 9a4cd55..abd1adb 100644
--- a/main/AndroidManifest.xml
+++ b/main/AndroidManifest.xml
@@ -215,12 +215,6 @@
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation" >
</activity>
- <activity
- android:name=".LiveMapInfo"
- android:label="@string/app_name"
- android:theme="@style/popup_dark"
- android:configChanges="keyboardHidden|orientation" >
- </activity>
<provider android:name=".apps.LocusDataStorageProvider"
android:authorities="cgeo.geocaching.apps.locusdatastorageprovider" />
<activity android:name="WaypointPopup"
diff --git a/main/res/layout/livemapinfo.xml b/main/res/layout/livemapinfo.xml
index 66f9da4..5dd8ccd 100644
--- a/main/res/layout/livemapinfo.xml
+++ b/main/res/layout/livemapinfo.xml
@@ -1,56 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/live_map_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:background="?background_color_transparent"
- android:orientation="vertical" >
+ android:orientation="vertical"
+ android:padding="4dip" >
- <LinearLayout style="@style/action_bar" >
-
- <TextView style="@style/action_bar_title" />
- </LinearLayout>
-
- <ScrollView
- android:id="@+id/live_map_scroll"
+ <LinearLayout
android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- android:padding="4dip" >
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
- <LinearLayout
+ <TextView
+ android:id="@+id/live_map_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/live_map_text"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/live_map_notification"
- android:textColor="?text_color"
- android:textSize="14dip" />
+ android:text="@string/live_map_notification"
+ android:textColor="?text_color"
+ android:textSize="14dip" />
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
-
- <CheckBox
- android:id="@+id/live_map_hint_hide"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="left"
- android:text="@string/live_map_note_dontshow"
- android:visibility="gone" />
-
- <Button
- android:id="@+id/live_map_hint_ok"
- style="@style/button_small"
- android:layout_width="60dip"
- android:layout_alignParentRight="true"
- android:layout_marginRight="1dip"
- android:text="@string/live_map_note_close" />
- </RelativeLayout>
- </LinearLayout>
- </ScrollView>
+ <CheckBox
+ android:id="@+id/live_map_hint_hide"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:text="@string/live_map_note_dontshow"
+ android:visibility="gone" />
+ </LinearLayout>
-</LinearLayout> \ No newline at end of file
+</ScrollView> \ No newline at end of file
diff --git a/main/src/cgeo/geocaching/LiveMapInfo.java b/main/src/cgeo/geocaching/LiveMapInfo.java
deleted file mode 100644
index 2fee940..0000000
--- a/main/src/cgeo/geocaching/LiveMapInfo.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package cgeo.geocaching;
-
-import cgeo.geocaching.activity.AbstractActivity;
-
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Button;
-import android.widget.CheckBox;
-
-public class LiveMapInfo extends AbstractActivity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.livemapinfo);
-
- final int showCount = Settings.getLiveMapHintShowCount();
-
- if (showCount > 2) {
- final CheckBox cb = (CheckBox) findViewById(R.id.live_map_hint_hide);
- cb.setVisibility(View.VISIBLE);
- }
-
- final Button closeButton = (Button) findViewById(R.id.live_map_hint_ok);
- closeButton.setOnClickListener(new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
- final CheckBox cb = (CheckBox) findViewById(R.id.live_map_hint_hide);
- if (cb.isChecked()) {
- Settings.setHideLiveHint(true);
- }
- finish();
- }
- });
-
- Settings.setLiveMapHintShowCount(showCount + 1);
- }
-
- @Override
- protected void onStop() {
-
- final CheckBox cb = (CheckBox) findViewById(R.id.live_map_hint_hide);
- if (cb.isChecked()) {
- Settings.setHideLiveHint(true);
- }
-
- super.onStop();
- }
-
-}
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 80d3c89..6f14db6 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -3,7 +3,6 @@ package cgeo.geocaching.maps;
import cgeo.geocaching.DirectionProvider;
import cgeo.geocaching.IGeoData;
import cgeo.geocaching.IWaypoint;
-import cgeo.geocaching.LiveMapInfo;
import cgeo.geocaching.R;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
@@ -32,6 +31,7 @@ import cgeo.geocaching.maps.interfaces.MapProvider;
import cgeo.geocaching.maps.interfaces.MapSource;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
import cgeo.geocaching.maps.interfaces.OnMapDragListener;
+import cgeo.geocaching.ui.dialog.LiveMapInfoDialogBuilder;
import cgeo.geocaching.utils.AngleUtils;
import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.GeoDirHandler;
@@ -470,9 +470,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
prepareFilterBar();
if (!app.isLiveMapHintShown() && !Settings.getHideLiveMapHint()) {
- Intent hintIntent = new Intent(activity, LiveMapInfo.class);
- activity.startActivity(hintIntent);
- app.setLiveMapHintShown();
+ LiveMapInfoDialogBuilder.create(activity).show();
}
}
diff --git a/main/src/cgeo/geocaching/ui/dialog/LiveMapInfoDialogBuilder.java b/main/src/cgeo/geocaching/ui/dialog/LiveMapInfoDialogBuilder.java
new file mode 100644
index 0000000..9955958
--- /dev/null
+++ b/main/src/cgeo/geocaching/ui/dialog/LiveMapInfoDialogBuilder.java
@@ -0,0 +1,43 @@
+package cgeo.geocaching.ui.dialog;
+
+import cgeo.geocaching.R;
+import cgeo.geocaching.Settings;
+import cgeo.geocaching.cgeoapplication;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.view.View;
+import android.widget.CheckBox;
+
+public class LiveMapInfoDialogBuilder {
+
+ public static AlertDialog create(Activity activity) {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+
+ final View layout = activity.getLayoutInflater().inflate(R.layout.livemapinfo, null);
+ builder.setView(layout);
+
+ final CheckBox checkBoxHide = (CheckBox) layout.findViewById(R.id.live_map_hint_hide);
+
+ final int showCount = Settings.getLiveMapHintShowCount();
+ if (showCount > 2) {
+ checkBoxHide.setVisibility(View.VISIBLE);
+ }
+ Settings.setLiveMapHintShowCount(showCount + 1);
+
+ builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ cgeoapplication.getInstance().setLiveMapHintShown();
+ if (checkBoxHide.getVisibility() == View.VISIBLE && checkBoxHide.isChecked()) {
+ Settings.setHideLiveHint(true);
+ }
+ }
+ });
+ return builder.create();
+ }
+
+}