-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
925 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.