Пример #1
0
    @Override
    public boolean onSingleTapUp(MotionEvent e) {
      // Let the EmulatorView handle taps if mouse tracking is active
      if (view.isMouseTrackingActive()) return false;

      // Check for link at tap location
      String link = view.getURLat(e.getX(), e.getY());
      if (link != null) execURL(link);
      else
        doUIToggle((int) e.getX(), (int) e.getY(), view.getVisibleWidth(), view.getVisibleHeight());
      return true;
    }
Пример #2
0
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    mHaveFullHwKeyboard = checkHaveFullHwKeyboard(newConfig);

    EmulatorView v = (EmulatorView) mViewFlipper.getCurrentView();
    if (v != null) {
      v.updateSize(false);
    }

    if (mWinListAdapter != null) {
      // Force Android to redraw the label in the navigation dropdown
      mWinListAdapter.notifyDataSetChanged();
    }
  }
Пример #3
0
  @Override
  public void onResume() {
    super.onResume();

    SessionList sessions = mTermSessions;
    TermViewFlipper viewFlipper = mViewFlipper;
    if (sessions != null) {
      sessions.addCallback(this);
      WindowListAdapter adapter = mWinListAdapter;
      if (adapter != null) {
        sessions.addCallback(adapter);
        sessions.addTitleChangedListener(adapter);
        viewFlipper.addCallback(adapter);
      }
    }
    if (sessions != null && sessions.size() < viewFlipper.getChildCount()) {
      for (int i = 0; i < viewFlipper.getChildCount(); ++i) {
        EmulatorView v = (EmulatorView) viewFlipper.getChildAt(i);
        if (!sessions.contains(v.getTermSession())) {
          v.onPause();
          viewFlipper.removeView(v);
          --i;
        }
      }
    }

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    // the HOME dir needs to be set here since it comes from Context
    SharedPreferences.Editor editor = mPrefs.edit();
    String defValue = getDir("HOME", MODE_PRIVATE).getAbsolutePath();
    String homePath = mPrefs.getString("home_path", defValue);
    editor.putString("home_path", homePath);
    editor.commit();

    mSettings.readPrefs(mPrefs);
    updatePrefs();

    if (onResumeSelectWindow >= 0) {
      viewFlipper.setDisplayedChild(onResumeSelectWindow);
      onResumeSelectWindow = -1;
    }
    viewFlipper.onResume();
  }
Пример #4
0
  // Called when the list of sessions changes
  public void onUpdate() {
    SessionList sessions = mTermSessions;
    if (sessions == null) {
      return;
    }

    if (sessions.size() == 0) {
      mStopServiceOnFinish = true;
      finish();
    } else if (sessions.size() < mViewFlipper.getChildCount()) {
      for (int i = 0; i < mViewFlipper.getChildCount(); ++i) {
        EmulatorView v = (EmulatorView) mViewFlipper.getChildAt(i);
        if (!sessions.contains(v.getTermSession())) {
          v.onPause();
          mViewFlipper.removeView(v);
          --i;
        }
      }
    }
  }
Пример #5
0
  private void doCloseWindow() {
    if (mTermSessions == null) {
      return;
    }

    EmulatorView view = getCurrentEmulatorView();
    if (view == null) {
      return;
    }
    TermSession session = mTermSessions.remove(mViewFlipper.getDisplayedChild());
    view.onPause();
    session.finish();
    mViewFlipper.removeView(view);
    if (mTermSessions.size() == 0) {
      mStopServiceOnFinish = true;
      finish();
    } else {
      mViewFlipper.showNext();
    }
  }
Пример #6
0
  private void updatePrefs() {
    mUseKeyboardShortcuts = mSettings.getUseKeyboardShortcutsFlag();

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    ColorScheme colorScheme = new ColorScheme(mSettings.getColorScheme());

    mViewFlipper.updatePrefs(mSettings);

    for (View v : mViewFlipper) {
      ((EmulatorView) v).setDensity(metrics);
      ((TermView) v).updatePrefs(mSettings);
    }

    if (mTermSessions != null) {
      for (TermSession session : mTermSessions) {
        ((ShellTermSession) session).updatePrefs(mSettings);
      }
    }

    {
      Window win = getWindow();
      WindowManager.LayoutParams params = win.getAttributes();
      final int FULLSCREEN = WindowManager.LayoutParams.FLAG_FULLSCREEN;
      int desiredFlag = mSettings.showStatusBar() ? 0 : FULLSCREEN;
      if (desiredFlag != (params.flags & FULLSCREEN)
          || (AndroidCompat.SDK >= 11 && mActionBarMode != mSettings.actionBarMode())) {
        if (mAlreadyStarted) {
          // Can't switch to/from fullscreen after
          // starting the activity.
          restart();
        } else {
          win.setFlags(desiredFlag, FULLSCREEN);
          if (mActionBarMode == TermSettings.ACTION_BAR_MODE_HIDES) {
            mActionBar.hide();
          }
        }
      }
    }

    int orientation = mSettings.getScreenOrientation();
    int o = 0;
    if (orientation == 0) {
      o = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    } else if (orientation == 1) {
      o = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    } else if (orientation == 2) {
      o = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    } else {
      /* Shouldn't be happened. */
    }
    setRequestedOrientation(o);
  }
Пример #7
0
  private void updatePrefs() {
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    ColorScheme colorScheme = new ColorScheme(mSettings.getColorScheme());

    mViewFlipper.updatePrefs(mSettings);

    for (View v : mViewFlipper) {
      ((EmulatorView) v).setDensity(metrics);
      ((TermView) v).updatePrefs(mSettings);
    }

    if (mTermSessions != null) {
      for (TermSession session : mTermSessions) {
        ((ShellTermSession) session).updatePrefs(mSettings);
      }
    }

    {
      Window win = getWindow();
      WindowManager.LayoutParams params = win.getAttributes();
      final int FULLSCREEN = WindowManager.LayoutParams.FLAG_FULLSCREEN;
      int desiredFlag = mSettings.showStatusBar() ? 0 : FULLSCREEN;
      if (desiredFlag != (params.flags & FULLSCREEN)
          || (AndroidCompat.SDK >= 11 && mActionBarMode != mSettings.actionBarMode())) {
        if (mAlreadyStarted) {
          // Can't switch to/from fullscreen after
          // starting the activity.
          restart();
        } else {
          win.setFlags(desiredFlag, FULLSCREEN);
          if (mActionBarMode == TermSettings.ACTION_BAR_MODE_HIDES) {
            mActionBar.hide();
          }
        }
      }
    }
  }
Пример #8
0
 @Override
 public boolean onSingleTapUp(MotionEvent e) {
   doUIToggle((int) e.getX(), (int) e.getY(), view.getVisibleWidth(), view.getVisibleHeight());
   return true;
 }