Skip to content

Commit

Permalink
初版
Browse files Browse the repository at this point in the history
  • Loading branch information
asnhkl1 committed Jul 9, 2021
1 parent 03ddfbe commit 7f7a399
Show file tree
Hide file tree
Showing 21 changed files with 925 additions and 11 deletions.
45 changes: 45 additions & 0 deletions .idea/jarRepositories.xml

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

7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {

defaultConfig {
applicationId "com.mrlee.xuploader"
minSdkVersion 29
targetSdkVersion 30
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"

Expand All @@ -35,4 +35,7 @@ dependencies {
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

implementation 'com.github.getActivity:XXPermissions:11.6'
implementation project(':library')
}
20 changes: 18 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mrlee.xuploader">
package="com.mrlee.xuploader"

android:requestLegacyExternalStorage="true">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.XUploader" />
android:requestLegacyExternalStorage="true"
android:theme="@style/Theme.XUploader" >

<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

</manifest>
65 changes: 65 additions & 0 deletions app/src/main/java/com/mrlee/xuploader/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.mrlee.xuploader;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.mrlee.library.ImageBean;
import com.mrlee.library.ResultData;
import com.mrlee.library.XUploader;

import java.util.List;

public class MainActivity extends Activity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
XXPermissions.with(MainActivity.this)
.permission(Permission.Group.STORAGE)
.request(new OnPermissionCallback() {

@Override
public void onGranted(List<String> permissions, boolean all) {

}

@Override
public void onDenied(List<String> permissions, boolean never) {
if (never) {
toast("被永久拒绝授权,请手动授予权限");
// 如果是被永久拒绝就跳转到应用权限系统设置页面
XXPermissions.startPermissionActivity(MainActivity.this, permissions);
} else {
toast("获取权限失败");
}
}
});
XUploader uploader = findViewById(R.id.uploader);
Button getData = findViewById(R.id.getData);
TextView log = findViewById(R.id.log);

getData.setOnClickListener(v->{
StringBuilder sb =new StringBuilder();
List<ResultData> imageData = uploader.getImageData();
for (int i = 0; i < imageData.size(); i++) {
sb.append("图"+i+": "+ imageData.get(i).getThumbnail()+"\r\n" );
}
log.setText(sb.toString());
});

}
private void toast(String s) {
Toast.makeText(this, ""+s, Toast.LENGTH_SHORT).show();
}
}
13 changes: 13 additions & 0 deletions app/src/main/java/com/mrlee/xuploader/app/Myapp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mrlee.xuploader.app;

import android.app.Application;

import com.hjq.permissions.XXPermissions;

public class Myapp extends Application {
@Override
public void onCreate() {
super.onCreate();
XXPermissions.setScopedStorage(true);
}
}
29 changes: 29 additions & 0 deletions app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.mrlee.library.XUploader
android:id="@+id/uploader"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:canEdit="true"
app:maxSelectNum="2"
/>
<Button
android:id="@+id/getData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="获取结果"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/uploader"/>
<TextView
android:id="@+id/log"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/getData"/>

</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {

maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
maven { url "https://jitpack.io" }
google()
mavenCentral()
}
Expand All @@ -14,6 +18,10 @@ buildscript {

allprojects {
repositories {

maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
maven { url "https://jitpack.io" }
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
android.useAndroidX=true
android.enableJetifier=true
10 changes: 8 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
buildToolsVersion "30.0.3"

defaultConfig {
minSdkVersion 29
targetSdkVersion 30
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"

Expand All @@ -32,6 +32,12 @@ dependencies {

implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'io.github.lucksiege:pictureselector:v2.7.3-rc05'
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
implementation 'com.github.xuxuliooo:RoundImageView:1.1.2'
implementation 'com.github.li-xiaojun:XPopup:2.4.3'
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Expand Down
Loading

0 comments on commit 7f7a399

Please sign in to comment.