Skip to content

Commit

Permalink
增强避让输入法功能
Browse files Browse the repository at this point in the history
  • Loading branch information
fg607 committed Sep 7, 2018
1 parent 9cc2475 commit 1ea8661
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 14 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
minSdkVersion 18
targetSdkVersion 28

versionCode 31
versionName "3.0.3"
versionCode 32
versionName "3.0.4"
}

signingConfigs {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<!-- <receiver
<receiver
android:name=".receiver.ScreenOffAdminReceiver"
android:description="@string/admin"
android:label="@string/admin"
Expand All @@ -100,7 +100,7 @@
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>-->
</receiver>

<service
android:name=".service.NotificationService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public void developerInfo() {
dialog.setTitle("关于悬浮助手");
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
dialog.setMessage("版本:3.0.3\r\n作者:fg607\r\n邮箱:[email protected]");
dialog.setMessage("版本:3.0.4\r\n作者:fg607\r\n邮箱:[email protected]");
dialog.show();
}

Expand Down Expand Up @@ -464,12 +464,12 @@ public void questionsAnswer() {
public void showUpdateInfo() {

AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle("悬浮助手-3.0.3版本更新内容");
dialog.setTitle("悬浮助手-3.0.4版本更新内容");
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
dialog.setMessage("" +
"1.适配安卓9.0\r\n"+
"2.修复已知bug\r\n"+
"1.完整的避让软键盘功能(自动避让,自动复原,只需一个输入法)\r\n"+
"2.恢复锁屏功能\r\n"+
"");
dialog.show();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.inputmethodservice.InputMethodService;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
Expand All @@ -23,6 +24,8 @@
import android.view.View;
import android.view.WindowManager;
import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.InputMethodManager;

import com.hardwork.fg607.relaxfinger.R;
import com.hardwork.fg607.relaxfinger.adapter.MenuFolderAdapter;
import com.hardwork.fg607.relaxfinger.model.HideAppInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class ScreenOffAdminReceiver extends DeviceAdminReceiver {

@Override
public void onEnabled(Context context, Intent intent) {

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.accessibilityservice.AccessibilityService;
import android.content.Context;
import android.content.Intent;
import android.inputmethodservice.InputMethodService;
import android.os.Build;
import android.util.Log;
import android.view.KeyEvent;
Expand All @@ -16,13 +17,18 @@

import net.grandcentrix.tray.AppPreferences;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
* Created by fg607 on 16-1-23.
*/
public class NavAccessibilityService extends AccessibilityService {

public static AccessibilityService instance = null;
private AppPreferences sp;
private InputMethodManager mIMM;

@Override
protected void onServiceConnected() {
Expand All @@ -32,6 +38,9 @@ protected void onServiceConnected() {

sp = FloatingBallUtils.getMultiProcessPreferences();

mIMM = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);


/* //动态配置
AccessibilityServiceInfo config = new AccessibilityServiceInfo();
config.eventTypes = AccessibilityEvent.TYPE_VIEW_CLICKED;
Expand Down Expand Up @@ -66,7 +75,43 @@ public void onAccessibilityEvent(final AccessibilityEvent accessibilityEvent) {

if("android.inputmethodservice.SoftInputWindow".equals(accessibilityEvent.getClassName())){

notifyInputWindowShow();
notifyInputWindowShow(true);


new Thread(new Runnable() {
@Override
public void run() {

while (true){

try {
Thread.sleep(500);
//反射判断键盘高度,为0则表明键盘关闭!
Class<InputMethodManager> iMSClass = InputMethodManager.class;
Method method = iMSClass.getMethod("getInputMethodWindowVisibleHeight");

int imeHeight = (int) method.invoke(mIMM);
if(imeHeight == 0){

notifyInputWindowShow(false);

break;
}

} catch (InterruptedException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}


}
}).start();
}


Expand Down Expand Up @@ -143,10 +188,10 @@ private void notifyWindowChange(String foregroundPackageName) {
startService(intent);
}

private void notifyInputWindowShow() {
private void notifyInputWindowShow(boolean isShowing) {
Intent intent = new Intent();
intent.putExtra("what", Config.FLOAT_AUTOMOVE);
intent.putExtra("move",true);
intent.putExtra("move",isShowing);
intent.setClass(this, FloatService.class);
startService(intent);
}
Expand Down
3 changes: 0 additions & 3 deletions input.txt

This file was deleted.

0 comments on commit 1ea8661

Please sign in to comment.