Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
Add a menu with back, forward, home, and refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Jan 8, 2012
1 parent 6c1e98d commit d797bf8
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 3 deletions.
19 changes: 17 additions & 2 deletions auxiliary/native/android/gen/edu/ucla/m/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,30 @@ public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
public static final int ic_menu_back=0x7f020000;
public static final int ic_menu_forward=0x7f020001;
public static final int ic_menu_home=0x7f020002;
public static final int ic_menu_refresh=0x7f020003;
public static final int icon=0x7f020004;
}
public static final class id {
public static final int webview=0x7f050000;
public static final int back=0x7f060001;
public static final int forward=0x7f060002;
public static final int home=0x7f060003;
public static final int refresh=0x7f060004;
public static final int webview=0x7f060000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class menu {
public static final int main_menu=0x7f050000;
}
public static final class string {
public static final int app_name=0x7f040000;
public static final int back=0x7f040001;
public static final int forward=0x7f040002;
public static final int home=0x7f040003;
public static final int refresh=0x7f040004;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions auxiliary/native/android/res/menu/main_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/back"
android:icon="@drawable/ic_menu_back"
android:title="@string/back" />
<item android:id="@+id/forward"
android:icon="@drawable/ic_menu_forward"
android:title="@string/forward" />
<item android:id="@+id/home"
android:icon="@drawable/ic_menu_home"
android:title="@string/home" />
<item android:id="@+id/refresh"
android:icon="@drawable/ic_menu_refresh"
android:title="@string/refresh" />
</menu>
4 changes: 4 additions & 0 deletions auxiliary/native/android/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">UCLA Mobile</string>
<string name="back">Back</string>
<string name="forward">Forward</string>
<string name="home">Home</string>
<string name="refresh">Refresh</string>
</resources>
33 changes: 32 additions & 1 deletion auxiliary/native/android/src/edu/ucla/m/MWFWebViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
Expand All @@ -21,7 +24,6 @@ public class MWFWebViewActivity extends Activity {

private ProgressDialog spinnerDialog;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

Expand All @@ -47,7 +49,36 @@ public void onCreate(Bundle savedInstanceState) {

webView.loadUrl(ONLINE_PAGE);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.refresh:
webView.reload();
return true;
case R.id.back:
if (webView.canGoBack())
webView.goBack();
return true;
case R.id.forward:
if (webView.canGoForward())
webView.goForward();
return true;
case R.id.home:
webView.loadUrl(ONLINE_PAGE);
return true;
default:
return super.onOptionsItemSelected(item);
}
}

/**
* Show the spinner. Must be called from the UI thread.
*
Expand Down

0 comments on commit d797bf8

Please sign in to comment.