Skip to content

Commit

Permalink
feat(Android):androidx 适配
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOnlyone authored and bbssyyuui committed Mar 8, 2023
1 parent a3467a6 commit 98f8310
Show file tree
Hide file tree
Showing 78 changed files with 262 additions and 154 deletions.
29 changes: 29 additions & 0 deletions android/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,33 @@ ext {

SOURCE_COMPATIBILITY = JavaVersion.VERSION_1_8
TARGET_COMPATIBILITY = JavaVersion.VERSION_1_8

androidx = [
"multidex" : 'androidx.multidex:multidex:2.0.0',
//androidx base
"appcompat" : 'androidx.appcompat:appcompat:1.1.0',
"annotation" : "androidx.annotation:annotation:1.1.0",
"fragment" : "androidx.fragment:fragment:1.2.0",
//androidx view
"cardview" : 'androidx.cardview:cardview:1.0.0',
"recyclerview" : 'androidx.recyclerview:recyclerview:1.1.0',
"webkit" : "androidx.webkit:webkit:1.3.0",
"drawerlayout" : "androidx.drawerlayout:drawerlayout:1.1.1",

//androidx kotlin
"core-ktx" : "androidx.core:core-ktx:1.3.0",
"activity-ktx" : "androidx.activity:activity-ktx:1.1.0",
"fragment-ktx" : "androidx.fragment:fragment-ktx:1.2.0",

//constraintLayout
"constraintLayout" : 'androidx.constraintlayout:constraintlayout:2.1.0',

//lifecycle
"lifecycle-viewmodel-savedstate": "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0",
"lifecycle-comm" : "androidx.lifecycle:lifecycle-common-java8:2.2.0",

//material
"material" : 'com.google.android.material:material:1.1.0',
]

}
2 changes: 2 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ org.gradle.daemon=true
org.gradle.parallel=true
# 开启安装Debug包
android.injected.testOnly=false
android.useAndroidX=true
android.enableJetifier=true

# 编译JS引擎库: All/JSC/QuickJS/V8/Hermes/NAPI
COMPILE_JS_ENGINE=NAPI
Expand Down
2 changes: 2 additions & 0 deletions android/hermes-debugger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ android {
}

dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')

compileOnly project(':hummer-sdk')

// OkHttp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

package com.didi.hummer.hermes.queue;

import android.support.annotation.Nullable;

import androidx.annotation.Nullable;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;

import androidx.annotation.Nullable;

/** Utility for interacting with the UI thread. */
public class UiThreadUtil {
Expand Down
6 changes: 4 additions & 2 deletions android/hummer-component/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ android {
}

dependencies {
api 'com.android.support:recyclerview-v7:28.0.0'
api 'com.android.support:support-v4:28.0.0'
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')

api rootProject.ext.androidx["appcompat"]
api rootProject.ext.androidx["recyclerview"]

api project(':hummer-sdk')
annotationProcessor project(":hummer-compiler")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;

import com.didi.hummer.render.style.HummerStyleUtils;
import com.didi.hummer.render.utility.DPUtil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;

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

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.didi.hummer.adapter.HummerAdapter;
import com.didi.hummer.adapter.imageloader.ImageSizeCallback;
import com.didi.hummer.annotation.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatImageView;
import android.text.TextUtils;
import android.util.AttributeSet;

import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;


public class RoundedImageView extends AppCompatImageView {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.text.InputFilter;
import android.text.InputType;
import android.text.TextUtils;
Expand All @@ -19,6 +18,8 @@
import android.widget.EditText;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.didi.hummer.component.text.FontManager;
import com.didi.hummer.context.HummerContext;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.didi.hummer.component.input;

import android.support.annotation.StringDef;

import androidx.annotation.StringDef;

/**
* @author: linjizong
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.didi.hummer.component.input;

import android.support.annotation.StringDef;

import androidx.annotation.StringDef;

/**
* @author: linjizong
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.didi.hummer.component.input;

import android.support.annotation.StringDef;

import androidx.annotation.StringDef;

/**
* @author: linjizong
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.didi.hummer.component.list;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.didi.hummer.core.engine.JSCallback;
import com.didi.hummer.core.engine.JSValue;
import com.didi.hummer.pool.ObjectPool;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.didi.hummer.component.list;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.didi.hummer.annotation.Component;
import com.didi.hummer.annotation.JsAttribute;
import com.didi.hummer.annotation.JsMethod;
Expand Down Expand Up @@ -274,6 +276,7 @@ protected void onStyleUpdated(Map<String, Object> newStyle) {
needUpdateEdgeSpacing = false;
}

@SuppressLint("WrongConstant")
private void initLayoutManager() {
switch (mode) {
case MODE_LIST:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.didi.hummer.component.list;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;


import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.didi.hummer.component.list;

import android.content.Context;
import android.support.v7.widget.LinearSmoothScroller;

import androidx.recyclerview.widget.LinearSmoothScroller;

/**
* 在RecyclerView滚动到某一个item的时候,使其始终滚动item到屏幕的开始处(RecyclerView默认是滚动item到屏幕的可见范围,不一定在屏幕开始处)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.didi.hummer.component.list.decoration;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.didi.hummer.component.list.ListUtil;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.didi.hummer.component.list.decoration;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.didi.hummer.component.list.ListUtil;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.didi.hummer.component.list.decoration;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.didi.hummer.component.list.ListUtil;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.didi.hummer.component.refresh;

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.didi.hummer.render.component.view.HMBase;
import com.didi.hummer.render.style.HummerLayout;
import com.scwang.smart.refresh.layout.api.RefreshFooter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.didi.hummer.component.refresh;

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import com.didi.hummer.render.component.view.HMBase;
import com.didi.hummer.render.style.HummerLayout;
import com.scwang.smart.refresh.layout.api.RefreshHeader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.didi.hummer.component.refresh;

import android.support.annotation.IntDef;

import androidx.annotation.IntDef;

/**
* Created by XiaoFeng on 2020/10/10.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.didi.hummer.component.refresh;

import android.support.annotation.IntDef;

import androidx.annotation.IntDef;

/**
* Created by XiaoFeng on 2020/10/10.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import android.app.Activity;
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.HorizontalScrollView;

import androidx.core.view.ViewCompat;

import com.didi.hummer.component.input.FocusUtil;
import com.didi.hummer.component.input.KeyboardUtil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.widget.CompoundButton;

import androidx.annotation.Nullable;

import com.didi.hummer.annotation.Component;
import com.didi.hummer.annotation.JsAttribute;
import com.didi.hummer.annotation.JsProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.text.style.ImageSpan;

import androidx.annotation.NonNull;

import java.lang.ref.WeakReference;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.didi.hummer.component.text;

import android.graphics.Color;
import android.support.annotation.NonNull;
import android.text.TextPaint;
import android.text.style.URLSpan;

import androidx.annotation.NonNull;

/**
* URLSpan扩展类,支持修改url文字颜色和去掉下划线
*
Expand Down
Loading

0 comments on commit 98f8310

Please sign in to comment.