コード例 #1
0
  public void showProgressDialog(final int messageId) {
    try {
      final MainPanel panel = mFileSystemController.getActivePanel();
      panel
          .getActivity()
          .runOnUiThread(
              new Runnable() {
                @Override
                public void run() {
                  if (mProgressDialog != null && mProgressDialog.isShowing()) {
                    dismissProgressDialog();
                  }

                  mProgressDialog =
                      new Dialog(panel.getActivity(), android.R.style.Theme_Translucent);
                  mProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                  mProgressDialog.setCancelable(false);
                  mProgressDialog.setContentView(R.layout.dialog_progress);
                  mProgressDialog.show();
                }
              });
      ((TextView) mProgressDialog.findViewById(R.id.progress_bar_text)).setText(messageId);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
  /**
   * Show dialog with available (authenticated) network (cloud) accounts for certain cloud type.
   *
   * @param networkType selected cloud type
   */
  private void showSelectAccountDialog(final NetworkEnum networkType, final MainPanel panel) {

    if (panel == null || panel.getActivity() == null) {
      // very weired situation; try to avoid crash.
      return;
    }

    final Dialog dialog = new Dialog(panel.getActivity(), R.style.Action_Dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    View dialogView =
        View.inflate(App.sInstance.getApplicationContext(), R.layout.network_type_chooser, null);
    ((TextView) dialogView.findViewById(R.id.network_dialog_title))
        .setText(App.sInstance.getString(R.string.action_select_account));

    final ListView networks = (ListView) dialogView.findViewById(R.id.network_types);

    NetworkApi api = App.sInstance.getNetworkApi(networkType);

    final BaseAdapter adapter =
        new NetworkAccountChooserAdapter(
            api,
            new NetworkAccountChooserAdapter.OnDeleteItemListener() {
              @Override
              public void onAccountDelete(NetworkAccount account) {
                NetworkAccountDbAdapter.delete(account.getId());
                ((NetworkAccountChooserAdapter) networks.getAdapter()).dataSetChanged();
              }
            });

    networks.setAdapter(adapter);

    dialogView
        .findViewById(R.id.cancel)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                dialog.dismiss();
              }
            });

    networks.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            openNetworkAccount((NetworkAccount) view.getTag(), null, panel);

            if (dialog.isShowing()) {
              dialog.dismiss();
            }
          }
        });

    dialog.setContentView(dialogView);
    dialog.show();

    adjustDialogSize(dialog, panel);
  }
コード例 #3
0
 public void openAvailableCloudsList() {
   MainPanel panel = mFileSystemController.getActivePanel();
   if (NetworkUtil.isNetworkAvailable()) {
     showNetworksDialog();
   } else {
     if (panel != null && panel.getActivity() != null) {
       ToastNotification.makeText(
               panel.getActivity(),
               App.sInstance.getString(R.string.error_no_network),
               Toast.LENGTH_LONG)
           .show();
     }
   }
 }
コード例 #4
0
        @Override
        public void handleMessage(Message msg) {
          super.handleMessage(msg);

          MainPanel panel = mFileSystemController.getActivePanel();
          if (msg.what == FTP_CONNECTED) {
            mFileSystemController.openNetworkPanel(NetworkEnum.FTP);
          } else if (msg.what == SFTP_CONNECTED) {
            mFileSystemController.openNetworkPanel(NetworkEnum.SFTP);
          } else if (msg.what == SMB_CONNECTED) {
            mFileSystemController.openNetworkPanel(NetworkEnum.SMB);
          } else if (msg.what == YANDEX_DISK_CONNECTED) {
            mFileSystemController.openNetworkPanel(NetworkEnum.YandexDisk);
          } else if (msg.what == SMB_SCAN_NETWORK_REQUESTED) {
            final Dialog dialog = new NetworkScanDialog(panel.getActivity(), mInAppAuthHandler);
            dialog.show();
            adjustDialogSize(dialog, panel);
          } else if (msg.what == SMB_SCAN_CANCELED) {
            startSmbAuthentication(panel);
          } else if (msg.what == SMB_IP_SELECTED) {
            startSmbAuthentication((String) msg.obj, panel);
          } else if (msg.what == GoogleDriveAuthWindow.MSG_HIDE_LOADING_DIALOG) {
            GoogleDriveApi.GoogleDriveAccount account = null;
            if (msg.arg1 == GoogleDriveAuthWindow.MSG_ARG_SUCCESS) {
              GoogleDriveApi api = App.sInstance.getGoogleDriveApi();
              Pair<About, Token> data = (Pair<About, Token>) msg.obj;
              account =
                  (GoogleDriveApi.GoogleDriveAccount) api.saveAccount(data.first, data.second);
            } else {
              ToastNotification.makeText(
                      App.sInstance.getApplicationContext(),
                      App.sInstance.getString(R.string.google_drive_get_token_error),
                      Toast.LENGTH_LONG)
                  .show();
            }

            dismissProgressDialog();

            if (account != null) {
              App.sInstance.getGoogleDriveApi().setup(account);
              mFileSystemController.openNetworkPanel(NetworkEnum.GoogleDrive);
            }
          } else if (msg.what == GoogleDriveAuthWindow.MSG_SHOW_LOADING_DIALOG) {
            showProgressDialog(R.string.loading);
          } else if (msg.what == MEDIA_FIRE_CONNECTED) {
            mFileSystemController.openNetworkPanel(NetworkEnum.MediaFire);
          } else if (msg.what == WEBDAV_CONNECTED) {
            mFileSystemController.openNetworkPanel(NetworkEnum.WebDav);
          }
        }
