Пример #1
0
  @Override
  protected void onResume() {
    super.onResume();

    refreshPeersFragment();

    initializeAppia();
    initializeOffercast();

    if (ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_GUI_TOS_ACCEPTED)) {
      if (ConfigurationManager.instance()
          .getBoolean(Constants.PREF_KEY_GUI_INITIAL_SETTINGS_COMPLETE)) {
        mainResume();
      } else {
        controller.startWizardActivity();
      }
    } else {
      trackDialog(
          TOS.showEula(
              this,
              new OnTOSAcceptListener() {
                public void onAccept() {
                  controller.startWizardActivity();
                }
              }));
    }

    checkLastSeenVersion();
  }
Пример #2
0
 private void refreshPeersFragment() {
   Fragment fragment = getCurrentFragment();
   if (fragment instanceof BrowsePeersFragment
       || fragment instanceof BrowsePeersDisabledFragment) {
     controller.switchFragment(R.id.menu_main_peers);
   }
   PeerManager.instance().updateLocalPeer();
 }
Пример #3
0
 @Override
 public void onDialogClick(String tag, int which) {
   if (tag.equals(LAST_BACK_DIALOG_ID) && which == AbstractDialog.BUTTON_POSITIVE) {
     onLastDialogButtonPositive();
   } else if (tag.equals(SHUTDOWN_DIALOG_ID) && which == AbstractDialog.BUTTON_POSITIVE) {
     onShutdownDialogButtonPositive();
   } else if (tag.equals(TermsUseDialog.TAG)) {
     controller.startWizardActivity();
   }
 }
Пример #4
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
      if (!(getCurrentFragment() instanceof SearchFragment)) {
        controller.switchFragment(R.id.menu_main_search);
      }
    } else if (keyCode == KeyEvent.KEYCODE_MENU) {
      toggleDrawer();
    } else {
      return super.onKeyDown(keyCode, event);
    }

    return true;
  }
Пример #5
0
  @Override
  protected void onResume() {
    super.onResume();

    refreshPlayerItem();

    if (ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_GUI_TOS_ACCEPTED)) {
      if (ConfigurationManager.instance()
          .getBoolean(Constants.PREF_KEY_GUI_INITIAL_SETTINGS_COMPLETE)) {
        mainResume();
        Offers.initAdNetworks(this);
      } else {
        controller.startWizardActivity();
      }
    } else {
      TermsUseDialog dlg = new TermsUseDialog();
      dlg.show(getFragmentManager());
    }

    checkLastSeenVersion();
    registerMainBroadcastReceiver();
  }
Пример #6
0
  @Override
  protected void onNewIntent(Intent intent) {

    if (isShutdown(intent)) {
      return;
    }

    String action = intent.getAction();
    // onResumeFragments();

    if (action != null && action.equals(Constants.ACTION_SHOW_TRANSFERS)) {
      controller.showTransfers(TransferStatus.ALL);
    } else if (action != null && action.equals(Constants.ACTION_OPEN_TORRENT_URL)) {
      // Open a Torrent from a URL or from a local file :), say from Astro File Manager.
      /**
       * TODO: Ask @aldenml the best way to plug in NewTransferDialog. I've refactored this dialog
       * so that it is forced (no matter if the setting to not show it again has been used) and when
       * that happens the checkbox is hidden.
       *
       * <p>However that dialog requires some data about the download, data which is not obtained
       * until we have instantiated the Torrent object.
       *
       * <p>I'm thinking that we can either: a) Pass a parameter to the transfer manager, but this
       * would probably not be cool since the transfer manager (I think) should work independently
       * from the UI thread.
       *
       * <p>b) Pass a "listener" to the transfer manager, once the transfer manager has the torrent
       * it can notify us and wait for the user to decide whether or not to continue with the
       * transfer
       *
       * <p>c) Forget about showing that dialog, and just start the download, the user can cancel
       * it.
       */

      // Show me the transfer tab
      Intent i = new Intent(this, MainActivity.class);
      i.setAction(Constants.ACTION_SHOW_TRANSFERS);
      i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
      startActivity(i);

      // go!
      final String uri = intent.getDataString();
      if (uri != null) {
        TransferManager.instance().downloadTorrent(uri);
      } else {
        LOG.warn(
            "MainActivity.onNewIntent(): Couldn't start torrent download from Intent's URI, intent.getDataString() -> null");
        LOG.warn("(maybe URI is coming in another property of the intent object - #fragmentation)");
      }
    }
    // When another application wants to "Share" a file and has chosen FrostWire to do so.
    // We make the file "Shared" so it's visible for other FrostWire devices on the local network.
    else if (action != null
        && (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE))) {
      controller.handleSendAction(intent);
      intent.setAction(null);
    } else if (action != null && action.equals(Constants.ACTION_START_TRANSFER_FROM_PREVIEW)) {
      if (Ref.alive(NewTransferDialog.srRef)) {
        SearchFragment.startDownload(
            this, NewTransferDialog.srRef.get(), getString(R.string.download_added_to_queue));
        UXStats.instance().log(UXAction.DOWNLOAD_CLOUD_FILE_FROM_PREVIEW);
      }
    }

    if (intent.hasExtra(Constants.EXTRA_DOWNLOAD_COMPLETE_NOTIFICATION)) {
      controller.showTransfers(TransferStatus.COMPLETED);
      TransferManager.instance().clearDownloadsToReview();
      try {
        ((NotificationManager) getSystemService(NOTIFICATION_SERVICE))
            .cancel(Constants.NOTIFICATION_DOWNLOAD_TRANSFER_FINISHED);
        Bundle extras = intent.getExtras();
        if (extras.containsKey(Constants.EXTRA_DOWNLOAD_COMPLETE_PATH)) {
          File file = new File(extras.getString(Constants.EXTRA_DOWNLOAD_COMPLETE_PATH));
          if (file.isFile()) {
            UIUtils.openFile(this, file.getAbsoluteFile());
          }
        }
      } catch (Throwable e) {
        LOG.warn("Error handling download complete notification", e);
      }
    }
  }
Пример #7
0
 /** public void showMyFiles() { controller.showMyFiles(); } */
 public void switchFragment(int itemId) {
   controller.switchFragment(itemId);
 }
Пример #8
0
 public void showMyFiles() {
   controller.showMyFiles();
 }