]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
UI fixes.
authorthadh <thadh@thadh-macbookpro>
Tue, 25 Sep 2012 15:41:39 +0000 (08:41 -0700)
committerthadh <thadh@thadh-macbookpro>
Tue, 25 Sep 2012 15:41:39 +0000 (08:41 -0700)
res/values-de/strings.xml
res/values-it/strings.xml
res/values/strings.xml
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/HtmlDisplayActivity.java
src/com/hughes/android/dictionary/engine/HtmlEntry.java

index 110a49f67294211e074ee566572f54634c6fb000..3f361425799a5e6b9b89d85191ee123230630792 100644 (file)
@@ -40,6 +40,7 @@
   <string name="aboutDictionary">Über Wörterbuch…</string> 
   <string name="randomWord">Random Wort</string> 
   <string name="fontFailure">Font failure: %s</string> 
+  <string name="seeAlso">vgl.: %s</string>
   
   
   <!-- About dictionary. -->
index ac8e3f097284e9445ad33c78fcb63f3ca9d52bd2..44224f62ec87ddd974c5f4c0577db1c67b93d940 100644 (file)
@@ -35,6 +35,7 @@ Rilevato problema di font (comune su apparecchi Sony Ericsson), ritorno a font d
 <string name="aboutDictionary">About dictionary…</string>
 <string name="randomWord">Parola a caso</string>
 <string name="fontFailure">Problema di Font: %s</string>
+<string name="seeAlso">Vedi anche: %s</string>
 <!-- About dictionary. -->
 <string name="dictionaryPath">File: %s</string>
 <string name="dictionarySize">Dimenzione: %,d bytes</string>
index 9023625d6d77b66dd671744fe580d8ca14990fb3..86e5b9c219b77479b8c813aff6ff36326d347263 100644 (file)
@@ -41,6 +41,7 @@
   <string name="aboutDictionary">About dictionary…</string> 
   <string name="randomWord">Random word</string> 
   <string name="fontFailure">Font failure: %s</string> 
+  <string name="seeAlso">See also: %s</string> 
   
 
   <!-- About dictionary. -->
index 01933557837d462c53e2d21898ec5d267da82964..158c1fcb326b5e46533fd53edb1049c20dfb5a04 100644 (file)
@@ -386,6 +386,7 @@ public class DictionaryActivity extends ListActivity {
 
     @Override
     protected void onResume() {
+        Log.d(LOG, "onResume");
         super.onResume();
         if (PreferenceActivity.prefsMightHaveChanged) {
             PreferenceActivity.prefsMightHaveChanged = false;
@@ -395,6 +396,7 @@ public class DictionaryActivity extends ListActivity {
         if (initialSearchText != null) {
             setSearchText(initialSearchText, true);
         }
+        showKeyboard();
     }
 
     @Override
@@ -444,6 +446,10 @@ public class DictionaryActivity extends ListActivity {
 
     private void onClearSearchTextButton() {
         setSearchText("", true);
+        showKeyboard();
+    }
+
+    private void showKeyboard() {
         Log.d(LOG, "Trying to show soft keyboard.");
         final InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
         manager.showSoftInput(searchText, InputMethodManager.SHOW_IMPLICIT);
@@ -1161,30 +1167,33 @@ public class DictionaryActivity extends ListActivity {
             return result;
         }
 
-        private TableLayout getView(HtmlEntry.Row row, ViewGroup parent, final TableLayout result) {
-            final HtmlEntry htmlEntry = row.getEntry();
-            return getPossibleHtmlEntryView(htmlEntry.title, false, Collections.singletonList(htmlEntry), parent, result);
-        }
-
-        private TableLayout getPossibleHtmlEntryView(final String text, final boolean hasMainEntry, final List<HtmlEntry> htmlEntries, ViewGroup parent, final TableLayout result) {
+        private TableLayout getPossibleHtmlEntryView(final boolean isTokenRow, final String text, final boolean hasMainEntry, final List<HtmlEntry> htmlEntries, final String htmlTextToHighlight, ViewGroup parent, final TableLayout result) {
             final Context context = parent.getContext();
             
             final TableRow tableRow = new TableRow(result.getContext());
             tableRow.setBackgroundResource(hasMainEntry ? theme.tokenRowMainBg
                     : theme.tokenRowOtherBg);
-            tableRow.setPadding(mPaddingDefault, mPaddingDefault, mPaddingDefault, 0);
+            if (isTokenRow) {
+                tableRow.setPadding(mPaddingDefault, mPaddingDefault, mPaddingDefault, 0);
+            } else {
+                tableRow.setPadding(mPaddingLarge, mPaddingDefault, mPaddingDefault, 0);
+            }
             result.addView(tableRow);
-            
 
             final TextView textView = new TextView(context);
             textView.setText(text);
             // Doesn't work:
             // textView.setTextColor(android.R.color.secondary_text_light);
-            textView.setTextAppearance(context, theme.tokenRowFg);
             textView.setTypeface(typeface);
-            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 5 * fontSizeSp / 4);
             TableRow.LayoutParams lp = new TableRow.LayoutParams(0);
+            if (isTokenRow) {
+                textView.setTextAppearance(context, theme.tokenRowFg);
+                textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 4 * fontSizeSp / 3);
+            } else {
+                textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSizeSp);
+            }
             lp.weight = 1.0f;
+            
             textView.setLayoutParams(lp);
             tableRow.addView(textView);
 
@@ -1197,7 +1206,7 @@ public class DictionaryActivity extends ListActivity {
                     public void onClick(View v) {
                         final String html = HtmlEntry.htmlBody(htmlEntries);
                         startActivity(HtmlDisplayActivity.getHtmlIntent(String.format(
-                                "<html><head></head><body>%s</body></html>", html), text));
+                                "<html><head></head><body>%s</body></html>", html), htmlTextToHighlight, false));
                     }
                 });
                 tableRow.addView(button);
