Skip to content

Commit fc755f9

Browse files
committed
Implement home/work selection map activity and supporting utils
1 parent dcc1141 commit fc755f9

22 files changed

+509
-64
lines changed

AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<category android:name="android.intent.category.LAUNCHER" />
1717
</intent-filter>
1818
</activity>
19+
20+
<activity android:name="edu.fsu.cs.contextprovider.map.AddPlaceMapActivity" android:label="@string/app_name" />
1921

2022
<activity android:name="PrefsActivity" android:label="@string/app_name"
2123
android:screenOrientation="portrait" />
@@ -117,6 +119,7 @@
117119
<action android:name="android.intent.action.CLOSE_SYSTEM_DIALOGS" />
118120
</intent-filter>
119121
</receiver>
122+
<uses-library android:name="com.google.android.maps" />
120123

121124
</application>
122125

assets/EntityConfiguration.xml

100644100755
File mode changed.

default.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
sdk-folder=/opt/android-sdk-linux_x86-1.1_r1
1111
# Project target.
12-
target=android-8
12+
target=Google Inc.:Google APIs:8

defunct/ContextServiceStarter.java

100644100755
File mode changed.

res/drawable/date.png

100644100755
File mode changed.

res/drawable/telephony.png

100644100755
File mode changed.

res/layout/accuracy.xml

100644100755
File mode changed.

res/layout/placemap.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical" android:layout_width="fill_parent"
4+
android:layout_height="fill_parent">
5+
<com.google.android.maps.MapView
6+
android:id="@+id/mapView" android:layout_width="fill_parent"
7+
android:layout_height="fill_parent" android:enabled="true"
8+
android:clickable="true" android:apiKey="0xOAiU9b5S5OkTHpM2IskmeoBeE1grUgfG2Uecw" />
9+
</LinearLayout>

src/edu/fsu/cs/contextprovider/ContextExpandableListActivity.java

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ public class ContextExpandableListActivity extends ExpandableListActivity implem
9292

9393
private ExpandableListAdapter mAdapter;
9494

95-
private static final int MENU_REFRESH_ID = Menu.FIRST + 1;
96-
private static final int MENU_ADD_ID = Menu.FIRST + 2;
97-
private static final int MENU_SHARE_ID = Menu.FIRST + 3;
95+
// private static final int MENU_ADD_ID = Menu.FIRST + 2;
96+
// private static final int MENU_SHARE_ID = Menu.FIRST + 3;
97+
private static final int MENU_SET_HOME_ID = Menu.FIRST + 1;
98+
private static final int MENU_SET_WORK_ID = Menu.FIRST + 2;
99+
private static final int MENU_REFRESH_ID = Menu.FIRST + 3;
98100
private static final int MENU_PREFS_ID = Menu.FIRST + 4;
99101
private static final int MENU_ABOUT_ID = Menu.FIRST + 5;
100102

@@ -132,8 +134,7 @@ public class ContextExpandableListActivity extends ExpandableListActivity implem
132134
// debug
133135
private boolean ttsEnabled;
134136
private boolean shakeEnabled;
135-
136-
137+
137138
public static boolean running = false;
138139
public static TextToSpeech tts;
139140

