|
@@ -1,4 +1,4 @@
|
|
|
-package info.knacki.pass.input;
|
|
|
|
|
|
|
+package info.knacki.pass.services;
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.annotation.SuppressLint;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
@@ -9,9 +9,9 @@ import android.os.Handler;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.MotionEvent;
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
|
+import android.view.Window;
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
-import android.widget.ScrollView;
|
|
|
|
|
import android.widget.Toast;
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
@@ -26,17 +26,14 @@ import info.knacki.pass.io.FileInterfaceFactory;
|
|
|
import info.knacki.pass.io.FileUtils;
|
|
import info.knacki.pass.io.FileUtils;
|
|
|
import info.knacki.pass.io.IFileInterface;
|
|
import info.knacki.pass.io.IFileInterface;
|
|
|
import info.knacki.pass.io.OnResponseListener;
|
|
import info.knacki.pass.io.OnResponseListener;
|
|
|
-import info.knacki.pass.io.PathUtils;
|
|
|
|
|
import info.knacki.pass.settings.SettingsManager;
|
|
import info.knacki.pass.settings.SettingsManager;
|
|
|
import info.knacki.pass.ui.MainActivity;
|
|
import info.knacki.pass.ui.MainActivity;
|
|
|
import info.knacki.pass.ui.alertPrompt.ServiceAlertPromptGenerator;
|
|
import info.knacki.pass.ui.alertPrompt.ServiceAlertPromptGenerator;
|
|
|
import info.knacki.pass.ui.alertPrompt.views.SimpleTextEditWithKeyboard;
|
|
import info.knacki.pass.ui.alertPrompt.views.SimpleTextEditWithKeyboard;
|
|
|
-import info.knacki.pass.ui.passwordList.PasswordClickListener;
|
|
|
|
|
-import info.knacki.pass.ui.passwordList.PasswordListView;
|
|
|
|
|
import info.knacki.pass.ui.passwordPicker.PasswordPickerFactory;
|
|
import info.knacki.pass.ui.passwordPicker.PasswordPickerFactory;
|
|
|
|
|
|
|
|
-public class InputService extends InputMethodService implements PasswordClickListener {
|
|
|
|
|
- protected PasswordListView fPasswordListView;
|
|
|
|
|
|
|
+public class InputService extends InputMethodService implements AccessibilityView.AccessibilityViewListener {
|
|
|
|
|
+ protected AccessibilityView fPasswordListView;
|
|
|
private static final Logger log = Logger.getLogger(InputService.class.getName());
|
|
private static final Logger log = Logger.getLogger(InputService.class.getName());
|
|
|
protected View fInputView;
|
|
protected View fInputView;
|
|
|
|
|
|
|
@@ -73,7 +70,8 @@ public class InputService extends InputMethodService implements PasswordClickLis
|
|
|
log.log(Level.SEVERE, "Cannot get Input method service");
|
|
log.log(Level.SEVERE, "Cannot get Input method service");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (!service.switchToLastInputMethod(getWindow().getWindow().getAttributes().token))
|
|
|
|
|
|
|
+ Window win = getWindow().getWindow();
|
|
|
|
|
+ if (win != null && !service.switchToLastInputMethod(win.getAttributes().token))
|
|
|
PromptInputService();
|
|
PromptInputService();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -82,11 +80,7 @@ public class InputService extends InputMethodService implements PasswordClickLis
|
|
|
@Override
|
|
@Override
|
|
|
public View onCreateInputView() {
|
|
public View onCreateInputView() {
|
|
|
fInputView = LayoutInflater.from(this).inflate(R.layout.input, null, false);
|
|
fInputView = LayoutInflater.from(this).inflate(R.layout.input, null, false);
|
|
|
- fPasswordListView = new PasswordListView<>(this, PathUtils.GetPassDir(this));
|
|
|
|
|
- ((ScrollView)fInputView.findViewById(R.id.passwordListContainer)).addView(fPasswordListView);
|
|
|
|
|
- fInputView.findViewById(R.id.prevButton).setOnClickListener(view -> {
|
|
|
|
|
- SwitchToPreviousInputMethod();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ fInputView.findViewById(R.id.prevButton).setOnClickListener(view -> SwitchToPreviousInputMethod());
|
|
|
fInputView.findViewById(R.id.backspaceButton).setOnTouchListener(new View.OnTouchListener() {
|
|
fInputView.findViewById(R.id.backspaceButton).setOnTouchListener(new View.OnTouchListener() {
|
|
|
private final static int INIT_DELAY = 650;
|
|
private final static int INIT_DELAY = 650;
|
|
|
private final static int DELAY = 250;
|
|
private final static int DELAY = 250;
|
|
@@ -124,11 +118,12 @@ public class InputService extends InputMethodService implements PasswordClickLis
|
|
|
});
|
|
});
|
|
|
fInputView.findViewById(R.id.generateButton).setOnClickListener(view -> CreatePassword());
|
|
fInputView.findViewById(R.id.generateButton).setOnClickListener(view -> CreatePassword());
|
|
|
fInputView.findViewById(R.id.openAppButton).setOnClickListener(view -> startActivity(new Intent(InputService.this, MainActivity.class)));
|
|
fInputView.findViewById(R.id.openAppButton).setOnClickListener(view -> startActivity(new Intent(InputService.this, MainActivity.class)));
|
|
|
|
|
+ fPasswordListView = ((AccessibilityView) fInputView.findViewById(R.id.accessibility)).Init(this, this);
|
|
|
return fInputView;
|
|
return fInputView;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected void CreatePassword() {
|
|
protected void CreatePassword() {
|
|
|
- new ServiceAlertPromptGenerator(fInputView).Generate(this)
|
|
|
|
|
|
|
+ new ServiceAlertPromptGenerator(fInputView.getWindowToken()).Generate(this)
|
|
|
.setCancelable(true)
|
|
.setCancelable(true)
|
|
|
.setView(new SimpleTextEditWithKeyboard(this))
|
|
.setView(new SimpleTextEditWithKeyboard(this))
|
|
|
.setPositiveButton(R.string.add, (dialogInterface, view) -> {
|
|
.setPositiveButton(R.string.add, (dialogInterface, view) -> {
|
|
@@ -137,7 +132,7 @@ public class InputService extends InputMethodService implements PasswordClickLis
|
|
|
Toast.makeText(InputService.this, "Error: Empty file name", Toast.LENGTH_LONG).show();
|
|
Toast.makeText(InputService.this, "Error: Empty file name", Toast.LENGTH_LONG).show();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- File f = new File(fPasswordListView.fCurrentDir +"/" +filename +FileInterfaceFactory.GetExtension(SettingsManager.GetDefaultEncryptionType(InputService.this)));
|
|
|
|
|
|
|
+ File f = new File(fPasswordListView.GetCurrentDir() +"/" +filename +FileInterfaceFactory.GetExtension(SettingsManager.GetDefaultEncryptionType(InputService.this)));
|
|
|
try {
|
|
try {
|
|
|
FileUtils.Touch(f);
|
|
FileUtils.Touch(f);
|
|
|
fPasswordListView.refresh();
|
|
fPasswordListView.refresh();
|
|
@@ -157,7 +152,7 @@ public class InputService extends InputMethodService implements PasswordClickLis
|
|
|
protected void GeneratePassword(final File f) {
|
|
protected void GeneratePassword(final File f) {
|
|
|
final PasswordGeneratorWizard wiz = new PasswordGeneratorWizard(this);
|
|
final PasswordGeneratorWizard wiz = new PasswordGeneratorWizard(this);
|
|
|
|
|
|
|
|
- new ServiceAlertPromptGenerator(fInputView).Generate(this)
|
|
|
|
|
|
|
+ new ServiceAlertPromptGenerator(fInputView.getWindowToken()).Generate(this)
|
|
|
.setCancelable(true)
|
|
.setCancelable(true)
|
|
|
.setView(wiz)
|
|
.setView(wiz)
|
|
|
.setPositiveButton(R.string.add, (dialogInterface, view) -> {
|
|
.setPositiveButton(R.string.add, (dialogInterface, view) -> {
|
|
@@ -196,7 +191,7 @@ public class InputService extends InputMethodService implements PasswordClickLis
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void OnPasswordClicked(File f) {
|
|
public void OnPasswordClicked(File f) {
|
|
|
- FileInterfaceFactory.GetFileInterface(this, PasswordPickerFactory.GetPasswordPicker(this, fInputView), f).ReadFile(new OnResponseListener<String>() {
|
|
|
|
|
|
|
+ FileInterfaceFactory.GetFileInterface(this, PasswordPickerFactory.GetPasswordPicker(this, fInputView.getWindowToken()), f).ReadFile(new OnResponseListener<String>() {
|
|
|
@Override
|
|
@Override
|
|
|
public void OnResponse(String passwordContent) {
|
|
public void OnResponse(String passwordContent) {
|
|
|
new android.os.Handler(getMainLooper()).post(() -> sendPassword(passwordContent));
|
|
new android.os.Handler(getMainLooper()).post(() -> sendPassword(passwordContent));
|
|
@@ -209,4 +204,8 @@ public class InputService extends InputMethodService implements PasswordClickLis
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void cancel() {
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|