aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2011-08-10 07:58:37 +0200
committerBananeweizen <bananeweizen@gmx.de>2011-08-10 07:58:37 +0200
commitcc9a678a367f34f693e9f2facabc79559ab72486 (patch)
treee07b955cfee33eed24ddfc7bb12e3b53c979cbfc /src
parentc47ca7defa34a44ec1b5955d722e54c61c2ef506 (diff)
downloadcgeo-cc9a678a367f34f693e9f2facabc79559ab72486.zip
cgeo-cc9a678a367f34f693e9f2facabc79559ab72486.tar.gz
cgeo-cc9a678a367f34f693e9f2facabc79559ab72486.tar.bz2
* have common base classes for cgeo related activities to encapsulate
the related code * move several methods from base to the activities classes * remove all duplicated goHome(), goManual() methods * remove instance variable "activity", which is only a this-pointer (all triggered by issue #98) If you have trouble merging afterwards, I'm happy to help.
Diffstat (limited to 'src')
-rw-r--r--src/cgeo/geocaching/activity/AbstractActivity.java37
-rw-r--r--src/cgeo/geocaching/activity/AbstractListActivity.java33
-rw-r--r--src/cgeo/geocaching/activity/ActivityMixin.java72
-rw-r--r--src/cgeo/geocaching/activity/IAbstractActivity.java14
-rw-r--r--src/cgeo/geocaching/cgBase.java35
-rw-r--r--src/cgeo/geocaching/cgFileList.java41
-rw-r--r--src/cgeo/geocaching/cgGPXListAdapter.java15
-rw-r--r--src/cgeo/geocaching/cgLogForm.java9
-rw-r--r--src/cgeo/geocaching/cgeo.java34
-rw-r--r--src/cgeo/geocaching/cgeoabout.java43
-rw-r--r--src/cgeo/geocaching/cgeoaddresses.java48
-rw-r--r--src/cgeo/geocaching/cgeoadvsearch.java94
-rw-r--r--src/cgeo/geocaching/cgeoauth.java25
-rw-r--r--src/cgeo/geocaching/cgeocaches.java207
-rw-r--r--src/cgeo/geocaching/cgeodetail.java139
-rw-r--r--src/cgeo/geocaching/cgeogpxes.java10
-rw-r--r--src/cgeo/geocaching/cgeohelpers.java33
-rw-r--r--src/cgeo/geocaching/cgeoimages.java90
-rw-r--r--src/cgeo/geocaching/cgeoinit.java58
-rw-r--r--src/cgeo/geocaching/cgeonavigate.java80
-rw-r--r--src/cgeo/geocaching/cgeopoint.java56
-rw-r--r--src/cgeo/geocaching/cgeopopup.java80
-rw-r--r--src/cgeo/geocaching/cgeosmaps.java26
-rw-r--r--src/cgeo/geocaching/cgeotouch.java58
-rw-r--r--src/cgeo/geocaching/cgeotrackable.java80
-rw-r--r--src/cgeo/geocaching/cgeotrackables.java51
-rw-r--r--src/cgeo/geocaching/cgeovisit.java55
-rw-r--r--src/cgeo/geocaching/cgeowaypoint.java61
-rw-r--r--src/cgeo/geocaching/cgeowaypointadd.java69
-rw-r--r--src/cgeo/geocaching/mapcommon/cgeomap.java29
30 files changed, 692 insertions, 990 deletions
diff --git a/src/cgeo/geocaching/activity/AbstractActivity.java b/src/cgeo/geocaching/activity/AbstractActivity.java
new file mode 100644
index 0000000..fa982b9
--- /dev/null
+++ b/src/cgeo/geocaching/activity/AbstractActivity.java
@@ -0,0 +1,37 @@
+package cgeo.geocaching.activity;
+
+import android.app.Activity;
+import android.view.View;
+
+public abstract class AbstractActivity extends Activity implements IAbstractActivity {
+
+ private String helpTopic;
+
+ public AbstractActivity() {
+ this(null);
+ }
+
+ public AbstractActivity(final String helpTopic) {
+ this.helpTopic = helpTopic;
+ }
+
+ final public void goHome(final View view) {
+ ActivityMixin.goHome(this);
+ }
+
+ public void goManual(final View view) {
+ ActivityMixin.goManual(this, helpTopic);
+ }
+
+ final public void setTitle(final String title) {
+ ActivityMixin.setTitle(this, title);
+ }
+
+ final public void showProgress(final boolean show) {
+ ActivityMixin.showProgress(this, show);
+ }
+
+ final public void setTheme() {
+ ActivityMixin.setTheme(this);
+ }
+}
diff --git a/src/cgeo/geocaching/activity/AbstractListActivity.java b/src/cgeo/geocaching/activity/AbstractListActivity.java
new file mode 100644
index 0000000..2a5dd7f
--- /dev/null
+++ b/src/cgeo/geocaching/activity/AbstractListActivity.java
@@ -0,0 +1,33 @@
+package cgeo.geocaching.activity;
+
+import android.app.ListActivity;
+import android.view.View;
+
+public abstract class AbstractListActivity extends ListActivity implements IAbstractActivity {
+
+ private String helpTopic;
+
+ public AbstractListActivity() {
+ this(null);
+ }
+
+ public AbstractListActivity(final String helpTopic) {
+ this.helpTopic = helpTopic;
+ }
+
+ final public void goHome(View view) {
+ ActivityMixin.goHome(this);
+ }
+
+ public void goManual(View view) {
+ ActivityMixin.goManual(this, helpTopic);
+ }
+
+ final public void showProgress(final boolean show) {
+ ActivityMixin.showProgress(this, show);
+ }
+
+ final public void setTheme() {
+ ActivityMixin.setTheme(this);
+ }
+}
diff --git a/src/cgeo/geocaching/activity/ActivityMixin.java b/src/cgeo/geocaching/activity/ActivityMixin.java
new file mode 100644
index 0000000..0f622da
--- /dev/null
+++ b/src/cgeo/geocaching/activity/ActivityMixin.java
@@ -0,0 +1,72 @@
+package cgeo.geocaching.activity;
+
+import gnu.android.app.appmanualclient.AppManualReaderClient;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.view.View;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import cgeo.geocaching.R;
+import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.cgeo;
+
+public final class ActivityMixin {
+ public final static void goHome(final Activity fromActivity) {
+ final Intent intent = new Intent(fromActivity, cgeo.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+
+ fromActivity.startActivity(intent);
+ fromActivity.finish();
+ }
+
+ public final static void goManual(final Context context, final String helpTopic) {
+ if (helpTopic == null || helpTopic.length() == 0) {
+ return;
+ }
+ try {
+ AppManualReaderClient.openManual(
+ "c-geo",
+ helpTopic,
+ context,
+ "http://cgeo.carnero.cc/manual/");
+ } catch (Exception e) {
+ // nothing
+ }
+ }
+
+ public final static void setTitle(final Activity activity, final String text) {
+ if (text == null) {
+ return;
+ }
+
+ final TextView title = (TextView) activity.findViewById(R.id.actionbar_title);
+ if (title != null) {
+ title.setText(text);
+ }
+ }
+
+ public final static void showProgress(final Activity activity, final boolean show) {
+ if (activity == null) {
+ return;
+ }
+
+ final ProgressBar progress = (ProgressBar) activity.findViewById(R.id.actionbar_progress);
+ if (show) {
+ progress.setVisibility(View.VISIBLE);
+ } else {
+ progress.setVisibility(View.GONE);
+ }
+ }
+
+ public static void setTheme(final Activity activity) {
+ cgSettings settings = new cgSettings(activity, activity.getSharedPreferences(cgSettings.preferences, 0));
+ if (settings.skin == 1) {
+ activity.setTheme(R.style.light);
+ } else {
+ activity.setTheme(R.style.dark);
+ }
+ }
+
+
+}
diff --git a/src/cgeo/geocaching/activity/IAbstractActivity.java b/src/cgeo/geocaching/activity/IAbstractActivity.java
new file mode 100644
index 0000000..e7cb7a8
--- /dev/null
+++ b/src/cgeo/geocaching/activity/IAbstractActivity.java
@@ -0,0 +1,14 @@
+package cgeo.geocaching.activity;
+
+import android.view.View;
+
+public interface IAbstractActivity {
+ public void goHome(View view);
+
+ public void goManual(View view);
+
+ public void showProgress(final boolean show);
+
+ public void setTheme();
+
+}
diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java
index d2eda0f..0d2d88e 100644
--- a/src/cgeo/geocaching/cgBase.java
+++ b/src/cgeo/geocaching/cgBase.java
@@ -64,10 +64,7 @@ import android.text.Spannable;
import android.text.style.StrikethroughSpan;
import android.util.Log;
import android.view.Display;
-import android.view.View;
import android.view.WindowManager;
-import android.widget.ProgressBar;
-import android.widget.TextView;
public class cgBase {
@@ -5492,36 +5489,4 @@ public class cgBase {
return elv;
}
-
- public void showProgress(Activity activity, boolean status) {
- if (activity == null) {
- return;
- }
-
- final ProgressBar progress = (ProgressBar) activity.findViewById(R.id.actionbar_progress);
- if (status == true) {
- progress.setVisibility(View.VISIBLE);
- } else {
- progress.setVisibility(View.GONE);
- }
- }
-
- public void goHome(Activity activity) {
- final Intent intent = new Intent(activity, cgeo.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-
- activity.startActivity(intent);
- activity.finish();
- }
-
- public void setTitle(Activity activity, String text) {
- if (activity == null || text == null) {
- return;
- }
-
- final TextView title = (TextView) activity.findViewById(R.id.actionbar_title);
- if (title != null) {
- title.setText(text);
- }
- }
}
diff --git a/src/cgeo/geocaching/cgFileList.java b/src/cgeo/geocaching/cgFileList.java
index a9371be..21a6b6b 100644
--- a/src/cgeo/geocaching/cgFileList.java
+++ b/src/cgeo/geocaching/cgFileList.java
@@ -3,8 +3,6 @@ package cgeo.geocaching;
import java.io.File;
import java.util.ArrayList;
-import android.app.Activity;
-import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.res.Resources;
@@ -13,17 +11,16 @@ import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
-import android.view.View;
import android.widget.ArrayAdapter;
+import cgeo.geocaching.activity.AbstractListActivity;
-public abstract class cgFileList<T extends ArrayAdapter<File>> extends ListActivity {
+public abstract class cgFileList<T extends ArrayAdapter<File>> extends AbstractListActivity {
private ArrayList<File> files = new ArrayList<File>();
private cgeoapplication app = null;
private cgSettings settings = null;
private cgBase base = null;
private cgWarning warning = null;
- private Activity activity = null;
private T adapter = null;
private ProgressDialog waitDialog = null;
private Resources res = null;
@@ -76,21 +73,15 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends ListActiv
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
base = new cgBase(getApp(), getSettings(), getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (getSettings().skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.gpx);
- getBase().setTitle(getActivity(), getRes().getString(R.string.gpx_import_title));
+ setTitle(getRes().getString(R.string.gpx_import_title));
Bundle extras = getIntent().getExtras();
if (extras != null) {
@@ -128,14 +119,14 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends ListActiv
@Override
public void onResume() {
super.onResume();
-
+
getSettings().load();
}
-
+
final protected cgSettings getSettings() {
return settings;
}
-
+
protected abstract T getAdapter(ArrayList<File> files);
private void setAdapter() {
@@ -144,13 +135,13 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends ListActiv
setListAdapter(adapter);
}
}
-
+
/**
* Gets the base folder for file searches
* @return The folder to start the recursive search in
*/
- protected abstract String[] getBaseFolders();
-
+ protected abstract String[] getBaseFolders();
+
private class loadFiles extends Thread {
public void notifyEnd() {
endSearching = true;
@@ -166,7 +157,7 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends ListActiv
for(String baseFolder : getBaseFolders())
{
final File dir = new File(baseFolder);
-
+
if (dir.exists() && dir.isDirectory()) {
listDir(list, dir);
if (list.size() > 0) {
@@ -198,7 +189,7 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends ListActiv
/**
* Get the file extension to search for
- * @return The file extension
+ * @return The file extension
*/
protected abstract String getFileExtension();
@@ -251,10 +242,6 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends ListActiv
return;
}
- public void goHome(View view) {
- getBase().goHome(getActivity());
- }
-
protected cgeoapplication getApp() {
return app;
}
@@ -267,10 +254,6 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends ListActiv
return warning;
}
- protected Activity getActivity() {
- return activity;
- }
-
protected Resources getRes() {
return res;
}
diff --git a/src/cgeo/geocaching/cgGPXListAdapter.java b/src/cgeo/geocaching/cgGPXListAdapter.java
index 78ad881..0c2b10d 100644
--- a/src/cgeo/geocaching/cgGPXListAdapter.java
+++ b/src/cgeo/geocaching/cgGPXListAdapter.java
@@ -1,26 +1,25 @@
package cgeo.geocaching;
+import java.io.File;
import java.util.List;
+
import android.app.Activity;
+import android.util.Log;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.LayoutInflater;
-import android.widget.TextView;
import android.widget.ArrayAdapter;
-import android.util.Log;
-import java.io.File;
+import android.widget.TextView;
public class cgGPXListAdapter extends ArrayAdapter<File> {
private cgGPXView holder = null;
private cgeogpxes parent = null;
- private cgSettings settings = null;
private LayoutInflater inflater = null;
public cgGPXListAdapter(cgeogpxes parentIn, cgSettings settingsIn, List<File> listIn) {
super(parentIn, 0, listIn);
parent = parentIn;
- settings = settingsIn;
}
@Override
@@ -40,7 +39,7 @@ public class cgGPXListAdapter extends ArrayAdapter<File> {
holder = new cgGPXView();
holder.filepath = (TextView)rowView.findViewById(R.id.filepath);
holder.filename = (TextView)rowView.findViewById(R.id.filename);
-
+
rowView.setTag(holder);
} else {
holder = (cgGPXView)rowView.getTag();
@@ -54,7 +53,7 @@ public class cgGPXListAdapter extends ArrayAdapter<File> {
return rowView;
}
-
+
@Override
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
diff --git a/src/cgeo/geocaching/cgLogForm.java b/src/cgeo/geocaching/cgLogForm.java
index 9cbd557..c2274f1 100644
--- a/src/cgeo/geocaching/cgLogForm.java
+++ b/src/cgeo/geocaching/cgLogForm.java
@@ -1,9 +1,14 @@
package cgeo.geocaching;
-import android.app.Activity;
import java.util.Calendar;
-public class cgLogForm extends Activity {
+import cgeo.geocaching.activity.AbstractActivity;
+
+public class cgLogForm extends AbstractActivity {
+ public cgLogForm(String helpTopic) {
+ super(helpTopic);
+ }
+
public void setDate(Calendar dateIn) {
// to be overwritten
}
diff --git a/src/cgeo/geocaching/cgeo.java b/src/cgeo/geocaching/cgeo.java
index 156a2d3..285d8b4 100644
--- a/src/cgeo/geocaching/cgeo.java
+++ b/src/cgeo/geocaching/cgeo.java
@@ -1,7 +1,5 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -9,7 +7,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
-import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -30,8 +27,10 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
+import cgeo.geocaching.activity.ActivityMixin;
-public class cgeo extends Activity {
+public class cgeo extends AbstractActivity {
private Resources res = null;
private cgeoapplication app = null;
@@ -118,6 +117,10 @@ public class cgeo extends Activity {
}
};
+ public cgeo() {
+ super("c:geo-main-screen");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -160,16 +163,7 @@ public class cgeo extends Activity {
helper.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-intro",
- context,
- "http://cgeo.carnero.cc/manual/");
- } catch (Exception e) {
- // nothing
- }
-
+ ActivityMixin.goManual(context, "c:geo-intro");
view.setVisibility(View.GONE);
}
});
@@ -656,16 +650,4 @@ public class cgeo extends Activity {
public void goSearch(View view) {
onSearchRequested();
}
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-main-screen",
- context,
- "http://cgeo.carnero.cc/manual/");
- } catch (Exception e) {
- // nothing
- }
- }
}
diff --git a/src/cgeo/geocaching/cgeoabout.java b/src/cgeo/geocaching/cgeoabout.java
index 3fe2f25..db40b53 100644
--- a/src/cgeo/geocaching/cgeoabout.java
+++ b/src/cgeo/geocaching/cgeoabout.java
@@ -1,6 +1,5 @@
package cgeo.geocaching;
-import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -11,39 +10,31 @@ import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeoabout extends Activity {
- private Activity activity = null;
+public class cgeoabout extends AbstractActivity {
private Resources res = null;
private cgSettings settings = null;
- private cgBase base = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
settings = new cgSettings(this, this.getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase((cgeoapplication) this.getApplication(), settings, this.getSharedPreferences(cgSettings.preferences, 0));
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.about);
- base.setTitle(activity, res.getString(R.string.about));
+ setTitle(res.getString(R.string.about));
init();
}
-
+
@Override
public void onResume() {
super.onResume();
-
+
settings.load();
}
@@ -57,7 +48,7 @@ public class cgeoabout extends Activity {
PackageManager manager = this.getPackageManager();
PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
- base.setTitle(activity, res.getString(R.string.about) + " (ver. " + info.versionName + ")");
+ setTitle(res.getString(R.string.about) + " (ver. " + info.versionName + ")");
manager = null;
@@ -68,42 +59,38 @@ public class cgeoabout extends Activity {
}
public void donateMore(View view) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FMLNN8GXZKJEE")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FMLNN8GXZKJEE")));
//activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=N2FKGNCPPRUVE")));
//activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2Z69QWLRCBE9N&lc=US&item_name=c%3ageo&currency_code=EUR&amount=15&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted")));
}
public void donateLess(View view) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FMLNN8GXZKJEE")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FMLNN8GXZKJEE")));
//activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4PRD9CX4Y8XR6")));
//activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2Z69QWLRCBE9N&lc=US&item_name=c%3ageo&currency_code=EUR&amount=7&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted")));
}
public void author(View view) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://carnero.cc/")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://carnero.cc/")));
}
public void support(View view) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:support@cgeo.org")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:support@cgeo.org")));
}
public void website(View view) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.cgeo.org/")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.cgeo.org/")));
}
public void facebook(View view) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/pages/cgeo/297269860090")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/pages/cgeo/297269860090")));
}
public void twitter(View view) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://twitter.com/android_gc")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://twitter.com/android_gc")));
}
public void nutshellmanual(View view) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://cgeo.carnero.cc/manual/")));
- }
-
- public void goHome(View view) {
- base.goHome(activity);
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://cgeo.carnero.cc/manual/")));
}
}
diff --git a/src/cgeo/geocaching/cgeoaddresses.java b/src/cgeo/geocaching/cgeoaddresses.java
index e723260..731cb8a 100644
--- a/src/cgeo/geocaching/cgeoaddresses.java
+++ b/src/cgeo/geocaching/cgeoaddresses.java
@@ -1,30 +1,28 @@
package cgeo.geocaching;
-import android.app.Activity;
-import android.app.ProgressDialog;
import java.util.ArrayList;
-import android.os.Bundle;
-import android.view.View;
-import android.view.LayoutInflater;
-import android.widget.Button;
-import android.widget.LinearLayout;
+import java.util.List;
+import java.util.Locale;
+
+import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Resources;
import android.location.Address;
import android.location.Geocoder;
+import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
-import java.util.List;
-import java.util.Locale;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeoaddresses extends Activity {
+public class cgeoaddresses extends AbstractActivity {
private final ArrayList<Address> addresses = new ArrayList<Address>();
private String keyword = null;
- private Activity activity = null;
- private cgeoapplication app = null;
private cgSettings settings = null;
- private cgBase base = null;
private Resources res = null;
private cgWarning warning = null;
private LayoutInflater inflater = null;
@@ -97,22 +95,14 @@ public class cgeoaddresses extends Activity {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
- app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
inflater = getLayoutInflater();
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.addresses);
- base.setTitle(activity, res.getString(R.string.search_address_result));
+ setTitle(res.getString(R.string.search_address_result));
// get parameters
Bundle extras = getIntent().getExtras();
@@ -137,7 +127,7 @@ public class cgeoaddresses extends Activity {
@Override
public void onResume() {
super.onResume();
-
+
settings.load();
}
@@ -150,7 +140,7 @@ public class cgeoaddresses extends Activity {
@Override
public void run() {
- Geocoder geocoder = new Geocoder(activity, Locale.getDefault());
+ Geocoder geocoder = new Geocoder(cgeoaddresses.this, Locale.getDefault());
try {
List<Address> knownLocations = geocoder.getFromLocationName(keyword, 20);
@@ -179,20 +169,16 @@ public class cgeoaddresses extends Activity {
}
public void onClick(View arg0) {
- Intent addressIntent = new Intent(activity, cgeocaches.class);
+ Intent addressIntent = new Intent(cgeoaddresses.this, cgeocaches.class);
addressIntent.putExtra("type", "address");
addressIntent.putExtra("latitude", (Double) latitude);
addressIntent.putExtra("longitude", (Double) longitude);
addressIntent.putExtra("address", (String) address);
addressIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(addressIntent);
+ startActivity(addressIntent);
finish();
return;
}
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
}
diff --git a/src/cgeo/geocaching/cgeoadvsearch.java b/src/cgeo/geocaching/cgeoadvsearch.java
index da2b8c0..f3fd16d 100644
--- a/src/cgeo/geocaching/cgeoadvsearch.java
+++ b/src/cgeo/geocaching/cgeoadvsearch.java
@@ -1,32 +1,30 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.*;
-
import java.util.HashMap;
-import android.os.Bundle;
-import android.app.Activity;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import android.app.SearchManager;
-import android.view.View;
-import android.widget.Button;
-import android.widget.TextView;
-import android.widget.EditText;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeoadvsearch extends Activity {
+public class cgeoadvsearch extends AbstractActivity {
private Resources res = null;
- private Activity activity = null;
private cgeoapplication app = null;
private cgSettings settings = null;
private cgBase base = null;
@@ -37,12 +35,15 @@ public class cgeoadvsearch extends Activity {
private EditText lonEdit = null;
private String[] geocodesInCache = null;
+ public cgeoadvsearch() {
+ super("c:geo-search");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
app.setAction(null);
@@ -63,14 +64,9 @@ public class cgeoadvsearch extends Activity {
}
}
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.search);
- base.setTitle(activity, res.getString(R.string.search));
+ setTitle(res.getString(R.string.search));
init();
}
@@ -127,23 +123,23 @@ public class cgeoadvsearch extends Activity {
try {
if (gcCodeM.find()) { // GC-code
- final Intent cachesIntent = new Intent(activity, cgeodetail.class);
+ final Intent cachesIntent = new Intent(this, cgeodetail.class);
cachesIntent.putExtra("geocode", query.trim().toUpperCase());
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
found = true;
} else if (tbCodeM.find()) { // TB-code
- final Intent trackablesIntent = new Intent(activity, cgeotrackable.class);
+ final Intent trackablesIntent = new Intent(this, cgeotrackable.class);
trackablesIntent.putExtra("geocode", query.trim().toUpperCase());
- activity.startActivity(trackablesIntent);
+ startActivity(trackablesIntent);
found = true;
} else { // keyword (fallback)
- final Intent cachesIntent = new Intent(activity, cgeocaches.class);
+ final Intent cachesIntent = new Intent(this, cgeocaches.class);
cachesIntent.putExtra("type", "keyword");
cachesIntent.putExtra("keyword", query);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
found = true;
}
@@ -163,7 +159,7 @@ public class cgeoadvsearch extends Activity {
}
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
((EditText) findViewById(R.id.latitude)).setOnEditorActionListener(new findByCoordsAction());
@@ -317,12 +313,12 @@ public class cgeoadvsearch extends Activity {
return;
}
- final Intent cachesIntent = new Intent(activity, cgeocaches.class);
+ final Intent cachesIntent = new Intent(this, cgeocaches.class);
cachesIntent.putExtra("type", "coordinate");
cachesIntent.putExtra("latitude", (Double) latParsed.get("coordinate"));
cachesIntent.putExtra("longitude", (Double) lonParsed.get("coordinate"));
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
}
}
@@ -355,11 +351,11 @@ public class cgeoadvsearch extends Activity {
return;
}
- final Intent cachesIntent = new Intent(activity, cgeocaches.class);
+ final Intent cachesIntent = new Intent(this, cgeocaches.class);
cachesIntent.putExtra("type", "keyword");
cachesIntent.putExtra("keyword", keyText);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
}
private class findByAddressAction implements TextView.OnEditorActionListener {
@@ -390,9 +386,9 @@ public class cgeoadvsearch extends Activity {
return;
}
- final Intent addressesIntent = new Intent(activity, cgeoaddresses.class);
+ final Intent addressesIntent = new Intent(this, cgeoaddresses.class);
addressesIntent.putExtra("keyword", addText);
- activity.startActivity(addressesIntent);
+ startActivity(addressesIntent);
}
private class findByUsernameAction implements TextView.OnEditorActionListener {
@@ -423,11 +419,11 @@ public class cgeoadvsearch extends Activity {
return;
}
- final Intent cachesIntent = new Intent(activity, cgeocaches.class);
+ final Intent cachesIntent = new Intent(this, cgeocaches.class);
cachesIntent.putExtra("type", "username");
cachesIntent.putExtra("username", usernameText);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
}
private class findByOwnerAction implements TextView.OnEditorActionListener {
@@ -458,11 +454,11 @@ public class cgeoadvsearch extends Activity {
return;
}
- final Intent cachesIntent = new Intent(activity, cgeocaches.class);
+ final Intent cachesIntent = new Intent(this, cgeocaches.class);
cachesIntent.putExtra("type", "owner");
cachesIntent.putExtra("username", usernameText);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
}
private class findByGeocodeAction implements TextView.OnEditorActionListener {
@@ -493,9 +489,9 @@ public class cgeoadvsearch extends Activity {
return;
}
- final Intent cachesIntent = new Intent(activity, cgeodetail.class);
+ final Intent cachesIntent = new Intent(this, cgeodetail.class);
cachesIntent.putExtra("geocode", geocodeText.toUpperCase());
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
}
private class findTrackableAction implements TextView.OnEditorActionListener {
@@ -526,24 +522,8 @@ public class cgeoadvsearch extends Activity {
return;
}
- final Intent trackablesIntent = new Intent(activity, cgeotrackable.class);
+ final Intent trackablesIntent = new Intent(this, cgeotrackable.class);
trackablesIntent.putExtra("geocode", trackableText.toUpperCase());
- activity.startActivity(trackablesIntent);
- }
-
- public void goHome(View view) {
- base.goHome(activity);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-search",
- activity,
- "http://cgeo.carnero.cc/manual/");
- } catch (Exception e) {
- // nothing
- }
+ startActivity(trackablesIntent);
}
}
diff --git a/src/cgeo/geocaching/cgeoauth.java b/src/cgeo/geocaching/cgeoauth.java
index 9dc1c32..7108c9d 100644
--- a/src/cgeo/geocaching/cgeoauth.java
+++ b/src/cgeo/geocaching/cgeoauth.java
@@ -14,7 +14,6 @@ import java.util.regex.Pattern;
import javax.net.ssl.HttpsURLConnection;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -27,13 +26,12 @@ import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeoauth extends Activity {
+public class cgeoauth extends AbstractActivity {
private cgeoapplication app = null;
private Resources res = null;
- private Activity activity = null;
private cgSettings settings = null;
- private cgBase base = null;
private cgWarning warning = null;
private SharedPreferences prefs = null;
private String OAtoken = null;
@@ -100,23 +98,16 @@ public class cgeoauth extends Activity {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
app.setAction("setting up");
prefs = getSharedPreferences(cgSettings.preferences, 0);
settings = new cgSettings(this, prefs);
- base = new cgBase(app, settings, prefs);
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.auth);
- base.setTitle(activity, res.getString(R.string.auth_twitter));
+ setTitle(res.getString(R.string.auth_twitter));
init();
}
@@ -354,7 +345,7 @@ public class cgeoauth extends Activity {
public void onClick(View arg0) {
if (requestTokenDialog == null) {
- requestTokenDialog = new ProgressDialog(activity);
+ requestTokenDialog = new ProgressDialog(cgeoauth.this);
requestTokenDialog.setCancelable(false);
requestTokenDialog.setMessage(res.getString(R.string.auth_dialog_wait));
}
@@ -387,7 +378,7 @@ public class cgeoauth extends Activity {
}
if (changeTokensDialog == null) {
- changeTokensDialog = new ProgressDialog(activity);
+ changeTokensDialog = new ProgressDialog(cgeoauth.this);
changeTokensDialog.setCancelable(false);
changeTokensDialog.setMessage(res.getString(R.string.auth_dialog_wait));
}
@@ -405,8 +396,4 @@ public class cgeoauth extends Activity {
}).start();
}
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
}
diff --git a/src/cgeo/geocaching/cgeocaches.java b/src/cgeo/geocaching/cgeocaches.java
index ccc0a20..f1fea9a 100644
--- a/src/cgeo/geocaching/cgeocaches.java
+++ b/src/cgeo/geocaching/cgeocaches.java
@@ -1,7 +1,5 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -16,9 +14,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
-import android.app.Activity;
import android.app.AlertDialog;
-import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -44,6 +40,8 @@ import android.widget.EditText;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractListActivity;
+import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
import cgeo.geocaching.apps.cachelist.CacheListAppFactory;
import cgeo.geocaching.filter.cgFilter;
@@ -61,7 +59,7 @@ import cgeo.geocaching.sorting.SizeComparator;
import cgeo.geocaching.sorting.TerrainComparator;
import cgeo.geocaching.sorting.VoteComparator;
-public class cgeocaches extends ListActivity {
+public class cgeocaches extends AbstractListActivity {
private static final int MENU_COMPASS = 1;
private static final int MENU_REFRESH_STORED = 2;
@@ -136,7 +134,6 @@ public class cgeocaches extends ListActivity {
private ArrayList<cgCache> cacheList = new ArrayList<cgCache>();
private cgeoapplication app = null;
private Resources res = null;
- private static Activity activity = null;
private cgCacheListAdapter adapter = null;
private LayoutInflater inflater = null;
private View listFooter = null;
@@ -169,7 +166,7 @@ public class cgeocaches extends ListActivity {
public void handleMessage(Message msg) {
try {
if (searchId != null && searchId > 0) {
- base.setTitle(activity, title + " [" + app.getCount(searchId) + "]");
+ setTitle(title + " [" + app.getCount(searchId) + "]");
cacheList.clear();
final ArrayList<cgCache> cacheListTmp = app.getCaches(searchId);
@@ -180,7 +177,7 @@ public class cgeocaches extends ListActivity {
Collections.sort((List<cgCache>)cacheList, gcComparator);
}
} else {
- base.setTitle(activity, title);
+ setTitle(title);
}
setAdapter();
@@ -203,7 +200,7 @@ public class cgeocaches extends ListActivity {
}
if (cacheList != null && app.getError(searchId) != null && app.getError(searchId).equalsIgnoreCase(cgBase.errorRetrieve.get(-7)) == true) {
- AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
+ AlertDialog.Builder dialog = new AlertDialog.Builder(cgeocaches.this);
dialog.setTitle(res.getString(R.string.license));
dialog.setMessage(res.getString(R.string.err_license));
dialog.setCancelable(true);
@@ -218,7 +215,7 @@ public class cgeocaches extends ListActivity {
public void onClick(DialogInterface dialog, int id) {
settings.deleteCookies();
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/software/agreement.aspx?ID=0")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/software/agreement.aspx?ID=0")));
}
});
@@ -228,7 +225,7 @@ public class cgeocaches extends ListActivity {
warning.showToast(res.getString(R.string.err_download_fail) + app.getError(searchId) + ".");
hideLoading();
- base.showProgress(activity, false);
+ showProgress(false);
finish();
return;
@@ -243,7 +240,7 @@ public class cgeocaches extends ListActivity {
Log.e(cgSettings.tag, "cgeocaches.loadCachesHandler: " + e.toString());
hideLoading();
- base.showProgress(activity, false);
+ showProgress(false);
finish();
return;
@@ -251,7 +248,7 @@ public class cgeocaches extends ListActivity {
try {
hideLoading();
- base.showProgress(activity, false);
+ showProgress(false);
} catch (Exception e2) {
Log.e(cgSettings.tag, "cgeocaches.loadCachesHandler.2: " + e2.toString());
}
@@ -267,7 +264,7 @@ public class cgeocaches extends ListActivity {
public void handleMessage(Message msg) {
try {
if (searchId != null && searchId > 0) {
- base.setTitle(activity, title + " [" + app.getCount(searchId) + "]");
+ setTitle(title + " [" + app.getCount(searchId) + "]");
cacheList.clear();
final ArrayList<cgCache> cacheListTmp = app.getCaches(searchId);
@@ -280,7 +277,7 @@ public class cgeocaches extends ListActivity {
adapter.reFilter();
}
} else {
- base.setTitle(activity, title);
+ setTitle(title);
}
setAdapter();
@@ -306,7 +303,7 @@ public class cgeocaches extends ListActivity {
listFooter.setOnClickListener(new moreCachesListener());
hideLoading();
- base.showProgress(activity, false);
+ showProgress(false);
finish();
return;
@@ -324,7 +321,7 @@ public class cgeocaches extends ListActivity {
listFooter.setOnClickListener(new moreCachesListener());
hideLoading();
- base.showProgress(activity, false);
+ showProgress(false);
if (adapter != null) {
adapter.setSelectMode(false, true);
@@ -373,17 +370,17 @@ public class cgeocaches extends ListActivity {
adapter.setActualHeading(northHeading);
}
- base.showProgress(activity, false);
+ showProgress(false);
if (waitDialog != null) {
waitDialog.dismiss();
waitDialog.setOnCancelListener(null);
}
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(cgeocaches.this, geoUpdate, base, settings, warning, 0, 0);
}
if (settings.livelist == 1 && settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(cgeocaches.this, dirUpdate, warning);
}
}
}
@@ -537,7 +534,6 @@ public class cgeocaches extends ListActivity {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
app.setAction(action);
@@ -545,14 +541,9 @@ public class cgeocaches extends ListActivity {
base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.caches);
- base.setTitle(activity, "caches");
+ setTitle("caches");
// get parameters
Bundle extras = getIntent().getExtras();
@@ -581,8 +572,8 @@ public class cgeocaches extends ListActivity {
title = list.title;
}
- base.setTitle(activity, title);
- base.showProgress(activity, true);
+ setTitle(title);
+ showProgress(true);
setLoadingCaches();
threadPure = new geocachesLoadByOffline(loadCachesHandler, latitude, longitude, listId);
@@ -593,8 +584,8 @@ public class cgeocaches extends ListActivity {
}
title = res.getString(R.string.caches_history);
- base.setTitle(activity, title);
- base.showProgress(activity, true);
+ setTitle(title);
+ showProgress(true);
setLoadingCaches();
threadPure = new geocachesLoadByHistory(loadCachesHandler);
@@ -602,70 +593,70 @@ public class cgeocaches extends ListActivity {
} else if (type.equals("nearest") == true) {
action = "pending";
title = res.getString(R.string.caches_nearby);
- base.setTitle(activity, title);
- base.showProgress(activity, true);
+ setTitle(title);
+ showProgress(true);
setLoadingCaches();
thread = new geocachesLoadByCoords(loadCachesHandler, latitude, longitude, cachetype);
- thread.setRecaptchaHandler(new cgSearchHandler(activity, res, thread));
+ thread.setRecaptchaHandler(new cgSearchHandler(this, res, thread));
thread.start();
} else if (type.equals("coordinate") == true) {
action = "planning";
title = base.formatCoordinate(latitude, res.getString(R.string.search_lat), true) + " | " + base.formatCoordinate(longitude, res.getString(R.string.search_lon), true);
- base.setTitle(activity, title);
- base.showProgress(activity, true);
+ setTitle(title);
+ showProgress(true);
setLoadingCaches();
thread = new geocachesLoadByCoords(loadCachesHandler, latitude, longitude, cachetype);
- thread.setRecaptchaHandler(new cgSearchHandler(activity, res, thread));
+ thread.setRecaptchaHandler(new cgSearchHandler(this, res, thread));
thread.start();
} else if (type.equals("keyword") == true) {
title = keyword;
- base.setTitle(activity, title);
- base.showProgress(activity, true);
+ setTitle(title);
+ showProgress(true);
setLoadingCaches();
thread = new geocachesLoadByKeyword(loadCachesHandler, keyword, cachetype);
- thread.setRecaptchaHandler(new cgSearchHandler(activity, res, thread));
+ thread.setRecaptchaHandler(new cgSearchHandler(this, res, thread));
thread.start();
} else if (type.equals("address") == true) {
action = "planning";
if (address != null && address.length() > 0) {
title = address;
- base.setTitle(activity, title);
- base.showProgress(activity, true);
+ setTitle(title);
+ showProgress(true);
setLoadingCaches();
} else {
title = base.formatCoordinate(latitude, res.getString(R.string.search_lat), true) + " | " + base.formatCoordinate(longitude, res.getString(R.string.search_lon), true);
- base.setTitle(activity, title);
- base.showProgress(activity, true);
+ setTitle(title);
+ showProgress(true);
setLoadingCaches();
}
thread = new geocachesLoadByCoords(loadCachesHandler, latitude, longitude, cachetype);
- thread.setRecaptchaHandler(new cgSearchHandler(activity, res, thread));
+ thread.setRecaptchaHandler(new cgSearchHandler(this, res, thread));
thread.start();
} else if (type.equals("username") == true) {
title = username;
- base.setTitle(activity, title);
- base.showProgress(activity, true);
+ setTitle(title);
+ showProgress(true);
setLoadingCaches();
thread = new geocachesLoadByUserName(loadCachesHandler, username, cachetype);
- thread.setRecaptchaHandler(new cgSearchHandler(activity, res, thread));
+ thread.setRecaptchaHandler(new cgSearchHandler(this, res, thread));
thread.start();
} else if (type.equals("owner") == true) {
title = username;
- base.setTitle(activity, title);
- base.showProgress(activity, true);
+ setTitle(title);
+ showProgress(true);
setLoadingCaches();
thread = new geocachesLoadByOwner(loadCachesHandler, username, cachetype);
- thread.setRecaptchaHandler(new cgSearchHandler(activity, res, thread));
+ thread.setRecaptchaHandler(new cgSearchHandler(this, res, thread));
thread.start();
} else {
title = "caches";
- base.setTitle(activity, title);
+ setTitle(title);
Log.e(cgSettings.tag, "cgeocaches.onCreate: No action or unknown action specified");
}
}
@@ -800,7 +791,7 @@ public class cgeocaches extends ListActivity {
menu.add(0, MENU_REFRESH_STORED, 0, res.getString(R.string.caches_store_offline)).setIcon(android.R.drawable.ic_menu_set_as); // download details for all caches
}
- navigationMenu = CacheListAppFactory.addMenuItems(menu, activity, res);
+ navigationMenu = CacheListAppFactory.addMenuItems(menu, this, res);
if (type.equals("offline")) {
SubMenu subMenu = menu.addSubMenu(0, SUBMENU_MANAGE_LISTS, 0, res.getString(R.string.list_menu)).setIcon(android.R.drawable.ic_menu_more);
@@ -1002,7 +993,7 @@ public class cgeocaches extends ListActivity {
return false;
}
- return CacheListAppFactory.onMenuItemSelected(item, geo, cacheList, activity, res, null);
+ return CacheListAppFactory.onMenuItemSelected(item, geo, cacheList, this, res, null);
}
private void setComparator(MenuItem item,
@@ -1073,7 +1064,7 @@ public class cgeocaches extends ListActivity {
if (cache.latitude != null && cache.longitude != null) {
menu.add(0, MENU_COMPASS, 0, res.getString(R.string.cache_menu_compass));
SubMenu subMenu = menu.addSubMenu(1, 0, 0, res.getString(R.string.cache_menu_navigate)).setIcon(android.R.drawable.ic_menu_more);
- NavigationAppFactory.addMenuItems(subMenu, activity, res);
+ NavigationAppFactory.addMenuItems(subMenu, this, res);
menu.add(0, MENU_LOG_VISIT, 0, res.getString(R.string.cache_menu_visit));
menu.add(0, MENU_CACHE_DETAILS, 0, res.getString(R.string.cache_menu_details));
}
@@ -1126,13 +1117,13 @@ public class cgeocaches extends ListActivity {
}
if (id == MENU_COMPASS) {
- Intent navigateIntent = new Intent(activity, cgeonavigate.class);
+ Intent navigateIntent = new Intent(this, cgeonavigate.class);
navigateIntent.putExtra("latitude", cache.latitude);
navigateIntent.putExtra("longitude", cache.longitude);
navigateIntent.putExtra("geocode", cache.geocode.toUpperCase());
navigateIntent.putExtra("name", cache.name);
- activity.startActivity(navigateIntent);
+ startActivity(navigateIntent);
return true;
} else if (id == MENU_LOG_VISIT) {
@@ -1141,19 +1132,19 @@ public class cgeocaches extends ListActivity {
return true;
}
- Intent logVisitIntent = new Intent(activity, cgeovisit.class);
+ Intent logVisitIntent = new Intent(this, cgeovisit.class);
logVisitIntent.putExtra("id", cache.cacheid);
logVisitIntent.putExtra("geocode", cache.geocode.toUpperCase());
logVisitIntent.putExtra("type", cache.type.toLowerCase());
- activity.startActivity(logVisitIntent);
+ startActivity(logVisitIntent);
return true;
} else if (id == MENU_CACHE_DETAILS) {
- Intent cachesIntent = new Intent(activity, cgeodetail.class);
+ Intent cachesIntent = new Intent(this, cgeodetail.class);
cachesIntent.putExtra("geocode", cache.geocode.toUpperCase());
cachesIntent.putExtra("name", cache.name);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
return true;
}
@@ -1209,7 +1200,7 @@ public class cgeocaches extends ListActivity {
} else if (id == MENU_FILTER_TYPE_GPS) {
return setFilter(new cgFilterByType("gps"));
} else if (id == MENU_DROP_CACHE) {
- base.dropCache(app, activity, cache, new Handler() {
+ base.dropCache(app, this, cache, new Handler() {
@Override
public void handleMessage(Message msg) {
switchList(listId, -1); // refresh
@@ -1228,7 +1219,7 @@ public class cgeocaches extends ListActivity {
// https://code.google.com/p/android/issues/detail?id=7139
lastMenuInfo = info;
- return NavigationAppFactory.onMenuItemSelected(item, geo, activity,
+ return NavigationAppFactory.onMenuItemSelected(item, geo, this,
res, warning, cache, null, null, null);
}
@@ -1259,7 +1250,7 @@ public class cgeocaches extends ListActivity {
private void setAdapter() {
if (listFooter == null) {
if (inflater == null) {
- inflater = activity.getLayoutInflater();
+ inflater = getLayoutInflater();
}
listFooter = inflater.inflate(R.layout.caches_footer, null);
@@ -1277,7 +1268,7 @@ public class cgeocaches extends ListActivity {
list.setLongClickable(true);
list.addFooterView(listFooter);
- adapter = new cgCacheListAdapter(activity, settings, cacheList, base);
+ adapter = new cgCacheListAdapter(this, settings, cacheList, base);
setListAdapter(adapter);
} else {
adapter.notifyDataSetChanged();
@@ -1330,31 +1321,31 @@ public class cgeocaches extends ListActivity {
private void init() {
// sensor & geolocation manager
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
if (settings.livelist == 1 && settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(this, dirUpdate, warning);
}
if (cacheList != null) {
- base.setTitle(activity, title);
+ setTitle(title);
}
if (cacheList != null && cacheList.isEmpty() == false) {
final Integer count = app.getTotal(searchId);
if (count != null && count > 0) {
- base.setTitle(activity, title);
+ setTitle(title);
if (cacheList.size() < app.getTotal(searchId) && cacheList.size() < 1000) {
setMoreCaches(true);
} else {
setMoreCaches(false);
}
} else {
- base.setTitle(activity, title);
+ setTitle(title);
setMoreCaches(false);
}
} else {
- base.setTitle(activity, title);
+ setTitle(title);
}
setAdapter();
@@ -1368,9 +1359,9 @@ public class cgeocaches extends ListActivity {
}
private void importGpx() {
- final Intent intent = new Intent(activity, cgeogpxes.class);
+ final Intent intent = new Intent(this, cgeogpxes.class);
intent.putExtra("list", listId);
- activity.startActivity(intent);
+ startActivity(intent);
finish();
}
@@ -1385,7 +1376,7 @@ public class cgeocaches extends ListActivity {
}
detailProgress = 0;
- base.showProgress(activity, false);
+ showProgress(false);
waitDialog = new ProgressDialog(this);
waitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@@ -1396,10 +1387,10 @@ public class cgeocaches extends ListActivity {
}
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(cgeocaches.this, geoUpdate, base, settings, warning, 0, 0);
}
if (settings.livelist == 1 && settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(cgeocaches.this, dirUpdate, warning);
}
} catch (Exception e) {
Log.e(cgSettings.tag, "cgeocaches.onOptionsItemSelected.onCancel: " + e.toString());
@@ -1428,7 +1419,7 @@ public class cgeocaches extends ListActivity {
public void removeFromHistoryCheck()
{
- AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
+ AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setCancelable(true);
dialog.setTitle(res.getString(R.string.caches_removing_from_history));
dialog.setMessage((adapter != null && adapter.getChecked() > 0) ? res.getString(R.string.cache_remove_from_history)
@@ -1463,7 +1454,7 @@ public class cgeocaches extends ListActivity {
}
detailProgress = 0;
- base.showProgress(activity, false);
+ showProgress(false);
waitDialog = new ProgressDialog(this);
waitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@@ -1507,7 +1498,7 @@ public class cgeocaches extends ListActivity {
}
detailProgress = 0;
- base.showProgress(activity, false);
+ showProgress(false);
waitDialog = new ProgressDialog(this);
waitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@@ -1541,7 +1532,7 @@ public class cgeocaches extends ListActivity {
detailProgress = 0;
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- base.showProgress(activity, false);
+ showProgress(false);
waitDialog = new ProgressDialog(this);
waitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@@ -1552,10 +1543,10 @@ public class cgeocaches extends ListActivity {
}
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(cgeocaches.this, geoUpdate, base, settings, warning, 0, 0);
}
if (settings.livelist == 1 && settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(cgeocaches.this, dirUpdate, warning);
}
} catch (Exception e) {
Log.e(cgSettings.tag, "cgeocaches.importWeb.onCancel: " + e.toString());
@@ -1573,7 +1564,7 @@ public class cgeocaches extends ListActivity {
}
public void dropStored() {
- AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
+ AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setCancelable(true);
dialog.setTitle(res.getString(R.string.caches_drop_stored));
@@ -1951,7 +1942,7 @@ public class cgeocaches extends ListActivity {
}
detailProgress++;
- base.storeCache(app, activity, cache, null, reason, handler);
+ base.storeCache(app, cgeocaches.this, cache, null, reason, handler);
handler.sendEmptyMessage(cacheList.indexOf(cache));
@@ -2024,7 +2015,7 @@ public class cgeocaches extends ListActivity {
handler.sendMessage(mes);
yield();
- base.storeCache(app, activity, null, GCcode, reason, null);
+ base.storeCache(app, cgeocaches.this, null, GCcode, reason, null);
Message mes1 = new Message();
mes1.what = 2;
@@ -2293,13 +2284,13 @@ public class cgeocaches extends ListActivity {
@Override
public void onClick(View arg0) {
- base.showProgress(activity, true);
+ showProgress(true);
setLoadingCaches();
listFooter.setOnClickListener(null);
geocachesLoadNextPage thread;
thread = new geocachesLoadNextPage(loadNextPageHandler);
- thread.setRecaptchaHandler(new cgSearchHandler(activity, res, thread));
+ thread.setRecaptchaHandler(new cgSearchHandler(cgeocaches.this, res, thread));
thread.start();
}
}
@@ -2332,7 +2323,7 @@ public class cgeocaches extends ListActivity {
final CharSequence[] items = new CharSequence[listsTitle.size()];
- AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(res.getString(R.string.list_title));
builder.setItems(listsTitle.toArray(items), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int item) {
@@ -2373,7 +2364,7 @@ public class cgeocaches extends ListActivity {
settings.saveLastList(listId);
- base.showProgress(activity, true);
+ showProgress(true);
setLoadingCaches();
Handler handlerMove = new Handler() {
@@ -2480,40 +2471,20 @@ public class cgeocaches extends ListActivity {
return;
}
- Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass());
+ Intent mapIntent = new Intent(this, settings.getMapFactory().getMapClass());
mapIntent.putExtra("detail", false);
mapIntent.putExtra("searchid", searchId);
- activity.startActivity(mapIntent);
- }
-
- public void goHome(View view) {
- base.goHome(activity);
+ startActivity(mapIntent);
}
public void goManual(View view) {
- try {
- if (type != null && type.equals("offline") == true) {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-stored",
- activity,
- "http://cgeo.carnero.cc/manual/");
- } else if (type != null && type.equals("history") == true) {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-history",
- activity,
- "http://cgeo.carnero.cc/manual/");
- } else {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-nearby",
- activity,
- "http://cgeo.carnero.cc/manual/");
- }
- } catch (Exception e) {
- // nothing
+ if (type != null && type.equals("offline") == true) {
+ ActivityMixin.goManual(this, "c:geo-stored");
+ } else if (type != null && type.equals("history") == true) {
+ ActivityMixin.goManual(this, "c:geo-history");
+ } else {
+ ActivityMixin.goManual(this, "c:geo-nearby");
}
}
}
diff --git a/src/cgeo/geocaching/cgeodetail.java b/src/cgeo/geocaching/cgeodetail.java
index 9aaec3b..e3f646e 100644
--- a/src/cgeo/geocaching/cgeodetail.java
+++ b/src/cgeo/geocaching/cgeodetail.java
@@ -1,7 +1,5 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
@@ -11,7 +9,6 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map.Entry;
-import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ContentValues;
@@ -49,17 +46,22 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.apps.cache.GeneralAppsFactory;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
-public class cgeodetail extends Activity {
+public class cgeodetail extends AbstractActivity {
+
+ public cgeodetail() {
+ super("c:geo-cache-details");
+ }
+
public Long searchId = null;
public cgCache cache = null;
public String geocode = null;
public String name = null;
public String guid = null;
private Resources res = null;
- private Activity activity = null;
private LayoutInflater inflater = null;
private cgeoapplication app = null;
private cgSettings settings = null;
@@ -199,7 +201,7 @@ public class cgeodetail extends Activity {
@Override
public void handleMessage(Message msg) {
if (longDesc == null && cache != null && cache.description != null) {
- longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(activity, settings, geocode, true, cache.reason, false), null);
+ longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(cgeodetail.this, settings, geocode, true, cache.reason, false), null);
}
if (longDesc != null) {
@@ -270,21 +272,15 @@ public class cgeodetail extends Activity {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.detail);
- base.setTitle(activity, res.getString(R.string.cache));
+ setTitle(res.getString(R.string.cache));
init();
@@ -377,7 +373,7 @@ public class cgeodetail extends Activity {
settings.load();
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
setView();
}
@@ -444,27 +440,27 @@ public class cgeodetail extends Activity {
final int id = item.getItemId();
if (id == 1) {
- final Intent cachesIntent = new Intent(activity, cgeocaches.class);
+ final Intent cachesIntent = new Intent(this, cgeocaches.class);
cachesIntent.putExtra("type", "owner");
cachesIntent.putExtra("username", contextMenuUser);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
return true;
} else if (id == 2) {
- final Intent cachesIntent = new Intent(activity, cgeocaches.class);
+ final Intent cachesIntent = new Intent(this, cgeocaches.class);
cachesIntent.putExtra("type", "username");
cachesIntent.putExtra("username", contextMenuUser);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
return true;
} else if (id == 3) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/profile/?u=" + URLEncoder.encode(contextMenuUser))));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/profile/?u=" + URLEncoder.encode(contextMenuUser))));
return true;
}
@@ -505,8 +501,8 @@ public class cgeodetail extends Activity {
}
private void addNavigationMenuItems(final Menu menu) {
- NavigationAppFactory.addMenuItems(menu, activity, res);
- GeneralAppsFactory.addMenuItems(menu, activity, res, cache);
+ NavigationAppFactory.addMenuItems(menu, this, res);
+ GeneralAppsFactory.addMenuItems(menu, this, res, cache);
}
@Override
@@ -523,7 +519,7 @@ public class cgeodetail extends Activity {
showSpoilers();
return true;
} else if (menuItem == 7) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/seek/cache_details.aspx?wp=" + cache.geocode)));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/seek/cache_details.aspx?wp=" + cache.geocode)));
return true;
} else if (menuItem == 10) {
cachesAround();
@@ -535,10 +531,10 @@ public class cgeodetail extends Activity {
shareCache();
return true;
}
- if (NavigationAppFactory.onMenuItemSelected(item, geo, activity, res, warning, cache, searchId, null, null)) {
+ if (NavigationAppFactory.onMenuItemSelected(item, geo, this, res, warning, cache, searchId, null, null)) {
return true;
}
- return GeneralAppsFactory.onMenuItemSelected(item, activity, cache);
+ return GeneralAppsFactory.onMenuItemSelected(item, this, cache);
}
private void init() {
@@ -546,10 +542,10 @@ public class cgeodetail extends Activity {
pixelRatio = dm.density;
if (inflater == null) {
- inflater = activity.getLayoutInflater();
+ inflater = getLayoutInflater();
}
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
if (searchId != null && searchId > 0) {
@@ -609,9 +605,9 @@ public class cgeodetail extends Activity {
geocode = geocode.toUpperCase();
- base.setTitle(activity, geocode);
+ setTitle(geocode);
- inflater = activity.getLayoutInflater();
+ inflater = getLayoutInflater();
ScrollView scroll = (ScrollView) findViewById(R.id.details_list_box);
scroll.setVisibility(View.VISIBLE);
@@ -624,7 +620,7 @@ public class cgeodetail extends Activity {
if (cache.type != null && gcIcons.containsKey(cache.type) == true) { // cache icon
typeId = cache.type;
}
- ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) activity.getResources().getDrawable(gcIcons.get(typeId)), null, null, null);
+ ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) getResources().getDrawable(gcIcons.get(typeId)), null, null, null);
// cache name (full name)
itemLayout = (RelativeLayout) inflater.inflate(R.layout.cache_item, null);
@@ -909,14 +905,14 @@ public class cgeodetail extends Activity {
TextView descView = (TextView) findViewById(R.id.shortdesc);
descView.setVisibility(View.VISIBLE);
- descView.setText(Html.fromHtml(cache.shortdesc.trim(), new cgHtmlImg(activity, settings, geocode, true, cache.reason, false), null), TextView.BufferType.SPANNABLE);
+ descView.setText(Html.fromHtml(cache.shortdesc.trim(), new cgHtmlImg(this, settings, geocode, true, cache.reason, false), null), TextView.BufferType.SPANNABLE);
descView.setMovementMethod(LinkMovementMethod.getInstance());
}
// cache long desc
if (longDescDisplayed == true) {
if (longDesc == null && cache != null && cache.description != null) {
- longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(activity, settings, geocode, true, cache.reason, false), null);
+ longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(this, settings, geocode, true, cache.reason, false), null);
}
if (longDesc != null && longDesc.length() > 0) {
@@ -1171,7 +1167,7 @@ public class cgeodetail extends Activity {
}
// avoid parsing HTML if not necessary
if (log.log.indexOf('<') >= 0 || log.log.indexOf('&') >= 0) {
- ((TextView) rowView.findViewById(R.id.log)).setText(Html.fromHtml(log.log, new cgHtmlImg(activity, settings, null, false, cache.reason, false), null), TextView.BufferType.SPANNABLE);
+ ((TextView) rowView.findViewById(R.id.log)).setText(Html.fromHtml(log.log, new cgHtmlImg(this, settings, null, false, cache.reason, false), null), TextView.BufferType.SPANNABLE);
}
else {
((TextView) rowView.findViewById(R.id.log)).setText(log.log);
@@ -1193,12 +1189,12 @@ public class cgeodetail extends Activity {
log_img_title.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Intent logImgIntent = new Intent(activity, cgeoimages.class);
+ Intent logImgIntent = new Intent(cgeodetail.this, cgeoimages.class);
logImgIntent.putExtra("geocode", geocode.toUpperCase());
logImgIntent.putExtra("type", cgeoimages.LOG_IMAGE);
logImgIntent.putExtra("title", title);
logImgIntent.putExtra("url", url);
- activity.startActivity(logImgIntent);
+ startActivity(logImgIntent);
}
});
logLayout.addView(log_imgView);
@@ -1291,14 +1287,14 @@ public class cgeodetail extends Activity {
try {
final String latlonMap = String.format((Locale) null, "%.6f", cache.latitude) + "," + String.format((Locale) null, "%.6f", cache.longitude);
- final Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
+ final Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
int height = (int) (90 * pixelRatio);
String markerUrl = cgBase.urlencode_rfc3986("http://cgeo.carnero.cc/_markers/my_location_mdpi.png");
- cgHtmlImg mapGetter = new cgHtmlImg(activity, settings, cache.geocode, false, 0, false);
+ cgHtmlImg mapGetter = new cgHtmlImg(cgeodetail.this, settings, cache.geocode, false, 0, false);
image = mapGetter.getDrawable("http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=15&size=" + width + "x" + height + "&maptype=terrain&markers=icon%3A" + markerUrl + "%7C" + latlonMap + "&sensor=false");
Message message = handler.obtainMessage(0, image);
handler.sendMessage(message);
@@ -1309,8 +1305,8 @@ public class cgeodetail extends Activity {
}
public void loadLongDesc() {
- if (activity != null && (waitDialog == null || waitDialog.isShowing() == false)) {
- descDialog = ProgressDialog.show(activity, null, res.getString(R.string.cache_dialog_loading_description), true);
+ if (waitDialog == null || waitDialog.isShowing() == false) {
+ descDialog = ProgressDialog.show(this, null, res.getString(R.string.cache_dialog_loading_description), true);
descDialog.setCancelable(true);
}
@@ -1331,7 +1327,7 @@ public class cgeodetail extends Activity {
return;
}
- longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(activity, settings, geocode, true, cache.reason, false), null);
+ longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(cgeodetail.this, settings, geocode, true, cache.reason, false), null);
handler.sendMessage(new Message());
}
}
@@ -1380,13 +1376,13 @@ public class cgeodetail extends Activity {
private void cachesAround() {
cgeocaches cachesActivity = new cgeocaches();
- Intent cachesIntent = new Intent(activity, cachesActivity.getClass());
+ Intent cachesIntent = new Intent(this, cachesActivity.getClass());
cachesIntent.putExtra("type", "coordinate");
cachesIntent.putExtra("latitude", cache.latitude);
cachesIntent.putExtra("longitude", cache.longitude);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
finish();
}
@@ -1433,7 +1429,7 @@ public class cgeodetail extends Activity {
final CharSequence[] items = calendars.values().toArray(new CharSequence[calendars.size()]);
- AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.cache_calendars);
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
@@ -1520,7 +1516,7 @@ public class cgeodetail extends Activity {
cgeonavigate navigateActivity = new cgeonavigate();
- Intent navigateIntent = new Intent(activity, navigateActivity.getClass());
+ Intent navigateIntent = new Intent(this, navigateActivity.getClass());
navigateIntent.putExtra("latitude", cache.latitude);
navigateIntent.putExtra("longitude", cache.longitude);
navigateIntent.putExtra("geocode", cache.geocode.toUpperCase());
@@ -1530,7 +1526,7 @@ public class cgeodetail extends Activity {
cgeonavigate.coordinates.clear();
}
cgeonavigate.coordinates = getCoordinates();
- activity.startActivity(navigateIntent);
+ startActivity(navigateIntent);
}
public void shareCache() {
@@ -1564,20 +1560,20 @@ public class cgeodetail extends Activity {
}
public void onClick(View arg0) {
- Intent waypointIntent = new Intent(activity, cgeowaypoint.class);
+ Intent waypointIntent = new Intent(cgeodetail.this, cgeowaypoint.class);
waypointIntent.putExtra("waypoint", id);
waypointIntent.putExtra("geocode", cache.geocode);
- activity.startActivity(waypointIntent);
+ startActivity(waypointIntent);
}
}
private void logVisit() {
- Intent logVisitIntent = new Intent(activity, cgeovisit.class);
+ Intent logVisitIntent = new Intent(this, cgeovisit.class);
logVisitIntent.putExtra("id", cache.cacheid);
logVisitIntent.putExtra("geocode", cache.geocode.toUpperCase());
logVisitIntent.putExtra("type", cache.type.toLowerCase());
logVisitIntent.putExtra("found", cache.found);
- activity.startActivity(logVisitIntent);
+ startActivity(logVisitIntent);
}
private void showSpoilers() {
@@ -1585,10 +1581,10 @@ public class cgeodetail extends Activity {
warning.showToast(res.getString(R.string.err_detail_no_spoiler));
}
- Intent spoilersIntent = new Intent(activity, cgeoimages.class);
+ Intent spoilersIntent = new Intent(this, cgeoimages.class);
spoilersIntent.putExtra("geocode", geocode.toUpperCase());
spoilersIntent.putExtra("type", cgeoimages.SPOILER_IMAGE);
- activity.startActivity(spoilersIntent);
+ startActivity(spoilersIntent);
}
public class codeHint implements View.OnClickListener {
@@ -1647,9 +1643,9 @@ public class cgeodetail extends Activity {
public void onClick(View arg0) {
// show list of trackables
try {
- Intent trackablesIntent = new Intent(activity, cgeotrackables.class);
+ Intent trackablesIntent = new Intent(cgeodetail.this, cgeotrackables.class);
trackablesIntent.putExtra("geocode", geocode.toUpperCase());
- activity.startActivity(trackablesIntent);
+ startActivity(trackablesIntent);
} catch (Exception e) {
Log.e(cgSettings.tag, "cgeodetail.selectTrackable: " + e.toString());
}
@@ -1667,7 +1663,7 @@ public class cgeodetail extends Activity {
return;
}
- storeDialog = ProgressDialog.show(activity, res.getString(R.string.cache_dialog_offline_save_title), res.getString(R.string.cache_dialog_offline_save_message), true);
+ storeDialog = ProgressDialog.show(cgeodetail.this, res.getString(R.string.cache_dialog_offline_save_title), res.getString(R.string.cache_dialog_offline_save_message), true);
storeDialog.setCancelable(true);
if (storeThread != null) {
@@ -1690,7 +1686,7 @@ public class cgeodetail extends Activity {
return;
}
- refreshDialog = ProgressDialog.show(activity, res.getString(R.string.cache_dialog_refresh_title), res.getString(R.string.cache_dialog_refresh_message), true);
+ refreshDialog = ProgressDialog.show(cgeodetail.this, res.getString(R.string.cache_dialog_refresh_title), res.getString(R.string.cache_dialog_refresh_message), true);
refreshDialog.setCancelable(true);
if (refreshThread != null) {
@@ -1715,7 +1711,7 @@ public class cgeodetail extends Activity {
if (cache.reason > 1) {
reason = cache.reason;
}
- base.storeCache(app, activity, cache, null, reason, handler);
+ base.storeCache(app, cgeodetail.this, cache, null, reason, handler);
}
}
@@ -1749,7 +1745,7 @@ public class cgeodetail extends Activity {
return;
}
- dropDialog = ProgressDialog.show(activity, res.getString(R.string.cache_dialog_offline_drop_title), res.getString(R.string.cache_dialog_offline_drop_message), true);
+ dropDialog = ProgressDialog.show(cgeodetail.this, res.getString(R.string.cache_dialog_offline_drop_title), res.getString(R.string.cache_dialog_offline_drop_message), true);
dropDialog.setCancelable(false);
Thread thread = new dropCacheThread(dropCacheHandler);
thread.start();
@@ -1766,7 +1762,7 @@ public class cgeodetail extends Activity {
@Override
public void run() {
- base.dropCache(app, activity, cache, handler);
+ base.dropCache(app, cgeodetail.this, cache, handler);
}
}
@@ -1779,7 +1775,7 @@ public class cgeodetail extends Activity {
warning.showToast(res.getString(R.string.err_watchlist_still_managing));
return;
}
- watchlistDialog = ProgressDialog.show(activity,
+ watchlistDialog = ProgressDialog.show(cgeodetail.this,
res.getString(titleId), res.getString(messageId), true);
watchlistDialog.setCancelable(true);
@@ -1841,7 +1837,7 @@ public class cgeodetail extends Activity {
private class addWaypoint implements View.OnClickListener {
public void onClick(View view) {
- Intent addWptIntent = new Intent(activity, cgeowaypointadd.class);
+ Intent addWptIntent = new Intent(cgeodetail.this, cgeowaypointadd.class);
addWptIntent.putExtra("geocode", geocode);
int wpCount = 0;
@@ -1850,7 +1846,7 @@ public class cgeodetail extends Activity {
}
addWptIntent.putExtra("count", wpCount);
- activity.startActivity(addWptIntent);
+ startActivity(addWptIntent);
}
}
@@ -1909,10 +1905,6 @@ public class cgeodetail extends Activity {
}
}
- public void goHome(View view) {
- base.goHome(activity);
- }
-
public void goCompass(View view) {
if (cache == null || cache.latitude == null || cache.longitude == null) {
warning.showToast(res.getString(R.string.cache_coordinates_no));
@@ -1920,7 +1912,7 @@ public class cgeodetail extends Activity {
return;
}
- Intent navigateIntent = new Intent(activity, cgeonavigate.class);
+ Intent navigateIntent = new Intent(this, cgeonavigate.class);
navigateIntent.putExtra("latitude", cache.latitude);
navigateIntent.putExtra("longitude", cache.longitude);
navigateIntent.putExtra("geocode", cache.geocode.toUpperCase());
@@ -1930,19 +1922,6 @@ public class cgeodetail extends Activity {
cgeonavigate.coordinates.clear();
}
cgeonavigate.coordinates = getCoordinates();
- activity.startActivity(navigateIntent);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-cache-details",
- activity,
- "http://cgeo.carnero.cc/manual/"
- );
- } catch (Exception e) {
- // nothing
- }
+ startActivity(navigateIntent);
}
}
diff --git a/src/cgeo/geocaching/cgeogpxes.java b/src/cgeo/geocaching/cgeogpxes.java
index ed5c488..16f6f88 100644
--- a/src/cgeo/geocaching/cgeogpxes.java
+++ b/src/cgeo/geocaching/cgeogpxes.java
@@ -8,7 +8,6 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
-import android.view.View;
public class cgeogpxes extends cgFileList<cgGPXListAdapter> {
@@ -63,7 +62,7 @@ public class cgeogpxes extends cgFileList<cgGPXListAdapter> {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
Bundle extras = getIntent().getExtras();
if (extras != null) {
listId = extras.getInt("list");
@@ -77,7 +76,7 @@ public class cgeogpxes extends cgFileList<cgGPXListAdapter> {
public void loadGPX(File file) {
parseDialog = ProgressDialog.show(
- getActivity(),
+ this,
getRes().getString(R.string.gpx_import_title_reading_file),
getRes().getString(R.string.gpx_import_loading),
true,
@@ -103,9 +102,4 @@ public class cgeogpxes extends cgFileList<cgGPXListAdapter> {
loadCachesHandler.sendMessage(new Message());
}
}
-
- public void goHome(View view) {
- getBase().goHome(getActivity());
- }
-
}
diff --git a/src/cgeo/geocaching/cgeohelpers.java b/src/cgeo/geocaching/cgeohelpers.java
index 33a596c..0492656 100644
--- a/src/cgeo/geocaching/cgeohelpers.java
+++ b/src/cgeo/geocaching/cgeohelpers.java
@@ -2,21 +2,18 @@ package cgeo.geocaching;
import java.util.Locale;
-import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeohelpers extends Activity {
+public class cgeohelpers extends AbstractActivity {
- private cgeoapplication app = null;
private Resources res = null;
- private Activity activity = null;
private cgSettings settings = null;
- private cgBase base = null;
private SharedPreferences prefs = null;
@Override
@@ -24,21 +21,13 @@ public class cgeohelpers extends Activity {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
- app = (cgeoapplication) this.getApplication();
prefs = getSharedPreferences(cgSettings.preferences, 0);
settings = new cgSettings(this, prefs);
- base = new cgBase(app, settings, prefs);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.helpers);
- base.setTitle(activity, res.getString(R.string.helpers));
+ setTitle(res.getString(R.string.helpers));
}
@Override
@@ -54,9 +43,9 @@ public class cgeohelpers extends Activity {
try {
if (lng.equalsIgnoreCase("de")) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:gnu.android.app.cgeomanual.de")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:gnu.android.app.cgeomanual.de")));
} else {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:gnu.android.app.cgeomanual.en")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:gnu.android.app.cgeomanual.en")));
}
} catch (Exception e) {
// market not available in standard emulator
@@ -68,7 +57,7 @@ public class cgeohelpers extends Activity {
public void installLocus(View view) {
try {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:menion.android.locus")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:menion.android.locus")));
} catch (Exception e) {
// market not available in standard emulator
}
@@ -79,7 +68,7 @@ public class cgeohelpers extends Activity {
public void installGpsStatus(View view) {
try {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:com.eclipsim.gpsstatus2")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:com.eclipsim.gpsstatus2")));
} catch (Exception e) {
// market not available in standard emulator
}
@@ -89,15 +78,11 @@ public class cgeohelpers extends Activity {
public void installBluetoothGps(View view) {
try {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:googoo.android.btgps")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:googoo.android.btgps")));
} catch (Exception e) {
// market not available in standard emulator
}
finish();
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
}
diff --git a/src/cgeo/geocaching/cgeoimages.java b/src/cgeo/geocaching/cgeoimages.java
index fd61240..3bdd7a6 100644
--- a/src/cgeo/geocaching/cgeoimages.java
+++ b/src/cgeo/geocaching/cgeoimages.java
@@ -3,42 +3,41 @@ package cgeo.geocaching;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
+
+import android.app.ProgressDialog;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.graphics.Bitmap.CompressFormat;
+import android.graphics.Rect;
+import android.graphics.drawable.BitmapDrawable;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
-import android.net.Uri;
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.util.Log;
import android.text.Html;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
-import android.widget.TextView;
import android.widget.LinearLayout;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.graphics.Rect;
-import android.graphics.Bitmap.CompressFormat;
-import android.graphics.drawable.BitmapDrawable;
-import android.view.ViewGroup.LayoutParams;
+import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
+
+public class cgeoimages extends AbstractActivity {
-public class cgeoimages extends Activity {
-
public static final int LOG_IMAGE = 1;
public static final int SPOILER_IMAGE = 2;
-
+
private int img_type;
private ArrayList<cgImage> images = new ArrayList<cgImage>();
private Resources res = null;
private String geocode = null;
private String title = null;
- private String url = null;
+ private String url = null;
private cgeoapplication app = null;
- private Activity activity = null;
private cgSettings settings = null;
- private cgBase base = null;
private cgWarning warning = null;
private LayoutInflater inflater = null;
private ProgressDialog progressDialog = null;
@@ -49,7 +48,7 @@ public class cgeoimages extends Activity {
private int count = 0;
private int countDone = 0;
private String load_process_string;
-
+
private Handler loadImagesHandler = new Handler() {
@Override
@@ -66,7 +65,7 @@ public class cgeoimages extends Activity {
case SPOILER_IMAGE:
warning.showToast(res.getString(R.string.warn_load_spoiler_image));
break;
- }
+ }
finish();
return;
@@ -77,15 +76,15 @@ public class cgeoimages extends Activity {
if (app.isOffline(geocode, null) == true) {
offline = 1;
- if ((img_type == LOG_IMAGE) && (settings.storelogimages == false)) {
+ if ((img_type == LOG_IMAGE) && (settings.storelogimages == false)) {
offline = 0;
- }
+ }
} else {
offline = 0;
}
count = images.size();
- progressDialog = new ProgressDialog(activity);
+ progressDialog = new ProgressDialog(cgeoimages.this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMessage(load_process_string);
progressDialog.setCancelable(true);
@@ -112,7 +111,7 @@ public class cgeoimages extends Activity {
public void run() {
BitmapDrawable image = null;
try {
- cgHtmlImg imgGetter = new cgHtmlImg(activity, settings, geocode, true, offline, false, save);
+ cgHtmlImg imgGetter = new cgHtmlImg(cgeoimages.this, settings, geocode, true, offline, false, save);
image = imgGetter.getDrawable(img.url);
Message message = handler.obtainMessage(0, image);
@@ -141,38 +140,31 @@ public class cgeoimages extends Activity {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
- setContentView(R.layout.spoilers);
+ setTheme();
+ setContentView(R.layout.spoilers);
// get parameters
Bundle extras = getIntent().getExtras();
// try to get data from extras
if (extras != null) {
- geocode = extras.getString("geocode");
- img_type = extras.getInt("type", 0);
+ geocode = extras.getString("geocode");
+ img_type = extras.getInt("type", 0);
}
-
+
// google analytics
- if (img_type == SPOILER_IMAGE)
+ if (img_type == SPOILER_IMAGE)
{
- base.setTitle(activity, res.getString(R.string.cache_spoiler_images_title));
+ setTitle(res.getString(R.string.cache_spoiler_images_title));
} else if (img_type == LOG_IMAGE) {
- base.setTitle(activity, res.getString(R.string.cache_log_images_title));
+ setTitle(res.getString(R.string.cache_log_images_title));
}
-
+
if (geocode == null) {
warning.showToast("Sorry, c:geo forgot for what cache you want to load spoiler images.");
finish();
@@ -189,12 +181,12 @@ public class cgeoimages extends Activity {
}
break;
}
-
- inflater = activity.getLayoutInflater();
+
+ inflater = getLayoutInflater();
if (imagesView == null) {
imagesView = (LinearLayout) findViewById(R.id.spoiler_list);
}
-
+
switch (img_type) {
case SPOILER_IMAGE:
load_process_string = res.getString(R.string.cache_spoiler_images_loading);
@@ -227,20 +219,20 @@ public class cgeoimages extends Activity {
Log.e(cgSettings.tag, "cgeoimages.loadImagesHandler.sendMessage: " + e.toString());
}
break;
- case SPOILER_IMAGE:
+ case SPOILER_IMAGE:
(new loadSpoilers()).start();
break;
default:
warning.showToast("Sorry, can't load unknown image type.");
finish();
}
-
+
}
@Override
public void onResume() {
super.onResume();
-
+
settings.load();
}
@@ -280,7 +272,7 @@ public class cgeoimages extends Activity {
image_view.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
- final String directoryTarget = Environment.getExternalStorageDirectory() + "/" + cgSettings.cache + "/" + "temp.jpg";
+ final String directoryTarget = Environment.getExternalStorageDirectory() + "/" + cgSettings.cache + "/" + "temp.jpg";
File file = new File(directoryTarget);
FileOutputStream fos;
try {
@@ -295,7 +287,7 @@ public class cgeoimages extends Activity {
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "image/jpg");
- activity.startActivity(intent);
+ startActivity(intent);
if (file.exists())
file.deleteOnExit();
@@ -315,8 +307,4 @@ public class cgeoimages extends Activity {
}
}
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
}
diff --git a/src/cgeo/geocaching/cgeoinit.java b/src/cgeo/geocaching/cgeoinit.java
index c8f19e1..8a73497 100644
--- a/src/cgeo/geocaching/cgeoinit.java
+++ b/src/cgeo/geocaching/cgeoinit.java
@@ -1,10 +1,7 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.io.File;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -27,14 +24,14 @@ import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import cgeo.geocaching.cgSettings.mapSourceEnum;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeoinit extends Activity {
+public class cgeoinit extends AbstractActivity {
private final int SELECT_MAPFILE_REQUEST=1;
private cgeoapplication app = null;
private Resources res = null;
- private Activity activity = null;
private cgSettings settings = null;
private cgBase base = null;
private cgWarning warning = null;
@@ -102,12 +99,15 @@ public class cgeoinit extends Activity {
}
};
+ public cgeoinit() {
+ super("c:geo-configuration");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
prefs = getSharedPreferences(cgSettings.preferences, 0);
@@ -115,14 +115,9 @@ public class cgeoinit extends Activity {
base = new cgBase(app, settings, prefs);
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.init);
- base.setTitle(activity, res.getString(R.string.settings));
+ setTitle(res.getString(R.string.settings));
init();
}
@@ -209,7 +204,7 @@ public class cgeoinit extends Activity {
legalNote.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/about/termsofuse.aspx")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/about/termsofuse.aspx")));
}
});
@@ -225,7 +220,7 @@ public class cgeoinit extends Activity {
go4cache.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://go4cache.com/")));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://go4cache.com/")));
}
});
@@ -242,8 +237,8 @@ public class cgeoinit extends Activity {
authorizeTwitter.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
- Intent authIntent = new Intent(activity, cgeoauth.class);
- activity.startActivity(authIntent);
+ Intent authIntent = new Intent(cgeoinit.this, cgeoauth.class);
+ startActivity(authIntent);
}
});
@@ -431,8 +426,8 @@ public class cgeoinit extends Activity {
@Override
public void onClick(View v) {
- Intent selectIntent = new Intent(activity, cgSelectMapfile.class);
- activity.startActivityForResult(selectIntent, SELECT_MAPFILE_REQUEST);
+ Intent selectIntent = new Intent(cgeoinit.this, cgSelectMapfile.class);
+ startActivityForResult(selectIntent, SELECT_MAPFILE_REQUEST);
}
});
@@ -552,8 +547,8 @@ public class cgeoinit extends Activity {
edit.commit();
if (settings.twitter == 1 && (settings.tokenPublic == null || settings.tokenPublic.length() == 0 || settings.tokenSecret == null || settings.tokenSecret.length() == 0)) {
- Intent authIntent = new Intent(activity, cgeoauth.class);
- activity.startActivity(authIntent);
+ Intent authIntent = new Intent(cgeoinit.this, cgeoauth.class);
+ startActivity(authIntent);
}
if (prefs.getInt("twitter", 0) == 0) {
@@ -986,7 +981,7 @@ public class cgeoinit extends Activity {
return;
}
- loginDialog = ProgressDialog.show(activity, res.getString(R.string.init_login_popup), res.getString(R.string.init_login_popup_working), true);
+ loginDialog = ProgressDialog.show(cgeoinit.this, res.getString(R.string.init_login_popup), res.getString(R.string.init_login_popup_working), true);
loginDialog.setCancelable(false);
settings.setLogin(username, password);
@@ -1014,7 +1009,7 @@ public class cgeoinit extends Activity {
return;
}
- webDialog = ProgressDialog.show(activity, res.getString(R.string.init_sendToCgeo), res.getString(R.string.init_sendToCgeo_registering), true);
+ webDialog = ProgressDialog.show(cgeoinit.this, res.getString(R.string.init_sendToCgeo), res.getString(R.string.init_sendToCgeo_registering), true);
webDialog.setCancelable(false);
(new Thread() {
@@ -1062,21 +1057,4 @@ public class cgeoinit extends Activity {
initMapfileEdittext(true);
}
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-configuration",
- activity,
- "http://cgeo.carnero.cc/manual/"
- );
- } catch (Exception e) {
- // nothing
- }
- }
}
diff --git a/src/cgeo/geocaching/cgeonavigate.java b/src/cgeo/geocaching/cgeonavigate.java
index 6421376..61cf516 100644
--- a/src/cgeo/geocaching/cgeonavigate.java
+++ b/src/cgeo/geocaching/cgeonavigate.java
@@ -1,34 +1,31 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.*;
-
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Locale;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.util.Log;
-import android.app.Activity;
import android.view.Menu;
-import android.view.SubMenu;
import android.view.MenuItem;
-import android.widget.TextView;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.view.View;
+import android.view.SubMenu;
import android.view.WindowManager;
-import java.util.HashMap;
-import java.util.Locale;
+import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeonavigate extends Activity {
+public class cgeonavigate extends AbstractActivity {
public static ArrayList<cgCoord> coordinates = new ArrayList<cgCoord>();
private Resources res = null;
private cgeoapplication app = null;
- private Activity activity = null;
private cgSettings settings = null;
private cgBase base = null;
private cgWarning warning = null;
@@ -65,12 +62,15 @@ public class cgeonavigate extends Activity {
}
};
+ public cgeonavigate() {
+ super("c:geo-compass");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// class init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
@@ -79,20 +79,16 @@ public class cgeonavigate extends Activity {
// set layout
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.navigate);
- base.setTitle(activity, res.getString(R.string.compass_title));
+ setTitle(res.getString(R.string.compass_title));
// sensor & geolocation manager
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
if (settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(this, dirUpdate, warning);
}
// get parameters
@@ -111,8 +107,8 @@ public class cgeonavigate extends Activity {
}
}
} else {
- Intent pointIntent = new Intent(activity, cgeopoint.class);
- activity.startActivity(pointIntent);
+ Intent pointIntent = new Intent(this, cgeopoint.class);
+ startActivity(pointIntent);
finish();
return;
@@ -157,10 +153,10 @@ public class cgeonavigate extends Activity {
// sensor & geolocation manager
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
if (settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(this, dirUpdate, warning);
}
// keep backlight on
@@ -260,12 +256,12 @@ public class cgeonavigate extends Activity {
int id = item.getItemId();
if (id == 0) {
- Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass());
+ Intent mapIntent = new Intent(this, settings.getMapFactory().getMapClass());
mapIntent.putExtra("detail", false);
mapIntent.putExtra("latitude", dstLatitude);
mapIntent.putExtra("longitude", dstLongitude);
- activity.startActivity(mapIntent);
+ startActivity(mapIntent);
} else if (id == 1) {
if (settings.useCompass == 1) {
settings.useCompass = 0;
@@ -281,7 +277,7 @@ public class cgeonavigate extends Activity {
settings.useCompass = 1;
if (dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(this, dirUpdate, warning);
}
SharedPreferences.Editor prefsEdit = getSharedPreferences(cgSettings.preferences, 0).edit();
@@ -289,8 +285,8 @@ public class cgeonavigate extends Activity {
prefsEdit.commit();
}
} else if (id == 2) {
- Intent pointIntent = new Intent(activity, cgeopoint.class);
- activity.startActivity(pointIntent);
+ Intent pointIntent = new Intent(this, cgeopoint.class);
+ startActivity(pointIntent);
finish();
return true;
@@ -313,9 +309,9 @@ public class cgeonavigate extends Activity {
private void setTitle() {
if (title != null && title.length() > 0) {
- base.setTitle(activity, title);
+ setTitle(title);
} else {
- base.setTitle(activity, res.getString(R.string.navigation));
+ setTitle(res.getString(R.string.navigation));
}
}
@@ -481,20 +477,4 @@ public class cgeonavigate extends Activity {
}
}
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-compass",
- activity,
- "http://cgeo.carnero.cc/manual/");
- } catch (Exception e) {
- // nothing
- }
- }
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/cgeopoint.java b/src/cgeo/geocaching/cgeopoint.java
index 4b22876..520881e 100644
--- a/src/cgeo/geocaching/cgeopoint.java
+++ b/src/cgeo/geocaching/cgeopoint.java
@@ -1,7 +1,5 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -34,9 +32,10 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
-public class cgeopoint extends Activity {
+public class cgeopoint extends AbstractActivity {
private class DestinationHistoryAdapter extends ArrayAdapter<cgDestination> {
private LayoutInflater inflater = null;
@@ -90,7 +89,6 @@ public class cgeopoint extends Activity {
private SharedPreferences prefs = null;
private cgBase base = null;
private cgWarning warning = null;
- private Activity activity = null;
private cgGeo geo = null;
private cgUpdateLoc geoUpdate = new update();
private EditText latEdit = null;
@@ -103,27 +101,25 @@ public class cgeopoint extends Activity {
private static final int CONTEXT_MENU_DELETE_WAYPOINT = Menu.FIRST;
+ public cgeopoint() {
+ super("c:geo-navigate-any");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
app = (cgeoapplication) this.getApplication();
res = this.getResources();
- settings = new cgSettings(activity, activity.getSharedPreferences(cgSettings.preferences, 0));
+ settings = new cgSettings(this, this.getSharedPreferences(cgSettings.preferences, 0));
prefs = getSharedPreferences(cgSettings.preferences, 0);
- base = new cgBase(app, settings, activity.getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(activity);
+ base = new cgBase(app, settings, this.getSharedPreferences(cgSettings.preferences, 0));
+ warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.point);
- base.setTitle(activity, res.getString(R.string.search_destination));
+ setTitle(res.getString(R.string.search_destination));
createHistoryView();
@@ -256,7 +252,7 @@ public class cgeopoint extends Activity {
private void init() {
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
EditText latitudeEdit = (EditText) findViewById(R.id.latitude);
@@ -295,7 +291,7 @@ public class cgeopoint extends Activity {
menu.add(0, 2, 0, res.getString(R.string.cache_menu_compass)).setIcon(android.R.drawable.ic_menu_compass); // compass
SubMenu subMenu = menu.addSubMenu(1, 0, 0, res.getString(R.string.cache_menu_navigate)).setIcon(android.R.drawable.ic_menu_more);
- NavigationAppFactory.addMenuItems(subMenu, activity, res);
+ NavigationAppFactory.addMenuItems(subMenu, this, res);
menu.add(0, 5, 0, res.getString(R.string.cache_menu_around)).setIcon(android.R.drawable.ic_menu_rotate); // caches around
@@ -354,7 +350,7 @@ public class cgeopoint extends Activity {
return true;
}
- return NavigationAppFactory.onMenuItemSelected(item, geo, activity, res, warning, null, null, null, coords);
+ return NavigationAppFactory.onMenuItemSelected(item, geo, this, res, warning, null, null, null, coords);
}
private void addToHistory(ArrayList<Double> coords) {
@@ -423,13 +419,13 @@ public class cgeopoint extends Activity {
cgeonavigate navigateActivity = new cgeonavigate();
- Intent navigateIntent = new Intent(activity, navigateActivity.getClass());
+ Intent navigateIntent = new Intent(this, navigateActivity.getClass());
navigateIntent.putExtra("latitude", coords.get(0));
navigateIntent.putExtra("longitude", coords.get(1));
navigateIntent.putExtra("geocode", "");
navigateIntent.putExtra("name", "Some destination");
- activity.startActivity(navigateIntent);
+ startActivity(navigateIntent);
}
private void cachesAround() {
@@ -441,14 +437,14 @@ public class cgeopoint extends Activity {
cgeocaches cachesActivity = new cgeocaches();
- Intent cachesIntent = new Intent(activity, cachesActivity.getClass());
+ Intent cachesIntent = new Intent(this, cachesActivity.getClass());
cachesIntent.putExtra("type", "coordinate");
cachesIntent.putExtra("latitude", coords.get(0));
cachesIntent.putExtra("longitude", coords.get(1));
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
finish();
}
@@ -633,20 +629,4 @@ public class cgeopoint extends Activity {
edit.commit();
}
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-navigate-any",
- activity,
- "http://cgeo.carnero.cc/manual/");
- } catch (Exception e) {
- // nothing
- }
- }
}
diff --git a/src/cgeo/geocaching/cgeopopup.java b/src/cgeo/geocaching/cgeopopup.java
index d9de22d..f25ba4e 100644
--- a/src/cgeo/geocaching/cgeopopup.java
+++ b/src/cgeo/geocaching/cgeopopup.java
@@ -1,11 +1,8 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.util.HashMap;
import java.util.Locale;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Configuration;
@@ -28,11 +25,11 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
-public class cgeopopup extends Activity {
+public class cgeopopup extends AbstractActivity {
- private Activity activity = null;
private Resources res = null;
private cgeoapplication app = null;
private cgSettings settings = null;
@@ -108,12 +105,15 @@ public class cgeopopup extends Activity {
}
};
+ public cgeopopup() {
+ super("c:geo-cache-info");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
@@ -123,7 +123,7 @@ public class cgeopopup extends Activity {
// set layout
setTheme(R.style.transparent);
setContentView(R.layout.popup);
- base.setTitle(activity, res.getString(R.string.detail));
+ setTitle(res.getString(R.string.detail));
// get parameters
Bundle extras = getIntent().getExtras();
@@ -145,7 +145,7 @@ public class cgeopopup extends Activity {
menu.add(0, 2, 0, res.getString(R.string.cache_menu_compass)).setIcon(android.R.drawable.ic_menu_compass); // compass
SubMenu subMenu = menu.addSubMenu(1, 0, 0, res.getString(R.string.cache_menu_navigate)).setIcon(android.R.drawable.ic_menu_more);
- NavigationAppFactory.addMenuItems(subMenu, activity, res);
+ NavigationAppFactory.addMenuItems(subMenu, this, res);
menu.add(0, 6, 0, res.getString(R.string.cache_menu_visit)).setIcon(android.R.drawable.ic_menu_agenda); // log visit
menu.add(0, 5, 0, res.getString(R.string.cache_menu_around)).setIcon(android.R.drawable.ic_menu_rotate); // caches around
@@ -197,26 +197,26 @@ public class cgeopopup extends Activity {
return false;
}
- Intent logVisitIntent = new Intent(activity, cgeovisit.class);
+ Intent logVisitIntent = new Intent(this, cgeovisit.class);
logVisitIntent.putExtra("id", cache.cacheid);
logVisitIntent.putExtra("geocode", cache.geocode.toUpperCase());
logVisitIntent.putExtra("type", cache.type.toLowerCase());
- activity.startActivity(logVisitIntent);
+ startActivity(logVisitIntent);
- activity.finish();
+ finish();
return true;
} else if (menuItem == 7) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/seek/cache_details.aspx?wp=" + cache.geocode)));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/seek/cache_details.aspx?wp=" + cache.geocode)));
return true;
}
- return NavigationAppFactory.onMenuItemSelected(item, geo, activity, res, warning, cache, null, null, null);
+ return NavigationAppFactory.onMenuItemSelected(item, geo, this, res, warning, cache, null, null, null);
}
private void init() {
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
app.setAction(geocode);
@@ -254,12 +254,12 @@ public class cgeopopup extends Activity {
}
if (cache.name != null && cache.name.length() > 0) {
- base.setTitle(activity, cache.name);
+ setTitle(cache.name);
} else {
- base.setTitle(activity, geocode.toUpperCase());
+ setTitle(geocode.toUpperCase());
}
- inflater = activity.getLayoutInflater();
+ inflater = getLayoutInflater();
geocode = cache.geocode.toUpperCase();
((ScrollView) findViewById(R.id.details_list_box)).setVisibility(View.VISIBLE);
@@ -268,9 +268,9 @@ public class cgeopopup extends Activity {
// actionbar icon
if (cache.type != null && gcIcons.containsKey(cache.type) == true) { // cache icon
- ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) activity.getResources().getDrawable(gcIcons.get(cache.type)), null, null, null);
+ ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) getResources().getDrawable(gcIcons.get(cache.type)), null, null, null);
} else { // unknown cache type, "mystery" icon
- ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) activity.getResources().getDrawable(gcIcons.get("mystery")), null, null, null);
+ ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) getResources().getDrawable(gcIcons.get("mystery")), null, null, null);
}
// cache type
@@ -432,11 +432,11 @@ public class cgeopopup extends Activity {
buttonMore.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
- Intent cachesIntent = new Intent(activity, cgeodetail.class);
+ Intent cachesIntent = new Intent(cgeopopup.this, cgeodetail.class);
cachesIntent.putExtra("geocode", geocode.toUpperCase());
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
- activity.finish();
+ finish();
return;
}
});
@@ -569,13 +569,13 @@ public class cgeopopup extends Activity {
cgeonavigate navigateActivity = new cgeonavigate();
- Intent navigateIntent = new Intent(activity, navigateActivity.getClass());
+ Intent navigateIntent = new Intent(this, navigateActivity.getClass());
navigateIntent.putExtra("latitude", cache.latitude);
navigateIntent.putExtra("longitude", cache.longitude);
navigateIntent.putExtra("geocode", "");
navigateIntent.putExtra("name", "Some destination");
- activity.startActivity(navigateIntent);
+ startActivity(navigateIntent);
}
private void cachesAround() {
@@ -585,14 +585,14 @@ public class cgeopopup extends Activity {
cgeocaches cachesActivity = new cgeocaches();
- Intent cachesIntent = new Intent(activity, cachesActivity.getClass());
+ Intent cachesIntent = new Intent(this, cachesActivity.getClass());
cachesIntent.putExtra("type", "coordinate");
cachesIntent.putExtra("latitude", cache.latitude);
cachesIntent.putExtra("longitude", cache.longitude);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
finish();
}
@@ -605,7 +605,7 @@ public class cgeopopup extends Activity {
return;
}
- storeDialog = ProgressDialog.show(activity, res.getString(R.string.cache_dialog_offline_save_title), res.getString(R.string.cache_dialog_offline_save_message), true);
+ storeDialog = ProgressDialog.show(cgeopopup.this, res.getString(R.string.cache_dialog_offline_save_title), res.getString(R.string.cache_dialog_offline_save_message), true);
storeDialog.setCancelable(false);
Thread thread = new storeCacheThread(storeCacheHandler);
thread.start();
@@ -622,7 +622,7 @@ public class cgeopopup extends Activity {
@Override
public void run() {
- base.storeCache(app, activity, cache, null, 1, handler);
+ base.storeCache(app, cgeopopup.this, cache, null, 1, handler);
}
}
@@ -634,7 +634,7 @@ public class cgeopopup extends Activity {
return;
}
- dropDialog = ProgressDialog.show(activity, res.getString(R.string.cache_dialog_offline_drop_title), res.getString(R.string.cache_dialog_offline_drop_message), true);
+ dropDialog = ProgressDialog.show(cgeopopup.this, res.getString(R.string.cache_dialog_offline_drop_title), res.getString(R.string.cache_dialog_offline_drop_message), true);
dropDialog.setCancelable(false);
Thread thread = new dropCacheThread(dropCacheHandler);
thread.start();
@@ -651,7 +651,7 @@ public class cgeopopup extends Activity {
@Override
public void run() {
- base.dropCache(app, activity, cache, handler);
+ base.dropCache(app, cgeopopup.this, cache, handler);
}
}
@@ -692,10 +692,6 @@ public class cgeopopup extends Activity {
detailsList.addView(itemLayout);
}
- public void goHome(View view) {
- base.goHome(activity);
- }
-
public void goCompass(View view) {
if (cache == null || cache.latitude == null || cache.longitude == null) {
warning.showToast(res.getString(R.string.cache_coordinates_no));
@@ -705,29 +701,19 @@ public class cgeopopup extends Activity {
cgeonavigate navigateActivity = new cgeonavigate();
- Intent navigateIntent = new Intent(activity, navigateActivity.getClass());
+ Intent navigateIntent = new Intent(cgeopopup.this, navigateActivity.getClass());
navigateIntent.putExtra("latitude", cache.latitude);
navigateIntent.putExtra("longitude", cache.longitude);
navigateIntent.putExtra("geocode", cache.geocode.toUpperCase());
navigateIntent.putExtra("name", cache.name);
- activity.startActivity(navigateIntent);
+ startActivity(navigateIntent);
finish();
}
public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-cache-info",
- activity,
- "http://cgeo.carnero.cc/manual/"
- );
- } catch (Exception e) {
- // nothing
- }
-
+ super.goManual(view);
finish();
}
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/cgeosmaps.java b/src/cgeo/geocaching/cgeosmaps.java
index 02d7c2f..354d32d 100644
--- a/src/cgeo/geocaching/cgeosmaps.java
+++ b/src/cgeo/geocaching/cgeosmaps.java
@@ -2,7 +2,6 @@ package cgeo.geocaching;
import java.util.ArrayList;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -12,19 +11,16 @@ import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
-import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeosmaps extends Activity {
+public class cgeosmaps extends AbstractActivity {
private ArrayList<Bitmap> maps = new ArrayList<Bitmap>();
private String geocode = null;
private Resources res = null;
- private cgeoapplication app = null;
- private Activity activity = null;
private cgSettings settings = null;
- private cgBase base = null;
private cgWarning warning = null;
private LayoutInflater inflater = null;
private ProgressDialog waitDialog = null;
@@ -50,7 +46,7 @@ public class cgeosmaps extends Activity {
}
if (inflater == null) {
- inflater = activity.getLayoutInflater();
+ inflater = getLayoutInflater();
}
if (smapsView == null) {
@@ -80,21 +76,13 @@ public class cgeosmaps extends Activity {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
- app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.map_static);
- base.setTitle(activity, res.getString(R.string.map_static_title));
+ setTitle(res.getString(R.string.map_static_title));
// get parameters
Bundle extras = getIntent().getExtras();
@@ -162,8 +150,4 @@ public class cgeosmaps extends Activity {
}
}
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/cgeotouch.java b/src/cgeo/geocaching/cgeotouch.java
index 4f6fd73..b2ce64f 100644
--- a/src/cgeo/geocaching/cgeotouch.java
+++ b/src/cgeo/geocaching/cgeotouch.java
@@ -1,12 +1,10 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.*;
-
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
-import android.app.Activity;
+
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.res.Configuration;
@@ -16,7 +14,6 @@ import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ContextMenu;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
@@ -29,9 +26,7 @@ import android.widget.TextView;
public class cgeotouch extends cgLogForm {
private cgeoapplication app = null;
- private Activity activity = null;
private Resources res = null;
- private LayoutInflater inflater = null;
private cgBase base = null;
private cgSettings settings = null;
private cgWarning warning = null;
@@ -40,7 +35,6 @@ public class cgeotouch extends cgLogForm {
private ProgressDialog waitDialog = null;
private String guid = null;
private String geocode = null;
- private String text = null;
private String viewstate = null;
private String viewstate1 = null;
private Boolean gettingViewstate = true;
@@ -53,7 +47,7 @@ public class cgeotouch extends cgLogForm {
private Handler showProgressHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
- base.showProgress(activity, true);
+ showProgress(true);
}
};
@@ -70,7 +64,7 @@ public class cgeotouch extends cgLogForm {
return;
} else if ((viewstate == null || viewstate.length() == 0) && attempts >= 2) {
warning.showToast(res.getString(R.string.err_log_load_data));
- base.showProgress(activity, false);
+ showProgress(false);
return;
}
@@ -81,7 +75,7 @@ public class cgeotouch extends cgLogForm {
buttonPost.setEnabled(true);
buttonPost.setOnClickListener(new postListener());
- base.showProgress(activity, false);
+ showProgress(false);
}
};
@@ -118,41 +112,38 @@ public class cgeotouch extends cgLogForm {
}
};
+ public cgeotouch() {
+ super("c:geo-log-trackable");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication)this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.touch);
- base.setTitle(activity, res.getString(R.string.trackable_touch));
+ setTitle(res.getString(R.string.trackable_touch));
// get parameters
Bundle extras = getIntent().getExtras();
if (extras != null) {
geocode = extras.getString("geocode");
guid = extras.getString("guid");
- text = extras.getString("text");
}
trackable = app.getTrackableByGeocode("logging trackable");
if (trackable.name != null && trackable.name.length() > 0) {
- base.setTitle(activity, res.getString(R.string.trackable_touch) + trackable.name);
+ setTitle(res.getString(R.string.trackable_touch) + trackable.name);
} else {
- base.setTitle(activity, res.getString(R.string.trackable_touch) + trackable.geocode.toUpperCase());
+ setTitle(res.getString(R.string.trackable_touch) + trackable.geocode.toUpperCase());
}
app.setAction("logging trackable");
@@ -170,7 +161,7 @@ public class cgeotouch extends cgLogForm {
@Override
public void onResume() {
super.onResume();
-
+
settings.load();
}
@@ -222,7 +213,7 @@ public class cgeotouch extends cgLogForm {
textContent = text.getText().toString();
dateString = cgBase.dateOut.format(new Date());
timeString = cgBase.timeOut.format(new Date());
-
+
if ((id & 0x4) == 0x4) {
addText += dateString;
if ((id & 0x2) == 0x2) {
@@ -342,7 +333,7 @@ public class cgeotouch extends cgLogForm {
private class cgeotouchDateListener implements View.OnClickListener {
public void onClick(View arg0) {
- Dialog dateDialog = new cgeodate(activity, (cgeotouch)activity, date);
+ Dialog dateDialog = new cgeodate(cgeotouch.this, cgeotouch.this, date);
dateDialog.setCancelable(true);
dateDialog.show();
}
@@ -351,7 +342,7 @@ public class cgeotouch extends cgLogForm {
private class postListener implements View.OnClickListener {
public void onClick(View arg0) {
if (gettingViewstate == false) {
- waitDialog = ProgressDialog.show(activity, null, res.getString(R.string.log_saving), true);
+ waitDialog = ProgressDialog.show(cgeotouch.this, null, res.getString(R.string.log_saving), true);
waitDialog.setCancelable(true);
String tracking = ((EditText)findViewById(R.id.tracking)).getText().toString();
@@ -464,21 +455,4 @@ public class cgeotouch extends cgLogForm {
return 1000;
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-log-trackable",
- activity,
- "http://cgeo.carnero.cc/manual/"
- );
- } catch (Exception e) {
- // nothing
- }
- }
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/cgeotrackable.java b/src/cgeo/geocaching/cgeotrackable.java
index 7319aa6..19ae77e 100644
--- a/src/cgeo/geocaching/cgeotrackable.java
+++ b/src/cgeo/geocaching/cgeotrackable.java
@@ -1,13 +1,10 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Resources;
@@ -30,8 +27,9 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeotrackable extends Activity {
+public class cgeotrackable extends AbstractActivity {
public cgTrackable trackable = null;
public String geocode = null;
public String name = null;
@@ -40,7 +38,6 @@ public class cgeotrackable extends Activity {
private String contextMenuUser = null;
private Resources res = null;
private cgeoapplication app = null;
- private Activity activity = null;
private LayoutInflater inflater = null;
private cgSettings settings = null;
private cgBase base = null;
@@ -84,13 +81,13 @@ public class cgeotrackable extends Activity {
}
try {
- inflater = activity.getLayoutInflater();
+ inflater = getLayoutInflater();
geocode = trackable.geocode.toUpperCase();
if (trackable.name != null && trackable.name.length() > 0) {
- base.setTitle(activity, Html.fromHtml(trackable.name).toString());
+ setTitle(Html.fromHtml(trackable.name).toString());
} else {
- base.setTitle(activity, trackable.name.toUpperCase());
+ setTitle(trackable.name.toUpperCase());
}
((ScrollView) findViewById(R.id.details_list_box)).setVisibility(View.VISIBLE);
@@ -184,10 +181,10 @@ public class cgeotrackable extends Activity {
if (cgTrackable.SPOTTED_CACHE == trackable.spottedType) {
itemLayout.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
- Intent cacheIntent = new Intent(activity, cgeodetail.class);
+ Intent cacheIntent = new Intent(cgeotrackable.this, cgeodetail.class);
cacheIntent.putExtra("guid", (String) trackable.spottedGuid);
cacheIntent.putExtra("name", (String) trackable.spottedName);
- activity.startActivity(cacheIntent);
+ startActivity(cacheIntent);
}
});
} else if (cgTrackable.SPOTTED_USER == trackable.spottedType) {
@@ -237,7 +234,7 @@ public class cgeotrackable extends Activity {
((LinearLayout) findViewById(R.id.goal_box)).setVisibility(View.VISIBLE);
TextView descView = (TextView) findViewById(R.id.goal);
descView.setVisibility(View.VISIBLE);
- descView.setText(Html.fromHtml(trackable.goal, new cgHtmlImg(activity, settings, geocode, true, 0, false), null), TextView.BufferType.SPANNABLE);
+ descView.setText(Html.fromHtml(trackable.goal, new cgHtmlImg(cgeotrackable.this, settings, geocode, true, 0, false), null), TextView.BufferType.SPANNABLE);
descView.setMovementMethod(LinkMovementMethod.getInstance());
}
@@ -246,7 +243,7 @@ public class cgeotrackable extends Activity {
((LinearLayout) findViewById(R.id.details_box)).setVisibility(View.VISIBLE);
TextView descView = (TextView) findViewById(R.id.details);
descView.setVisibility(View.VISIBLE);
- descView.setText(Html.fromHtml(trackable.details, new cgHtmlImg(activity, settings, geocode, true, 0, false), null), TextView.BufferType.SPANNABLE);
+ descView.setText(Html.fromHtml(trackable.details, new cgHtmlImg(cgeotrackable.this, settings, geocode, true, 0, false), null), TextView.BufferType.SPANNABLE);
descView.setMovementMethod(LinkMovementMethod.getInstance());
}
@@ -262,7 +259,7 @@ public class cgeotrackable extends Activity {
trackableImage.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(trackable.image)));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(trackable.image)));
}
});
@@ -284,7 +281,7 @@ public class cgeotrackable extends Activity {
public void run() {
BitmapDrawable image = null;
try {
- cgHtmlImg imgGetter = new cgHtmlImg(activity, settings, geocode, true, 0, false);
+ cgHtmlImg imgGetter = new cgHtmlImg(cgeotrackable.this, settings, geocode, true, 0, false);
image = imgGetter.getDrawable(trackable.image);
Message message = handler.obtainMessage(0, image);
@@ -309,26 +306,24 @@ public class cgeotrackable extends Activity {
}
};
+ public cgeotrackable() {
+ super("c:geo-trackable-details");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.trackable_detail);
- base.setTitle(activity, res.getString(R.string.trackable));
+ setTitle(res.getString(R.string.trackable));
// get parameters
Bundle extras = getIntent().getExtras();
@@ -439,27 +434,27 @@ public class cgeotrackable extends Activity {
final int id = item.getItemId();
if (id == 1) {
- final Intent cachesIntent = new Intent(activity, cgeocaches.class);
+ final Intent cachesIntent = new Intent(this, cgeocaches.class);
cachesIntent.putExtra("type", "owner");
cachesIntent.putExtra("username", contextMenuUser);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
return true;
} else if (id == 2) {
- final Intent cachesIntent = new Intent(activity, cgeocaches.class);
+ final Intent cachesIntent = new Intent(this, cgeocaches.class);
cachesIntent.putExtra("type", "username");
cachesIntent.putExtra("username", contextMenuUser);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
return true;
} else if (id == 3) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/profile/?u=" + URLEncoder.encode(contextMenuUser))));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/profile/?u=" + URLEncoder.encode(contextMenuUser))));
return true;
}
@@ -481,7 +476,7 @@ public class cgeotrackable extends Activity {
logTouch();
return true;
case 2:
- activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/track/details.aspx?tracker=" + trackable.geocode)));
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/track/details.aspx?tracker=" + trackable.geocode)));
return true;
}
@@ -564,15 +559,15 @@ public class cgeotrackable extends Activity {
final String cacheName = log.cacheName;
((TextView) rowView.findViewById(R.id.location)).setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
- Intent cacheIntent = new Intent(activity, cgeodetail.class);
+ Intent cacheIntent = new Intent(cgeotrackable.this, cgeodetail.class);
cacheIntent.putExtra("guid", (String) cacheGuid);
cacheIntent.putExtra("name", (String) Html.fromHtml(cacheName).toString());
- activity.startActivity(cacheIntent);
+ startActivity(cacheIntent);
}
});
}
- ((TextView) rowView.findViewById(R.id.log)).setText(Html.fromHtml(log.log, new cgHtmlImg(activity, settings, null, false, 0, false), null), TextView.BufferType.SPANNABLE);
+ ((TextView) rowView.findViewById(R.id.log)).setText(Html.fromHtml(log.log, new cgHtmlImg(cgeotrackable.this, settings, null, false, 0, false), null), TextView.BufferType.SPANNABLE);
((TextView) rowView.findViewById(R.id.author)).setOnClickListener(new userActions());
listView.addView(rowView);
@@ -601,10 +596,10 @@ public class cgeotrackable extends Activity {
}
private void logTouch() {
- Intent logTouchIntent = new Intent(activity, cgeotouch.class);
+ Intent logTouchIntent = new Intent(this, cgeotouch.class);
logTouchIntent.putExtra("geocode", trackable.geocode.toUpperCase());
logTouchIntent.putExtra("guid", trackable.guid);
- activity.startActivity(logTouchIntent);
+ startActivity(logTouchIntent);
}
private class tbIconThread extends Thread {
@@ -624,7 +619,7 @@ public class cgeotrackable extends Activity {
BitmapDrawable image = null;
try {
- cgHtmlImg imgGetter = new cgHtmlImg(activity, settings, trackable.geocode, false, 0, false);
+ cgHtmlImg imgGetter = new cgHtmlImg(cgeotrackable.this, settings, trackable.geocode, false, 0, false);
image = imgGetter.getDrawable(url);
Message message = handler.obtainMessage(0, image);
@@ -650,21 +645,4 @@ public class cgeotrackable extends Activity {
}
}
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-trackable-details",
- activity,
- "http://cgeo.carnero.cc/manual/"
- );
- } catch (Exception e) {
- // nothing
- }
- }
}
diff --git a/src/cgeo/geocaching/cgeotrackables.java b/src/cgeo/geocaching/cgeotrackables.java
index b578cc9..094311a 100644
--- a/src/cgeo/geocaching/cgeotrackables.java
+++ b/src/cgeo/geocaching/cgeotrackables.java
@@ -1,9 +1,7 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.*;
-
import java.util.ArrayList;
-import android.app.Activity;
+
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
@@ -15,15 +13,14 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
+import cgeo.geocaching.activity.AbstractActivity;
-public class cgeotrackables extends Activity {
+public class cgeotrackables extends AbstractActivity {
private ArrayList<cgTrackable> trackables = new ArrayList<cgTrackable>();
private String geocode = null;
private cgeoapplication app = null;
private cgSettings settings = null;
- private cgBase base = null;
private cgWarning warning = null;
- private Activity activity = null;
private LayoutInflater inflater = null;
private LinearLayout addList = null;
private ProgressDialog waitDialog = null;
@@ -33,7 +30,7 @@ public class cgeotrackables extends Activity {
public void handleMessage(Message msg) {
try {
if (inflater == null) {
- inflater = activity.getLayoutInflater();
+ inflater = getLayoutInflater();
}
if (addList == null) {
@@ -79,25 +76,22 @@ public class cgeotrackables extends Activity {
}
};
+ public cgeotrackables() {
+ super("c:geo-trackable-list");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.trackables);
- base.setTitle(activity, "Trackables");
+ setTitle("Trackables");
// get parameters
Bundle extras = getIntent().getExtras();
@@ -118,11 +112,11 @@ public class cgeotrackables extends Activity {
(new loadInventory()).start();
}
-
+
@Override
public void onResume() {
super.onResume();
-
+
settings.load();
}
@@ -153,31 +147,14 @@ public class cgeotrackables extends Activity {
}
public void onClick(View arg0) {
- Intent trackableIntent = new Intent(activity, cgeotrackable.class);
+ Intent trackableIntent = new Intent(cgeotrackables.this, cgeotrackable.class);
trackableIntent.putExtra("guid", guid);
trackableIntent.putExtra("geocode", geocode);
trackableIntent.putExtra("name", name);
- activity.startActivity(trackableIntent);
+ startActivity(trackableIntent);
finish();
return;
}
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-trackable-list",
- activity,
- "http://cgeo.carnero.cc/manual/"
- );
- } catch (Exception e) {
- // nothing
- }
- }
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/cgeovisit.java b/src/cgeo/geocaching/cgeovisit.java
index 923ada7..59e26b0 100644
--- a/src/cgeo/geocaching/cgeovisit.java
+++ b/src/cgeo/geocaching/cgeovisit.java
@@ -1,14 +1,11 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
-import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
@@ -32,7 +29,6 @@ import android.widget.TextView;
public class cgeovisit extends cgLogForm {
private cgeoapplication app = null;
- private Activity activity = null;
private Resources res = null;
private LayoutInflater inflater = null;
private cgBase base = null;
@@ -71,7 +67,7 @@ public class cgeovisit extends cgLogForm {
@Override
public void handleMessage(Message msg) {
if (progressBar == true) {
- base.showProgress(activity, true);
+ showProgress(true);
}
}
};
@@ -96,7 +92,7 @@ public class cgeovisit extends cgLogForm {
return;
} else if ((viewstate == null || viewstate.length() == 0) && attempts >= 2) {
warning.showToast(res.getString(R.string.err_log_load_data));
- base.showProgress(activity, false);
+ showProgress(false);
return;
}
@@ -112,7 +108,7 @@ public class cgeovisit extends cgLogForm {
// add trackables
if (trackables != null && trackables.isEmpty() == false) {
if (inflater == null) {
- inflater = activity.getLayoutInflater();
+ inflater = getLayoutInflater();
}
final LinearLayout inventoryView = (LinearLayout) findViewById(R.id.inventory);
@@ -132,9 +128,9 @@ public class cgeovisit extends cgLogForm {
inventoryItem.findViewById(R.id.info).setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
- final Intent trackablesIntent = new Intent(activity, cgeotrackable.class);
+ final Intent trackablesIntent = new Intent(cgeovisit.this, cgeotrackable.class);
trackablesIntent.putExtra("geocode", tbCode);
- activity.startActivity(trackablesIntent);
+ startActivity(trackablesIntent);
}
});
inventoryItem.findViewById(R.id.action).setOnClickListener(new View.OnClickListener() {
@@ -172,7 +168,7 @@ public class cgeovisit extends cgLogForm {
}
}
- base.showProgress(activity, false);
+ showProgress(false);
}
};
@@ -220,26 +216,24 @@ public class cgeovisit extends cgLogForm {
}
};
+ public cgeovisit() {
+ super("c:geo-log");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.visit);
- base.setTitle(activity, res.getString(R.string.log_new_log));
+ setTitle(res.getString(R.string.log_new_log));
// get parameters
Bundle extras = getIntent().getExtras();
@@ -260,9 +254,9 @@ public class cgeovisit extends cgLogForm {
cache = app.getCacheByGeocode(geocode);
if (cache.name != null && cache.name.length() > 0) {
- base.setTitle(activity, res.getString(R.string.log_new_log) + " " + cache.name);
+ setTitle(res.getString(R.string.log_new_log) + " " + cache.name);
} else {
- base.setTitle(activity, res.getString(R.string.log_new_log) + " " + cache.geocode.toUpperCase());
+ setTitle(res.getString(R.string.log_new_log) + " " + cache.geocode.toUpperCase());
}
app.setAction(geocode);
@@ -718,7 +712,7 @@ public class cgeovisit extends cgLogForm {
private class cgeovisitDateListener implements View.OnClickListener {
public void onClick(View arg0) {
- Dialog dateDialog = new cgeodate(activity, (cgeovisit) activity, date);
+ Dialog dateDialog = new cgeodate(cgeovisit.this, cgeovisit.this, date);
dateDialog.setCancelable(true);
dateDialog.show();
}
@@ -728,7 +722,7 @@ public class cgeovisit extends cgLogForm {
public void onClick(View arg0) {
if (gettingViewstate == false) {
- waitDialog = ProgressDialog.show(activity, null, res.getString(R.string.log_saving), true);
+ waitDialog = ProgressDialog.show(cgeovisit.this, null, res.getString(R.string.log_saving), true);
waitDialog.setCancelable(true);
String log = ((EditText) findViewById(R.id.log)).getText().toString();
@@ -926,21 +920,4 @@ public class cgeovisit extends cgLogForm {
return 1000;
}
-
- public void goHome(View view) {
- base.goHome(activity);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-log",
- activity,
- "http://cgeo.carnero.cc/manual/"
- );
- } catch (Exception e) {
- // nothing
- }
- }
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/cgeowaypoint.java b/src/cgeo/geocaching/cgeowaypoint.java
index 543312c..b17f278 100644
--- a/src/cgeo/geocaching/cgeowaypoint.java
+++ b/src/cgeo/geocaching/cgeowaypoint.java
@@ -1,10 +1,7 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.util.ArrayList;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Resources;
@@ -22,9 +19,10 @@ import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
+import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
-public class cgeowaypoint extends Activity {
+public class cgeowaypoint extends AbstractActivity {
private static final int MENU_ID_NAVIGATION = 0;
private static final int MENU_ID_CACHES_AROUND = 5;
@@ -34,7 +32,6 @@ public class cgeowaypoint extends Activity {
private int id = -1;
private cgeoapplication app = null;
private Resources res = null;
- private Activity activity = null;
private cgSettings settings = null;
private cgBase base = null;
private cgWarning warning = null;
@@ -66,9 +63,9 @@ public class cgeowaypoint extends Activity {
registerNavigationMenu(headline);
if (waypoint.name != null && waypoint.name.length() > 0) {
- base.setTitle(activity, Html.fromHtml(waypoint.name.trim()).toString());
+ setTitle(Html.fromHtml(waypoint.name.trim()).toString());
} else {
- base.setTitle(activity, res.getString(R.string.waypoint_title));
+ setTitle(res.getString(R.string.waypoint_title));
}
if (waypoint.prefix.equalsIgnoreCase("OWN") == false) {
@@ -131,26 +128,24 @@ public class cgeowaypoint extends Activity {
}
};
+ public cgeowaypoint() {
+ super("c:geo-waypoint-details");
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.waypoint);
- base.setTitle(activity, "waypoint");
+ setTitle("waypoint");
// get parameters
Bundle extras = getIntent().getExtras();
@@ -168,7 +163,7 @@ public class cgeowaypoint extends Activity {
}
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
waitDialog = ProgressDialog.show(this, null, res.getString(R.string.waypoint_loading), true);
@@ -184,7 +179,7 @@ public class cgeowaypoint extends Activity {
settings.load();
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
if (waitDialog == null) {
@@ -235,7 +230,7 @@ public class cgeowaypoint extends Activity {
}
private void addNavigationMenuItems(Menu menu) {
- NavigationAppFactory.addMenuItems(menu, activity, res);
+ NavigationAppFactory.addMenuItems(menu, this, res);
}
@Override
@@ -265,7 +260,7 @@ public class cgeowaypoint extends Activity {
return true;
}
- return NavigationAppFactory.onMenuItemSelected(item, geo, activity, res, warning, null, null, waypoint, null);
+ return NavigationAppFactory.onMenuItemSelected(item, geo, this, res, warning, null, null, waypoint, null);
}
private void cachesAround() {
@@ -275,13 +270,13 @@ public class cgeowaypoint extends Activity {
cgeocaches cachesActivity = new cgeocaches();
- Intent cachesIntent = new Intent(activity, cachesActivity.getClass());
+ Intent cachesIntent = new Intent(this, cachesActivity.getClass());
cachesIntent.putExtra("type", "coordinate");
cachesIntent.putExtra("latitude", waypoint.latitude);
cachesIntent.putExtra("longitude", waypoint.longitude);
cachesIntent.putExtra("cachetype", settings.cacheType);
- activity.startActivity(cachesIntent);
+ startActivity(cachesIntent);
finish();
}
@@ -317,9 +312,9 @@ public class cgeowaypoint extends Activity {
}
public void onClick(View arg0) {
- Intent editIntent = new Intent(activity, cgeowaypointadd.class);
+ Intent editIntent = new Intent(cgeowaypoint.this, cgeowaypointadd.class);
editIntent.putExtra("waypoint", id);
- activity.startActivity(editIntent);
+ startActivity(editIntent);
}
}
@@ -343,28 +338,12 @@ public class cgeowaypoint extends Activity {
}
}
- public void goHome(View view) {
- base.goHome(activity);
- }
-
- public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-waypoint-details",
- activity,
- "http://cgeo.carnero.cc/manual/");
- } catch (Exception e) {
- // nothing
- }
- }
-
public void goCompass(View view) {
if (waypoint == null || waypoint.latitude == null || waypoint.longitude == null) {
warning.showToast(res.getString(R.string.err_location_unknown));
}
- Intent navigateIntent = new Intent(activity, cgeonavigate.class);
+ Intent navigateIntent = new Intent(this, cgeonavigate.class);
navigateIntent.putExtra("latitude", waypoint.latitude);
navigateIntent.putExtra("longitude", waypoint.longitude);
navigateIntent.putExtra("geocode", waypoint.prefix.trim() + "/" + waypoint.lookup.trim());
@@ -375,7 +354,7 @@ public class cgeowaypoint extends Activity {
}
cgeonavigate.coordinates = new ArrayList<cgCoord>();
cgeonavigate.coordinates.add(new cgCoord(waypoint));
- activity.startActivity(navigateIntent);
+ startActivity(navigateIntent);
}
@Override
diff --git a/src/cgeo/geocaching/cgeowaypointadd.java b/src/cgeo/geocaching/cgeowaypointadd.java
index e039a43..6d13cb8 100644
--- a/src/cgeo/geocaching/cgeowaypointadd.java
+++ b/src/cgeo/geocaching/cgeowaypointadd.java
@@ -1,11 +1,13 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
-import android.app.Activity;
import android.app.ProgressDialog;
-import android.os.Bundle;
import android.content.res.Resources;
+import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Html;
@@ -15,19 +17,16 @@ import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import cgeo.geocaching.activity.AbstractActivity;
+import cgeo.geocaching.activity.ActivityMixin;
-public class cgeowaypointadd extends Activity {
+public class cgeowaypointadd extends AbstractActivity {
private cgeoapplication app = null;
private Resources res = null;
private cgSettings settings = null;
private cgBase base = null;
private cgWarning warning = null;
- private Activity activity = null;
private String geocode = null;
private int id = -1;
private cgGeo geo = null;
@@ -88,24 +87,18 @@ public class cgeowaypointadd extends Activity {
super.onCreate(savedInstanceState);
// init
- activity = this;
res = this.getResources();
app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(activity, activity.getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, activity.getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(activity);
+ settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
+ base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
+ warning = new cgWarning(this);
- // set layout
- if (settings.skin == 1) {
- setTheme(R.style.light);
- } else {
- setTheme(R.style.dark);
- }
+ setTheme();
setContentView(R.layout.waypoint_new);
- base.setTitle(activity, "waypoint");
+ setTitle("waypoint");
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
// get parameters
@@ -124,9 +117,9 @@ public class cgeowaypointadd extends Activity {
}
if (id <= 0) {
- base.setTitle(activity, res.getString(R.string.waypoint_add_title));
+ setTitle(res.getString(R.string.waypoint_add_title));
} else {
- base.setTitle(activity, res.getString(R.string.waypoint_edit_title));
+ setTitle(res.getString(R.string.waypoint_edit_title));
}
if (geocode != null) {
@@ -156,11 +149,11 @@ public class cgeowaypointadd extends Activity {
@Override
public void onResume() {
super.onResume();
-
+
settings.load();
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
}
if (id > 0) {
@@ -403,29 +396,11 @@ public class cgeowaypointadd extends Activity {
}
}
- public void goHome(View view) {
- base.goHome(activity);
- }
-
public void goManual(View view) {
- try {
- if (id >= 0) {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-waypoint-edit",
- activity,
- "http://cgeo.carnero.cc/manual/"
- );
- } else {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-waypoint-new",
- activity,
- "http://cgeo.carnero.cc/manual/"
- );
- }
- } catch (Exception e) {
- // nothing
+ if (id >= 0) {
+ ActivityMixin.goManual(this, "c:geo-waypoint-edit");
+ } else {
+ ActivityMixin.goManual(this, "c:geo-waypoint-new");
}
}
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java
index ce7aada..25f0b4e 100644
--- a/src/cgeo/geocaching/mapcommon/cgeomap.java
+++ b/src/cgeo/geocaching/mapcommon/cgeomap.java
@@ -1,7 +1,5 @@
package cgeo.geocaching.mapcommon;
-import gnu.android.app.appmanualclient.AppManualReaderClient;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
@@ -37,6 +35,7 @@ import cgeo.geocaching.cgUser;
import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.mapinterfaces.ActivityImpl;
import cgeo.geocaching.mapinterfaces.CacheOverlayItemImpl;
import cgeo.geocaching.mapinterfaces.GeoPointImpl;
@@ -155,7 +154,7 @@ public class cgeomap extends MapBase {
title.append("]");
}
- base.setTitle(activity, title.toString());
+ ActivityMixin.setTitle(activity, title.toString());
} else if (what == 1 && mapView != null) {
mapView.invalidate();
}
@@ -168,9 +167,9 @@ public class cgeomap extends MapBase {
final int what = msg.what;
if (what == 0) {
- base.showProgress(activity, false);
+ ActivityMixin.showProgress(activity, false);
} else if (what == 1) {
- base.showProgress(activity, true);
+ ActivityMixin.showProgress(activity, true);
}
}
};
@@ -249,13 +248,9 @@ public class cgeomap extends MapBase {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// set layout
- if (settings.skin == 1) {
- activity.setTheme(R.style.light);
- } else {
- activity.setTheme(R.style.dark);
- }
+ ActivityMixin.setTheme(activity);
activity.setContentView(settings.getMapFactory().getMapLayoutId());
- base.setTitle(activity, res.getString(R.string.map_map));
+ ActivityMixin.setTitle(activity, res.getString(R.string.map_map));
if (geo == null) {
geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
@@ -1781,19 +1776,11 @@ public class cgeomap extends MapBase {
// close activity and open homescreen
public void goHome(View view) {
- base.goHome(activity);
+ ActivityMixin.goHome(activity);
}
// open manual entry
public void goManual(View view) {
- try {
- AppManualReaderClient.openManual(
- "c-geo",
- "c:geo-live-map",
- activity,
- "http://cgeo.carnero.cc/manual/");
- } catch (Exception e) {
- // nothing
- }
+ ActivityMixin.goManual(activity, "c:geo-live-map");
}
}