1 // Copyright 2011 Google Inc. All Rights Reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 package com.hughes.android.dictionary;
17 import android.Manifest;
18 import android.app.AlertDialog;
19 import android.app.DownloadManager;
20 import android.app.DownloadManager.Request;
21 import android.content.BroadcastReceiver;
22 import android.content.ContentResolver;
23 import android.content.Context;
24 import android.content.Intent;
25 import android.content.IntentFilter;
26 import android.content.SharedPreferences;
27 import android.content.SharedPreferences.Editor;
28 import android.content.pm.PackageManager;
29 import android.database.Cursor;
30 import android.net.Uri;
31 import android.os.Bundle;
32 import android.os.Environment;
33 import android.os.Handler;
34 import android.preference.PreferenceManager;
35 import android.provider.Settings;
36 import android.support.v4.app.ActivityCompat;
37 import android.support.v4.content.ContextCompat;
38 import android.support.v4.view.MenuItemCompat;
39 import android.support.v7.app.ActionBar;
40 import android.support.v7.app.ActionBarActivity;
41 import android.support.v7.widget.SearchView;
42 import android.support.v7.widget.SearchView.OnQueryTextListener;
43 import android.support.v7.widget.Toolbar;
44 import android.text.InputType;
45 import android.util.Log;
46 import android.util.TypedValue;
47 import android.view.ContextMenu;
48 import android.view.ContextMenu.ContextMenuInfo;
49 import android.view.LayoutInflater;
50 import android.view.Menu;
51 import android.view.MenuItem;
52 import android.view.View;
53 import android.view.View.OnClickListener;
54 import android.view.ViewGroup;
55 import android.view.inputmethod.EditorInfo;
56 import android.view.inputmethod.InputMethodManager;
57 import android.widget.AdapterView.AdapterContextMenuInfo;
58 import android.widget.BaseAdapter;
59 import android.widget.Button;
60 import android.widget.CompoundButton;
61 import android.widget.CompoundButton.OnCheckedChangeListener;
62 import android.widget.FrameLayout;
63 import android.widget.LinearLayout;
64 import android.widget.ListAdapter;
65 import android.widget.ListView;
66 import android.widget.TextView;
67 import android.widget.Toast;
68 import android.widget.ToggleButton;
70 import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;
71 import com.hughes.android.util.IntentLauncher;
74 import java.io.FileInputStream;
75 import java.io.FileOutputStream;
76 import java.io.IOException;
77 import java.io.InputStream;
78 import java.io.OutputStream;
79 import java.net.MalformedURLException;
81 import java.util.Collections;
82 import java.util.HashSet;
83 import java.util.List;
85 import java.util.zip.ZipEntry;
86 import java.util.zip.ZipFile;
87 import java.util.zip.ZipInputStream;
90 // Delete, move to top.
92 public class DictionaryManagerActivity extends ActionBarActivity {
94 static final String LOG = "QuickDic";
95 static boolean blockAutoLaunch = false;
97 private ListView listView;
98 private ListView getListView() {
99 if (listView == null) {
100 listView = (ListView)findViewById(android.R.id.list);
104 private void setListAdapter(ListAdapter adapter) {
105 getListView().setAdapter(adapter);
107 private ListAdapter getListAdapter() {
108 return getListView().getAdapter();
111 // For DownloadManager bug workaround
112 private Set<Long> finishedDownloadIds = new HashSet<Long>();
114 DictionaryApplication application;
116 SearchView filterSearchView;
117 ToggleButton showDownloadable;
119 LinearLayout dictionariesOnDeviceHeaderRow;
120 LinearLayout downloadableDictionariesHeaderRow;
124 Runnable dictionaryUpdater = new Runnable() {
127 if (uiHandler == null) {
130 uiHandler.post(new Runnable() {
139 final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
141 public synchronized void onReceive(Context context, Intent intent) {
142 final String action = intent.getAction();
144 if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
145 final long downloadId = intent.getLongExtra(
146 DownloadManager.EXTRA_DOWNLOAD_ID, 0);
147 if (finishedDownloadIds.contains(downloadId)) return; // ignore double notifications
148 final DownloadManager.Query query = new DownloadManager.Query();
149 query.setFilterById(downloadId);
150 final DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
151 final Cursor cursor = downloadManager.query(query);
153 if (cursor == null || !cursor.moveToFirst()) {
154 Log.e(LOG, "Couldn't find download.");
158 final String dest = cursor
159 .getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
160 final int status = cursor
162 .getColumnIndex(DownloadManager.COLUMN_STATUS));
163 if (DownloadManager.STATUS_SUCCESSFUL != status) {
164 final int reason = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_REASON));
166 "Download failed: status=" + status +
167 ", reason=" + reason);
168 String msg = Integer.toString(reason);
170 case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
173 case DownloadManager.ERROR_FILE_ERROR:
176 case DownloadManager.ERROR_INSUFFICIENT_SPACE:
177 msg = "Not enough space";
180 new AlertDialog.Builder(context).setTitle(getString(R.string.error)).setMessage(getString(R.string.downloadFailed, msg)).setNeutralButton("Close", null).show();
184 Log.w(LOG, "Download finished: " + dest + " Id: " + downloadId);
185 Toast.makeText(context, getString(R.string.unzippingDictionary, dest),
186 Toast.LENGTH_LONG).show();
189 final Uri zipUri = Uri.parse(dest);
190 File localZipFile = null;
191 InputStream zipFileStream = null;
192 ZipInputStream zipFile = null;
193 OutputStream zipOut = null;
195 if (zipUri.getScheme().equals("content")) {
196 zipFileStream = context.getContentResolver().openInputStream(zipUri);
199 localZipFile = new File(zipUri.getPath());
200 zipFileStream = new FileInputStream(localZipFile);
202 zipFile = new ZipInputStream(zipFileStream);
203 final ZipEntry zipEntry = zipFile.getNextEntry();
204 Log.d(LOG, "Unzipping entry: " + zipEntry.getName());
205 File targetFile = new File(application.getDictDir(), zipEntry.getName());
206 if (targetFile.exists()) {
207 targetFile.renameTo(new File(targetFile.getAbsolutePath().replace(".quickdic", ".bak.quickdic")));
208 targetFile = new File(application.getDictDir(), zipEntry.getName());
210 zipOut = new FileOutputStream(targetFile);
211 copyStream(zipFile, zipOut);
212 application.backgroundUpdateDictionaries(dictionaryUpdater);
213 Toast.makeText(context, getString(R.string.installationFinished, dest),
214 Toast.LENGTH_LONG).show();
215 finishedDownloadIds.add(downloadId);
216 Log.w(LOG, "Unzipping finished: " + dest + " Id: " + downloadId);
217 } catch (Exception e) {
218 String msg = getString(R.string.unzippingFailed, dest);
219 File dir = application.getDictDir();
220 if (!dir.canWrite() || !application.checkFileCreate(dir)) {
221 msg = getString(R.string.notWritable, dir.getAbsolutePath());
223 new AlertDialog.Builder(context).setTitle(getString(R.string.error)).setMessage(msg).setNeutralButton("Close", null).show();
224 Log.e(LOG, "Failed to unzip.", e);
227 if (zipOut != null) zipOut.close();
228 } catch (IOException e) {}
230 if (zipFile != null) zipFile.close();
231 } catch (IOException e) {}
233 if (zipFileStream != null) zipFileStream.close();
234 } catch (IOException e) {}
235 if (localZipFile != null) localZipFile.delete();
241 public static Intent getLaunchIntent(Context c) {
242 final Intent intent = new Intent(c, DictionaryManagerActivity.class);
243 intent.putExtra(C.CAN_AUTO_LAUNCH_DICT, false);
247 public void readableCheckAndError(boolean requestPermission) {
248 final File dictDir = application.getDictDir();
249 if (dictDir.canRead() && dictDir.canExecute()) return;
250 blockAutoLaunch = true;
251 if (requestPermission &&
252 ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
253 ActivityCompat.requestPermissions(this,
254 new String[] {Manifest.permission.READ_EXTERNAL_STORAGE,
255 Manifest.permission.WRITE_EXTERNAL_STORAGE
259 blockAutoLaunch = true;
261 AlertDialog.Builder builder = new AlertDialog.Builder(getListView().getContext());
262 builder.setTitle(getString(R.string.error));
263 builder.setMessage(getString(
264 R.string.unableToReadDictionaryDir,
265 dictDir.getAbsolutePath(),
266 Environment.getExternalStorageDirectory()));
267 builder.setNeutralButton("Close", null);
268 builder.create().show();
272 public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
273 readableCheckAndError(false);
275 application.backgroundUpdateDictionaries(dictionaryUpdater);
281 public void onCreate(Bundle savedInstanceState) {
282 // This must be first, otherwise the actiona bar doesn't get
284 setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId);
286 super.onCreate(savedInstanceState);
287 Log.d(LOG, "onCreate:" + this);
289 application = (DictionaryApplication) getApplication();
291 blockAutoLaunch = false;
294 setContentView(R.layout.dictionary_manager_activity);
296 dictionariesOnDeviceHeaderRow = (LinearLayout) LayoutInflater.from(
297 getListView().getContext()).inflate(
298 R.layout.dictionary_manager_header_row_on_device, getListView(), false);
300 downloadableDictionariesHeaderRow = (LinearLayout) LayoutInflater.from(
301 getListView().getContext()).inflate(
302 R.layout.dictionary_manager_header_row_downloadable, getListView(), false);
304 showDownloadable = (ToggleButton) downloadableDictionariesHeaderRow
305 .findViewById(R.id.hideDownloadable);
306 showDownloadable.setOnCheckedChangeListener(new OnCheckedChangeListener() {
308 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
309 onShowDownloadableChanged();
313 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
314 final String thanksForUpdatingLatestVersion = getString(R.string.thanksForUpdatingVersion);
315 if (!prefs.getString(C.THANKS_FOR_UPDATING_VERSION, "").equals(
316 thanksForUpdatingLatestVersion)) {
317 blockAutoLaunch = true;
318 startActivity(HtmlDisplayActivity.getWhatsNewLaunchIntent(getApplicationContext()));
319 prefs.edit().putString(C.THANKS_FOR_UPDATING_VERSION, thanksForUpdatingLatestVersion)
323 registerReceiver(broadcastReceiver, new IntentFilter(
324 DownloadManager.ACTION_DOWNLOAD_COMPLETE));
327 registerForContextMenu(getListView());
328 getListView().setItemsCanFocus(true);
330 readableCheckAndError(true);
332 onCreateSetupActionBar();
335 private void onCreateSetupActionBar() {
336 ActionBar actionBar = getSupportActionBar();
337 actionBar.setDisplayShowTitleEnabled(false);
338 actionBar.setDisplayShowHomeEnabled(false);
339 actionBar.setDisplayHomeAsUpEnabled(false);
341 filterSearchView = new SearchView(getSupportActionBar().getThemedContext());
342 filterSearchView.setIconifiedByDefault(false);
343 // filterSearchView.setIconified(false); // puts the magnifying glass in
346 filterSearchView.setQueryHint(getString(R.string.searchText));
347 filterSearchView.setSubmitButtonEnabled(false);
348 FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
349 FrameLayout.LayoutParams.WRAP_CONTENT);
350 filterSearchView.setLayoutParams(lp);
351 filterSearchView.setInputType(InputType.TYPE_CLASS_TEXT);
352 filterSearchView.setImeOptions(
353 EditorInfo.IME_ACTION_DONE |
354 EditorInfo.IME_FLAG_NO_EXTRACT_UI |
355 // EditorInfo.IME_FLAG_NO_FULLSCREEN | // Requires API
357 EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
359 filterSearchView.setOnQueryTextListener(new OnQueryTextListener() {
361 public boolean onQueryTextSubmit(String query) {
362 filterSearchView.clearFocus();
367 public boolean onQueryTextChange(String filterText) {
372 filterSearchView.setFocusable(true);
374 actionBar.setCustomView(filterSearchView);
375 actionBar.setDisplayShowCustomEnabled(true);
377 // Avoid wasting space on large left inset
378 Toolbar tb = (Toolbar)filterSearchView.getParent();
379 tb.setContentInsetsRelative(0, 0);
383 public void onDestroy() {
385 unregisterReceiver(broadcastReceiver);
388 private static int copyStream(final InputStream in, final OutputStream out)
391 final byte[] bytes = new byte[1024 * 16];
392 while ((bytesRead = in.read(bytes)) != -1) {
393 out.write(bytes, 0, bytesRead);
401 protected void onStart() {
403 uiHandler = new Handler();
407 protected void onStop() {
413 protected void onResume() {
416 if (PreferenceActivity.prefsMightHaveChanged) {
417 PreferenceActivity.prefsMightHaveChanged = false;
419 startActivity(getIntent());
422 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
423 showDownloadable.setChecked(prefs.getBoolean(C.SHOW_DOWNLOADABLE, true));
425 if (!blockAutoLaunch &&
426 getIntent().getBooleanExtra(C.CAN_AUTO_LAUNCH_DICT, true) &&
427 prefs.contains(C.DICT_FILE) &&
428 prefs.contains(C.INDEX_SHORT_NAME)) {
429 Log.d(LOG, "Skipping DictionaryManager, going straight to dictionary.");
430 startActivity(DictionaryActivity.getLaunchIntent(getApplicationContext(),
431 new File(prefs.getString(C.DICT_FILE, "")),
432 prefs.getString(C.INDEX_SHORT_NAME, ""),
433 prefs.getString(C.SEARCH_TOKEN, "")));
438 // Remove the active dictionary from the prefs so we won't autolaunch
440 final Editor editor = prefs.edit();
441 editor.remove(C.DICT_FILE);
442 editor.remove(C.INDEX_SHORT_NAME);
443 editor.remove(C.SEARCH_TOKEN);
446 application.backgroundUpdateDictionaries(dictionaryUpdater);
452 public boolean onCreateOptionsMenu(final Menu menu) {
453 if ("true".equals(Settings.System.getString(getContentResolver(), "firebase.test.lab")))
455 return false; // testing the menu is not very interesting
457 final MenuItem sort = menu.add(getString(R.string.sortDicts));
458 MenuItemCompat.setShowAsAction(sort, MenuItem.SHOW_AS_ACTION_NEVER);
459 sort.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
460 public boolean onMenuItemClick(final MenuItem menuItem) {
461 application.sortDictionaries();
467 application.onCreateGlobalOptionsMenu(this, menu);
472 public void onCreateContextMenu(final ContextMenu menu, final View view,
473 final ContextMenuInfo menuInfo) {
474 super.onCreateContextMenu(menu, view, menuInfo);
475 Log.d(LOG, "onCreateContextMenu, " + menuInfo);
477 final AdapterContextMenuInfo adapterContextMenuInfo =
478 (AdapterContextMenuInfo) menuInfo;
479 final int position = adapterContextMenuInfo.position;
480 final MyListAdapter.Row row = (MyListAdapter.Row) getListAdapter().getItem(position);
482 if (row.dictionaryInfo == null) {
486 if (position > 0 && row.onDevice) {
487 final android.view.MenuItem moveToTopMenuItem =
488 menu.add(R.string.moveToTop);
489 moveToTopMenuItem.setOnMenuItemClickListener(new
490 android.view.MenuItem.OnMenuItemClickListener() {
492 public boolean onMenuItemClick(android.view.MenuItem item) {
493 application.moveDictionaryToTop(row.dictionaryInfo);
501 final android.view.MenuItem deleteMenuItem = menu.add(R.string.deleteDictionary);
503 .setOnMenuItemClickListener(new android.view.MenuItem.OnMenuItemClickListener() {
505 public boolean onMenuItemClick(android.view.MenuItem item) {
506 application.deleteDictionary(row.dictionaryInfo);
514 private void onShowDownloadableChanged() {
516 Editor prefs = PreferenceManager.getDefaultSharedPreferences(this).edit();
517 prefs.putBoolean(C.SHOW_DOWNLOADABLE, showDownloadable.isChecked());
521 class MyListAdapter extends BaseAdapter {
523 List<DictionaryInfo> dictionariesOnDevice;
524 List<DictionaryInfo> downloadableDictionaries;
527 DictionaryInfo dictionaryInfo;
530 private Row(DictionaryInfo dictionaryInfo, boolean onDevice) {
531 this.dictionaryInfo = dictionaryInfo;
532 this.onDevice = onDevice;
536 private MyListAdapter(final String[] filters) {
537 dictionariesOnDevice = application.getDictionariesOnDevice(filters);
538 if (showDownloadable.isChecked()) {
539 downloadableDictionaries = application.getDownloadableDictionaries(filters);
541 downloadableDictionaries = Collections.emptyList();
546 public int getCount() {
547 return 2 + dictionariesOnDevice.size() + downloadableDictionaries.size();
551 public Row getItem(int position) {
553 return new Row(null, true);
557 if (position < dictionariesOnDevice.size()) {
558 return new Row(dictionariesOnDevice.get(position), true);
560 position -= dictionariesOnDevice.size();
563 return new Row(null, false);
567 assert position < downloadableDictionaries.size();
568 return new Row(downloadableDictionaries.get(position), false);
572 public long getItemId(int position) {
577 public View getView(int position, View convertView, ViewGroup parent) {
578 if (convertView instanceof LinearLayout &&
579 convertView != dictionariesOnDeviceHeaderRow &&
580 convertView != downloadableDictionariesHeaderRow) {
582 * This is done to try to avoid leaking memory that used to
583 * happen on Android 4.0.3
585 ((LinearLayout) convertView).removeAllViews();
588 final Row row = getItem(position);
591 if (row.dictionaryInfo == null) {
592 return dictionariesOnDeviceHeaderRow;
594 return createDictionaryRow(row.dictionaryInfo, parent, true);
597 if (row.dictionaryInfo == null) {
598 return downloadableDictionariesHeaderRow;
600 return createDictionaryRow(row.dictionaryInfo, parent, false);
605 private void setMyListAdapater() {
606 final String filter = filterSearchView == null ? "" : filterSearchView.getQuery()
608 final String[] filters = filter.trim().toLowerCase().split("(\\s|-)+");
609 setListAdapter(new MyListAdapter(filters));
612 private View createDictionaryRow(final DictionaryInfo dictionaryInfo,
613 final ViewGroup parent, boolean canLaunch) {
615 View row = LayoutInflater.from(parent.getContext()).inflate(
616 R.layout.dictionary_manager_row, parent, false);
617 final TextView name = (TextView) row.findViewById(R.id.dictionaryName);
618 final TextView details = (TextView) row.findViewById(R.id.dictionaryDetails);
619 name.setText(application.getDictionaryName(dictionaryInfo.uncompressedFilename));
621 final boolean updateAvailable = application.updateAvailable(dictionaryInfo);
622 final Button downloadButton = (Button) row.findViewById(R.id.downloadButton);
623 final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename);
624 boolean broken = false;
625 if (!dictionaryInfo.isValid()) {
629 if (downloadable != null && (!canLaunch || updateAvailable)) {
632 R.string.downloadButton,
633 downloadable.zipBytes / 1024.0 / 1024.0));
634 downloadButton.setMinWidth(application.languageButtonPixels * 3 / 2);
635 downloadButton.setOnClickListener(new OnClickListener() {
637 public void onClick(View arg0) {
638 downloadDictionary(downloadable.downloadUrl, downloadable.zipBytes, downloadButton);
642 downloadButton.setVisibility(View.INVISIBLE);
645 LinearLayout buttons = (LinearLayout) row.findViewById(R.id.dictionaryLauncherButtons);
646 final List<IndexInfo> sortedIndexInfos = application
647 .sortedIndexInfos(dictionaryInfo.indexInfos);
648 final StringBuilder builder = new StringBuilder();
649 if (updateAvailable) {
650 builder.append(getString(R.string.updateAvailable));
652 for (IndexInfo indexInfo : sortedIndexInfos) {
653 final View button = application.createButton(buttons.getContext(), dictionaryInfo,
655 buttons.addView(button);
658 button.setOnClickListener(
659 new IntentLauncher(buttons.getContext(),
660 DictionaryActivity.getLaunchIntent(getApplicationContext(),
661 application.getPath(dictionaryInfo.uncompressedFilename),
662 indexInfo.shortName, "")));
665 button.setEnabled(false);
666 button.setFocusable(false);
668 if (builder.length() != 0) {
669 builder.append("; ");
671 builder.append(getString(R.string.indexInfo, indexInfo.shortName,
672 indexInfo.mainTokenCount));
674 builder.append("; ");
675 builder.append(getString(R.string.downloadButton, dictionaryInfo.uncompressedBytes / 1024.0 / 1024.0));
677 name.setText("Broken: " + application.getDictionaryName(dictionaryInfo.uncompressedFilename));
678 builder.append("; Cannot be used, redownload, check hardware/file system");
679 // Allow deleting, but cannot open
680 row.setLongClickable(true);
682 details.setText(builder.toString());
685 row.setClickable(true);
686 row.setOnClickListener(new IntentLauncher(parent.getContext(),
687 DictionaryActivity.getLaunchIntent(getApplicationContext(),
688 application.getPath(dictionaryInfo.uncompressedFilename),
689 dictionaryInfo.indexInfos.get(0).shortName, "")));
690 // do not setFocusable, for keyboard navigation
691 // offering only the index buttons is better.
692 row.setLongClickable(true);
694 row.setBackgroundResource(android.R.drawable.menuitem_background);
699 private synchronized void downloadDictionary(final String downloadUrl, long bytes, Button downloadButton) {
702 destFile = new File(new URL(downloadUrl).getPath()).getName();
703 } catch (MalformedURLException e) {
704 throw new RuntimeException("Invalid download URL!", e);
706 DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
707 final DownloadManager.Query query = new DownloadManager.Query();
708 query.setFilterByStatus(DownloadManager.STATUS_PAUSED | DownloadManager.STATUS_PENDING | DownloadManager.STATUS_RUNNING);
709 final Cursor cursor = downloadManager.query(query);
711 // Due to a bug, cursor is null instead of empty when
712 // the download manager is disabled.
713 if (cursor == null) {
714 new AlertDialog.Builder(DictionaryManagerActivity.this).setTitle(getString(R.string.error))
715 .setMessage(getString(R.string.downloadFailed, R.string.downloadManagerQueryFailed))
716 .setNeutralButton("Close", null).show();
720 while (cursor.moveToNext()) {
721 if (downloadUrl.equals(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_URI))))
723 if (destFile.equals(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_TITLE))))
726 if (!cursor.isAfterLast()) {
727 downloadManager.remove(cursor.getLong(cursor.getColumnIndex(DownloadManager.COLUMN_ID)));
730 R.string.downloadButton,
731 bytes / 1024.0 / 1024.0));
736 Request request = new Request(
737 Uri.parse(downloadUrl));
739 Log.d(LOG, "Downloading to: " + destFile);
740 request.setTitle(destFile);
742 File destFilePath = new File(application.getDictDir(), destFile);
743 destFilePath.delete();
745 request.setDestinationUri(Uri.fromFile(destFilePath));
746 } catch (Exception e) {
750 downloadManager.enqueue(request);
751 } catch (SecurityException e) {
752 request = new Request(Uri.parse(downloadUrl));
753 request.setTitle(destFile);
754 downloadManager.enqueue(request);
756 Log.w(LOG, "Download started: " + destFile);
757 downloadButton.setText("X");