protected void downloadFilesCheckFreeVersion() { if (Version.isFreeVersion(getMyApplication())) { int total = settings.NUMBER_OF_FREE_DOWNLOADS.get(); boolean wiki = false; for (IndexItem es : downloadListIndexThread.getEntriesToDownload().keySet()) { if (es.getBasename() != null && es.getBasename().contains("_wiki")) { wiki = true; break; } else if (DownloadActivityType.isCountedInDownloads(es)) { total++; } } if (total > MAXIMUM_AVAILABLE_FREE_DOWNLOADS || wiki) { String msgTx = getString(R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS + ""); Builder msg = new AlertDialog.Builder(this); msg.setTitle(R.string.free_version_title); msg.setMessage(msgTx); msg.setPositiveButton(R.string.default_buttons_ok, null); msg.show(); } else { downloadFilesCheckInternet(); } } else { downloadFilesCheckInternet(); } }
public void updateDownloadButton(boolean scroll) { int x = getListView().getScrollX(); int y = getListView().getScrollY(); if (getEntriesToDownload().isEmpty()) { findViewById(R.id.DownloadButton).setVisibility(View.GONE); } else { BasicProgressAsyncTask<?, ?, ?> task = downloadListIndexThread.getCurrentRunningTask(); boolean running = task instanceof DownloadIndexesThread.DownloadIndexesAsyncTask; ((Button) findViewById(R.id.DownloadButton)).setEnabled(!running); String text; int downloads = downloadListIndexThread.getDownloads(); if (!running) { text = getString(R.string.download_files) + " (" + downloads + ")"; // $NON-NLS-1$ } else { text = getString(R.string.downloading_file_new) + " (" + downloads + ")"; // $NON-NLS-1$ } findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE); if (Version.isFreeVersion(getMyApplication())) { int countedDownloads = downloadListIndexThread.getDownloads(); int left = MAXIMUM_AVAILABLE_FREE_DOWNLOADS - settings.NUMBER_OF_FREE_DOWNLOADS.get() - downloads; boolean excessLimit = left < 0; if (left < 0) left = 0; if (DownloadActivityType.isCountedInDownloads(getType())) { text += " (" + (excessLimit ? "! " : "") + getString(R.string.files_limit, left).toLowerCase() + ")"; } } ((Button) findViewById(R.id.DownloadButton)).setText(text); } if (scroll) { getListView().scrollTo(x, y); } }