Skip to content

Commit

Permalink
Adds a menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpk committed Feb 6, 2011
1 parent 474554d commit 88e41ae
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 11 deletions.
18 changes: 12 additions & 6 deletions gen/com/geoloqi/android1/R.java
Expand Up @@ -14,20 +14,26 @@ public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int buttonStart=0x7f060002;
public static final int buttonStop=0x7f060003;
public static final int buttonUpdate=0x7f060004;
public static final int textLatitude=0x7f060000;
public static final int textLongitude=0x7f060001;
public static final int buttonStart=0x7f070002;
public static final int buttonStop=0x7f070003;
public static final int buttonUpdate=0x7f070004;
public static final int quit=0x7f070006;
public static final int settings=0x7f070005;
public static final int textLatitude=0x7f070000;
public static final int textLongitude=0x7f070001;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class menu {
public static final int main_menu=0x7f060000;
}
public static final class raw {
public static final int braincandy=0x7f040000;
}
public static final class string {
public static final int app_name=0x7f050000;
public static final int sending=0x7f050001;
public static final int quit=0x7f050001;
public static final int sending=0x7f050002;
}
}
7 changes: 7 additions & 0 deletions res/menu/main_menu.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/settings"
android:title="Settings" />
<item android:id="@+id/quit"
android:title="@string/quit" />
</menu>
1 change: 1 addition & 0 deletions res/values/strings.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Geoloqi</string>
<string name="quit">Exit</string>
<string name="sending">Sending points to the server!</string>
</resources>
29 changes: 29 additions & 0 deletions src/com/geoloqi/android1/Geoloqi.java
Expand Up @@ -10,6 +10,9 @@
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
Expand Down Expand Up @@ -41,6 +44,29 @@ public void onCreate(Bundle savedInstanceState) {
new Timer().schedule(new MyTimerTask(), 0, 1000);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Log.d(TAG, "Inflating menu!");
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.settings:

return true;
case R.id.quit:
// exit();
return true;
default:
return super.onOptionsItemSelected(item);
}
}

public void onClick(View src) {
switch (src.getId()) {
case R.id.buttonStart:
Expand All @@ -61,6 +87,7 @@ public void onClick(View src) {
class LQUpdateUI extends AsyncTask<Void, Void, Cursor> {

// Doesn't have access to the UI thread
@Override
protected Cursor doInBackground(Void... v) {
return db.getLastLocation();
}
Expand All @@ -70,6 +97,7 @@ protected void onProgressUpdate() {
}

// Runs with the return value of doInBackground, has access to the UI thread
@Override
protected void onPostExecute(Cursor cursor) {
double latitude = cursor.getDouble(cursor.getColumnIndex(LQLocationData.LATITUDE));
double longitude = cursor.getDouble(cursor.getColumnIndex(LQLocationData.LONGITUDE));
Expand All @@ -88,6 +116,7 @@ public void run() {
}
};

@Override
public void run() {
handler.post(runnable);
}
Expand Down
7 changes: 3 additions & 4 deletions src/com/geoloqi/android1/GeoloqiService.java
Expand Up @@ -3,12 +3,8 @@
import java.util.Timer;
import java.util.TimerTask;

import com.geoloqi.android1.Geoloqi.LQUpdateUI;
import com.geoloqi.android1.Geoloqi.MyTimerTask;

import android.app.Service;
import android.content.Intent;
import android.database.Cursor;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
Expand Down Expand Up @@ -94,6 +90,7 @@ public void onStatusChanged(String provider, int status, Bundle extras) {
class LQFlushQueue extends AsyncTask<Void, Void, Void> {

// Doesn't have access to the UI thread
@Override
protected Void doInBackground(Void... v) {
Log.d(TAG, "Flushing queue...");

Expand All @@ -105,6 +102,7 @@ protected void onProgressUpdate() {
}

// Runs with the return value of doInBackground
@Override
protected void onPostExecute(Void v) {
Log.d(TAG, "Flush queue completed");

Expand All @@ -118,6 +116,7 @@ public void run() {
}
};

@Override
public void run() {
handler.post(runnable);
}
Expand Down
1 change: 0 additions & 1 deletion src/com/geoloqi/android1/LQLocationData.java
Expand Up @@ -4,7 +4,6 @@
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.location.Location;

Expand Down

0 comments on commit 88e41ae

Please sign in to comment.