@@ -1212,9 +1221,16 @@ public class DictionaryActivity extends ListActivity {
         
         private TableLayout getView(TokenRow row, ViewGroup parent, final TableLayout result) {
             final IndexEntry indexEntry = row.getIndexEntry();
-            return getPossibleHtmlEntryView(indexEntry.token, row.hasMainEntry, indexEntry.htmlEntries, parent, result);
+            return getPossibleHtmlEntryView(true, indexEntry.token, row.hasMainEntry, indexEntry.htmlEntries, null, parent, result);
+        }
+        
+        private TableLayout getView(HtmlEntry.Row row, ViewGroup parent, final TableLayout result) {
+            final HtmlEntry htmlEntry = row.getEntry();
+            final TokenRow tokenRow = row.getTokenRow(true);
+            return getPossibleHtmlEntryView(false, getString(R.string.seeAlso, htmlEntry.title), false, Collections.singletonList(htmlEntry), tokenRow.getToken(), parent, result);
         }
 
+
     }
     
 
index f4bc8ce795661808a9dc25d372151521be492bef..a987f5d4146bc85b71387418ecb89e541767760f 100644 (file)
@@ -17,23 +17,23 @@ package com.hughes.android.dictionary;
 import android.app.Activity;\r
 import android.content.Intent;\r
 import android.os.Bundle;\r
-import android.view.ContextMenu;\r
-import android.view.ContextMenu.ContextMenuInfo;\r
-import android.view.MenuItem;\r
-import android.view.MenuItem.OnMenuItemClickListener;\r
+import android.util.Log;\r
 import android.view.View;\r
 import android.view.View.OnClickListener;\r
-import android.view.View.OnCreateContextMenuListener;\r
 import android.webkit.WebView;\r
 import android.widget.Button;\r
 \r
 import com.hughes.util.StringUtil;\r
 \r
 public final class HtmlDisplayActivity extends Activity {\r
+    \r
+  static final String LOG = "QuickDic";\r
+\r
   \r
   static final String HTML_RES = "html_res";\r
   static final String HTML = "html";\r
   static final String TEXT_TO_HIGHLIGHT = "textToHighlight";\r
+  static final String SHOW_OK_BUTTON = "showOKButton";\r
   \r
   public static Intent getHelpLaunchIntent() {\r
     final Intent intent = new Intent();\r
@@ -49,11 +49,12 @@ public final class HtmlDisplayActivity extends Activity {
     return intent;\r
   }\r
 \r
-  public static Intent getHtmlIntent(final String html, final String textToHighlight) {\r
+  public static Intent getHtmlIntent(final String html, final String textToHighlight, final boolean showOkButton) {\r
     final Intent intent = new Intent();\r
     intent.setClassName(HtmlDisplayActivity.class.getPackage().getName(), HtmlDisplayActivity.class.getName());\r
     intent.putExtra(HTML, html);\r
     intent.putExtra(TEXT_TO_HIGHLIGHT, textToHighlight);\r
+    intent.putExtra(SHOW_OK_BUTTON, showOkButton);\r
     return intent;\r
   }\r
 \r
@@ -76,8 +77,11 @@ public final class HtmlDisplayActivity extends Activity {
     webView.loadData(html, "text/html", "utf-8");\r
     \r
     final String textToHighlight = getIntent().getStringExtra(TEXT_TO_HIGHLIGHT);\r
-    if (textToHighlight != null && "".equals(textToHighlight)) {\r
-        webView.findAllAsync(textToHighlight);\r
+    if (textToHighlight != null && !"".equals(textToHighlight)) {\r
+        Log.d(LOG, "Highlighting text: " + textToHighlight);\r
+        // This isn't working:\r
+        webView.findAll(textToHighlight);\r
+        //webView.showFindDialog(textToHighlight, false);\r
     }\r
     \r
     final Button okButton = (Button) findViewById(R.id.okButton);\r
@@ -87,6 +91,9 @@ public final class HtmlDisplayActivity extends Activity {
         finish();\r
       }\r
     });\r
+    if (!getIntent().getBooleanExtra(SHOW_OK_BUTTON, true)) {\r
+        okButton.setVisibility(View.INVISIBLE);\r
+    }\r
   }\r
 \r
 }\r
index 8ff40e362ec13ee0dc43075d722b267d89c6985c..dc5437ba112dd46474813eb1f731f3290c7d71c0 100644 (file)
@@ -141,7 +141,7 @@ public class HtmlEntry extends AbstractEntry implements RAFSerializable<HtmlEntr
     public static String htmlBody(final List<HtmlEntry> htmlEntries) {
         final StringBuilder result = new StringBuilder();
         for (final HtmlEntry htmlEntry : htmlEntries) {
-            result.append(String.format("<h1>%s</h1>%s\n", htmlEntry.title, htmlEntry.html));
+            result.append(String.format("<h1><a href=\"%s\">%s</a></h1>%s\n", htmlEntry.title, htmlEntry.title, htmlEntry.html));
         }
         return result.toString();
     }