aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-06-09 07:28:09 +0200
committerBananeweizen <bananeweizen@gmx.de>2013-06-09 07:28:09 +0200
commit52681d8ab984caaa95db03076b6e369f7033bb36 (patch)
tree0224e0fc78a10eb0359511a40201710a2642c319 /main
parent75ef80dc91bea395f7c7d089d8ca16b83d93e01f (diff)
downloadcgeo-52681d8ab984caaa95db03076b6e369f7033bb36.zip
cgeo-52681d8ab984caaa95db03076b6e369f7033bb36.tar.gz
cgeo-52681d8ab984caaa95db03076b6e369f7033bb36.tar.bz2
#2866: Use Android Annotations to implement standard patterns
Diffstat (limited to 'main')
-rw-r--r--main/.factorypath1
-rw-r--r--main/AndroidManifest.xml4
-rw-r--r--main/build.xml93
-rw-r--r--main/compile-libs/androidannotations-2.7.1.jarbin0 -> 555665 bytes
-rw-r--r--main/libs/androidannotations-api-2.7.1.jarbin0 -> 61745 bytes
-rw-r--r--main/res/layout/about_activity.xml6
-rw-r--r--main/src/cgeo/geocaching/AboutActivity.java71
-rw-r--r--main/src/cgeo/geocaching/MainActivity.java2
-rw-r--r--main/src/cgeo/geocaching/StaticMapsActivity.java61
9 files changed, 141 insertions, 97 deletions
diff --git a/main/.factorypath b/main/.factorypath
index d54f9b4..62efc08 100644
--- a/main/.factorypath
+++ b/main/.factorypath
@@ -1,3 +1,4 @@
<factorypath>
<factorypathentry kind="WKSPJAR" id="/cgeo/libs/butterknife-1.3.2.jar" enabled="true" runInBatchMode="false"/>
+ <factorypathentry kind="WKSPJAR" id="/cgeo/compile-libs/androidannotations-2.7.1.jar" enabled="true" runInBatchMode="false"/>
</factorypath>
diff --git a/main/AndroidManifest.xml b/main/AndroidManifest.xml
index ef9d3fe..c391fe9 100644
--- a/main/AndroidManifest.xml
+++ b/main/AndroidManifest.xml
@@ -93,7 +93,7 @@
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
- android:name=".AboutActivity"
+ android:name=".AboutActivity_"
android:configChanges="keyboardHidden|orientation"
android:label="@string/about"
android:windowSoftInputMode="stateHidden" >
@@ -168,7 +168,7 @@
android:label="@string/map_map" >
</activity>
<activity
- android:name=".StaticMapsActivity"
+ android:name=".StaticMapsActivity_"
android:label="@string/map_static_title" >
</activity>
<activity
diff --git a/main/build.xml b/main/build.xml
index b97a158..2444787 100644
--- a/main/build.xml
+++ b/main/build.xml
@@ -91,13 +91,94 @@
</copy>
</target>
-<!--
- <target name="-pre-compile">
+<!-- start of modifications for android annotations, see https://github.com/excilys/androidannotations/wiki/Building-Project-Ant -->
+ <property name="generated.dir" value="annotation_gen" />
+ <property name="generated.absolute.dir" location="${generated.dir}" />
+ <property name="java.compilerargs" value="-s &apos;${generated.absolute.dir}&apos;" />
+ <target name="-pre-compile">
+ <mkdir dir="${generated.absolute.dir}" />
+ </target>
+ <target name="-compile" depends="-pre-build, -build-setup, -code-gen, -pre-compile">
+ <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
+ <!-- merge the project's own classpath and the tested project's classpath -->
+ <path id="project.javac.classpath">
+ <path refid="project.all.jars.path" />
+ <path refid="tested.project.classpath" />
+ <path path="${java.compiler.classpath}" />
+ <fileset dir="compile-libs" includes="*.jar"/>
+ </path>
+ <javac encoding="${java.encoding}"
+ source="${java.source}" target="${java.target}"
+ debug="true" extdirs="" includeantruntime="false"
+ destdir="${out.classes.absolute.dir}"
+ bootclasspathref="project.target.class.path"
+ verbose="${verbose}"
+ classpathref="project.javac.classpath"
+ fork="${need.javac.fork}">
+ <src path="${source.absolute.dir}" />
+ <src path="${gen.absolute.dir}" />
+ <compilerarg line="${java.compilerargs}" />
+ </javac>
+
+ <!-- if the project is instrumented, intrument the classes -->
+ <if condition="${build.is.instrumented}">
+ <then>
+ <echo level="info">Instrumenting classes from ${out.absolute.dir}/classes...</echo>
+
+ <!-- build the filter to remove R, Manifest, BuildConfig -->
+ <getemmafilter
+ appPackage="${project.app.package}"
+ libraryPackagesRefId="project.library.packages"
+ filterOut="emma.default.filter"/>
+
+ <!-- define where the .em file is going. This may have been
+ setup already if this is a library -->
+ <property name="emma.coverage.absolute.file" location="${out.absolute.dir}/coverage.em" />
+
+ <!-- It only instruments class files, not any external libs -->
+ <emma enabled="true">
+ <instr verbosity="${verbosity}"
+ mode="overwrite"
+ instrpath="${out.absolute.dir}/classes"
+ outdir="${out.absolute.dir}/classes"
+ metadatafile="${emma.coverage.absolute.file}">
+ <filter excludes="${emma.default.filter}" />
+ <filter value="${emma.filter}" />
+ </instr>
+ </emma>
+ </then>
+ </if>
+
+ <!-- if the project is a library then we generate a jar file -->
+ <if condition="${project.is.library}">
+ <then>
+ <echo level="info">Creating library output jar file...</echo>
+ <property name="out.library.jar.file" location="${out.absolute.dir}/classes.jar" />
+ <if>
+ <condition>
+ <length string="${android.package.excludes}" trim="true" when="greater" length="0" />
+ </condition>
+ <then>
+ <echo level="info">Custom jar packaging exclusion: ${android.package.excludes}</echo>
+ </then>
+ </if>
+
+ <propertybyreplace name="project.app.package.path" input="${project.app.package}" replace="." with="/" />
+
+ <jar destfile="${out.library.jar.file}">
+ <fileset dir="${out.classes.absolute.dir}"
+ includes="**/*.class"
+ excludes="${project.app.package.path}/R.class ${project.app.package.path}/R$*.class ${project.app.package.path}/BuildConfig.class"/>
+ <fileset dir="${source.absolute.dir}" excludes="**/*.java ${android.package.excludes}" />
+ </jar>
+ </then>
+ </if>
+
+ </do-only-if-manifest-hasCode>
</target>
--->
- <!-- This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir} -->
+<!-- end of modifications for android-annotations -->
+
+
<!--
<target name="-post-compile">
</target>
diff --git a/main/compile-libs/androidannotations-2.7.1.jar b/main/compile-libs/androidannotations-2.7.1.jar
new file mode 100644
index 0000000..5fb9634
--- /dev/null
+++ b/main/compile-libs/androidannotations-2.7.1.jar
Binary files differ
diff --git a/main/libs/androidannotations-api-2.7.1.jar b/main/libs/androidannotations-api-2.7.1.jar
new file mode 100644
index 0000000..a829474
--- /dev/null
+++ b/main/libs/androidannotations-api-2.7.1.jar
Binary files differ
diff --git a/main/res/layout/about_activity.xml b/main/res/layout/about_activity.xml
index c13b4b4..4bf9917 100644
--- a/main/res/layout/about_activity.xml
+++ b/main/res/layout/about_activity.xml
@@ -96,6 +96,7 @@
<Button
style="@style/button_full"
+ android:id="@+id/donate"
android:layout_width="280dip"
android:lines="2"
android:onClick="donate"
@@ -140,7 +141,6 @@
android:clickable="true"
android:focusable="true"
android:linksClickable="false"
- android:onClick="website"
android:text="@string/website"
android:textColor="?text_color"
android:textColorLink="?text_color_link"
@@ -157,7 +157,6 @@
android:clickable="true"
android:focusable="true"
android:linksClickable="false"
- android:onClick="facebook"
android:text="@string/facebook"
android:textColor="?text_color"
android:textColorLink="?text_color_link"
@@ -174,7 +173,6 @@
android:clickable="true"
android:focusable="true"
android:linksClickable="false"
- android:onClick="twitter"
android:text="@string/twitter"
android:textColor="?text_color"
android:textColorLink="?text_color_link"
@@ -191,7 +189,6 @@
android:clickable="true"
android:focusable="true"
android:linksClickable="false"
- android:onClick="nutshellmanual"
android:text="@string/nutshellmanual"
android:textColor="?text_color"
android:textColorLink="?text_color_link"
@@ -208,7 +205,6 @@
android:clickable="true"
android:focusable="true"
android:linksClickable="false"
- android:onClick="market"
android:text="@string/market"
android:textColor="?text_color"
android:textColorLink="?text_color_link"
diff --git a/main/src/cgeo/geocaching/AboutActivity.java b/main/src/cgeo/geocaching/AboutActivity.java
index 3164602..f947655 100644
--- a/main/src/cgeo/geocaching/AboutActivity.java
+++ b/main/src/cgeo/geocaching/AboutActivity.java
@@ -1,85 +1,72 @@
package cgeo.geocaching;
-import butterknife.InjectView;
-
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.ui.AnchorAwareLinkMovementMethod;
import cgeo.geocaching.utils.Version;
+import com.googlecode.androidannotations.annotations.AfterViews;
+import com.googlecode.androidannotations.annotations.Click;
+import com.googlecode.androidannotations.annotations.EActivity;
+import com.googlecode.androidannotations.annotations.ViewById;
+
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
-import android.view.View;
import android.widget.TextView;
+@EActivity
public class AboutActivity extends AbstractActivity {
- @InjectView(R.id.about_version_string) protected TextView version;
- @InjectView(R.id.contributors) protected TextView contributors;
- @InjectView(R.id.changelog) protected TextView changeLog;
+ @ViewById(R.id.about_version_string) protected TextView version;
+ @ViewById(R.id.contributors) protected TextView contributors;
+ @ViewById(R.id.changelog) protected TextView changeLog;
@Override
public void onCreate(Bundle savedInstanceState) {
+ // TODO remove this after the theme has been fixed
super.onCreate(savedInstanceState, R.layout.about_activity);
+ }
+ @AfterViews
+ void initializeViews() {
version.setText(Version.getVersionName(this));
contributors.setMovementMethod(AnchorAwareLinkMovementMethod.getInstance());
changeLog.setMovementMethod(AnchorAwareLinkMovementMethod.getInstance());
}
- /**
- * @param view
- * unused here but needed since this method is referenced from XML layout
- */
- public void donate(View view) {
+ @Click(R.id.donate)
+ public void donate() {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FMLNN8GXZKJEE")));
}
- /**
- * @param view
- * unused here but needed since this method is referenced from XML layout
- */
- public void support(View view) {
+ @Click(R.id.support)
+ public void support() {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:support@cgeo.org")));
}
- /**
- * @param view
- * unused here but needed since this method is referenced from XML layout
- */
- public void website(View view) {
+
+ @Click(R.id.website)
+ void webSite() {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.cgeo.org/")));
}
- /**
- * @param view
- * unused here but needed since this method is referenced from XML layout
- */
- public void facebook(View view) {
+ @Click(R.id.facebook)
+ public void facebook() {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/pages/cgeo/297269860090")));
}
- /**
- * @param view
- * unused here but needed since this method is referenced from XML layout
- */
- public void twitter(View view) {
+ @Click(R.id.twitter)
+ public void twitter() {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://twitter.com/android_gc")));
}
- /**
- * @param view
- * unused here but needed since this method is referenced from XML layout
- */
- public void nutshellmanual(View view) {
+ @Click(R.id.nutshellmanual)
+ public void nutshellmanual() {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://manual.cgeo.org/")));
}
- /**
- * @param view
- * unused here but needed since this method is referenced from XML layout
- */
- public void market(View view) {
- Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()));
+ @Click(R.id.market)
+ public void market() {
+ final Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()));
marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(marketIntent);
}
diff --git a/main/src/cgeo/geocaching/MainActivity.java b/main/src/cgeo/geocaching/MainActivity.java
index 87f7ffd..e8de1f7 100644
--- a/main/src/cgeo/geocaching/MainActivity.java
+++ b/main/src/cgeo/geocaching/MainActivity.java
@@ -756,7 +756,7 @@ public class MainActivity extends AbstractActivity {
* unused here but needed since this method is referenced from XML layout
*/
public void showAbout(View view) {
- startActivity(new Intent(this, AboutActivity.class));
+ AboutActivity_.intent(this).start();
}
/**
diff --git a/main/src/cgeo/geocaching/StaticMapsActivity.java b/main/src/cgeo/geocaching/StaticMapsActivity.java
index a6a81d5..d8bc614 100644
--- a/main/src/cgeo/geocaching/StaticMapsActivity.java
+++ b/main/src/cgeo/geocaching/StaticMapsActivity.java
@@ -1,36 +1,43 @@
package cgeo.geocaching;
+import cgeo.geocaching.StaticMapsActivity_.IntentBuilder_;
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.utils.Log;
+import com.googlecode.androidannotations.annotations.EActivity;
+import com.googlecode.androidannotations.annotations.Extra;
+import com.googlecode.androidannotations.annotations.OptionsItem;
+import com.googlecode.androidannotations.annotations.OptionsMenu;
+
import org.apache.commons.collections.CollectionUtils;
import android.app.ProgressDialog;
import android.content.Context;
-import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.List;
+@EActivity
+@OptionsMenu(R.menu.static_maps_activity_options)
public class StaticMapsActivity extends AbstractActivity {
private static final String EXTRAS_WAYPOINT = "waypoint";
private static final String EXTRAS_DOWNLOAD = "download";
private static final String EXTRAS_GEOCODE = "geocode";
+
+ @Extra(EXTRAS_DOWNLOAD) boolean download = false;
+ @Extra(EXTRAS_WAYPOINT) Integer waypoint_id = null;
+ @Extra(EXTRAS_GEOCODE) String geocode = null;
+
private final List<Bitmap> maps = new ArrayList<Bitmap>();
- private boolean download = false;
- private Integer waypoint_id = null;
- private String geocode = null;
private LayoutInflater inflater = null;
private ProgressDialog waitDialog = null;
private LinearLayout smapsView = null;
@@ -89,18 +96,6 @@ public class StaticMapsActivity extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState, R.layout.map_static);
- // get parameters
- final Bundle extras = getIntent().getExtras();
-
- // try to get data from extras
- if (extras != null) {
- download = extras.getBoolean(EXTRAS_DOWNLOAD, false);
- geocode = extras.getString(EXTRAS_GEOCODE);
- if (extras.containsKey(EXTRAS_WAYPOINT)) {
- waypoint_id = extras.getInt(EXTRAS_WAYPOINT);
- }
- }
-
if (geocode == null) {
showToast("Sorry, c:geo forgot for what cache you want to load static maps.");
finish();
@@ -156,20 +151,10 @@ public class StaticMapsActivity extends AbstractActivity {
}
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.static_maps_activity_options, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.menu_refresh) {
- downloadStaticMaps();
- restartActivity();
- return true;
- }
- return super.onOptionsItemSelected(item);
+ @OptionsItem(R.id.menu_refresh)
+ void refreshMaps() {
+ downloadStaticMaps();
+ restartActivity();
}
private boolean downloadStaticMaps() {
@@ -192,16 +177,10 @@ public class StaticMapsActivity extends AbstractActivity {
}
public static void startActivity(final Context activity, final String geocode, final boolean download, final Waypoint waypoint) {
- final Intent intent = new Intent(activity, StaticMapsActivity.class);
- // if resuming our app within this activity, finish it and return to the cache activity
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
- intent.putExtra(EXTRAS_GEOCODE, geocode);
- if (download) {
- intent.putExtra(EXTRAS_DOWNLOAD, true);
- }
+ IntentBuilder_ builder = StaticMapsActivity_.intent(activity).geocode(geocode).download(download);
if (waypoint != null) {
- intent.putExtra(EXTRAS_WAYPOINT, waypoint.getId());
+ builder.waypoint_id(waypoint.getId());
}
- activity.startActivity(intent);
+ builder.start();
}
} \ No newline at end of file