コード例 #5
0
  /**
   * Adjust dialog size. Actuall for old android version only (due to absence of Holo themes).
   *
   * @param dialog dialog whose size should be adjusted.
   * @param panel active panel
   * @param scaleFactor relative size scale factor (between 0 and 1)
   */
  private void adjustDialogSize(Dialog dialog, MainPanel panel, float scaleFactor) {
    if (!SystemUtils.isHoneycombOrNever()) {
      DisplayMetrics metrics = new DisplayMetrics();
      panel.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);

      WindowManager.LayoutParams params = new WindowManager.LayoutParams();
      params.copyFrom(dialog.getWindow().getAttributes());
      params.width = (int) (metrics.widthPixels * scaleFactor);
      params.height = (int) (metrics.heightPixels * scaleFactor);

      dialog.getWindow().setAttributes(params);
    }
  }
コード例 #6
0
 private void startYandexDiskAuthentication(MainPanel panel) {
   final Dialog dialog = new YandexDiskAuthDialog(panel.getActivity(), mInAppAuthHandler);
   dialog.show();
   adjustDialogSize(dialog, panel);
 }
コード例 #7
0
 private void startSkyDriveAuthentication(MainPanel panel) {
   App.sInstance
       .getSkyDriveApi()
       .startAuthentication(panel.getActivity(), mOnSkyDriveLoginListener);
 }
コード例 #8
0
 private void startGoogleDriveAuthentication(MainPanel panel) {
   GoogleDriveAuthWindow popupWindow =
       new GoogleDriveAuthWindow(panel.getActivity(), mInAppAuthHandler);
   popupWindow.show();
 }
コード例 #9
0
 private void startDropboxAuthentication(MainPanel panel) {
   App.sInstance.getDropboxApi().getSession().startAuthentication(panel.getActivity());
   mNetworkAuthRequested = true;
 }
コード例 #10
0
 private void startSmbAuthentication(String selectedIp, MainPanel panel) {
   final Dialog dialog = new SmbAuthDialog(panel.getActivity(), mInAppAuthHandler, selectedIp);
   dialog.show();
   adjustDialogSize(dialog, panel);
 }
コード例 #11
0
  /** Show dialog with available networks (clouds). */
  private void showNetworksDialog() {

    final MainPanel panel = mFileSystemController.getActivePanel();

    if (panel == null || panel.getActivity() == null) {
      // very weired situation; try to avoid crash.
      return;
    }

    final Dialog dialog = new Dialog(panel.getActivity(), R.style.Action_Dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    View dialogView =
        View.inflate(App.sInstance.getApplicationContext(), R.layout.network_type_chooser, null);

    final ListView networks = (ListView) dialogView.findViewById(R.id.network_types);
    final NetworkChooserAdapter adapter = new NetworkChooserAdapter();
    networks.setAdapter(adapter);

    dialogView
        .findViewById(R.id.cancel)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                dialog.dismiss();
              }
            });

    networks.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            NetworkEnum network = (NetworkEnum) view.getTag();

            switch (network) {
              case FTP:
                openFTP(panel);
                break;
              case SFTP:
                openSFTP(panel);
                break;
              case SMB:
                openSmb(panel);
                break;
              case Dropbox:
                openDropbox(panel);
                break;
              case SkyDrive:
                openSkyDrive(panel);
                break;
              case YandexDisk:
                openYandexDisk(panel);
                break;
              case GoogleDrive:
                openGoogleDrive(panel);
                break;
              case MediaFire:
                openMediaFire(panel);
                break;
              case WebDav:
                openWebDav(panel);
                break;
            }

            if (dialog.isShowing()) {
              dialog.dismiss();
            }
          }
        });

    dialog.setContentView(dialogView);
    dialog.show();

    adjustDialogSize(dialog, panel);
  }