Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: srynot4sale/jarvis-android
base: 1fc7b9e69a
...
head fork: srynot4sale/jarvis-android
compare: b33b9b20c3
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
2  AndroidManifest.xml
View
@@ -17,7 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nz.net.io.jarvis"
android:versionCode="1"
- android:versionName="1.0">
+ android:versionName="1.0.12">
<application android:icon="@drawable/app_icon" android:label="@string/app_name"
android:description="@string/app_descrip">
BIN  res/drawable/app_icon.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 res/menu/lookup.xml
View
@@ -26,4 +26,10 @@
android:title="@string/lookup_about"
android:icon="@android:drawable/ic_menu_help" />
+ <item
+ android:id="@+id/lookup_help"
+ android:title="@string/lookup_help"
+ android:icon="@android:drawable/ic_menu_help" />
+
+
</menu>
1  res/values/strings.xml
View
@@ -51,5 +51,6 @@
<string name="lookup_about">About</string>
<string name="empty_result">No entry found for this word, or problem reading data.</string>
+ <string name="lookup_help">Help</string>
</resources>
18 src/nz/net/io/jarvis/BaseActivity.java
View
@@ -19,6 +19,7 @@
import android.widget.TextView;
import java.util.Stack;
+import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
@@ -38,6 +39,10 @@
protected Animation mSlideIn;
protected Animation mSlideOut;
+ protected String function;
+ protected String action;
+ protected String data;
+
/**
* History stack of previous words browsed in this session. This is
* referenced when the user taps the "back" key, to possibly intercept and
@@ -131,6 +136,16 @@ protected void setEntryTitle(String entryText) {
mEntryTitle = entryText;
mTitle.setText(mEntryTitle);
}
+
+ Pattern pattern = Pattern.compile("/");
+ String[] parts = pattern.split(entryText, 4);
+ function = parts[1];
+ action = parts[2];
+ if (parts.length > 3) {
+ data = parts[3];
+ } else {
+ data = "";
+ }
}
/**
@@ -144,6 +159,7 @@ protected void setEntryContent(String entryContent) {
html += "div#body { margin-left: 2px; padding: 3px; font-size: 17px; color: #fff; background:rgba(0, 0, 0, 0.5); }";
html += "h3, p, ul { display: block; padding: 1px 10px; }";
html += "ul { padding-left: 30px; }";
+ html += "li { padding-bottom: 5px; }";
html += "a { color: #fff; }";
html += "</style>";
html += "<div id=\"body\">";
@@ -180,7 +196,7 @@ protected void setEntryContent(String entryContent) {
html = html + "<li>";
while (j < item.length()) {
if (j > 0) {
- html = html + "|";
+ html = html + " | ";
}
html = html + item.getString(j);
j++;
56 src/nz/net/io/jarvis/GraphicalActivity.java
View
@@ -6,22 +6,17 @@
package nz.net.io.jarvis;
-import android.app.AlertDialog;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
-import android.widget.TextView;
/**
@@ -118,55 +113,6 @@ public boolean dispatchKeyEvent(KeyEvent event) {
}
/**
- * {@inheritDoc}
- */
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.lookup, menu);
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.lookup_apicall: {
- onSearchRequested();
- return true;
- }
- case R.id.lookup_about: {
- showAbout();
- return true;
- }
- }
- return false;
- }
-
- /**
- * Show an about dialog that cites data sources.
- */
- protected void showAbout() {
- // Inflate the about message contents
- View messageView = getLayoutInflater().inflate(R.layout.about, null, false);
-
- // When linking text, force to always use default color. This works
- // around a pressed color state bug.
- TextView textView = (TextView) messageView.findViewById(R.id.about_credits);
- int defaultColor = textView.getTextColors().getDefaultColor();
- textView.setTextColor(defaultColor);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setIcon(R.drawable.app_icon);
- builder.setTitle(R.string.app_name);
- builder.setView(messageView);
- builder.create();
- builder.show();
- }
-
- /**
* Because we're singleTop, we handle our own new intents. These usually
* come from the {@link SearchManager} when a search is requested, or from
* internal links the user clicks on.
@@ -228,7 +174,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
public void onClick(View v) {
Button b = (Button)v;
String buttonText = b.getText().toString();
- openLookup(buttonText+" help");
+ openLookup(buttonText+" default");
}
});
34 src/nz/net/io/jarvis/LookupActivity.java
View
@@ -21,11 +21,13 @@
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
+import android.view.MenuItem;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.widget.ProgressBar;
import android.widget.TextView;
+
/**
* Activity that lets users browse through Wiktionary content. This is just the
* user interface, and all API communication and parsing is handled in
@@ -139,4 +141,36 @@ public void onNewIntent(Intent intent) {
startNavigating(null, true);
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.lookup_apicall: {
+ onSearchRequested();
+ return true;
+ }
+ case R.id.lookup_help: {
+ openHelp();
+ return true;
+ }
+ case R.id.lookup_about: {
+ showAbout();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void openHelp() {
+ String func;
+ if (function.length() > 0) {
+ func = function;
+ } else {
+ func = "server";
+ }
+ startNavigating(func+" help", true);
+ }
}

No commit comments for this range

Something went wrong with that request. Please try again.