use of jackpal.androidterm.emulatorview.TermSession in project Android-Terminal-Emulator by jackpal.
the class Term method doCloseWindow.
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) {
mViewFlipper.showNext();
}
}
use of jackpal.androidterm.emulatorview.TermSession in project Android-Terminal-Emulator by jackpal.
the class Term method createTermSession.
private TermSession createTermSession() throws IOException {
TermSettings settings = mSettings;
TermSession session = createTermSession(this, settings, settings.getInitialCommand());
session.setFinishCallback(mTermService);
return session;
}
use of jackpal.androidterm.emulatorview.TermSession in project Android-Terminal-Emulator by jackpal.
the class Term method doCreateNewWindow.
private void doCreateNewWindow() {
if (mTermSessions == null) {
Log.w(TermDebug.LOG_TAG, "Couldn't create new window because mTermSessions == null");
return;
}
try {
TermSession session = createTermSession();
mTermSessions.add(session);
TermView view = createEmulatorView(session);
view.updatePrefs(mSettings);
mViewFlipper.addView(view);
mViewFlipper.setDisplayedChild(mViewFlipper.getChildCount() - 1);
} catch (IOException e) {
Toast.makeText(this, "Failed to create a session", Toast.LENGTH_SHORT).show();
}
}
use of jackpal.androidterm.emulatorview.TermSession in project Android-Terminal-Emulator by jackpal.
the class TermService method onDestroy.
@Override
public void onDestroy() {
compat.stopForeground(true);
for (TermSession session : mTermSessions) {
/* Don't automatically remove from list of sessions -- we clear the
* list below anyway and we could trigger
* ConcurrentModificationException if we do */
session.setFinishCallback(null);
session.finish();
}
mTermSessions.clear();
return;
}
use of jackpal.androidterm.emulatorview.TermSession 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. */
}
Aggregations