Permalink
Browse files

Added settings item to Activities' option menus

  • Loading branch information...
1 parent 929f33d commit 9e336e34ab791897ee09f3454044e9167145815c @dbjorge committed Mar 11, 2011
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -9,4 +9,8 @@
android:id="@+id/refresh"
android:icon="@drawable/ic_menu_refresh"
android:title="@string/refresh" />
+ <item
+ android:id="@+id/settings"
+ android:icon="@drawable/ic_menu_preferences"
+ android:title="@string/settings" />
</menu>
View
@@ -6,6 +6,7 @@
<string name="back">Previous Page</string>
<string name="forward">Next Page</string>
<string name="refresh">Refresh</string>
+ <string name="settings">Settings</string>
<string name="go_to">Go to Page</string>
<string name="quote">Quote</string>
<string name="forums_title">Forums</string>
@@ -182,19 +182,20 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
+ case R.id.settings:
+ startActivity(new Intent().setClass(this, SettingsActivity.class));
+ return true;
case R.id.logout:
NetworkUtils.clearLoginCookies(this);
startActivityForResult(new Intent().setClass(this, AwfulLoginActivity.class), 0);
- break;
+ return true;
case R.id.refresh:
mFetchTask = new FetchThreadsTask();
mFetchTask.execute(mForum.getForumId());
- break;
+ return true;
default:
return super.onOptionsItemSelected(item);
}
-
- return true;
}
@Override
@@ -302,18 +302,19 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
+ case R.id.settings:
+ startActivity(new Intent().setClass(this, SettingsActivity.class));
+ return true;
case R.id.logout:
NetworkUtils.clearLoginCookies(this);
startActivityForResult(new Intent().setClass(this, AwfulLoginActivity.class), 0);
- break;
+ return true;
case R.id.refresh:
mLoadTask = new LoadForumsTask();
mLoadTask.execute();
- break;
+ return true;
default:
return super.onOptionsItemSelected(item);
}
-
- return true;
}
}
@@ -29,7 +29,12 @@
import android.os.Bundle;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
+/**
+ * Simple, purely xml driven preferences. Access using
+ * {@link PreferenceManager#getDefaultSharedPreferences(android.content.Context)}
+ */
public class SettingsActivity extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -248,6 +248,9 @@ public void onClick(DialogInterface aDialog, int aWhich) {
mFetchTask = new FetchThreadTask(true);
mFetchTask.execute(mThread);
break;
+ case R.id.settings:
+ startActivity(new Intent().setClass(this, SettingsActivity.class));
+ break;
default:
return super.onOptionsItemSelected(item);
}
@@ -154,6 +154,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
+ case R.id.settings:
+ startActivity(new Intent().setClass(this, SettingsActivity.class));
+ return true;
case R.id.logout:
NetworkUtils.clearLoginCookies(this);
startActivityForResult(new Intent().setClass(this, AwfulLoginActivity.class), 0);

0 comments on commit 9e336e3

Please sign in to comment.