summaryrefslogtreecommitdiff
path: root/android/src
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2013-04-03 14:09:05 +0100
committerPaul Gardiner <paulg.artifex@glidos.net>2013-04-03 14:10:21 +0100
commit4f7fe4d970af13bbbc92bfa51ca9ddafc760a83c (patch)
tree000e241dba427a55ed6de9e45137149e3f6b3e84 /android/src
parenta2e41dc56a75768b32e0a9085118105a8c3cb17e (diff)
downloadmupdf-4f7fe4d970af13bbbc92bfa51ca9ddafc760a83c.tar.xz
Android: prepare for localisation
Diffstat (limited to 'android/src')
-rw-r--r--android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java4
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFActivity.java52
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFCore.java9
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFPageView.java8
-rw-r--r--android/src/com/artifex/mupdfdemo/ReaderView.java4
-rw-r--r--android/src/com/artifex/mupdfdemo/SearchTask.java2
6 files changed, 40 insertions, 39 deletions
diff --git a/android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java b/android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java
index 6f19a063..06b2fd13 100644
--- a/android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java
+++ b/android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java
@@ -44,7 +44,7 @@ public class ChoosePDFActivity extends ListActivity {
builder.setTitle(R.string.no_media_warning);
builder.setMessage(R.string.no_media_hint);
AlertDialog alert = builder.create();
- alert.setButton(AlertDialog.BUTTON_POSITIVE,"Dismiss",
+ alert.setButton(AlertDialog.BUTTON_POSITIVE,getString(R.string.dismiss),
new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
@@ -114,7 +114,7 @@ public class ChoosePDFActivity extends ListActivity {
adapter.clear();
if (mParent != null)
- adapter.add(new ChoosePDFItem(ChoosePDFItem.Type.PARENT, "[Up one level]"));
+ adapter.add(new ChoosePDFItem(ChoosePDFItem.Type.PARENT, getString(R.string._up_one_level_)));
for (File f : mDirs)
adapter.add(new ChoosePDFItem(ChoosePDFItem.Type.DIR, f.getName()));
for (File f : mFiles)
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
index 4cd3d8a4..56ca9b0c 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
@@ -149,19 +149,19 @@ public class MuPDFActivity extends Activity
switch (result.buttonGroupType)
{
case OkCancel:
- mAlertDialog.setButton(AlertDialog.BUTTON2, "Cancel", listener);
+ mAlertDialog.setButton(AlertDialog.BUTTON2, getString(R.string.cancel), listener);
pressed[1] = MuPDFAlert.ButtonPressed.Cancel;
case Ok:
- mAlertDialog.setButton(AlertDialog.BUTTON1, "Ok", listener);
+ mAlertDialog.setButton(AlertDialog.BUTTON1, getString(R.string.ok), listener);
pressed[0] = MuPDFAlert.ButtonPressed.Ok;
break;
case YesNoCancel:
- mAlertDialog.setButton(AlertDialog.BUTTON3, "Cancel", listener);
+ mAlertDialog.setButton(AlertDialog.BUTTON3, getString(R.string.cancel), listener);
pressed[2] = MuPDFAlert.ButtonPressed.Cancel;
case YesNo:
- mAlertDialog.setButton(AlertDialog.BUTTON1, "Yes", listener);
+ mAlertDialog.setButton(AlertDialog.BUTTON1, getString(R.string.yes), listener);
pressed[0] = MuPDFAlert.ButtonPressed.Yes;
- mAlertDialog.setButton(AlertDialog.BUTTON2, "No", listener);
+ mAlertDialog.setButton(AlertDialog.BUTTON2, getString(R.string.no), listener);
pressed[1] = MuPDFAlert.ButtonPressed.No;
break;
}
@@ -204,7 +204,7 @@ public class MuPDFActivity extends Activity
System.out.println("Trying to open "+path);
try
{
- core = new MuPDFCore(path);
+ core = new MuPDFCore(this, path);
// New file: drop the old outline data
OutlineActivityData.set(null);
}
@@ -221,7 +221,7 @@ public class MuPDFActivity extends Activity
System.out.println("Trying to open byte buffer");
try
{
- core = new MuPDFCore(buffer);
+ core = new MuPDFCore(this, buffer);
// New file: drop the old outline data
OutlineActivityData.set(null);
}
@@ -245,8 +245,8 @@ public class MuPDFActivity extends Activity
if (core == null) {
core = (MuPDFCore)getLastNonConfigurationInstance();
- if (savedInstanceState != null && savedInstanceState.containsKey("FileName")) {
- mFileName = savedInstanceState.getString("FileName");
+ if (savedInstanceState != null && savedInstanceState.containsKey(getString(R.string.filename))) {
+ mFileName = savedInstanceState.getString(getString(R.string.filename));
}
}
if (core == null) {
@@ -286,7 +286,7 @@ public class MuPDFActivity extends Activity
String contentFailure = res.getString(R.string.content_failure);
String openFailed = res.getString(R.string.open_failed);
setTitle(String.format(contentFailure, openFailed, failString));
- alert.setButton(AlertDialog.BUTTON_POSITIVE, "Dismiss",
+ alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.dismiss),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
@@ -318,7 +318,7 @@ public class MuPDFActivity extends Activity
{
AlertDialog alert = mAlertBuilder.create();
alert.setTitle(R.string.open_failed);
- alert.setButton(AlertDialog.BUTTON_POSITIVE, "Dismiss",
+ alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.dismiss),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
@@ -339,7 +339,7 @@ public class MuPDFActivity extends Activity
AlertDialog alert = mAlertBuilder.create();
alert.setTitle(R.string.enter_password);
alert.setView(mPasswordView);
- alert.setButton(AlertDialog.BUTTON_POSITIVE, "Ok",
+ alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (core.authenticatePassword(mPasswordView.getText().toString())) {
@@ -349,7 +349,7 @@ public class MuPDFActivity extends Activity
}
}
});
- alert.setButton(AlertDialog.BUTTON_NEGATIVE, "Cancel",
+ alert.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@@ -603,7 +603,7 @@ public class MuPDFActivity extends Activity
private void toggleReflow() {
reflowModeSet(!mReflow);
- showInfo(mReflow ? "Entering reflow mode" : "Leaving reflow mode");
+ showInfo(mReflow ? getString(R.string.entering_reflow_mode) : getString(R.string.leaving_reflow_mode));
}
@Override
@@ -611,7 +611,7 @@ public class MuPDFActivity extends Activity
super.onSaveInstanceState(outState);
if (mFileName != null && mDocView != null) {
- outState.putString("FileName", mFileName);
+ outState.putString(getString(R.string.filename), mFileName);
// Store current page in the prefs against the file name,
// so that we can pick it up each time the file is loaded
@@ -778,7 +778,7 @@ public class MuPDFActivity extends Activity
Uri docUri = myIntent != null ? myIntent.getData() : null;
if (docUri == null) {
- showInfo("Print failed");
+ showInfo(getString(R.string.print_failed));
}
if (docUri.getScheme() == null)
@@ -848,7 +848,7 @@ public class MuPDFActivity extends Activity
mDocView.setMode(MuPDFReaderView.Mode.Selecting);
mTopBarMode = TopBarMode.Text;
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
- showInfo("Select text");
+ showInfo(getString(R.string.select_text));
}
public void OnCancelSelectButtonClick(View v) {
@@ -868,7 +868,7 @@ public class MuPDFActivity extends Activity
mDocView.setMode(MuPDFReaderView.Mode.Viewing);
mTopBarMode = TopBarMode.Main;
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
- showInfo(copied?"Copied to clipboard":"No text selected");
+ showInfo(copied?getString(R.string.copied_to_clipboard):getString(R.string.no_text_selected));
}
public void OnHighlightButtonClick(View v) {
@@ -880,7 +880,7 @@ public class MuPDFActivity extends Activity
mTopBarMode = TopBarMode.Main;
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
if (!success)
- showInfo("No text selected");
+ showInfo(getString(R.string.no_text_selected));
}
public void OnUnderlineButtonClick(View v) {
@@ -892,7 +892,7 @@ public class MuPDFActivity extends Activity
mTopBarMode = TopBarMode.Main;
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
if (!success)
- showInfo("No text selected");
+ showInfo(getString(R.string.no_text_selected));
}
public void OnStrikeOutButtonClick(View v) {
@@ -904,7 +904,7 @@ public class MuPDFActivity extends Activity
mTopBarMode = TopBarMode.Main;
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
if (!success)
- showInfo("No text selected");
+ showInfo(getString(R.string.no_text_selected));
}
public void OnCancelSearchButtonClick(View v) {
@@ -941,7 +941,7 @@ public class MuPDFActivity extends Activity
mDocView.setMode(MuPDFReaderView.Mode.Drawing);
mTopBarMode = TopBarMode.InkCreate;
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
- showInfo("Draw annotation");
+ showInfo(getString(R.string.draw_annotation));
}
public void OnSaveInkButtonClick(View v) {
@@ -953,7 +953,7 @@ public class MuPDFActivity extends Activity
mTopBarMode = TopBarMode.Main;
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
if (!success)
- showInfo("Nothing to save");
+ showInfo(getString(R.string.nothing_to_save));
}
public void OnCancelInkButtonClick(View v) {
@@ -1046,9 +1046,9 @@ public class MuPDFActivity extends Activity
};
AlertDialog alert = mAlertBuilder.create();
alert.setTitle("MuPDF");
- alert.setMessage("Document has changes. Save them?");
- alert.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", listener);
- alert.setButton(AlertDialog.BUTTON_NEGATIVE, "No", listener);
+ alert.setMessage(getString(R.string.document_has_changes_save_them_));
+ alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.yes), listener);
+ alert.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.no), listener);
alert.show();
} else {
super.onBackPressed();
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFCore.java b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
index 456cd1c5..0d50aacc 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFCore.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
@@ -1,6 +1,7 @@
package com.artifex.mupdfdemo;
import java.util.ArrayList;
+import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.PointF;
@@ -68,23 +69,23 @@ public class MuPDFCore
public static native boolean javascriptSupported();
- public MuPDFCore(String filename) throws Exception
+ public MuPDFCore(Context context, String filename) throws Exception
{
globals = openFile(filename);
if (globals == 0)
{
- throw new Exception("Failed to open "+filename);
+ throw new Exception(context.getString(R.string.failed_to_open_)+filename);
}
file_format = fileFormatInternal();
}
- public MuPDFCore(byte buffer[]) throws Exception
+ public MuPDFCore(Context context, byte buffer[]) throws Exception
{
fileBuffer = buffer;
globals = openBuffer();
if (globals == 0)
{
- throw new Exception("Failed to open buffer");
+ throw new Exception(context.getString(R.string.failed_to_open_buffer));
}
file_format = fileFormatInternal();
}
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFPageView.java b/android/src/com/artifex/mupdfdemo/MuPDFPageView.java
index cb3fac0b..b4d816ac 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFPageView.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFPageView.java
@@ -81,16 +81,16 @@ public class MuPDFPageView extends PageView implements MuPDFView {
super(c, parentSize);
mCore = core;
mTextEntryBuilder = new AlertDialog.Builder(c);
- mTextEntryBuilder.setTitle("MuPDF: fill out text field");
+ mTextEntryBuilder.setTitle("MuPDF: "+getContext().getString(R.string.fill_out_text_field));
LayoutInflater inflater = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mEditText = (EditText)inflater.inflate(R.layout.textentry, null);
mTextEntryBuilder.setView(mEditText);
- mTextEntryBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ mTextEntryBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
- mTextEntryBuilder.setPositiveButton("Okay", new DialogInterface.OnClickListener() {
+ mTextEntryBuilder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
mSetWidgetText = new AsyncTask<String,Void,Boolean> () {
@Override
@@ -111,7 +111,7 @@ public class MuPDFPageView extends PageView implements MuPDFView {
mTextEntry = mTextEntryBuilder.create();
mChoiceEntryBuilder = new AlertDialog.Builder(c);
- mChoiceEntryBuilder.setTitle("MuPDF: choose value");
+ mChoiceEntryBuilder.setTitle("MuPDF: "+getContext().getString(R.string.choose_value));
}
public LinkInfo hitLink(float x, float y) {
diff --git a/android/src/com/artifex/mupdfdemo/ReaderView.java b/android/src/com/artifex/mupdfdemo/ReaderView.java
index 4df67ed0..2c7287f4 100644
--- a/android/src/com/artifex/mupdfdemo/ReaderView.java
+++ b/android/src/com/artifex/mupdfdemo/ReaderView.java
@@ -658,7 +658,7 @@ public class ReaderView extends AdapterView<Adapter>
@Override
public View getSelectedView() {
- throw new UnsupportedOperationException("Not supported");
+ throw new UnsupportedOperationException(getContext().getString(R.string.not_supported));
}
@Override
@@ -671,7 +671,7 @@ public class ReaderView extends AdapterView<Adapter>
@Override
public void setSelection(int arg0) {
- throw new UnsupportedOperationException("Not supported");
+ throw new UnsupportedOperationException(getContext().getString(R.string.not_supported));
}
private View getCached() {
diff --git a/android/src/com/artifex/mupdfdemo/SearchTask.java b/android/src/com/artifex/mupdfdemo/SearchTask.java
index c6548d1f..ae7951af 100644
--- a/android/src/com/artifex/mupdfdemo/SearchTask.java
+++ b/android/src/com/artifex/mupdfdemo/SearchTask.java
@@ -92,7 +92,7 @@ public abstract class SearchTask {
} else {
mAlertBuilder.setTitle(SearchTaskResult.get() == null ? R.string.text_not_found : R.string.no_further_occurences_found);
AlertDialog alert = mAlertBuilder.create();
- alert.setButton(AlertDialog.BUTTON_POSITIVE, "Dismiss",
+ alert.setButton(AlertDialog.BUTTON_POSITIVE, mContext.getString(R.string.dismiss),
(DialogInterface.OnClickListener)null);
alert.show();
}