V1.0.1(2)导入图片限制最大5M
This commit is contained in:
parent
bbfeeac425
commit
890645da5a
@ -14,11 +14,11 @@ android {
|
||||
applicationId = "com.paintings.tool"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
versionCode = 2
|
||||
versionName = "1.0.1"
|
||||
setProperty(
|
||||
"archivesBaseName",
|
||||
"AR Drawing-Paintings Tool_V" + versionName + "(${versionCode})_$timestamp"
|
||||
"AR Drawing_V" + versionName + "(${versionCode})_$timestamp"
|
||||
)
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
149
app/proguard-rules.pro
vendored
149
app/proguard-rules.pro
vendored
@ -19,140 +19,19 @@
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
-keepclassmembers class * implements android.os.Parcelable {
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
}
|
||||
# 保持 Room 的核心类不被混淆
|
||||
-keep class androidx.room.** { *; }
|
||||
-keep class androidx.sqlite.db.** { *; }
|
||||
|
||||
-keepclassmembers class com.app.paintingstool.myuntils.Keys {
|
||||
public static final java.lang.String tatab;
|
||||
public static final int ababa;
|
||||
}
|
||||
# 保持 Room 数据库类的基本结构
|
||||
-keep class * extends androidx.room.RoomDatabase { *; }
|
||||
|
||||
-keepclassmembers class * {
|
||||
@androidx.room.Query <methods>;
|
||||
}
|
||||
-keep class com.app.paintingstool.mydao.AppDatabase { *; }
|
||||
#noinspection ShrinkerUnresolvedReference
|
||||
#unity
|
||||
-keep class com.google.android.gms.ads.** {public *;}
|
||||
-keep class com.google.android.gms.appset.** { *; }
|
||||
-keep class com.google.android.gms.tasks.** { *; }
|
||||
#adapters
|
||||
-keep class com.ironsource.adapters.** { *; }
|
||||
#sdk
|
||||
-dontwarn com.ironsource.**
|
||||
-dontwarn com.ironsource.adapters.**
|
||||
-keepclassmembers class com.ironsource.** { public *; }
|
||||
-keep public class com.ironsource.**
|
||||
-keep class com.ironsource.adapters.** { *;
|
||||
}
|
||||
#omid
|
||||
-dontwarn com.iab.omid.**
|
||||
-keep class com.iab.omid.** {*;}
|
||||
#javascript
|
||||
-keepattributes JavascriptInterface
|
||||
-keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; }
|
||||
#For AmazonAps integration
|
||||
-keep class com.amazon.device.ads.DtbThreadService {
|
||||
static *;
|
||||
}
|
||||
-keep public interface com.amazon.device.ads** {*; }
|
||||
#For AppLovin integration
|
||||
-keepclassmembers class com.applovin.sdk.AppLovinSdk {
|
||||
static *;
|
||||
}
|
||||
-keep public interface com.applovin.sdk** {*; }
|
||||
-keep public interface com.applovin.adview** {*; }
|
||||
-keep public interface com.applovin.mediation** {*; }
|
||||
-keep public interface com.applovin.communicator** {*; }
|
||||
#For Bytedance integration
|
||||
-keep public interface com.bytedance.sdk.openadsdk** {*; }
|
||||
#For Facebook integration
|
||||
-keepclassmembers class com.facebook.ads.internal.AdSdkVersion {
|
||||
static *;
|
||||
}
|
||||
-keepclassmembers class com.facebook.ads.internal.settings.AdSdkVersion {
|
||||
static *;
|
||||
}
|
||||
-keepclassmembers class com.facebook.ads.BuildConfig {
|
||||
static *;
|
||||
}
|
||||
-keep public interface com.facebook.ads** {*; }
|
||||
#For Fairbid
|
||||
-keep public interface com.fyber.fairbid.ads.interstitial** {*; }
|
||||
-keep public interface com.fyber.fairbid.ads.rewarded** {*; }
|
||||
-keep class com.fyber.offerwall.*
|
||||
#For Fivead
|
||||
-keep public interface com.five_corp.ad** {*; }
|
||||
#For Fyber(Inneractive) integration
|
||||
-keep public interface com.fyber.inneractive.sdk.external** {*; }
|
||||
-keep public interface com.fyber.inneractive.sdk.activities** {*; }
|
||||
-keep public interface com.fyber.inneractive.sdk.ui** {*; }
|
||||
#For HyprMX integration
|
||||
-keepclassmembers class com.hyprmx.android.sdk.utility.HyprMXProperties {
|
||||
static *;
|
||||
}
|
||||
-keepclassmembers class com.hyprmx.android.BuildConfig {
|
||||
static *;
|
||||
}
|
||||
-keep public interface com.hyprmx.android.sdk.activity** {*; }
|
||||
-keep public interface com.hyprmx.android.sdk.graphics** {*; }
|
||||
# For Inmobi integration
|
||||
-keep class com.inmobi.*
|
||||
-keep public interface com.inmobi.ads.listeners** {*; }
|
||||
-keep public interface com.inmobi.ads.InMobiInterstitial** {*; }
|
||||
-keep public interface com.inmobi.ads.InMobiBanner** {*; }
|
||||
# For ironSource integration
|
||||
-keep public interface com.ironsource.mediationsdk.sdk** {*; }
|
||||
-keep public interface com.ironsource.mediationsdk.impressionData.ImpressionDataListener {*; }
|
||||
#For Maio integration
|
||||
-keep public interface jp.maio.sdk.android.MaioAdsListenerInterface {*; }
|
||||
# For Mintergral integration
|
||||
-keep public interface com.mbridge.msdk.out** {*; }
|
||||
-keep public interface com.mbridge.msdk.videocommon.listener** {*; }
|
||||
-keep public interface com.mbridge.msdk.interstitialvideo.out** {*; }
|
||||
-keep public interface com.mintegral.msdk.out** {*; }
|
||||
-keep public interface com.mintegral.msdk.videocommon.listener** {*; }
|
||||
-keep public interface com.mintegral.msdk.interstitialvideo.out** {*; }
|
||||
#For MyTarget integration
|
||||
-keep class com.my.target.** {*;}
|
||||
#For Ogury integration
|
||||
-keep public interface io.presage.interstitial** {*; }
|
||||
-keep public interface io.presage.interstitial.PresageInterstitialCallback {*; }
|
||||
#For Pubnative integration
|
||||
-keep public interface net.pubnative.lite.sdk.interstitial.HyBidInterstitialAd** {*; }
|
||||
-keep public interface net.pubnative.lite.sdk.rewarded.HyBidRewardedAd** {*; }
|
||||
-keep public interface net.pubnative.lite.sdk.views.HyBidAdView** {*; }
|
||||
#For Smaato integration
|
||||
-keep public interface com.smaato.sdk.interstitial** {*; }
|
||||
-keep public interface com.smaato.sdk.video.vast** {*; }
|
||||
-keep public interface com.smaato.sdk.banner.widget** {*; }
|
||||
-keep public interface com.smaato.sdk.core.util** {*; }
|
||||
# For Tapjoy integration
|
||||
-keep public interface com.tapjoy.** {*; }
|
||||
# For Tencent integration
|
||||
-keep public interface com.qq.e.ads.interstitial2** {*; }
|
||||
-keep public interface com.qq.e.ads.interstitial3** {*; }
|
||||
-keep public interface com.qq.e.ads.rewardvideo** {*; }
|
||||
-keep public interface com.qq.e.ads.rewardvideo2** {*; }
|
||||
-keep public interface com.qq.e.ads.banner2** {*; }
|
||||
-keep public interface com.qq.e.comm.adevent** {*; }
|
||||
#For Verizon integration
|
||||
-keepclassmembers class com.verizon.ads.edition.BuildConfig {
|
||||
static *;
|
||||
}
|
||||
-keep public interface com.verizon.ads.interstitialplacement** {*; }
|
||||
-keep public interface com.verizon.ads.inlineplacement** {*; }
|
||||
-keep public interface com.verizon.ads.vastcontroller** {*; }
|
||||
-keep public interface com.verizon.ads.webcontroller** {*; }
|
||||
#For Vungle integration
|
||||
-keep public interface com.vungle.warren.PlayAdCallback {*; }
|
||||
-keep public interface com.vungle.warren.ui.contract** {*; }
|
||||
-keep public interface com.vungle.warren.ui.view** {*; }
|
||||
#For AndroidX
|
||||
-keep class androidx.localbroadcastmanager.content.LocalBroadcastManager { *;}
|
||||
-keep class androidx.recyclerview.widget.RecyclerView { *;}
|
||||
-keep class androidx.recyclerview.widget.RecyclerView$OnScrollListener { *;}
|
||||
#For Android
|
||||
-keep class * extends android.app.Activity
|
||||
#-----------------------------------------------------ironSource SDK
|
||||
# 保持 Room DAO 接口
|
||||
-keep @androidx.room.Dao interface * { *; }
|
||||
-keep @androidx.room.Dao class * { *; }
|
||||
|
||||
# 保持 Room 实体类
|
||||
-keep @androidx.room.Entity class * { *; }
|
||||
|
||||
# 保持 Room 的注解类
|
||||
-keep @androidx.room.Database class * { *; }
|
||||
@ -40,8 +40,10 @@ import androidx.core.view.WindowInsetsCompat;
|
||||
import com.app.paintingstool.R;
|
||||
import com.app.paintingstool.databinding.ActivityCarmelBinding;
|
||||
import com.app.paintingstool.myuntils.Keys;
|
||||
import com.app.paintingstool.myuntils.Utils;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
@ -79,7 +81,26 @@ public class CarmelActivity extends AppCompatActivity implements View.OnTouchLis
|
||||
intentActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
|
||||
Uri imageUri = result.getData().getData();
|
||||
binding.image.setImageURI(imageUri);
|
||||
if (imageUri == null) return;
|
||||
new Thread(() -> {
|
||||
InputStream putStream = null;
|
||||
try {
|
||||
putStream = getContentResolver().openInputStream(imageUri);
|
||||
double v = Utils.convertBytesToMB(putStream.available());
|
||||
runOnUiThread(() -> {
|
||||
if (v >= 5) {
|
||||
Toast.makeText(CarmelActivity.this, getString(R.string.im_big), Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
binding.image.setImageURI(imageUri);
|
||||
}
|
||||
});
|
||||
putStream.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@ -10,6 +10,7 @@ import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
@ -25,6 +26,7 @@ import com.app.paintingstool.databinding.ActivityImporImageBinding;
|
||||
import com.app.paintingstool.myadapter.ImageAdapter1;
|
||||
import com.app.paintingstool.myuntils.ImageItem;
|
||||
import com.app.paintingstool.myuntils.MyItemDecoration;
|
||||
import com.app.paintingstool.myuntils.Utils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
@ -64,7 +66,7 @@ public class ImporImageActivity extends AppCompatActivity {
|
||||
finish();
|
||||
});
|
||||
imageList = new ArrayList<>();
|
||||
imageAdapter1 = new ImageAdapter1(imageList,this,this);
|
||||
imageAdapter1 = new ImageAdapter1(imageList, this, this);
|
||||
importImage();
|
||||
loadImageList();
|
||||
RecyclerView recyclerView = findViewById(R.id.recycler_view_import);
|
||||
@ -74,25 +76,48 @@ public class ImporImageActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void importImage() {
|
||||
intentActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
|
||||
Uri imageUri = result.getData().getData();
|
||||
Intent data = result.getData();
|
||||
Uri imageUri = data.getData();
|
||||
if (imageUri == null) return;
|
||||
new Thread(() -> {
|
||||
try {
|
||||
assert imageUri != null;
|
||||
String mimeType = getContentResolver().getType(imageUri);
|
||||
fileExtension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
|
||||
fileName = "image_" + System.currentTimeMillis() + "." + fileExtension;
|
||||
File outputFile = new File(getFilesDir(), fileName);
|
||||
try (InputStream inputStream = getContentResolver().openInputStream(imageUri);
|
||||
OutputStream outputStream = new FileOutputStream(outputFile)) {
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
inputStream = getContentResolver().openInputStream(imageUri);
|
||||
double v = Utils.convertBytesToMB(inputStream.available());
|
||||
Log.d("----------","-----------"+v);
|
||||
if (v >= 5) {
|
||||
runOnUiThread(() -> {
|
||||
Toast.makeText(ImporImageActivity.this, getString(R.string.im_big), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
outputStream = new FileOutputStream(outputFile);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = inputStream.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, length);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
if (outputStream != null) {
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
Glide.with(this).load(outputFile)
|
||||
@ -104,6 +129,7 @@ public class ImporImageActivity extends AppCompatActivity {
|
||||
binding.reDef.setVisibility(View.GONE);
|
||||
saveImageList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
}
|
||||
@ -123,7 +149,7 @@ public class ImporImageActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void saveImageList() {
|
||||
if(imageList.isEmpty()){
|
||||
if (imageList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@ -146,29 +172,30 @@ public class ImporImageActivity extends AppCompatActivity {
|
||||
File file = new File(getFilesDir(), "image_list.json");
|
||||
if (!file.exists()) {
|
||||
return; // 如果文件不存在,则不加载数据
|
||||
}else {
|
||||
try {
|
||||
FileInputStream fileInputStream = openFileInput("image_list.json");
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
|
||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
stringBuilder.append(line);
|
||||
} else {
|
||||
try {
|
||||
FileInputStream fileInputStream = openFileInput("image_list.json");
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
|
||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
stringBuilder.append(line);
|
||||
}
|
||||
binding.reDef.setVisibility(View.GONE);
|
||||
bufferedReader.close();
|
||||
JSONArray jsonArray = new JSONArray(stringBuilder.toString());
|
||||
imageList.clear(); // 清空 imageList,避免重复添加
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String imagePath = jsonObject.getString("imagePath");
|
||||
imageList.add(new ImageItem(imagePath));
|
||||
}
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
binding.reDef.setVisibility(View.GONE);
|
||||
bufferedReader.close();
|
||||
JSONArray jsonArray = new JSONArray(stringBuilder.toString());
|
||||
imageList.clear(); // 清空 imageList,避免重复添加
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String imagePath = jsonObject.getString("imagePath");
|
||||
imageList.add(new ImageItem(imagePath));
|
||||
}
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -34,7 +34,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
public void run() {
|
||||
// 使用 ValueAnimator 创建进度条动画
|
||||
ValueAnimator animation = ValueAnimator.ofInt(0, binding.progressBar.getMax());
|
||||
animation.setDuration(4000); // 动画时长
|
||||
animation.setDuration(2000); // 动画时长
|
||||
animation.setInterpolator(new DecelerateInterpolator()); // 减速插值器
|
||||
animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
@ -61,6 +61,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||
public void onAnimationRepeat(android.animation.Animator animation) {}
|
||||
});
|
||||
}
|
||||
}, 1500);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
@ -1,2 +1,8 @@
|
||||
package com.app.paintingstool.myuntils;public class Utils {
|
||||
package com.app.paintingstool.myuntils;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static double convertBytesToMB(long bytes) {
|
||||
return bytes / (1024.0 * 1024.0); // 字节转换为兆
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
android:elevation="0dp"
|
||||
android:text="@string/tate_us"
|
||||
android:text="@string/rate_us"
|
||||
android:textSize="14sp"
|
||||
app:chipBackgroundColor="#00000000"
|
||||
app:chipIcon="@mipmap/icon_rate"
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
<string name="my_favorites">My favorites</string>
|
||||
<string name="myfav">No favorites have been added yet, please go to the homepage to check it out</string>
|
||||
<string name="share">Share</string>
|
||||
<string name="tate_us">Tate us</string>
|
||||
<string name="rate_us">Rate us</string>
|
||||
<string name="todo">TODO</string>
|
||||
<string name="im_big">Please reselect an image no larger than 5M</string>
|
||||
</resources>
|
||||
@ -1,5 +1,5 @@
|
||||
[versions]
|
||||
agp = "8.5.0"
|
||||
agp = "8.1.0"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.2.1"
|
||||
espressoCore = "3.6.1"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user