aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2013-01-23 21:07:51 +0100
committerBananeweizen <Bananeweizen@gmx.de>2013-01-23 21:07:51 +0100
commit10f23bdcc058b7233b471aeefec73014cfb34a73 (patch)
treef6b846b109480f440ab817fb493ad3e3b37aadb3
parent5432089c6edfe4df2c940dda3682a74e0e36deb1 (diff)
downloadcgeo-10f23bdcc058b7233b471aeefec73014cfb34a73.zip
cgeo-10f23bdcc058b7233b471aeefec73014cfb34a73.tar.gz
cgeo-10f23bdcc058b7233b471aeefec73014cfb34a73.tar.bz2
#1791: remove selfmade dialog button
-rw-r--r--main/res/layout/fieldnote_export_dialog.xml9
-rw-r--r--main/res/layout/gpx_export_dialog.xml9
-rw-r--r--main/src/cgeo/geocaching/export/FieldnoteExport.java78
-rw-r--r--main/src/cgeo/geocaching/export/GpxExport.java60
4 files changed, 71 insertions, 85 deletions
diff --git a/main/res/layout/fieldnote_export_dialog.xml b/main/res/layout/fieldnote_export_dialog.xml
index ca0b01d..4548602 100644
--- a/main/res/layout/fieldnote_export_dialog.xml
+++ b/main/res/layout/fieldnote_export_dialog.xml
@@ -9,8 +9,8 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textColor="?text_color"
- android:text="@string/export_fieldnotes_info" />
+ android:text="@string/export_fieldnotes_info"
+ android:textColor="?text_color" />
<CheckBox
android:id="@+id/upload"
@@ -23,9 +23,4 @@
android:enabled="false"
android:text="@string/export_fieldnotes_onlynew" />
- <Button
- android:id="@+id/export"
- style="@style/button_full"
- android:text="@string/export" />
-
</LinearLayout> \ No newline at end of file
diff --git a/main/res/layout/gpx_export_dialog.xml b/main/res/layout/gpx_export_dialog.xml
index a997d6b..4863417 100644
--- a/main/res/layout/gpx_export_dialog.xml
+++ b/main/res/layout/gpx_export_dialog.xml
@@ -10,17 +10,12 @@
android:id="@id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textColor="?text_color"
- android:text="@string/export_gpx_info" />
+ android:text="@string/export_gpx_info"
+ android:textColor="?text_color" />
<CheckBox
android:id="@+id/share"
style="@style/checkbox_full"
android:text="@string/init_share_after_export" />
- <Button
- android:id="@+id/export"
- style="@style/button_full"
- android:text="@string/export" />
-
</LinearLayout> \ No newline at end of file
diff --git a/main/src/cgeo/geocaching/export/FieldnoteExport.java b/main/src/cgeo/geocaching/export/FieldnoteExport.java
index de78c22..8ec2112 100644
--- a/main/src/cgeo/geocaching/export/FieldnoteExport.java
+++ b/main/src/cgeo/geocaching/export/FieldnoteExport.java
@@ -2,10 +2,10 @@ package cgeo.geocaching.export;
import cgeo.geocaching.LogEntry;
import cgeo.geocaching.R;
-import cgeo.geocaching.activity.ActivityMixin;
-import cgeo.geocaching.activity.Progress;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
+import cgeo.geocaching.activity.ActivityMixin;
+import cgeo.geocaching.activity.Progress;
import cgeo.geocaching.connector.gc.Login;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.network.Network;
@@ -18,6 +18,8 @@ import org.apache.commons.lang3.StringUtils;
import android.app.Activity;
import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Environment;
import android.view.View;
@@ -53,43 +55,6 @@ class FieldnoteExport extends AbstractExport {
super(getString(R.string.export_fieldnotes));
}
- /**
- * A dialog to allow the user to set options for the export.
- *
- * Currently available options are: upload field notes, only new logs since last export/upload
- */
- private class ExportOptionsDialog extends AlertDialog {
- public ExportOptionsDialog(final List<cgCache> caches, final Activity activity) {
- super(activity);
-
- View layout = activity.getLayoutInflater().inflate(R.layout.fieldnote_export_dialog, null);
- setView(layout);
-
- final CheckBox uploadOption = (CheckBox) layout.findViewById(R.id.upload);
- final CheckBox onlyNewOption = (CheckBox) layout.findViewById(R.id.onlynew);
-
- uploadOption.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onlyNewOption.setEnabled(uploadOption.isChecked());
- }
- });
-
- layout.findViewById(R.id.export).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- dismiss();
- new ExportTask(
- caches,
- activity,
- uploadOption.isChecked(),
- onlyNewOption.isChecked())
- .execute((Void) null);
- }
- });
- }
- }
-
@Override
public void export(final List<cgCache> caches, final Activity activity) {
if (null == activity) {
@@ -98,10 +63,43 @@ class FieldnoteExport extends AbstractExport {
new ExportTask(caches, null, false, false).execute((Void) null);
} else {
// Show configuration dialog
- new ExportOptionsDialog(caches, activity).show();
+ getExportOptionsDialog(caches, activity).show();
}
}
+ private Dialog getExportOptionsDialog(final List<cgCache> caches, final Activity activity) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+
+ View layout = activity.getLayoutInflater().inflate(R.layout.fieldnote_export_dialog, null);
+ builder.setView(layout);
+
+ final CheckBox uploadOption = (CheckBox) layout.findViewById(R.id.upload);
+ final CheckBox onlyNewOption = (CheckBox) layout.findViewById(R.id.onlynew);
+
+ uploadOption.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ onlyNewOption.setEnabled(uploadOption.isChecked());
+ }
+ });
+
+ builder.setPositiveButton(R.string.export, new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ new ExportTask(
+ caches,
+ activity,
+ uploadOption.isChecked(),
+ onlyNewOption.isChecked())
+ .execute((Void) null);
+ }
+ });
+
+ return builder.create();
+ }
+
private class ExportTask extends AsyncTask<Void, Integer, Boolean> {
private final List<cgCache> caches;
private final Activity activity;
diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java
index a2d5be6..1cba79d 100644
--- a/main/src/cgeo/geocaching/export/GpxExport.java
+++ b/main/src/cgeo/geocaching/export/GpxExport.java
@@ -4,10 +4,10 @@ import cgeo.geocaching.LogEntry;
import cgeo.geocaching.R;
import cgeo.geocaching.Settings;
import cgeo.geocaching.Waypoint;
-import cgeo.geocaching.activity.ActivityMixin;
-import cgeo.geocaching.activity.Progress;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
+import cgeo.geocaching.activity.ActivityMixin;
+import cgeo.geocaching.activity.Progress;
import cgeo.geocaching.enumerations.CacheAttribute;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.geopoint.Geopoint;
@@ -20,7 +20,9 @@ import org.xmlpull.v1.XmlSerializer;
import android.app.Activity;
import android.app.AlertDialog;
+import android.app.Dialog;
import android.app.ProgressDialog;
+import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
@@ -58,44 +60,40 @@ class GpxExport extends AbstractExport {
} else {
// Show configuration dialog
- new ExportOptionsDialog(caches, activity).show();
+ getExportDialog(caches, activity).show();
}
}
- /**
- * A dialog to allow the user to set options for the export.
- *
- * Currently available option is: opening of share menu after successful export
- */
- private class ExportOptionsDialog extends AlertDialog {
- public ExportOptionsDialog(final List<cgCache> caches, final Activity activity) {
- super(activity);
+ private Dialog getExportDialog(final List<cgCache> caches, final Activity activity) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
- View layout = activity.getLayoutInflater().inflate(R.layout.gpx_export_dialog, null);
- setView(layout);
+ View layout = activity.getLayoutInflater().inflate(R.layout.gpx_export_dialog, null);
+ builder.setView(layout);
- final TextView text = (TextView) layout.findViewById(R.id.info);
- text.setText(getString(R.string.export_gpx_info, Settings.getGpxExportDir()));
+ final TextView text = (TextView) layout.findViewById(R.id.info);
+ text.setText(getString(R.string.export_gpx_info, Settings.getGpxExportDir()));
- final CheckBox shareOption = (CheckBox) layout.findViewById(R.id.share);
+ final CheckBox shareOption = (CheckBox) layout.findViewById(R.id.share);
- shareOption.setChecked(Settings.getShareAfterExport());
+ shareOption.setChecked(Settings.getShareAfterExport());
- shareOption.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Settings.setShareAfterExport(shareOption.isChecked());
- }
- });
+ shareOption.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Settings.setShareAfterExport(shareOption.isChecked());
+ }
+ });
- layout.findViewById(R.id.export).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- dismiss();
- new ExportTask(caches, activity).execute((Void) null);
- }
- });
- }
+ builder.setPositiveButton(R.string.export, new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ new ExportTask(caches, activity).execute((Void) null);
+ }
+ });
+
+ return builder.create();
}
private class ExportTask extends AsyncTask<Void, Integer, File> {