Exemplo n.º 1
1
  @Override
  public synchronized void loadUrl(String url) {
    if (url == null || url.trim().isEmpty()) {
      NinjaToast.show(context, R.string.toast_load_error);
      return;
    }

    url = BrowserUnit.queryWrapper(context, url.trim());
    if (url.startsWith(BrowserUnit.URL_SCHEME_MAIL_TO)) {
      Intent intent = IntentUnit.getEmailIntent(MailTo.parse(url));
      context.startActivity(intent);
      reload();

      return;
    } else if (url.startsWith(BrowserUnit.URL_SCHEME_INTENT)) {
      Intent intent;
      try {
        intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
        context.startActivity(intent);
      } catch (URISyntaxException u) {
      }

      return;
    }

    webViewClient.updateWhite(adBlock.isWhite(url));
    super.loadUrl(url);
    if (browserController != null && foreground) {
      browserController.updateBookmarks();
    }
  }
Exemplo n.º 2
0
 public synchronized void update(String title, String url) {
   album.setAlbumTitle(title);
   if (foreground) {
     browserController.updateBookmarks();
     browserController.updateInputBox(url);
   }
 }
Exemplo n.º 3
0
  /**
   * Purpose: Creates the post-login GUI for browsing remote files and rendering them on screen
   *
   * @param remoteFiles a static list of files that are present on the server and can be retrieved
   *     through the UI
   */
  private void createBrowserUI(File[] remoteFiles) {
    // reset the main area
    this.removeAll();
    JPanel mainPanel = new JPanel(new GridLayout(1, 1));
    this.add(mainPanel);

    // split the main panel vertically
    JSplitPane vertSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    vertSplitPane.setDividerSize(1);
    vertSplitPane.setEnabled(false);
    mainPanel.add(vertSplitPane);

    // create header controls
    vertSplitPane.setLeftComponent(createFileSelectionHeader());

    // split the lower content area horizontally
    JSplitPane hSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    browserController.setContentSplitter(hSplitPane);
    hSplitPane.setContinuousLayout(true);
    vertSplitPane.setRightComponent(hSplitPane);

    // add the file list to the left hand side
    JScrollPane fileListPane = createFileList(remoteFiles);
    hSplitPane.setLeftComponent(fileListPane);

    // initialize the browser control
    browserController.setSelectedFiles(null);
    this.revalidate();
    this.repaint();
  }
Exemplo n.º 4
0
  public synchronized void update(int progress) {
    if (foreground) {
      browserController.updateProgress(progress);
    }

    setAlbumCover(ViewUnit.capture(this, dimen144dp, dimen108dp, false, Bitmap.Config.RGB_565));
    if (isLoadFinish()) {
      SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
      if (sp.getBoolean(context.getString(R.string.sp_scroll_bar), true)) {
        setHorizontalScrollBarEnabled(true);
        setVerticalScrollBarEnabled(true);
      } else {
        setHorizontalScrollBarEnabled(false);
        setVerticalScrollBarEnabled(false);
      }
      setScrollbarFadingEnabled(true);

      new Handler()
          .postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  setAlbumCover(
                      ViewUnit.capture(
                          NinjaWebView.this, dimen144dp, dimen108dp, false, Bitmap.Config.RGB_565));
                }
              },
              animTime);

      if (prepareRecord()) {
        RecordAction action = new RecordAction(context);
        action.open(true);
        action.addHistory(new Record(getTitle(), getUrl(), System.currentTimeMillis()));
        action.close();
        browserController.updateAutoComplete();
      }
    }
  }
Exemplo n.º 5
0
  /**
   * Purpose: Create the controls that adorn the top of the file browser content area and which
   * control the playback parameters and provides a save button for file selections
   *
   * @return
   */
  private Component createFileSelectionHeader() {
    JPanel headerControls = new JPanel();
    JPanel playbackPanel = Gui.GBPanel(headerControls, null, "Multi-Selection Playback Controls");

    // add random/in order toggle
    final String RandomCommand = "Random";
    browserController.setPlayRandomly(true);
    ButtonGroup randomOrderGroup = new ButtonGroup();
    ActionListener randomListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            browserController.setPlayRandomly(ae.getActionCommand().equals(RandomCommand));
          }
        };
    Gui.addRadioButton(
        playbackPanel, "In Order", false, randomOrderGroup, "Ordered", randomListener);
    Gui.addRadioButton(
        playbackPanel, "Random Order", true, randomOrderGroup, RandomCommand, randomListener);

    // add speed control
    browserController.setRotationSpeed(2000);
    final JSlider speedSlider = Gui.createSlider(250, 0, 10000, Boolean.TRUE, Boolean.TRUE);
    speedSlider.setValue(browserController.getRotationSpeed());
    speedSlider.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent ce) {
            browserController.setRotationSpeed(speedSlider.getValue());
          }
        });
    Gui.addBoxSpace(playbackPanel, 30, 55);
    playbackPanel.add(new JLabel("No Delay"));
    playbackPanel.add(speedSlider);
    playbackPanel.add(new JLabel("10s Delay"));

    // add "replay" button
    Gui.addBoxSpace(playbackPanel, 40, 50);
    Gui.addButton(
        playbackPanel,
        "Start Over",
        null,
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            browserController.replaySelectedFiles();
          }
        });

    // a spacer, then our save controls
    Gui.addBoxSpace(headerControls, 35, 65);
    Gui.addButton(
        headerControls,
        "Save",
        null,
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            JFileChooser chooser = new JFileChooser();
            //                chooser.setCurrentDirectory(new
            // java.io.File(serverPathLabel.getText()));
            chooser.setDialogTitle("Select Folder to Save to....");
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setAcceptAllFileFilterUsed(false);
            int result = chooser.showDialog(_ref, "Ok");
            if (result == JFileChooser.APPROVE_OPTION) {
              File selectedFile = chooser.getSelectedFile();
              browserController.saveSelectedFiles(selectedFile.getAbsolutePath().toString());
            }
          }
        });
    return headerControls;
  }