use of jackpal.androidterm.emulatorview.EmulatorView in project Android-Terminal-Emulator by jackpal.
the class Term method onUpdate.
// 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;
}
}
}
}
use of jackpal.androidterm.emulatorview.EmulatorView in project Android-Terminal-Emulator by jackpal.
the class TermViewFlipper method adjustChildSize.
private void adjustChildSize() {
updateVisibleRect();
Rect visible = mVisibleRect;
int width = visible.width();
int height = visible.height();
if (mCurWidth != width || mCurHeight != height) {
mCurWidth = width;
mCurHeight = height;
LayoutParams params = mChildParams;
params.width = width;
params.height = height;
for (View v : this) {
updateViewLayout(v, params);
}
mRedoLayout = true;
EmulatorView currentView = (EmulatorView) getCurrentView();
if (currentView != null) {
currentView.updateSize(false);
}
}
}
use of jackpal.androidterm.emulatorview.EmulatorView in project Android-Terminal-Emulator by jackpal.
the class TermViewFlipper method resumeCurrentView.
public void resumeCurrentView() {
EmulatorView view = (EmulatorView) getCurrentView();
if (view == null) {
return;
}
view.onResume();
view.requestFocus();
}
use of jackpal.androidterm.emulatorview.EmulatorView in project Android-Terminal-Emulator by jackpal.
the class TermActivity method onCreate.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.term_activity);
/* Text entry box at the bottom of the activity. Note that you can
also send input (whether from a hardware device or soft keyboard)
directly to the EmulatorView. */
mEntry = (EditText) findViewById(R.id.term_entry);
mEntry.setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int action, KeyEvent ev) {
// Ignore enter-key-up events
if (ev != null && ev.getAction() == KeyEvent.ACTION_UP) {
return false;
}
// Don't try to send something if we're not connected yet
TermSession session = mSession;
if (mSession == null) {
return true;
}
Editable e = (Editable) v.getText();
// Write to the terminal session
session.write(e.toString());
session.write('\r');
TextKeyListener.clear(e);
return true;
}
});
/* Sends the content of the text entry box to the terminal, without
sending a carriage return afterwards */
Button sendButton = (Button) findViewById(R.id.term_entry_send);
sendButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Don't try to send something if we're not connected yet
TermSession session = mSession;
if (mSession == null) {
return;
}
Editable e = (Editable) mEntry.getText();
session.write(e.toString());
TextKeyListener.clear(e);
}
});
/**
* EmulatorView setup.
*/
EmulatorView view = (EmulatorView) findViewById(R.id.emulatorView);
mEmulatorView = view;
/* Let the EmulatorView know the screen's density. */
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
view.setDensity(metrics);
/* Create a TermSession. */
Intent myIntent = getIntent();
String sessionType = myIntent.getStringExtra("type");
TermSession session;
if (sessionType != null && sessionType.equals("telnet")) {
/* Telnet connection: we need to do the network connect on a
separate thread, so kick that off and wait for it to finish. */
connectToTelnet(myIntent.getStringExtra("host"));
return;
} else {
// Create a local shell session.
session = createLocalTermSession();
if (session == null) {
finish();
return;
}
mSession = session;
}
/* Attach the TermSession to the EmulatorView. */
view.attachSession(session);
/* That's all you have to do! The EmulatorView will call the attached
TermSession's initializeEmulator() automatically, once it can
calculate the appropriate screen size for the terminal emulator. */
}
use of jackpal.androidterm.emulatorview.EmulatorView in project Android-Terminal-Emulator by jackpal.
the class Term method populateViewFlipper.
private void populateViewFlipper() {
if (mTermService != null) {
mTermSessions = mTermService.getSessions();
if (mTermSessions.size() == 0) {
try {
mTermSessions.add(createTermSession());
} catch (IOException e) {
Toast.makeText(this, "Failed to start terminal session", Toast.LENGTH_LONG).show();
finish();
return;
}
}
mTermSessions.addCallback(this);
for (TermSession session : mTermSessions) {
EmulatorView view = createEmulatorView(session);
mViewFlipper.addView(view);
}
updatePrefs();
if (onResumeSelectWindow >= 0) {
mViewFlipper.setDisplayedChild(onResumeSelectWindow);
onResumeSelectWindow = -1;
}
mViewFlipper.onResume();
}
}
Aggregations