Show window if launched when hidden

This commit is contained in:
Fredrik Fornwall
2017-04-02 14:46:00 +02:00
parent 63adb2b132
commit 19f838e3d1

View File

@@ -124,13 +124,12 @@ public class TermuxFloatService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
String action = intent.getAction();
if (ACTION_HIDE.equals(action)) {
mVisibleWindow = false;
mFloatingWindow.setVisibility(View.GONE);
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, buildNotification());
setVisible(false);
} else if (ACTION_SHOW.equals(action)) {
mFloatingWindow.setVisibility(View.VISIBLE);
mVisibleWindow = true;
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, buildNotification());
setVisible(true);
} else if (!mVisibleWindow) {
// Show window if hidden when launched through launcher icon.
setVisible(true);
}
return Service.START_NOT_STICKY;
}
@@ -141,6 +140,12 @@ public class TermuxFloatService extends Service {
if (mFloatingWindow != null) mFloatingWindow.closeFloatingWindow();
}
private void setVisible(boolean newVisibility) {
mVisibleWindow = newVisibility;
mFloatingWindow.setVisibility(newVisibility ? View.VISIBLE : View.GONE);
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, buildNotification());
}
public void changeFontSize(boolean increase) {
mFontSize += (increase ? 1 : -1) * 2;
mFontSize = Math.max(MIN_FONTSIZE, mFontSize);