Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
  • Loading branch information
XhhAndroid committed Mar 1, 2021
1 parent 6723767 commit b7980e2
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 47 deletions.
4 changes: 3 additions & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.idlefish.flutterboost">


<application>
<activity android:name=".containers.BoostFlutterActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.idlefish.flutterboost;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import io.flutter.embedding.engine.systemchannels.KeyEventChannel;
import io.flutter.plugin.editing.TextInputPlugin;

public class XAndroidKeyProcessor {
@NonNull
Expand All @@ -24,9 +24,11 @@ public XAndroidKeyProcessor(@NonNull KeyEventChannel keyEventChannel, @NonNull X

public void onKeyUp(@NonNull KeyEvent keyEvent) {
Character complexCharacter = applyCombiningCharacterToBaseCharacter(keyEvent.getUnicodeChar());
keyEventChannel.keyUp(
new KeyEventChannel.FlutterKeyEvent(keyEvent, complexCharacter)
);
if(complexCharacter != null){
keyEventChannel.keyUp(
new KeyEventChannel.FlutterKeyEvent(keyEvent, complexCharacter)
);
}
}

public void onKeyDown(@NonNull KeyEvent keyEvent) {
Expand All @@ -36,9 +38,11 @@ public void onKeyDown(@NonNull KeyEvent keyEvent) {
}

Character complexCharacter = applyCombiningCharacterToBaseCharacter(keyEvent.getUnicodeChar());
keyEventChannel.keyDown(
new KeyEventChannel.FlutterKeyEvent(keyEvent, complexCharacter)
);
if(complexCharacter != null){
keyEventChannel.keyDown(
new KeyEventChannel.FlutterKeyEvent(keyEvent, complexCharacter)
);
}
}

/**
Expand Down
22 changes: 12 additions & 10 deletions android/src/main/java/com/idlefish/flutterboost/XFlutterView.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package com.idlefish.flutterboost;

import android.annotation.TargetApi;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
//import android.graphics.Insets;
import android.graphics.Rect;
import android.os.Build;
import android.os.LocaleList;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.ViewCompat;
import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.view.KeyEvent;
Expand All @@ -25,15 +19,21 @@
import android.view.inputmethod.InputConnection;
import android.widget.FrameLayout;

import java.lang.reflect.Field;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import io.flutter.Log;
import io.flutter.embedding.android.*;
import io.flutter.embedding.android.AndroidTouchProcessor;
import io.flutter.embedding.android.FlutterSurfaceView;
import io.flutter.embedding.android.FlutterView;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.renderer.FlutterRenderer;
import io.flutter.embedding.engine.renderer.FlutterUiDisplayListener;
Expand All @@ -42,6 +42,8 @@
import io.flutter.plugin.platform.PlatformViewsController;
import io.flutter.view.AccessibilityBridge;

//import android.graphics.Insets;


public class XFlutterView extends FrameLayout {
private static final String TAG = "FlutterView";
Expand Down Expand Up @@ -581,7 +583,7 @@ public void attachToFlutterEngine(
textInputPlugin
);

this.androidTouchProcessor = new AndroidTouchProcessor(this.flutterEngine.getRenderer());
this.androidTouchProcessor = new AndroidTouchProcessor(this.flutterEngine.getRenderer(),true);
this.accessibilityBridge = new AccessibilityBridge(
this,
flutterEngine.getAccessibilityChannel(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;


import android.view.HapticFeedbackConstants;
import android.view.SoundEffectConstants;
import android.view.View;
import android.view.Window;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.ArrayList;
import java.util.List;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.flutter.embedding.engine.systemchannels.PlatformChannel;

public class XPlatformPlugin {
Expand Down Expand Up @@ -84,15 +82,24 @@ public void setClipboardData(@NonNull String text) {
XPlatformPlugin.this.setClipboardData(text);
}

/**
* The Flutter application would like to know if the clipboard currently contains a string that
* can be pasted.
*/
@Override
public List<Rect> getSystemGestureExclusionRects() {
return XPlatformPlugin.this.getSystemGestureExclusionRects();
public boolean clipboardHasStrings() {
return false;
}

@Override
public void setSystemGestureExclusionRects(@NonNull ArrayList<Rect> rects) {
XPlatformPlugin.this.setSystemGestureExclusionRects(rects);
}
// @Override
// public List<Rect> getSystemGestureExclusionRects() {
// return XPlatformPlugin.this.getSystemGestureExclusionRects();
// }

// @Override
// public void setSystemGestureExclusionRects(@NonNull ArrayList<Rect> rects) {
// XPlatformPlugin.this.setSystemGestureExclusionRects(rects);
// }
};

public XPlatformPlugin(PlatformChannel platformChannel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;

import android.text.Editable;
Expand Down Expand Up @@ -97,6 +98,16 @@ public void hide() {
hideTextInput(mView);
}

@Override
public void requestAutofill() {

}

@Override
public void finishAutofillContext(boolean shouldSave) {

}

@Override
public void setClient(int textInputClientId, TextInputChannel.Configuration configuration) {
setTextInputClient(textInputClientId, configuration);
Expand All @@ -107,6 +118,11 @@ public void setPlatformViewClient(int platformViewId) {
setPlatformViewTextInputClient(platformViewId);
}

@Override
public void setEditableSizeAndTransform(double width, double height, double[] transform) {

}

@Override
public void setEditingState(TextInputChannel.TextEditState editingState) {
setTextInputEditingState(mView, editingState);
Expand All @@ -116,6 +132,11 @@ public void setEditingState(TextInputChannel.TextEditState editingState) {
public void clearClient() {
clearTextInputClient();
}

@Override
public void sendAppPrivateCommand(String action, Bundle data) {

}
});
restartAlwaysRequired = isRestartAlwaysRequired();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@


import android.app.Activity;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
Expand All @@ -15,13 +12,26 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.*;
import android.widget.*;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;

import com.idlefish.flutterboost.FlutterBoost;
import com.idlefish.flutterboost.XFlutterView;
import com.idlefish.flutterboost.XPlatformPlugin;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import io.flutter.Log;
import io.flutter.embedding.android.DrawableSplashScreen;
import io.flutter.embedding.android.FlutterView;
Expand All @@ -30,11 +40,7 @@
import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.plugin.platform.PlatformPlugin;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class BoostFlutterActivity extends Activity
public class BoostFlutterActivity extends FragmentActivity
implements FlutterActivityAndFragmentDelegate.Host,
LifecycleOwner {

Expand Down Expand Up @@ -130,13 +136,13 @@ public void setMap(Map<String, Object> map) {
private LifecycleRegistry lifecycle;

public BoostFlutterActivity() {
lifecycle = new LifecycleRegistry(this);
// lifecycle = new LifecycleRegistry(this);
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
switchLaunchThemeForNormalTheme();

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
super.onCreate(savedInstanceState);

lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_CREATE);
Expand Down Expand Up @@ -284,11 +290,12 @@ protected void onDestroy() {
super.onDestroy();
delegate.onDestroyView();
delegate.onDetach();
// lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY);
lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode,resultCode,data);
delegate.onActivityResult(requestCode, resultCode, data);
}

Expand Down Expand Up @@ -353,6 +360,9 @@ public Activity getActivity() {
@Override
@NonNull
public Lifecycle getLifecycle() {
if (lifecycle == null) {
lifecycle = new LifecycleRegistry(this);
}
return lifecycle;
}

Expand Down Expand Up @@ -478,7 +488,7 @@ public String getContainerUrl() {
}

@Override
public Map<String ,Object> getContainerUrlParams() {
public Map<String, Object> getContainerUrlParams() {

if (getIntent().hasExtra(EXTRA_PARAMS)) {
SerializableMap serializableMap = (SerializableMap) getIntent().getSerializableExtra(EXTRA_PARAMS);
Expand All @@ -503,6 +513,4 @@ public enum BackgroundMode {
*/
transparent
}


}

0 comments on commit b7980e2

Please sign in to comment.