@@ -163,7 +164,7 @@ public void onServiceDisconnected(ComponentName name) {
163164
@Override
164165
public void onCreate(Bundle savedInstanceState) {
165166
super.onCreate(savedInstanceState);
166-
167+
167168
getPrefs();
168169

169170
// startup the primary context service (if just installed)
@@ -183,54 +184,28 @@ public void onCreate(Bundle savedInstanceState) {
183184
bindService(new Intent(this, ContextProviderService.class), conn, Context.BIND_AUTO_CREATE);
184185

185186
if (locationEnabled) {
186-
// /* Start GPS Service */
187-
// intent = new Intent(this.getApplicationContext(), edu.fsu.cs.contextprovider.sensor.GPSService.class);
188-
// startService(intent);
189-
// /* Start Network Service */
190-
// intent = new Intent(this.getApplicationContext(), edu.fsu.cs.contextprovider.sensor.NetworkService.class);
191-
// startService(intent);
192-
// /* Start LocationMonitor */
193-
// Geocoder geocoder = new Geocoder(this, Locale.getDefault());
194-
// LocationMonitor.StartThread(5, geocoder);
195187
refreshLocation();
196188
}
197-
189+
198190
if (movementEnabled) {
199-
// /* Start Accelerometer Service */
200-
// intent = new Intent(this.getApplicationContext(), edu.fsu.cs.contextprovider.sensor.AccelerometerService.class);
201-
// startService(intent);
202-
// /* Start movement context */
203-
// MovementMonitor.StartThread(5);
204191
refreshMovement();
205192
}
206-
193+
207194
if (weatherEnabled) {
208-
// /* Start weather monitor */
209-
// WeatherMonitor.StartThread(60);
210195
refreshWeather();
211196
}
212-
197+
213198
if (systemEnabled) {
214-
// /* Start Phone/SMS State Monitor Services */
215-
// intent = new Intent(this.getApplicationContext(), edu.fsu.cs.contextprovider.sensor.TelephonyService.class);
216-
// startService(intent);
217199
refreshSystem();
218200
}
219-
201+
220202
if (socialEnabled) {
221-
// /* Start social monitor */
222-
// SocialMonitor.StartThread(60);
223203
refreshSocial();
224204
}
225205
if (derivedEnabled) {
226-
// /* Start derived monitor */
227-
// DerivedMonitor.StartThread(60);
228206
refreshDerived();
229207
}
230-
231-
232208

233-
// Set up our adapter
234209
mAdapter = new SimpleExpandableListAdapter(this, groupData, android.R.layout.simple_expandable_list_item_1, new String[] { NAME, VALUE }, new int[] {
235210
android.R.id.text1, android.R.id.text2 }, childData, android.R.layout.simple_expandable_list_item_2, new String[] { NAME, VALUE }, new int[] {
236211
android.R.id.text1, android.R.id.text2 });
@@ -251,12 +226,12 @@ public void onInit(int status) {
251226

252227
private void getPrefs() {
253228

254-
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
255-
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
229+
// SharedPreferences prefs =
230+
// PreferenceManager.getDefaultSharedPreferences(this);
256231
SharedPreferences prefs = getSharedPreferences(ContextConstants.CONTEXT_PREFS, MODE_WORLD_READABLE);
257232

258233
// general
259-
// startupEnabled = prefs.getBoolean("PREFS_STARTUP_ENABLED", true);
234+
// startupEnabled = prefs.getBoolean("PREFS_STARTUP_ENABLED", true);
260235
ttsEnabled = prefs.getBoolean("PREFS_TTS_ENABLED", false);
261236

262237
locationEnabled = prefs.getBoolean("PREFS_LOCATION_ENABLED", true);
@@ -549,9 +524,14 @@ public void onDestroy() {
549524

550525
@Override
551526
public boolean onCreateOptionsMenu(Menu menu) {
527+
528+
// menu.add(Menu.NONE, MENU_ADD_ID, Menu.NONE,
529+
// "Add").setIcon(android.R.drawable.ic_menu_add).setAlphabeticShortcut('a');
530+
menu.add(Menu.NONE, MENU_SET_HOME_ID, Menu.NONE, "Set Home").setIcon(android.R.drawable.ic_menu_compass).setAlphabeticShortcut('h');
531+
menu.add(Menu.NONE, MENU_SET_WORK_ID, Menu.NONE, "Set Work").setIcon(android.R.drawable.ic_menu_compass).setAlphabeticShortcut('w');
552532
menu.add(Menu.NONE, MENU_REFRESH_ID, Menu.NONE, "Refresh").setIcon(android.R.drawable.ic_menu_rotate).setAlphabeticShortcut('r');
553-
menu.add(Menu.NONE, MENU_ADD_ID, Menu.NONE, "Add").setIcon(android.R.drawable.ic_menu_add).setAlphabeticShortcut('a');
554-
menu.add(Menu.NONE, MENU_SHARE_ID, Menu.NONE, "Share").setIcon(android.R.drawable.ic_menu_share).setAlphabeticShortcut('s');
533+
// menu.add(Menu.NONE, MENU_SHARE_ID, Menu.NONE,
534+
// "Share").setIcon(android.R.drawable.ic_menu_share).setAlphabeticShortcut('s');
555535
menu.add(Menu.NONE, MENU_PREFS_ID, Menu.NONE, "Prefs").setIcon(android.R.drawable.ic_menu_preferences).setAlphabeticShortcut('p');
556536
menu.add(Menu.NONE, MENU_ABOUT_ID, Menu.NONE, "About").setIcon(android.R.drawable.ic_menu_info_details).setAlphabeticShortcut('i');
557537

@@ -564,28 +544,39 @@ public boolean onOptionsItemSelected(MenuItem item) {
564544
case MENU_REFRESH_ID:
565545
refresh();
566546
return true;
567-
case MENU_ADD_ID:
568-
refresh();
569-
Context context = getApplicationContext();
570-
String address = null;
571-
try {
572-
address = mService.getCurrentAddress();
573-
} catch (RemoteException e) {
574-
// TODO Auto-generated catch block
575-
e.printStackTrace();
576-
}
577-
AddressDialog.add addAddressDialog = new AddressDialog.add(this, address);
578-
addAddressDialog.show();
579-
this.refreshProximity();
580-
return (true);
581-
case MENU_SHARE_ID:
582-
try {
583-
exportToFile();
584-
} catch (IOException e) {
585-
// TODO Auto-generated catch block
586-
e.printStackTrace();
587-
}
547+
case MENU_SET_HOME_ID:
548+
startActivityForResult(new Intent(getApplicationContext(), edu.fsu.cs.contextprovider.map.AddPlaceMapActivity.class),
549+
ContextConstants.SET_HOME_REQUEST);
550+
// refresh();
551+
return true;
552+
case MENU_SET_WORK_ID:
553+
startActivityForResult(new Intent(getApplicationContext(), edu.fsu.cs.contextprovider.map.AddPlaceMapActivity.class),
554+
ContextConstants.SET_WORK_REQUEST);
555+
// refresh();
588556
return true;
557+
// case MENU_ADD_ID:
558+
// refresh();
559+
// Context context = getApplicationContext();
560+
// String address = null;
561+
// try {
562+
// address = mService.getCurrentAddress();
563+
// } catch (RemoteException e) {
564+
// // TODO Auto-generated catch block
565+
// e.printStackTrace();
566+
// }
567+
// AddressDialog.add addAddressDialog = new AddressDialog.add(this,
568+
// address);
569+
// addAddressDialog.show();
570+
// this.refreshProximity();
571+
// return (true);
572+
// case MENU_SHARE_ID:
573+
// try {
574+
// exportToFile();
575+
// } catch (IOException e) {
576+
// // TODO Auto-generated catch block
577+
// e.printStackTrace();
578+
// }
579+
// return true;
589580
case MENU_PREFS_ID:
590581
editPrefs();
591582
return true;
@@ -597,6 +588,22 @@ public boolean onOptionsItemSelected(MenuItem item) {
597588
return (super.onOptionsItemSelected(item));
598589
}
599590

591+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
592+
if (requestCode == ContextConstants.SET_HOME_REQUEST) {
593+
if (resultCode == RESULT_OK) {
594+
// Toast.makeText(this, "My Location:" + location.getLatitude()
595+
// + "," + location.getLongitude(), Toast.LENGTH_LONG);
596+
Toast.makeText(this, "Home Set Sucessfully", Toast.LENGTH_LONG);
597+
}
598+
} else if (requestCode == ContextConstants.SET_WORK_REQUEST) {
599+
if (resultCode == RESULT_OK) {
600+
// Toast.makeText(this, "My Location:" + location.getLatitude()
601+
// + "," + location.getLongitude(), Toast.LENGTH_LONG);
602+
Toast.makeText(this, "Work Set Sucessfully", Toast.LENGTH_LONG);
603+
}
604+
}
605+
}
606+
600607
@Override
601608
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
602609
menu.add(Menu.NONE, CONTEXT_DELETE_ID, Menu.NONE, "Delete").setIcon(android.R.drawable.ic_menu_delete).setAlphabeticShortcut('d');

src/edu/fsu/cs/contextprovider/data/AccuracyEntity.java

100644100755
File mode changed.

0 commit comments

Comments
 (0)