Exemplo n.º 1
0
 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();
   }
 }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    settings = ((OsmandApplication) getApplication()).getSettings();
    if (downloadListIndexThread == null) {
      downloadListIndexThread = new DownloadIndexListThread(this);
    }
    // recreation upon rotation is prevented in manifest file
    CustomTitleBar titleBar =
        new CustomTitleBar(
            this, R.string.local_index_download, R.drawable.tab_download_screen_icon);
    setContentView(R.layout.download_index);
    titleBar.afterSetContentView();

    downloadFileHelper = new DownloadFileHelper(this);
    findViewById(R.id.DownloadButton)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                downloadFilesCheckFreeVersion();
              }
            });

    updateLoadedFiles();

    filterText = (EditText) findViewById(R.id.search_box);
    textWatcher =
        new TextWatcher() {
          @Override
          public void afterTextChanged(Editable s) {}

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            DownloadIndexAdapter adapter = ((DownloadIndexAdapter) getExpandableListAdapter());
            if (adapter != null) {
              adapter.getFilter().filter(s);
            }
          }
        };
    filterText.addTextChangedListener(textWatcher);
    final Intent intent = getIntent();
    if (intent != null && intent.getExtras() != null) {
      final String filter = intent.getExtras().getString(FILTER_KEY);
      if (filter != null) {
        filterText.setText(filter);
      }
    }

    if (downloadListIndexThread.getCachedIndexFiles() != null) {
      setListAdapter(new DownloadIndexAdapter(downloadListIndexThread.getCachedIndexFiles()));
    } else {
      downloadIndexList();
    }
    if (Version.isFreeVersion(this) && settings.checkFreeDownloadsNumberZero()) {
      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 + "", ""));
      msg.show();
    }
  }