|
12 | 12 | import android.content.ActivityNotFoundException; |
13 | 13 | import android.content.BroadcastReceiver; |
14 | 14 | import android.content.ClipData; |
15 | | -import android.content.ClipboardManager; |
16 | 15 | import android.content.ContentValues; |
17 | 16 | import android.content.Context; |
18 | 17 | import android.content.DialogInterface; |
|
159 | 158 | import net.gnu.util.Mht2Htm; |
160 | 159 | import net.gnu.util.Util; |
161 | 160 | import org.apache.commons.compress.PasswordRequiredException; |
| 161 | +import org.geometerplus.android.fbreader.DictionaryUtil; |
162 | 162 | import org.json.JSONArray; |
163 | 163 | import org.json.JSONException; |
164 | | -import org.geometerplus.android.fbreader.DictionaryUtil; |
165 | 164 |
|
166 | 165 | public class MainActivity extends ParentActivity { |
167 | 166 | private PowerManager.WakeLock mWakeLock; |
@@ -218,16 +217,7 @@ public class MainActivity extends ParentActivity { |
218 | 217 | // //todo jump to the picture view page |
219 | 218 | // } |
220 | 219 | // } |
221 | | - private ClipboardManager mClipboard; |
222 | | - private String clipData = ""; |
223 | 220 |
|
224 | | - private ClipboardManager.OnPrimaryClipChangedListener mPrimaryChangeListener |
225 | | - = new ClipboardManager.OnPrimaryClipChangedListener() { |
226 | | - public void onPrimaryClipChanged() { |
227 | | - updateClipData(true); |
228 | | - } |
229 | | - }; |
230 | | - |
231 | 221 | private static class CrawlerInfo implements Comparable<CrawlerInfo> { |
232 | 222 |
|
233 | 223 | final String url; |
@@ -4003,10 +3993,14 @@ public void onSystemUiVisibilityChange(int p1) { |
4003 | 3993 | updateFullScreen();}}); |
4004 | 3994 | isFullscreen = false; |
4005 | 3995 | isNightMode = prefs.getBoolean("night_mode", false); |
4006 | | - mClipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE); |
4007 | | - mClipboard.addPrimaryClipChangedListener(mPrimaryChangeListener); |
4008 | | - DictionaryUtil.init(this, null); |
4009 | 3996 |
|
| 3997 | + DictionaryUtil.init(this, null); |
| 3998 | + final CharSequence text = getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT); |
| 3999 | + ExceptionLogger.d(TAG, "onCreate text " + text); |
| 4000 | + if (text != null) { |
| 4001 | + DictionaryUtil.openTextInDictionary(MainActivity.this, text+"", false, 100, 10); |
| 4002 | + } |
| 4003 | + |
4010 | 4004 | webviews = (FrameLayout) findViewById(R.id.webviews); |
4011 | 4005 | currentTabIndex = 0; |
4012 | 4006 | address = (ViewGroup)findViewById(R.id.address); |
@@ -4215,16 +4209,6 @@ public void run() { |
4215 | 4209 | dialog.dismiss(); |
4216 | 4210 | } |
4217 | 4211 | })); |
4218 | | - actions.add(new MenuAction("Lookup", 0, new Runnable() { |
4219 | | - @Override |
4220 | | - public void run() { |
4221 | | - if (clipData != null && clipData.length() > 0) { |
4222 | | - DictionaryUtil.openTextInDictionary(MainActivity.this, clipData, false, 100, 10); |
4223 | | - } else { |
4224 | | - Toast.makeText(MainActivity.this, "Nothing to translate", Toast.LENGTH_SHORT).show(); |
4225 | | - } |
4226 | | - } |
4227 | | - })); |
4228 | 4212 | actions.add(new MenuAction("Save as Pdf", 0, new Runnable() { |
4229 | 4213 | @Override |
4230 | 4214 | public void run() { |
@@ -5282,7 +5266,7 @@ public void run() { |
5282 | 5266 | @Override |
5283 | 5267 | protected void onResume() { |
5284 | 5268 | super.onResume(); |
5285 | | - if (printJob != null && printBtnPressed) { |
| 5269 | + if (printJob != null && printBtnPressed) { |
5286 | 5270 | if (printJob.isCompleted()) { |
5287 | 5271 | AndroidUtils.toast(this, "Printing Completed"); |
5288 | 5272 | } else if (printJob.isStarted()) { |
@@ -5322,7 +5306,6 @@ protected void onDestroy() { |
5322 | 5306 | if (placesDb != null) { |
5323 | 5307 | placesDb.close(); |
5324 | 5308 | } |
5325 | | - mClipboard.removePrimaryClipChangedListener(mPrimaryChangeListener); |
5326 | 5309 | } |
5327 | 5310 |
|
5328 | 5311 | @Override |
@@ -5462,33 +5445,6 @@ public void run() { |
5462 | 5445 | } |
5463 | 5446 | } |
5464 | 5447 |
|
5465 | | - void updateClipData(boolean updateType) { |
5466 | | - final ClipData clip = mClipboard.getPrimaryClip(); |
5467 | | -// String[] mimeTypes = clip != null ? clip.getDescription().filterMimeTypes("*/*") : null; |
5468 | | -// if (mimeTypes != null) { |
5469 | | -// mMimeTypes.setText(""); |
5470 | | -// for (int i=0; i<mimeTypes.length; i++) { |
5471 | | -// if (i > 0) { |
5472 | | -// mMimeTypes.append("\n"); |
5473 | | -// } |
5474 | | -// mMimeTypes.append(mimeTypes[i]); |
5475 | | -// } |
5476 | | -// } else { |
5477 | | -// mMimeTypes.setText("NULL"); |
5478 | | -// } |
5479 | | - |
5480 | | - if (clip != null) { |
5481 | | - final ClipData.Item item = clip.getItemAt(0); |
5482 | | - final CharSequence text = item.getText(); |
5483 | | - clipData = text == null ? "" : (text + "").trim(); |
5484 | | - if (autoLookup) { |
5485 | | - if (clipData != null && clipData.length() > 0) { |
5486 | | - DictionaryUtil.openTextInDictionary(this, clipData, false, 100, 10); |
5487 | | - } |
5488 | | - } |
5489 | | - } |
5490 | | - } |
5491 | | - |
5492 | 5448 | //image = null, all=. |
5493 | 5449 | private void log(final String pat, final boolean showImages) { |
5494 | 5450 | final Tab currentTab = getCurrentTab(); |
@@ -6724,7 +6680,13 @@ private void closeTab(WebView webView, final int tabIndex) { |
6724 | 6680 |
|
6725 | 6681 | @Override |
6726 | 6682 | protected void onNewIntent(final Intent intent) { |
6727 | | - loadIntent(intent); |
| 6683 | + final CharSequence text = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT); |
| 6684 | + ExceptionLogger.d(TAG, "onNewIntent text " + text); |
| 6685 | + if (text != null) { |
| 6686 | + DictionaryUtil.openTextInDictionary(MainActivity.this, text+"", false, 100, 10); |
| 6687 | + } else { |
| 6688 | + loadIntent(intent); |
| 6689 | + } |
6728 | 6690 | } |
6729 | 6691 |
|
6730 | 6692 | private void loadIntent(final Intent intent) { |
|
0 commit comments