use of jackpal.androidterm.util.SessionList in project Android-Terminal-Emulator by jackpal.
the class RemoteInterface method appendToWindow.
protected String appendToWindow(String handle, String iInitialCommand) {
TermService service = getTermService();
// Find the target window
SessionList sessions = service.getSessions();
GenericTermSession target = null;
int index;
for (index = 0; index < sessions.size(); ++index) {
GenericTermSession session = (GenericTermSession) sessions.get(index);
String h = session.getHandle();
if (h != null && h.equals(handle)) {
target = session;
break;
}
}
if (target == null) {
// Target window not found, open a new one
return openNewWindow(iInitialCommand);
}
if (iInitialCommand != null) {
target.write(iInitialCommand);
target.write('\r');
}
Intent intent = new Intent(PRIVACT_SWITCH_WINDOW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(PRIVEXTRA_TARGET_WINDOW, index);
startActivity(intent);
return handle;
}
use of jackpal.androidterm.util.SessionList in project Android-Terminal-Emulator by jackpal.
the class WindowListAdapter method getView.
public View getView(int position, View convertView, ViewGroup parent) {
Activity act = findActivityFromContext(parent.getContext());
View child = act.getLayoutInflater().inflate(R.layout.window_list_item, parent, false);
View close = child.findViewById(R.id.window_list_close);
TextView label = (TextView) child.findViewById(R.id.window_list_label);
String defaultTitle = act.getString(R.string.window_title, position + 1);
label.setText(getSessionTitle(position, defaultTitle));
final SessionList sessions = mSessions;
final int closePosition = position;
close.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
TermSession session = sessions.remove(closePosition);
if (session != null) {
session.finish();
notifyDataSetChanged();
}
}
});
return child;
}
use of jackpal.androidterm.util.SessionList 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.util.SessionList in project Android-Terminal-Emulator by jackpal.
the class TermService method onCreate.
@Override
public void onCreate() {
// should really belong to the Application class, but we don't use one...
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = prefs.edit();
String defValue = getDir("HOME", MODE_PRIVATE).getAbsolutePath();
String homePath = prefs.getString("home_path", defValue);
editor.putString("home_path", homePath);
editor.commit();
compat = new ServiceForegroundCompat(this);
mTermSessions = new SessionList();
/* Put the service in the foreground. */
Notification notification = new Notification(R.drawable.ic_stat_service_notification_icon, getText(R.string.service_notify_text), System.currentTimeMillis());
notification.flags |= Notification.FLAG_ONGOING_EVENT;
Intent notifyIntent = new Intent(this, Term.class);
notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifyIntent, 0);
notification.setLatestEventInfo(this, getText(R.string.application_terminal), getText(R.string.service_notify_text), pendingIntent);
compat.startForeground(RUNNING_NOTIFICATION, notification);
Log.d(TermDebug.LOG_TAG, "TermService started");
return;
}
use of jackpal.androidterm.util.SessionList in project Android-Terminal-Emulator by jackpal.
the class RemoteInterface method finish.
@Override
public void finish() {
ServiceConnection conn = mTSConnection;
if (conn != null) {
unbindService(conn);
// Stop the service if no terminal sessions are running
TermService service = mTermService;
if (service != null) {
SessionList sessions = service.getSessions();
if (sessions == null || sessions.size() == 0) {
stopService(mTSIntent);
}
}
mTSConnection = null;
mTermService = null;
}
super.finish();
}
Aggregations