|
|
@@ -6,7 +6,6 @@ import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.view.Gravity;
|
|
|
-import android.view.View;
|
|
|
import android.view.WindowManager;
|
|
|
import android.view.accessibility.AccessibilityEvent;
|
|
|
import android.view.accessibility.AccessibilityNodeInfo;
|
|
|
@@ -19,10 +18,9 @@ import java.util.logging.Logger;
|
|
|
import info.knacki.pass.R;
|
|
|
|
|
|
public class AccessibilityService extends android.accessibilityservice.AccessibilityService {
|
|
|
- private final long CANCEL_DELAY_SEC = 10;
|
|
|
+ private final static long CANCEL_DELAY_SEC = 10;
|
|
|
private static AccessibilityService fInstance;
|
|
|
private boolean fManagingEvent;
|
|
|
- private View fOpenWindow;
|
|
|
|
|
|
private class LastCancellation {
|
|
|
public long lastCancelledTime;
|
|
|
@@ -77,12 +75,12 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
|
|
PixelFormat.TRANSLUCENT);
|
|
|
params.gravity = Gravity.START | Gravity.BOTTOM;
|
|
|
|
|
|
- fOpenWindow = new AccessibilityView(this)
|
|
|
- .Init(this, new AccessibilityView.AccessibilityViewListener() {
|
|
|
+ final AccessibilityView openWindow = new AccessibilityView(this);
|
|
|
+ openWindow.Init(this, new AccessibilityView.AccessibilityViewListener() {
|
|
|
@Override
|
|
|
public void OnPasswordClicked(File f) {
|
|
|
new Handler(getMainLooper()).post(() -> {
|
|
|
- CloseOpenWindow();
|
|
|
+ CloseOpenWindow(openWindow);
|
|
|
LoadFile(f, source);
|
|
|
});
|
|
|
}
|
|
|
@@ -91,7 +89,7 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
|
|
public void cancel() {
|
|
|
new Handler(getMainLooper()).post(() -> {
|
|
|
fLastCancellation.Cancel(source);
|
|
|
- CloseOpenWindow();
|
|
|
+ CloseOpenWindow(openWindow);
|
|
|
fManagingEvent = false;
|
|
|
SetFocus(source);
|
|
|
});
|
|
|
@@ -101,21 +99,19 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
|
|
|
|
|
try {
|
|
|
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
|
|
|
- wm.addView(fOpenWindow, params);
|
|
|
+ wm.addView(openWindow, params);
|
|
|
return true;
|
|
|
}
|
|
|
catch (WindowManager.BadTokenException e) {
|
|
|
- fOpenWindow = null;
|
|
|
Toast.makeText(this, getResources().getString(R.string.app_name) +": " +getResources().getString(R.string.unauthorized_draw_over), Toast.LENGTH_LONG).show();
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- private void CloseOpenWindow() {
|
|
|
- if (fOpenWindow != null) {
|
|
|
+ private void CloseOpenWindow(AccessibilityView openWindow) {
|
|
|
+ if (openWindow != null) {
|
|
|
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
|
|
|
- wm.removeViewImmediate(fOpenWindow);
|
|
|
- fOpenWindow = null;
|
|
|
+ wm.removeViewImmediate(openWindow);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -152,7 +148,6 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
|
|
|
|
|
@Override
|
|
|
public void onInterrupt() {
|
|
|
- new Handler(getMainLooper()).post(this::CloseOpenWindow);
|
|
|
}
|
|
|
|
|
|
@Override
|