Commit 1fa64518 authored by travelgeezer's avatar travelgeezer

Try compatible miui

parent 64860d7c
...@@ -13,6 +13,7 @@ import android.view.WindowManager; ...@@ -13,6 +13,7 @@ import android.view.WindowManager;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.beefe.picker.util.MIUIUtils;
import com.beefe.picker.view.OnSelectedListener; import com.beefe.picker.view.OnSelectedListener;
import com.beefe.picker.view.PickerViewAlone; import com.beefe.picker.view.PickerViewAlone;
import com.beefe.picker.view.PickerViewLinkage; import com.beefe.picker.view.PickerViewLinkage;
...@@ -349,8 +350,12 @@ public class PickerViewModule extends ReactContextBaseJavaModule implements Life ...@@ -349,8 +350,12 @@ public class PickerViewModule extends ReactContextBaseJavaModule implements Life
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
Window window = dialog.getWindow(); Window window = dialog.getWindow();
if (window != null) { 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.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
layoutParams.type = WindowManager.LayoutParams.TYPE_TOAST;
layoutParams.format = PixelFormat.TRANSPARENT; layoutParams.format = PixelFormat.TRANSPARENT;
layoutParams.windowAnimations = R.style.PickerAnim; layoutParams.windowAnimations = R.style.PickerAnim;
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
......
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<Entry<Object, Object>> 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<Object> keys() {
return properties.keys();
}
public Set<Object> keySet() {
return properties.keySet();
}
public int size() {
return properties.size();
}
public Collection<Object> values() {
return properties.values();
}
public static BuildProperties newInstance() throws IOException {
return new BuildProperties();
}
}
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;
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment