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