diff --git a/android/src/main/java/com/beefe/picker/PickerViewModule.java b/android/src/main/java/com/beefe/picker/PickerViewModule.java index c10059d870aefb2cdd0b681ac2b2a98a2cd107e9..3ae70ddb6178ade3eff03bb3523490f536d06908 100644 --- a/android/src/main/java/com/beefe/picker/PickerViewModule.java +++ b/android/src/main/java/com/beefe/picker/PickerViewModule.java @@ -13,6 +13,7 @@ import android.view.WindowManager; import android.widget.RelativeLayout; import android.widget.TextView; +import com.beefe.picker.util.MIUIUtils; import com.beefe.picker.view.OnSelectedListener; import com.beefe.picker.view.PickerViewAlone; import com.beefe.picker.view.PickerViewLinkage; @@ -349,8 +350,12 @@ public class PickerViewModule extends ReactContextBaseJavaModule implements Life WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); Window window = dialog.getWindow(); if (window != null) { + if (MIUIUtils.isMIUI()) { + layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION; + }else { + //layoutParams.type = WindowManager.LayoutParams.TYPE_TOAST; + } layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; - // layoutParams.type = WindowManager.LayoutParams.TYPE_TOAST; layoutParams.format = PixelFormat.TRANSPARENT; layoutParams.windowAnimations = R.style.PickerAnim; layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; diff --git a/android/src/main/java/com/beefe/picker/util/BuildProperties.java b/android/src/main/java/com/beefe/picker/util/BuildProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..dc5298d0184e364d43e626f8d92ed24e835d8f63 --- /dev/null +++ b/android/src/main/java/com/beefe/picker/util/BuildProperties.java @@ -0,0 +1,72 @@ +package com.beefe.picker.util; + +/** + * Created by geezer. on 2017/9/21. + */ + +import android.os.Environment; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; + + +public class BuildProperties { + + private final Properties properties; + + private BuildProperties() throws IOException { + properties = new Properties(); + properties.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop"))); + } + + public boolean containsKey(final Object key) { + return properties.containsKey(key); + } + + public boolean containsValue(final Object value) { + return properties.containsValue(value); + } + + public Set> entrySet() { + return properties.entrySet(); + } + + public String getProperty(final String name) { + return properties.getProperty(name); + } + + public String getProperty(final String name, final String defaultValue) { + return properties.getProperty(name, defaultValue); + } + + public boolean isEmpty() { + return properties.isEmpty(); + } + + public Enumeration keys() { + return properties.keys(); + } + + public Set keySet() { + return properties.keySet(); + } + + public int size() { + return properties.size(); + } + + public Collection values() { + return properties.values(); + } + + public static BuildProperties newInstance() throws IOException { + return new BuildProperties(); + } + +} diff --git a/android/src/main/java/com/beefe/picker/util/MIUIUtils.java b/android/src/main/java/com/beefe/picker/util/MIUIUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..573a6f418e4bedbe2bf99153a3842ac8410c4a0d --- /dev/null +++ b/android/src/main/java/com/beefe/picker/util/MIUIUtils.java @@ -0,0 +1,25 @@ +package com.beefe.picker.util; + +import java.io.IOException; + +/** + * Created by geezer. on 2017/9/21. + */ + +public final class MIUIUtils { + + private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code"; + private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name"; + private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage"; + + public static boolean isMIUI() { + try { + final BuildProperties prop = BuildProperties.newInstance(); + return prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null + || prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null + || prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null; + } catch (final IOException e) { + return false; + } + } +}