mirror of
https://github.com/Tencent/QMUI_Android.git
synced 2026-10-17 04:31:16 +08:00
modify minisdk to 21
This commit is contained in:
@@ -25,7 +25,7 @@ QMUI Android 的设计目的是用于辅助快速搭建一个具备基本设计
|
||||
请查看官网的[功能列表](http://qmuiteam.com/android/page/document.html)
|
||||
|
||||
## 支持 Android 版本
|
||||
QMUI Android 支持 API Level 19+。
|
||||
QMUI Android 支持 API Level 21+。
|
||||
|
||||
## 使用方法
|
||||
请查看官网的[开始使用](http://qmuiteam.com/android/page/start.html)。
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -885,7 +884,7 @@ public abstract class QMUIFragment extends Fragment implements
|
||||
} else {
|
||||
QMUIFragment.TransitionConfig transitionConfig = onFetchTransitionConfig();
|
||||
if (needInterceptLastFragmentFinish()) {
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !sPopBackWhenSwipeFinished){
|
||||
if(!sPopBackWhenSwipeFinished){
|
||||
activity.finishAfterTransition();
|
||||
}else{
|
||||
activity.finish();
|
||||
@@ -907,7 +906,7 @@ public abstract class QMUIFragment extends Fragment implements
|
||||
onHandleSpecLastFragmentFinish(activity, transitionConfig, toExec);
|
||||
}
|
||||
} else {
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !sPopBackWhenSwipeFinished){
|
||||
if(!sPopBackWhenSwipeFinished){
|
||||
activity.finishAfterTransition();
|
||||
}else{
|
||||
activity.finish();
|
||||
|
||||
@@ -17,22 +17,20 @@
|
||||
package com.qmuiteam.qmui.arch;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityOptions;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.qmuiteam.qmui.QMUILog;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
/**
|
||||
* Created by Chaojun Wang on 6/9/14.
|
||||
*/
|
||||
@@ -74,42 +72,8 @@ public class Utils {
|
||||
* with the {@link android.R.attr#windowIsFloating} attribute.
|
||||
*/
|
||||
public static void convertActivityToTranslucent(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
convertActivityToTranslucentAfterL(activity);
|
||||
} else {
|
||||
convertActivityToTranslucentBeforeL(activity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calling the convertToTranslucent method on platforms before Android 5.0
|
||||
*/
|
||||
private static void convertActivityToTranslucentBeforeL(Activity activity) {
|
||||
try {
|
||||
Class<?>[] classes = Activity.class.getDeclaredClasses();
|
||||
Class<?> translucentConversionListenerClazz = null;
|
||||
for (Class clazz : classes) {
|
||||
if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
|
||||
translucentConversionListenerClazz = clazz;
|
||||
}
|
||||
}
|
||||
@SuppressLint("PrivateApi") Method method = Activity.class.getDeclaredMethod("convertToTranslucent",
|
||||
translucentConversionListenerClazz);
|
||||
method.setAccessible(true);
|
||||
method.invoke(activity, new Object[]{
|
||||
null
|
||||
});
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calling the convertToTranslucent method on platforms after Android 5.0
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private static void convertActivityToTranslucentAfterL(Activity activity) {
|
||||
try {
|
||||
@SuppressLint("PrivateApi") Method getActivityOptions = Activity.class.getDeclaredMethod("getActivityOptions");
|
||||
@SuppressLint({"PrivateApi", "DiscouragedPrivateApi"}) Method getActivityOptions = Activity.class.getDeclaredMethod("getActivityOptions");
|
||||
getActivityOptions.setAccessible(true);
|
||||
Object options = getActivityOptions.invoke(activity);
|
||||
|
||||
@@ -128,6 +92,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void assertInMainThread() {
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
|
||||
|
||||
+3
-8
@@ -17,15 +17,14 @@
|
||||
package com.qmuiteam.qmui.nestedScroll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
|
||||
import com.qmuiteam.qmui.widget.webview.QMUIWebView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class QMUIContinuousNestedTopWebView extends QMUIWebView implements IQMUIContinuousNestedTopView {
|
||||
|
||||
public static final String KEY_SCROLL_INFO = "@qmui_scroll_info_top_webview";
|
||||
@@ -106,10 +105,6 @@ public class QMUIContinuousNestedTopWebView extends QMUIWebView implements IQMUI
|
||||
}
|
||||
|
||||
private void exec(final String jsCode) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
evaluateJavascript(jsCode, null);
|
||||
} else {
|
||||
loadUrl(jsCode);
|
||||
}
|
||||
evaluateJavascript(jsCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
@@ -701,9 +700,7 @@ public class QMUIQQFaceView extends View {
|
||||
if (mJumpHandleMeasureAndDraw) {
|
||||
break;
|
||||
}
|
||||
if (mCurrentCalLine > mMaxLine && mEllipsize == TextUtils.TruncateAt.END
|
||||
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
// 针对4.x的手机,如果超过最大行数,就打断测量,但这样存在的问题是getLines获取不到真实的行数
|
||||
if (mCurrentCalLine > mMaxLine && mEllipsize == TextUtils.TruncateAt.END) {
|
||||
break;
|
||||
}
|
||||
element = elements.get(i);
|
||||
|
||||
@@ -19,7 +19,6 @@ import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Trace;
|
||||
import android.text.Spanned;
|
||||
import android.util.ArrayMap;
|
||||
@@ -267,7 +266,7 @@ public final class QMUISkinManager {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Trace.beginSection("QMUISkin::dispatch");
|
||||
}
|
||||
SkinItem skinItem = mSkins.get(skinIndex);
|
||||
@@ -281,7 +280,7 @@ public final class QMUISkinManager {
|
||||
theme = skinItem.getTheme();
|
||||
}
|
||||
runDispatch(view, skinIndex, theme);
|
||||
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Trace.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.qmuiteam.qmui.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
@@ -363,16 +362,7 @@ public class QMUIDeviceHelper {
|
||||
*/
|
||||
public static boolean isFloatWindowOpAllowed(Context context) {
|
||||
final int version = Build.VERSION.SDK_INT;
|
||||
if (version >= 19) {
|
||||
return checkOp(context, 24); // 24 是AppOpsManager.OP_SYSTEM_ALERT_WINDOW 的值,该值无法直接访问
|
||||
} else {
|
||||
try {
|
||||
return (context.getApplicationInfo().flags & 1 << 27) == 1 << 27;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return checkOp(context, 24); // 24 是AppOpsManager.OP_SYSTEM_ALERT_WINDOW 的值,该值无法直接访问
|
||||
}
|
||||
|
||||
public static double getBatteryCapacity(Context context) {
|
||||
@@ -392,18 +382,15 @@ public class QMUIDeviceHelper {
|
||||
return sBatteryCapacity;
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
|
||||
private static boolean checkOp(Context context, int op) {
|
||||
final int version = Build.VERSION.SDK_INT;
|
||||
if (version >= Build.VERSION_CODES.KITKAT) {
|
||||
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
try {
|
||||
Method method = manager.getClass().getDeclaredMethod("checkOp", int.class, int.class, String.class);
|
||||
int property = (Integer) method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
|
||||
return AppOpsManager.MODE_ALLOWED == property;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
try {
|
||||
Method method = manager.getClass().getDeclaredMethod("checkOp", int.class, int.class, String.class);
|
||||
int property = (Integer) method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
|
||||
return AppOpsManager.MODE_ALLOWED == property;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,9 +62,8 @@ public class QMUIStatusBarHelper {
|
||||
}
|
||||
|
||||
private static boolean supportTranslucent() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
|
||||
// Essential Phone 在 Android 8 之前沉浸式做得不全,系统不从状态栏顶部开始布局却会下发 WindowInsets
|
||||
&& !(QMUIDeviceHelper.isEssentialPhone() && Build.VERSION.SDK_INT < 26);
|
||||
// Essential Phone 在 Android 8 之前沉浸式做得不全,系统不从状态栏顶部开始布局却会下发 WindowInsets
|
||||
return !(QMUIDeviceHelper.isEssentialPhone() && Build.VERSION.SDK_INT < 26);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,36 +96,25 @@ public class QMUIStatusBarHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
|
||||
systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
||||
window.getDecorView().setSystemUiVisibility(systemUiVisibility);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && supportTransclentStatusBar6()) {
|
||||
// android 6以后可以改状态栏字体颜色,因此可以自行设置为透明
|
||||
// ZUK Z1是个另类,自家应用可以实现字体颜色变色,但没开放接口
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(Color.TRANSPARENT);
|
||||
} else {
|
||||
// android 5不能修改状态栏字体颜色,因此直接用FLAG_TRANSLUCENT_STATUS,nexus表现为半透明
|
||||
// 魅族和小米的表现如何?
|
||||
// update: 部分手机运用FLAG_TRANSLUCENT_STATUS时背景不是半透明而是没有背景了。。。。。
|
||||
int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
|
||||
systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
||||
window.getDecorView().setSystemUiVisibility(systemUiVisibility);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && supportTransclentStatusBar6()) {
|
||||
// android 6以后可以改状态栏字体颜色,因此可以自行设置为透明
|
||||
// ZUK Z1是个另类,自家应用可以实现字体颜色变色,但没开放接口
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(Color.TRANSPARENT);
|
||||
} else {
|
||||
// android 5不能修改状态栏字体颜色,因此直接用FLAG_TRANSLUCENT_STATUS,nexus表现为半透明
|
||||
// 魅族和小米的表现如何?
|
||||
// update: 部分手机运用FLAG_TRANSLUCENT_STATUS时背景不是半透明而是没有背景了。。。。。
|
||||
// window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
|
||||
// 采取setStatusBarColor的方式,部分机型不支持,那就纯黑了,保证状态栏图标可见
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(colorOn5x);
|
||||
}
|
||||
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
// // android4.4的默认是从上到下黑到透明,我们的背景是白色,很难看,因此只做魅族和小米的
|
||||
// } else if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1){
|
||||
// // 如果app 为白色,需要更改状态栏颜色,因此不能让19一下支持透明状态栏
|
||||
// Window window = activity.getWindow();
|
||||
// Integer transparentValue = getStatusBarAPITransparentValue(activity);
|
||||
// if(transparentValue != null) {
|
||||
// window.getDecorView().setSystemUiVisibility(transparentValue);
|
||||
// }
|
||||
// 采取setStatusBarColor的方式,部分机型不支持,那就纯黑了,保证状态栏图标可见
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(colorOn5x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,18 +183,16 @@ public class QMUIStatusBarHelper {
|
||||
if (mStatusBarType != STATUSBAR_TYPE_DEFAULT) {
|
||||
return setStatusBarLightMode(activity, mStatusBarType);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (isMIUICustomStatusBarLightModeImpl() && MIUISetStatusBarLightMode(activity.getWindow(), true)) {
|
||||
mStatusBarType = STATUSBAR_TYPE_MIUI;
|
||||
return true;
|
||||
} else if (FlymeSetStatusBarLightMode(activity.getWindow(), true)) {
|
||||
mStatusBarType = STATUSBAR_TYPE_FLYME;
|
||||
return true;
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Android6SetStatusBarLightMode(activity.getWindow(), true);
|
||||
mStatusBarType = STATUSBAR_TYPE_ANDROID6;
|
||||
return true;
|
||||
}
|
||||
if (isMIUICustomStatusBarLightModeImpl() && MIUISetStatusBarLightMode(activity.getWindow(), true)) {
|
||||
mStatusBarType = STATUSBAR_TYPE_MIUI;
|
||||
return true;
|
||||
} else if (FlymeSetStatusBarLightMode(activity.getWindow(), true)) {
|
||||
mStatusBarType = STATUSBAR_TYPE_FLYME;
|
||||
return true;
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Android6SetStatusBarLightMode(activity.getWindow(), true);
|
||||
mStatusBarType = STATUSBAR_TYPE_ANDROID6;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -621,20 +621,6 @@ public class QMUIViewHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否需要对 LineSpacingExtra 进行额外的兼容处理
|
||||
* 安卓 5.0 以下版本中,LineSpacingExtra 在最后一行也会产生作用,因此会多出一个 LineSpacingExtra 的空白,可以通过该方法判断后进行兼容处理
|
||||
* if (QMUIViewHelper.getISLastLineSpacingExtraError()) {
|
||||
* textView.bottomMargin = -3dp;
|
||||
* } else {
|
||||
* textView.bottomMargin = 0;
|
||||
* }
|
||||
*/
|
||||
public static boolean getIsLastLineSpacingExtraError() {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* requestDisallowInterceptTouchEvent 的安全方法。存在它的原因是 QMUIPullRefreshLayout 会拦截这个事件
|
||||
*
|
||||
|
||||
@@ -22,13 +22,13 @@ import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.qmuiteam.qmui.BuildConfig;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* @author cginechen
|
||||
* @date 2016-08-05
|
||||
@@ -50,11 +50,7 @@ public class QMUIWindowHelper {
|
||||
*/
|
||||
|
||||
public static void setWindowType(WindowManager.LayoutParams layoutParams) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_TOAST;
|
||||
} else {
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE;
|
||||
}
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_TOAST;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,15 +21,11 @@ import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.database.DataSetObserver;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemClock;
|
||||
import androidx.collection.LongSparseArray;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
@@ -42,6 +38,9 @@ import android.widget.BaseAdapter;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.collection.LongSparseArray;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
import com.qmuiteam.qmui.QMUILog;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@@ -116,7 +115,6 @@ public class QMUIAnimationListView extends ListView {
|
||||
init();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public QMUIAnimationListView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -145,10 +144,8 @@ public class QMUIBottomSheet extends QMUIBaseDialog {
|
||||
super.onCreate(savedInstanceState);
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
}
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
}
|
||||
ViewCompat.requestApplyInsets(mRootView);
|
||||
|
||||
+1
-6
@@ -18,7 +18,6 @@ package com.qmuiteam.qmui.widget.pullRefreshLayout;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
@@ -716,11 +715,7 @@ public class QMUIPullRefreshLayout extends ViewGroup implements NestedScrollingP
|
||||
((RecyclerView) targetView).scrollToPosition(0);
|
||||
} else if (targetView instanceof AbsListView) {
|
||||
AbsListView listView = (AbsListView) targetView;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
listView.setSelectionFromTop(0, 0);
|
||||
} else {
|
||||
listView.setSelection(0);
|
||||
}
|
||||
listView.setSelectionFromTop(0, 0);
|
||||
} else {
|
||||
targetView.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
+4
-30
@@ -19,13 +19,12 @@ package com.qmuiteam.qmui.widget.roundwidget;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Build;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.qmuiteam.qmui.R;
|
||||
|
||||
/**
|
||||
@@ -51,18 +50,7 @@ public class QMUIRoundButtonDrawable extends GradientDrawable {
|
||||
* 设置按钮的背景色(只支持纯色,不支持 Bitmap 或 Drawable)
|
||||
*/
|
||||
public void setBgData(@Nullable ColorStateList colors) {
|
||||
if (hasNativeStateListAPI()) {
|
||||
super.setColor(colors);
|
||||
} else {
|
||||
mFillColors = colors;
|
||||
final int currentColor;
|
||||
if (colors == null) {
|
||||
currentColor = Color.TRANSPARENT;
|
||||
} else {
|
||||
currentColor = colors.getColorForState(getState(), 0);
|
||||
}
|
||||
setColor(currentColor);
|
||||
}
|
||||
super.setColor(colors);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,17 +59,7 @@ public class QMUIRoundButtonDrawable extends GradientDrawable {
|
||||
public void setStrokeData(int width, @Nullable ColorStateList colors) {
|
||||
mStrokeWidth = width;
|
||||
mStrokeColors = colors;
|
||||
if (hasNativeStateListAPI()) {
|
||||
super.setStroke(width, colors);
|
||||
} else {
|
||||
final int currentColor;
|
||||
if (colors == null) {
|
||||
currentColor = Color.TRANSPARENT;
|
||||
} else {
|
||||
currentColor = colors.getColorForState(getState(), 0);
|
||||
}
|
||||
setStroke(width, currentColor);
|
||||
}
|
||||
super.setStroke(width, colors);
|
||||
}
|
||||
|
||||
public int getStrokeWidth(){
|
||||
@@ -92,10 +70,6 @@ public class QMUIRoundButtonDrawable extends GradientDrawable {
|
||||
setStrokeData(mStrokeWidth, colors);
|
||||
}
|
||||
|
||||
private boolean hasNativeStateListAPI() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置圆角大小是否自动适应为 View 的高度的一半
|
||||
*/
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
package com.qmuiteam.qmui.widget.webview;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class QMUIWebViewClient extends WebViewClient {
|
||||
|
||||
public static final int JS_FAKE_KEY_CODE_EVENT = 112; // F1
|
||||
@@ -117,30 +117,15 @@ public class QMUIWebViewClient extends WebViewClient {
|
||||
}
|
||||
|
||||
private void runJsCode(WebView webView, @NonNull String jsCode, @Nullable final Runnable finishAction) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
||||
if (finishAction == null) {
|
||||
webView.evaluateJavascript(jsCode, null);
|
||||
} else {
|
||||
webView.evaluateJavascript(jsCode, new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
finishAction.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (finishAction == null) {
|
||||
webView.evaluateJavascript(jsCode, null);
|
||||
} else {
|
||||
// Usually, there is no chance to come here.
|
||||
webView.loadUrl("javascript:" + jsCode);
|
||||
if (finishAction != null) {
|
||||
webView.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finishAction.run();
|
||||
}
|
||||
}, 250);
|
||||
}
|
||||
|
||||
webView.evaluateJavascript(jsCode, new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
finishAction.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-25
@@ -17,7 +17,6 @@
|
||||
package com.qmuiteam.qmuidemo.fragment.components.qqface;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
@@ -100,31 +99,30 @@ public class QDQQFaceUsageFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
|
||||
TextParser textParser = new EmojiTextParser(QDQQFaceManager.getInstance());
|
||||
mMarqueeTypeView1.setFadeWidth(QMUIDisplayHelper.dp2px(getContext(), 40));
|
||||
mMarqueeTypeView1.setTextParser(textParser);
|
||||
mMarqueeTypeView1.setText("飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀这是一行很长很长[微笑][微笑][微笑][微笑]的文本,但是[微笑][微笑][微笑][微笑]只能单行显示");
|
||||
mMarqueeTypeView2.setFadeWidth(QMUIDisplayHelper.dp2px(getContext(), 40));
|
||||
mMarqueeTypeView2.setTextParser(textParser);
|
||||
mMarqueeTypeView2.setText("[大哭]我太短了,实在是飘不动了");
|
||||
TextParser textParser = new EmojiTextParser(QDQQFaceManager.getInstance());
|
||||
mMarqueeTypeView1.setFadeWidth(QMUIDisplayHelper.dp2px(getContext(), 40));
|
||||
mMarqueeTypeView1.setTextParser(textParser);
|
||||
mMarqueeTypeView1.setText("飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀飘呀这是一行很长很长[微笑][微笑][微笑][微笑]的文本,但是[微笑][微笑][微笑][微笑]只能单行显示");
|
||||
mMarqueeTypeView2.setFadeWidth(QMUIDisplayHelper.dp2px(getContext(), 40));
|
||||
mMarqueeTypeView2.setTextParser(textParser);
|
||||
mMarqueeTypeView2.setText("[大哭]我太短了,实在是飘不动了");
|
||||
|
||||
mLineType1.setTextParser(textParser);
|
||||
LineLayout lineLayout = mLineType1.getLineLayout();
|
||||
lineLayout.setMaxLines(6);
|
||||
lineLayout.setEllipsize(TextUtils.TruncateAt.END);
|
||||
lineLayout.setMoreText("更多");
|
||||
lineLayout.setMoreUnderlineHeight(QMUIDisplayHelper.dp2px(getContext(), 2));
|
||||
lineLayout.setMoreTextColor(Color.RED);
|
||||
lineLayout.setMoreUnderlineColor(Color.BLUE);
|
||||
mLineType1.setLineHeight(QMUIDisplayHelper.dp2px(getContext(), 36));
|
||||
mLineType1.setTextColor(Color.BLACK);
|
||||
mLineType1.setTextSize(QMUIDisplayHelper.sp2px(getContext(), 15));
|
||||
mLineType1.setTextParser(textParser);
|
||||
mLineType1.setText("QMUI Android 的设计[微笑]目的是用于辅助快速搭建一个具备基本设计还原[微笑]效果的 Android 项目," +
|
||||
"同时利用自身[微笑]提供的丰富控件及兼容处理,让开[微笑]发者能专注于业务需求而无需耗费[微笑]精力在基础代[微笑]码的设计上。" +
|
||||
"不管是新项目的创建,或是已有项[微笑]目的维护,均可使开[微笑]发效率和项目[微笑]质量得到大幅度提升。");
|
||||
|
||||
mLineType1.setTextParser(textParser);
|
||||
LineLayout lineLayout = mLineType1.getLineLayout();
|
||||
lineLayout.setMaxLines(6);
|
||||
lineLayout.setEllipsize(TextUtils.TruncateAt.END);
|
||||
lineLayout.setMoreText("更多");
|
||||
lineLayout.setMoreUnderlineHeight(QMUIDisplayHelper.dp2px(getContext(), 2));
|
||||
lineLayout.setMoreTextColor(Color.RED);
|
||||
lineLayout.setMoreUnderlineColor(Color.BLUE);
|
||||
mLineType1.setLineHeight(QMUIDisplayHelper.dp2px(getContext(), 36));
|
||||
mLineType1.setTextColor(Color.BLACK);
|
||||
mLineType1.setTextSize(QMUIDisplayHelper.sp2px(getContext(), 15));
|
||||
mLineType1.setTextParser(textParser);
|
||||
mLineType1.setText("QMUI Android 的设计[微笑]目的是用于辅助快速搭建一个具备基本设计还原[微笑]效果的 Android 项目," +
|
||||
"同时利用自身[微笑]提供的丰富控件及兼容处理,让开[微笑]发者能专注于业务需求而无需耗费[微笑]精力在基础代[微笑]码的设计上。" +
|
||||
"不管是新项目的创建,或是已有项[微笑]目的维护,均可使开[微笑]发效率和项目[微笑]质量得到大幅度提升。");
|
||||
}
|
||||
mQQFace1.setText("这是一行很长很长[微笑][微笑][微笑][微笑]的文本,但是[微笑][微笑][微笑][微笑]只能单行显示");
|
||||
mQQFace2.setText("这是一段很长很长[微笑][微笑][微笑][微笑]的文本,但是最多只能显示三行;" +
|
||||
"这是一段很长很长[微笑][微笑][微笑][微笑]的文本,但是最多只能显示三行;" +
|
||||
|
||||
+7
-18
@@ -17,7 +17,6 @@
|
||||
package com.qmuiteam.qmuidemo.fragment.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -160,15 +159,10 @@ public class QDNotchHelperFragment extends BaseFragment {
|
||||
}
|
||||
View decorView = window.getDecorView();
|
||||
int systemUi = decorView.getSystemUiVisibility();
|
||||
systemUi |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
systemUi |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
systemUi |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
}
|
||||
systemUi |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
decorView.setSystemUiVisibility(systemUi);
|
||||
QMUIDisplayHelper.setFullScreen(getActivity());
|
||||
QMUIViewHelper.fadeOut(mTopBar, 300, null, true);
|
||||
@@ -186,14 +180,9 @@ public class QDNotchHelperFragment extends BaseFragment {
|
||||
}
|
||||
final View decorView = window.getDecorView();
|
||||
int systemUi = decorView.getSystemUiVisibility();
|
||||
systemUi &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
systemUi &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
systemUi |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
systemUi &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
}
|
||||
systemUi &= ~(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||
systemUi |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
||||
|
||||
decorView.setSystemUiVisibility(systemUi);
|
||||
QMUIDisplayHelper.cancelFullScreen(getActivity());
|
||||
QMUIViewHelper.fadeIn(mTopBar, 300, null, true);
|
||||
|
||||
@@ -60,10 +60,7 @@ public class QDWebView extends QMUIWebView {
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||
webSettings.setTextZoom(100);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
|
||||
}
|
||||
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
|
||||
|
||||
String screen = QMUIDisplayHelper.getScreenWidth(context) + "x" + QMUIDisplayHelper.getScreenHeight(context);
|
||||
String userAgent = "QMUIDemo/" + QMUIPackageHelper.getAppVersion(context)
|
||||
@@ -75,17 +72,13 @@ public class QDWebView extends QMUIWebView {
|
||||
}
|
||||
|
||||
// 开启调试
|
||||
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
setWebContentsDebuggingEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void exec(final String jsCode) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
evaluateJavascript(jsCode, null);
|
||||
} else {
|
||||
loadUrl(jsCode);
|
||||
}
|
||||
evaluateJavascript(jsCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.qmuiteam.qmui.type.TypeModel
|
||||
import com.qmuiteam.qmui.type.parser.PlainTextParser
|
||||
import com.qmuiteam.qmui.type.parser.TextParser
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
class MarqueeTypeView : BaseTypeView {
|
||||
|
||||
constructor(context: Context): super(context)
|
||||
|
||||
Reference in New Issue
Block a user