<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_selected="true" android:drawable="@android:color/transparent" />
- <item android:drawable="@color/theme_default_normal_row_bg" />
-</selector>
\ No newline at end of file
+ <item android:state_selected="true" android:drawable="@android:color/transparent" />
+ <item android:drawable="@color/theme_default_normal_row_bg" />
+</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_selected="true" android:drawable="@android:color/transparent" />
- <item android:drawable="@color/theme_default_token_row_main_bg" />
-</selector>
\ No newline at end of file
+ <item android:state_selected="true" android:drawable="@android:color/transparent" />
+ <item android:drawable="@color/theme_default_token_row_main_bg" />
+</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_selected="true" android:drawable="@android:color/transparent" />
- <item android:drawable="@color/theme_default_token_row_other_bg" />
-</selector>
\ No newline at end of file
+ <item android:state_selected="true" android:drawable="@android:color/transparent" />
+ <item android:drawable="@color/theme_default_token_row_other_bg" />
+</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_selected="true" android:drawable="@android:color/transparent" />
- <item android:drawable="@color/theme_light_normal_row_bg" />
-</selector>
\ No newline at end of file
+ <item android:state_selected="true" android:drawable="@android:color/transparent" />
+ <item android:drawable="@color/theme_light_normal_row_bg" />
+</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_selected="true" android:drawable="@android:color/transparent" />
- <item android:drawable="@color/theme_light_token_row_main_bg" />
-</selector>
\ No newline at end of file
+ <item android:state_selected="true" android:drawable="@android:color/transparent" />
+ <item android:drawable="@color/theme_light_token_row_main_bg" />
+</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_selected="true" android:drawable="@android:color/transparent" />
- <item android:drawable="@color/theme_light_token_row_other_bg" />
-</selector>
\ No newline at end of file
+ <item android:state_selected="true" android:drawable="@android:color/transparent" />
+ <item android:drawable="@color/theme_light_token_row_other_bg" />
+</selector>
android:layout_height="wrap_content"
android:text="@string/contactMe"
android:textAppearance="?android:attr/textAppearanceSmall" />
-
+
<TextView
android:id="@+id/email"
android:layout_width="wrap_content"
<ScrollView android:id="@+id/ScrollView01"
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
+ android:layout_width="fill_parent"
android:layout_height="fill_parent">
-
- <TextView
+
+ <TextView
android:id="@+id/text"
- android:layout_width="wrap_content"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
android:layout_height="fill_parent"
android:orientation="vertical" >
- <!--
-
+ <!--
+
<LinearLayout
android:id="@+id/SearchBarLinearLayout"
android:layout_width="fill_parent"
</LinearLayout>
-->
-
+
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="@string/noSearchResults" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
</LinearLayout>
<!--
- http://stackoverflow.com/questions/11243867/android-last-line-of-textview-cut-off
+ http://stackoverflow.com/questions/11243867/android-last-line-of-textview-cut-off
-->
<TextView
android:id="@+id/dictionaryName"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
-
+
<com.hughes.android.dictionary.MyWebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@android:string/ok" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
- <ListView
- android:id="@id/android:list"
+ <ListView
+ android:id="@id/android:list"
android:layout_width="fill_parent"
- android:layout_height="0dip"
+ android:layout_height="0dip"
android:choiceMode="singleChoice"
- android:clickable="true"
+ android:clickable="true"
android:focusable="true"
android:layout_weight="1.0"
/>
<item>Weiß-Theme</item>
<item>Standard-Theme</item>
</string-array>
-
+
</resources>
<string name="nextWord">Nächstes Wort</string>
<string name="previousWord">Voriges Wort</string>
<string name="randomWord">Zufälliges Wort</string>
-
+
<!-- About dictionary. -->
<string name="dictionaryPath">Datei: %s</string>
<string name="dictionarySize">Größe: %,d bytes</string>
<string name="themeTitle">Farbschema</string>
<string name="themeSummary">Auswahl des Farbschemas für das Wörterbuch und die Menüs.</string>
<string name="chosenNotWritable">Chosen directory not writable, try one of</string>
-
+
</resources>
<item>Tema luminoso</item>
<item>Tema predeterminado</item>
</string-array>
-
+
</resources>
<!-- Download. -->
<string name="downloadFailed">Error descargando archivo: \n%s</string>
- <string name="downloadManagerQueryFailed">No se pudo consultar con el gestor de descargas.\nEstá deshabilitado o no se encuentra</string>
+ <string name="downloadManagerQueryFailed">No se pudo consultar con el gestor de descargas.\nEstá deshabilitado o no se encuentra</string>
<string name="unzippingDictionary">Descomprimiendo diccionario: \n%s</string>
<string name="unzippingFailed">Error descomprimiendo diccionario: \n%s</string>
<string name="installationFinished">Terminado: \n%s.</string>
<string name="help">Guida</string>
<string name="reportIssue">Segnala problema…</string>
<string name="no_dict_file">Please specify a default directory in the settings.</string>
-
+
<!-- DictionaryManagerActivity -->
<string name="dictionaryManager">Gestione dizionari</string>
<string name="dictionariesOnDevice">Dizionari sul dispositivo</string>
<string name="speak">Pronuncia</string>
<string name="nextWord">Next word</string>
<string name="previousWord">Previous word</string>
-
+
<!-- About dictionary. -->
<string name="dictionaryPath">File: %s</string>
<string name="dictionarySize">Dimenzione: %,d bytes</string>
<!-- About. -->
<string name="contactMe">Grazie a Fabio per la traduzione in italiano!
-Se stai usando QuickDic, mi piacerebbe saperlo.
-Sfortunatamente, non ho responsabilità circa il contenuto del dizionario
-(al difuori della formattazione), in quanto è creato con altre sorgenti.
-Per favore inviami (in inglese) commenti, suggerimenti,
+Se stai usando QuickDic, mi piacerebbe saperlo.
+Sfortunatamente, non ho responsabilità circa il contenuto del dizionario
+(al difuori della formattazione), in quanto è creato con altre sorgenti.
+Per favore inviami (in inglese) commenti, suggerimenti,
segnalazioni di bug o semplicemente un breve saluto a:</string>
<string name="webPage">Per più informazioni, guarda:</string>
<string name="contributionsFrom">Contributions from:</string>
<item>ライト テーマ</item>
<item>デフォルト テーマ</item>
</string-array>
-
+
</resources>
<resources>
-
+
<style name="AppBaseThemeLight" parent="@style/Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
backward-compatibility can go here.
-->
</style>
-
+
<style name="AppBaseThemeDark" parent="@style/Theme.AppCompat">
<!--
Theme customizations available in newer API levels can go in
<resources>
-
+
</resources>
<item>Light theme</item>
<item>Default theme</item>
</string-array>
-
+
</resources>
-// Copyright 2011 Google Inc. All Rights Reserved.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the "License");\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-\r
-package com.hughes.android.dictionary;\r
-\r
-import android.app.Activity;\r
-import android.content.pm.PackageInfo;\r
-import android.content.pm.PackageManager;\r
-import android.os.Bundle;\r
-import android.widget.TextView;\r
-\r
-public final class AboutActivity extends Activity {\r
-\r
- public static final String CURRENT_DICT_INFO = "currentDictInfo";\r
-\r
- /** Called when the activity is first created. */\r
- @Override\r
- public void onCreate(final Bundle savedInstanceState) {\r
- setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId);\r
-\r
- super.onCreate(savedInstanceState);\r
- setContentView(R.layout.about_activity);\r
- String ver = "???";\r
- try {\r
- PackageManager pm = getPackageManager();\r
- if (pm != null) {\r
- PackageInfo p = pm.getPackageInfo(getPackageName(), 0);\r
- ver = p.versionName + " (ID " + p.versionCode + ")";\r
- }\r
- } catch (Exception e) {\r
- }\r
- TextView titleView = (TextView)findViewById(R.id.titleText);\r
- titleView.setText("QuickDic " + ver);\r
- }\r
-\r
-}\r
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.hughes.android.dictionary;
+
+import android.app.Activity;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.widget.TextView;
+
+public final class AboutActivity extends Activity {
+
+ public static final String CURRENT_DICT_INFO = "currentDictInfo";
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(final Bundle savedInstanceState) {
+ setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId);
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.about_activity);
+ String ver = "???";
+ try {
+ PackageManager pm = getPackageManager();
+ if (pm != null) {
+ PackageInfo p = pm.getPackageInfo(getPackageName(), 0);
+ ver = p.versionName + " (ID " + p.versionCode + ")";
+ }
+ } catch (Exception e) {
+ }
+ TextView titleView = (TextView)findViewById(R.id.titleText);
+ titleView.setText("QuickDic " + ver);
+ }
+
+}
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
-
+
final LinearLayout customSearchView = new LinearLayout(getSupportActionBar().getThemedContext());
-
+
final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
customSearchView.setLayoutParams(layoutParams);
result.setFocusable(true);
result.setLongClickable(true);
// result.setBackgroundResource(android.R.drawable.menuitem_background);
-
+
result.setBackgroundResource(theme.normalRowBg);
result.setOnClickListener(new TextView.OnClickListener() {
final List<String> dictionaryFilesOrdered = new ArrayList<String>();
final Map<String, DictionaryInfo> uncompressedFilenameToDictionaryInfo = new LinkedHashMap<String, DictionaryInfo>();
-
+
/**
* Sometimes a deserialized version of this data structure isn't valid.
* @return
Log.w(LOG, "Download finished: " + dest + " Id: " + downloadId);
Toast.makeText(context, getString(R.string.unzippingDictionary, dest),
Toast.LENGTH_LONG).show();
-
-
+
+
final Uri zipUri = Uri.parse(dest);
File localZipFile = null;
InputStream zipFileStream = null;
-// Copyright 2011 Google Inc. All Rights Reserved.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the "License");\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-\r
-package com.hughes.android.dictionary;\r
-\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.os.Bundle;\r
-import android.support.v7.app.ActionBar;\r
-import android.support.v7.app.ActionBarActivity;\r
-import android.util.Base64;\r
-import android.util.Log;\r
-import android.view.MenuItem;\r
-import android.view.View;\r
-import android.view.View.OnClickListener;\r
-import android.widget.Button;\r
-\r
-import com.hughes.util.StringUtil;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.UnsupportedEncodingException;\r
-\r
-public final class HtmlDisplayActivity extends ActionBarActivity {\r
-\r
- static final String LOG = "QuickDic";\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(Context c) {\r
- final Intent intent = new Intent(c, HtmlDisplayActivity.class);\r
- intent.putExtra(HTML_RES, R.raw.help);\r
- return intent;\r
- }\r
-\r
- public static Intent getWhatsNewLaunchIntent(Context c) {\r
- final Intent intent = new Intent(c, HtmlDisplayActivity.class);\r
- intent.putExtra(HTML_RES, R.raw.whats_new);\r
- return intent;\r
- }\r
-\r
- public static Intent getHtmlIntent(Context c, final String html, final String textToHighlight,\r
- final boolean showOkButton) {\r
- final Intent intent = new Intent(c, HtmlDisplayActivity.class);\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
- /** Called when the activity is first created. */\r
- @Override\r
- public void onCreate(final Bundle savedInstanceState) {\r
- setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId);\r
-\r
- super.onCreate(savedInstanceState);\r
- setContentView(R.layout.html_display_activity);\r
- \r
- ActionBar actionBar = getSupportActionBar();\r
- actionBar.setDisplayHomeAsUpEnabled(true);\r
-\r
- final int htmlRes = getIntent().getIntExtra(HTML_RES, -1);\r
- String html;\r
- if (htmlRes != -1) {\r
- InputStream res = getResources().openRawResource(htmlRes);\r
- html = StringUtil.readToString(res);\r
- try {\r
- res.close();\r
- } catch (IOException e) {\r
- }\r
- } else {\r
- html = getIntent().getStringExtra(HTML);\r
- }\r
- final MyWebView webView = (MyWebView) findViewById(R.id.webView);\r
- try {\r
- // No way to get pure UTF-8 data into WebView\r
- html = Base64.encodeToString(html.getBytes("UTF-8"), Base64.DEFAULT);\r
- } catch (UnsupportedEncodingException e) {\r
- throw new RuntimeException("Missing UTF-8 support?!", e);\r
- }\r
- // Use loadURL to allow specifying a charset\r
- webView.loadUrl("data:text/html;charset=utf-8;base64," + html);\r
- webView.activity = this;\r
-\r
- final String textToHighlight = getIntent().getStringExtra(TEXT_TO_HIGHLIGHT);\r
- if (textToHighlight != null && !"".equals(textToHighlight)) {\r
- Log.d(LOG, "NOT 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
- okButton.setOnClickListener(new OnClickListener() {\r
- @Override\r
- public void onClick(View v) {\r
- finish();\r
- }\r
- });\r
- if (!getIntent().getBooleanExtra(SHOW_OK_BUTTON, true)) {\r
- okButton.setVisibility(Button.GONE);\r
- }\r
- }\r
-\r
- @Override\r
- public void onBackPressed() {\r
- final MyWebView webView = (MyWebView)findViewById(R.id.webView);\r
- if (webView.canGoBack()) webView.goBack();\r
- else super.onBackPressed();\r
- }\r
-\r
- @Override\r
- public boolean onOptionsItemSelected(MenuItem item) {\r
- // Explicitly handle the up button press so\r
- // we return to the dictionary.\r
- if (item.getItemId() == android.R.id.home)\r
- {\r
- finish();\r
- return true;\r
- }\r
- return super.onOptionsItemSelected(item);\r
- }\r
-}\r
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.hughes.android.dictionary;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarActivity;
+import android.util.Base64;
+import android.util.Log;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+
+import com.hughes.util.StringUtil;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+public final class HtmlDisplayActivity extends ActionBarActivity {
+
+ static final String LOG = "QuickDic";
+
+ static final String HTML_RES = "html_res";
+ static final String HTML = "html";
+ static final String TEXT_TO_HIGHLIGHT = "textToHighlight";
+ static final String SHOW_OK_BUTTON = "showOKButton";
+
+ public static Intent getHelpLaunchIntent(Context c) {
+ final Intent intent = new Intent(c, HtmlDisplayActivity.class);
+ intent.putExtra(HTML_RES, R.raw.help);
+ return intent;
+ }
+
+ public static Intent getWhatsNewLaunchIntent(Context c) {
+ final Intent intent = new Intent(c, HtmlDisplayActivity.class);
+ intent.putExtra(HTML_RES, R.raw.whats_new);
+ return intent;
+ }
+
+ public static Intent getHtmlIntent(Context c, final String html, final String textToHighlight,
+ final boolean showOkButton) {
+ final Intent intent = new Intent(c, HtmlDisplayActivity.class);
+ intent.putExtra(HTML, html);
+ intent.putExtra(TEXT_TO_HIGHLIGHT, textToHighlight);
+ intent.putExtra(SHOW_OK_BUTTON, showOkButton);
+ return intent;
+ }
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(final Bundle savedInstanceState) {
+ setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId);
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.html_display_activity);
+
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ final int htmlRes = getIntent().getIntExtra(HTML_RES, -1);
+ String html;
+ if (htmlRes != -1) {
+ InputStream res = getResources().openRawResource(htmlRes);
+ html = StringUtil.readToString(res);
+ try {
+ res.close();
+ } catch (IOException e) {
+ }
+ } else {
+ html = getIntent().getStringExtra(HTML);
+ }
+ final MyWebView webView = (MyWebView) findViewById(R.id.webView);
+ try {
+ // No way to get pure UTF-8 data into WebView
+ html = Base64.encodeToString(html.getBytes("UTF-8"), Base64.DEFAULT);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("Missing UTF-8 support?!", e);
+ }
+ // Use loadURL to allow specifying a charset
+ webView.loadUrl("data:text/html;charset=utf-8;base64," + html);
+ webView.activity = this;
+
+ final String textToHighlight = getIntent().getStringExtra(TEXT_TO_HIGHLIGHT);
+ if (textToHighlight != null && !"".equals(textToHighlight)) {
+ Log.d(LOG, "NOT Highlighting text: " + textToHighlight);
+ // This isn't working:
+ // webView.findAll(textToHighlight);
+ // webView.showFindDialog(textToHighlight, false);
+ }
+
+ final Button okButton = (Button) findViewById(R.id.okButton);
+ okButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ });
+ if (!getIntent().getBooleanExtra(SHOW_OK_BUTTON, true)) {
+ okButton.setVisibility(Button.GONE);
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ final MyWebView webView = (MyWebView)findViewById(R.id.webView);
+ if (webView.canGoBack()) webView.goBack();
+ else super.onBackPressed();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Explicitly handle the up button press so
+ // we return to the dictionary.
+ if (item.getItemId() == android.R.id.home)
+ {
+ finish();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
public void onCreate(Bundle savedInstanceState) {
final DictionaryApplication application = (DictionaryApplication) getApplication();
setTheme(application.getSelectedTheme().themeId);
-
+
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getString(getString(R.string.quickdicDirectoryKey), "").equals("")) {
prefs.edit().putString(getString(R.string.quickdicDirectoryKey), application.getDictDir().getAbsolutePath()).commit();
// limitations under the License.
/**
- *
+ *
*/
package com.hughes.android.dictionary.engine;
-// Copyright 2011 Google Inc. All Rights Reserved.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the "License");\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-\r
-package com.hughes.android.dictionary.engine;\r
-\r
-import com.hughes.android.dictionary.DictionaryApplication;\r
-import java.text.Collator;\r
-\r
-import java.util.Comparator;\r
-import java.util.LinkedHashMap;\r
-import java.util.Locale;\r
-import java.util.Map;\r
-import java.util.regex.Pattern;\r
-\r
-public class Language {\r
-\r
- public static final class LanguageResources {\r
- public final String englishName;\r
- public final int nameId;\r
- public final int flagId;\r
-\r
- public LanguageResources(final String englishName, int nameId, int flagId) {\r
- this.englishName = englishName;\r
- this.nameId = nameId;\r
- this.flagId = flagId;\r
- }\r
-\r
- public LanguageResources(final String englishName, int nameId) {\r
- this(englishName, nameId, 0);\r
- }\r
- }\r
-\r
- private static final Map<String, Language> registry = new LinkedHashMap<String, Language>();\r
-\r
- final String isoCode;\r
- final Locale locale;\r
-\r
- private Collator collator;\r
-\r
- private Language(final Locale locale, final String isoCode) {\r
- this.locale = locale;\r
- this.isoCode = isoCode;\r
-\r
- registry.put(isoCode.toLowerCase(), this);\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return locale.toString();\r
- }\r
-\r
- public String getIsoCode() {\r
- return isoCode;\r
- }\r
-\r
- public synchronized Comparator getCollator() {\r
- if (!DictionaryApplication.USE_COLLATOR)\r
- return String.CASE_INSENSITIVE_ORDER;\r
- // Don't think this is thread-safe...\r
- // if (collator == null) {\r
- this.collator = Collator.getInstance(locale);\r
- this.collator.setStrength(Collator.IDENTICAL);\r
- // }\r
- return collator;\r
- }\r
-\r
- public String getDefaultNormalizerRules() {\r
- return ":: Any-Latin; ' ' > ; :: Lower; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC ;";\r
- }\r
-\r
- /**\r
- * A practical pattern to identify strong RTL characters. This pattern is\r
- * not completely correct according to the Unicode standard. It is\r
- * simplified for performance and small code size.\r
- */\r
- private static final String rtlChars =\r
- "\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC";\r
-\r
- private static final String puncChars =\r
- "\\[\\]\\(\\)\\{\\}\\=";\r
-\r
- private static final Pattern RTL_LEFT_BOUNDARY = Pattern.compile("([" + puncChars + "])(["\r
- + rtlChars + "])");\r
- private static final Pattern RTL_RIGHT_BOUNDARY = Pattern.compile("([" + rtlChars + "])(["\r
- + puncChars + "])");\r
-\r
- public static String fixBidiText(String text) {\r
- // text = RTL_LEFT_BOUNDARY.matcher(text).replaceAll("$1\u200e $2");\r
- // text = RTL_RIGHT_BOUNDARY.matcher(text).replaceAll("$1 \u200e$2");\r
- return text;\r
- }\r
-\r
- // ----------------------------------------------------------------\r
-\r
- public static final Language en = new Language(Locale.ENGLISH, "EN");\r
- public static final Language fr = new Language(Locale.FRENCH, "FR");\r
- public static final Language it = new Language(Locale.ITALIAN, "IT");\r
-\r
- public static final Language de = new Language(Locale.GERMAN, "DE") {\r
- @Override\r
- public String getDefaultNormalizerRules() {\r
- return ":: Lower; 'ae' > 'ä'; 'oe' > 'ö'; 'ue' > 'ü'; 'ß' > 'ss'; ";\r
- }\r
- };\r
-\r
- // ----------------------------------------------------------------\r
-\r
- public static synchronized Language lookup(final String isoCode) {\r
- Language lang = registry.get(isoCode.toLowerCase());\r
- if (lang == null) {\r
- lang = new Language(new Locale(isoCode), isoCode);\r
- }\r
- return lang;\r
- }\r
-\r
-}\r
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.hughes.android.dictionary.engine;
+
+import com.hughes.android.dictionary.DictionaryApplication;
+import java.text.Collator;
+
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class Language {
+
+ public static final class LanguageResources {
+ public final String englishName;
+ public final int nameId;
+ public final int flagId;
+
+ public LanguageResources(final String englishName, int nameId, int flagId) {
+ this.englishName = englishName;
+ this.nameId = nameId;
+ this.flagId = flagId;
+ }
+
+ public LanguageResources(final String englishName, int nameId) {
+ this(englishName, nameId, 0);
+ }
+ }
+
+ private static final Map<String, Language> registry = new LinkedHashMap<String, Language>();
+
+ final String isoCode;
+ final Locale locale;
+
+ private Collator collator;
+
+ private Language(final Locale locale, final String isoCode) {
+ this.locale = locale;
+ this.isoCode = isoCode;
+
+ registry.put(isoCode.toLowerCase(), this);
+ }
+
+ @Override
+ public String toString() {
+ return locale.toString();
+ }
+
+ public String getIsoCode() {
+ return isoCode;
+ }
+
+ public synchronized Comparator getCollator() {
+ if (!DictionaryApplication.USE_COLLATOR)
+ return String.CASE_INSENSITIVE_ORDER;
+ // Don't think this is thread-safe...
+ // if (collator == null) {
+ this.collator = Collator.getInstance(locale);
+ this.collator.setStrength(Collator.IDENTICAL);
+ // }
+ return collator;
+ }
+
+ public String getDefaultNormalizerRules() {
+ return ":: Any-Latin; ' ' > ; :: Lower; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC ;";
+ }
+
+ /**
+ * A practical pattern to identify strong RTL characters. This pattern is
+ * not completely correct according to the Unicode standard. It is
+ * simplified for performance and small code size.
+ */
+ private static final String rtlChars =
+ "\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC";
+
+ private static final String puncChars =
+ "\\[\\]\\(\\)\\{\\}\\=";
+
+ private static final Pattern RTL_LEFT_BOUNDARY = Pattern.compile("([" + puncChars + "])(["
+ + rtlChars + "])");
+ private static final Pattern RTL_RIGHT_BOUNDARY = Pattern.compile("([" + rtlChars + "])(["
+ + puncChars + "])");
+
+ public static String fixBidiText(String text) {
+ // text = RTL_LEFT_BOUNDARY.matcher(text).replaceAll("$1\u200e $2");
+ // text = RTL_RIGHT_BOUNDARY.matcher(text).replaceAll("$1 \u200e$2");
+ return text;
+ }
+
+ // ----------------------------------------------------------------
+
+ public static final Language en = new Language(Locale.ENGLISH, "EN");
+ public static final Language fr = new Language(Locale.FRENCH, "FR");
+ public static final Language it = new Language(Locale.ITALIAN, "IT");
+
+ public static final Language de = new Language(Locale.GERMAN, "DE") {
+ @Override
+ public String getDefaultNormalizerRules() {
+ return ":: Lower; 'ae' > 'ä'; 'oe' > 'ö'; 'ue' > 'ü'; 'ß' > 'ss'; ";
+ }
+ };
+
+ // ----------------------------------------------------------------
+
+ public static synchronized Language lookup(final String isoCode) {
+ Language lang = registry.get(isoCode.toLowerCase());
+ if (lang == null) {
+ lang = new Language(new Locale(isoCode), isoCode);
+ }
+ return lang;
+ }
+
+}