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(); } }
private void showDialogOfFreeDownloadsIfNeeded() { if (Version.isFreeVersion(getMyApplication())) { Builder msg = new AlertDialog.Builder(this); msg.setTitle(R.string.free_version_title); String m = getString(R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS + "", "") + "\n"; m += getString( R.string.available_downloads_left, MAXIMUM_AVAILABLE_FREE_DOWNLOADS - settings.NUMBER_OF_FREE_DOWNLOADS.get()); msg.setMessage(m); if (Version.isMarketEnabled(getMyApplication())) { msg.setNeutralButton( R.string.install_paid, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(getMyApplication()) + "net.osmand.plus")); try { startActivity(intent); } catch (ActivityNotFoundException e) { } } }); } msg.setPositiveButton(R.string.default_buttons_ok, null); msg.show(); } }
protected void downloadFilesCheckFreeVersion() { if (Version.isFreeVersion(this)) { int total = settings.NUMBER_OF_FREE_DOWNLOADS.get() + entriesToDownload.size(); boolean wiki = false; for (DownloadEntry es : entriesToDownload.values()) { if (es.baseName != null && es.baseName.contains("_wiki")) { wiki = true; break; } } if (total > MAXIMUM_AVAILABLE_FREE_DOWNLOADS || wiki) { Builder msg = new AlertDialog.Builder(this); msg.setTitle(R.string.free_version_title); msg.setMessage( getString( R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS + "", "( =" + total + ") ")); msg.setPositiveButton(R.string.default_buttons_ok, null); msg.show(); } else { downloadFilesPreCheckSpace(); } } else { downloadFilesPreCheckSpace(); } }
@Override public void updateDownloadButton(boolean scroll) { // View view = getView(); // if (view == null || getExpandableListView() == null){ // return; // } // int x = getExpandableListView().getScrollX(); // int y = getExpandableListView().getScrollY(); if (getEntriesToDownload().isEmpty()) { findViewById(R.id.DownloadButton).setVisibility(View.GONE); } else { BasicProgressAsyncTask<?, ?, ?> task = DownloadActivity.downloadListIndexThread.getCurrentRunningTask(); boolean running = task instanceof DownloadIndexesThread.DownloadIndexesAsyncTask; ((Button) findViewById(R.id.DownloadButton)).setEnabled(!running); String text; int downloads = DownloadActivity.downloadListIndexThread.getDownloads(); if (!running) { text = getString(R.string.shared_string_download) + " (" + downloads + ")"; // $NON-NLS-1$ } else { text = getString(R.string.shared_string_downloading) + " (" + downloads + ")"; // $NON-NLS-1$ } findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE); if (Version.isFreeVersion(getMyApplication())) { int countedDownloads = DownloadActivity.downloadListIndexThread.getDownloads(); int left = DownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS - settings.NUMBER_OF_FREE_DOWNLOADS.get() - downloads; boolean excessLimit = left < 0; if (left < 0) left = 0; if (getDownloadType() == DownloadActivityType.NORMAL_FILE || getDownloadType() == DownloadActivityType.ROADS_FILE) { text += " (" + (excessLimit ? "! " : "") + getString(R.string.files_limit, left).toLowerCase() + ")"; } } ((Button) findViewById(R.id.DownloadButton)).setText(text); } // if (scroll) { // getExpandableListView().scrollTo(x, y); // } }
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); } }