Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新组件、依赖,目标 API 升级到 Android 12,升级到 AndroidX,重构代码、布局,移除废弃的方法,格式化代码等 #49

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
/.idea/compiler.xml
/.idea/jarRepositories.xml
/.idea/misc.xml
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 0 additions & 34 deletions .idea/misc.xml

This file was deleted.

12 changes: 9 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

30 changes: 18 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
namespace 'com.lcw.demo.imagepicker'
compileSdk 34
defaultConfig {
applicationId "com.lcw.demo.imagepicker"
minSdkVersion 16
targetSdkVersion 27
minSdkVersion 26
targetSdkVersion 34
versionCode 228
versionName "2.2.8"
//noinspection ChromeOsAbiSupport
ndk.abiFilters 'arm64-v8a'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

lintOptions {
lint {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

group = 'io.ruibu'
version = '1.0.0'

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

// implementation 'com.lcw.library:imagepicker:2.2.7'
implementation 'androidx.appcompat:appcompat:1.7.0-alpha03'
implementation 'com.github.bumptech.glide:glide:4.16.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'
implementation project(':imagepicker')

}
}
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lcw.demo.imagepicker">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:name=".MApplication"
Expand All @@ -10,7 +9,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/lcw/demo/imagepicker/GlideLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ public void loadImage(ImageView imageView, String imagePath) {
public void loadPreImage(ImageView imageView, String imagePath) {
//大图加载
Glide.with(imageView.getContext()).load(imagePath).apply(mPreOptions).into(imageView);

}

@Override
public void clearMemoryCache() {
//清理缓存
Glide.get(MApplication.getContext()).clearMemory();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public void onCreate() {
public static MApplication getContext() {
return mApplication;
}
}
}
42 changes: 19 additions & 23 deletions app/src/main/java/com/lcw/demo/imagepicker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.lcw.library.imagepicker.ImagePicker;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

private TextView mTextView;

private static final int REQUEST_SELECT_IMAGES_CODE = 0x01;
private ArrayList<String> mImagePaths;

Expand All @@ -22,35 +20,33 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextView = findViewById(R.id.tv_select_images);
findViewById(R.id.bt_select_images).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ImagePicker.getInstance()
.setTitle("标题")//设置标题
.showCamera(true)//设置是否显示拍照按钮
.showImage(true)//设置是否展示图片
.showVideo(true)//设置是否展示视频
.filterGif(false)//设置是否过滤gif图片
.setMaxCount(9)//设置最大选择图片数目(默认为1,单选)
.setSingleType(true)//设置图片视频不能同时选择
.setImagePaths(mImagePaths)//设置历史选择记录
.setImageLoader(new GlideLoader())//设置自定义图片加载器
.start(MainActivity.this, REQUEST_SELECT_IMAGES_CODE);//REQEST_SELECT_IMAGES_CODE为Intent调用的requestCode
}
findViewById(R.id.bt_select_images).setOnClickListener(v -> {
ImagePicker.getInstance()
.setTitle("标题")//设置标题
.showCamera(true)//设置是否显示拍照按钮
.showImage(true)//设置是否展示图片
.showVideo(true)//设置是否展示视频
.filterGif(false)//设置是否过滤gif图片
.setMaxCount(9)//设置最大选择图片数目(默认为1,单选)
.setSingleType(true)//设置图片视频不能同时选择
.setImagePaths(mImagePaths)//设置历史选择记录
.setImageLoader(new GlideLoader())//设置自定义图片加载器
.start(MainActivity.this, REQUEST_SELECT_IMAGES_CODE);//REQEST_SELECT_IMAGES_CODE为Intent调用的requestCode
});

}

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

if (requestCode == REQUEST_SELECT_IMAGES_CODE && resultCode == RESULT_OK) {
mImagePaths = data.getStringArrayListExtra(ImagePicker.EXTRA_SELECT_IMAGES);
StringBuffer stringBuffer = new StringBuffer();
StringBuilder stringBuffer = new StringBuilder();
stringBuffer.append("当前选中图片路径:\n\n");
for (int i = 0; i < mImagePaths.size(); i++) {
stringBuffer.append(mImagePaths.get(i) + "\n\n");
stringBuffer.append(mImagePaths.get(i)).append("\n\n");
}
mTextView.setText(stringBuffer.toString());
}
}
}
}
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@
android:layout_marginTop="20dp"
android:textColor="@color/text_color_white" />


</LinearLayout>
22 changes: 4 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.novoda:bintray-release:0.8.0'


classpath 'com.android.tools.build:gradle:8.4.0-alpha07'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -19,16 +15,6 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
}

tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
mavenCentral()
}

}

task clean(type: Delete) {
delete rootProject.buildDir
}
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6.all.zip
36 changes: 14 additions & 22 deletions imagepicker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'

publish {
userOrg = 'lichenwei'
groupId = 'com.lcw.library'
artifactId = 'imagepicker'
publishVersion = '2.2.8'
desc = 'Android image picker library'
website = 'https://github.com/Lichenwei-Dev/ImagePicker'
}

android {
compileSdkVersion 27
namespace 'com.lcw.library.imagepicker'
compileSdk 34
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 228
versionName "2.2.8"
minSdkVersion 26
targetSdkVersion 34
//noinspection ChromeOsAbiSupport
ndk.abiFilters 'arm64-v8a'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

lintOptions {
lint {
abortOnError false
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

repositories {
Expand All @@ -39,6 +31,6 @@ repositories {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
}
implementation 'androidx.appcompat:appcompat:1.7.0-alpha03'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
}
Loading