接Max 1.0.1(2)
This commit is contained in:
parent
5947f23b9e
commit
f2d030e169
2
.gitignore
vendored
2
.gitignore
vendored
@ -14,3 +14,5 @@
|
|||||||
.cxx
|
.cxx
|
||||||
local.properties
|
local.properties
|
||||||
app/src/test/java/com/draw/painting/test/ExampleUnitTest.java
|
app/src/test/java/com/draw/painting/test/ExampleUnitTest.java
|
||||||
|
.idea/
|
||||||
|
.safedk/
|
||||||
|
|||||||
@ -1,12 +1,19 @@
|
|||||||
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("org.jetbrains.kotlin.android")
|
id("org.jetbrains.kotlin.android")
|
||||||
// id("com.google.gms.google-services")
|
id("com.google.gms.google-services")
|
||||||
// id("com.google.firebase.crashlytics")
|
id("com.google.firebase.crashlytics")
|
||||||
|
id("applovin-quality-service")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applovin {
|
||||||
|
apiKey =
|
||||||
|
"0pn_nPmNSunNT9Oq6nyqrUVTGfbFsZUoU47_B5ydJsLCvMPzZ8VdNFvemW1bfJfLlQ4WEgrD_fu3M4ep7hS9Ng"
|
||||||
|
}
|
||||||
|
|
||||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||||
android {
|
android {
|
||||||
namespace = "com.draw.painting.test"
|
namespace = "com.draw.painting.test"
|
||||||
@ -17,9 +24,12 @@ android {
|
|||||||
applicationId = "com.draw.painting.helper"
|
applicationId = "com.draw.painting.helper"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 1
|
versionCode = 2
|
||||||
versionName = "1.0.0"
|
versionName = "1.0.1"
|
||||||
setProperty("archivesBaseName", "Painting Helper_V" + versionName + "(${versionCode})_$timestamp")
|
setProperty(
|
||||||
|
"archivesBaseName",
|
||||||
|
"Painting Helper_V" + versionName + "(${versionCode})_$timestamp"
|
||||||
|
)
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,33 +78,14 @@ dependencies {
|
|||||||
implementation("androidx.camera:camera-extensions:${camerax_version}")
|
implementation("androidx.camera:camera-extensions:${camerax_version}")
|
||||||
|
|
||||||
|
|
||||||
// implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
|
implementation("com.applovin:applovin-sdk:+")
|
||||||
// implementation("com.google.firebase:firebase-crashlytics")
|
implementation("com.applovin.mediation:vungle-adapter:+")
|
||||||
// implementation("com.google.firebase:firebase-analytics")
|
implementation("com.applovin.mediation:mintegral-adapter:+")
|
||||||
|
implementation("com.applovin.mediation:bytedance-adapter:+")
|
||||||
|
implementation("com.applovin.mediation:unityads-adapter:+")
|
||||||
|
implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
|
||||||
// implementation ("com.ironsource.sdk:mediationsdk:8.1.0")
|
implementation("com.google.firebase:firebase-crashlytics")
|
||||||
// implementation ("com.ironsource:adqualitysdk:7.20.2")
|
implementation("com.google.firebase:firebase-analytics")
|
||||||
//
|
|
||||||
// // Add Vungle Network(Liftoff Moneti)
|
|
||||||
// implementation ("com.ironsource.adapters:vungleadapter:4.3.24")
|
|
||||||
// implementation ("com.vungle:vungle-ads:7.3.2")
|
|
||||||
//
|
|
||||||
// //Mintegral
|
|
||||||
// implementation ("com.mbridge.msdk.oversea:mbbid:16.7.71")
|
|
||||||
// implementation ("com.mbridge.msdk.oversea:reward:16.7.71")
|
|
||||||
// implementation ("com.mbridge.msdk.oversea:mbbanner:16.7.71")
|
|
||||||
// implementation ("com.mbridge.msdk.oversea:newinterstitial:16.7.71")
|
|
||||||
//
|
|
||||||
// // Add Pangle Network
|
|
||||||
// implementation ("com.ironsource.adapters:pangleadapter:4.3.26")
|
|
||||||
// implementation ("com.pangle.global:ads-sdk:5.8.0.8")
|
|
||||||
//
|
|
||||||
// // Add UnityAds Network
|
|
||||||
// implementation ("com.ironsource.adapters:unityadsadapter:4.3.40")
|
|
||||||
// implementation ("com.unity3d.ads:unity-ads:4.12.0")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
29
app/src/google-services.json
Normal file
29
app/src/google-services.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "21924510593",
|
||||||
|
"project_id": "painting-helper",
|
||||||
|
"storage_bucket": "painting-helper.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:21924510593:android:6d87dde89c34f4c8bc8680",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.draw.painting.helper"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAjY1w9grBlztoWK_xncU7ImRySsoyKtms"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
||||||
@ -17,6 +17,7 @@
|
|||||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
android:name=".PaintingApp"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
|||||||
8
app/src/main/java/com/draw/painting/test/Adcallback.java
Normal file
8
app/src/main/java/com/draw/painting/test/Adcallback.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package com.draw.painting.test;
|
||||||
|
|
||||||
|
import com.applovin.mediation.MaxAd;
|
||||||
|
|
||||||
|
public interface Adcallback {
|
||||||
|
void onShowFail(MaxAd ad);
|
||||||
|
void onAdHidden( );
|
||||||
|
}
|
||||||
@ -1,39 +1,51 @@
|
|||||||
package com.draw.painting.test;
|
package com.draw.painting.test;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
import com.applovin.sdk.AppLovinMediationProvider;
|
||||||
|
import com.applovin.sdk.AppLovinSdk;
|
||||||
|
import com.applovin.sdk.AppLovinSdkConfiguration;
|
||||||
|
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
|
||||||
|
|
||||||
|
|
||||||
public class PaintingApp extends Application {
|
public class PaintingApp extends Application {
|
||||||
|
|
||||||
public static String Key_ViewDir = "pre_dir";
|
public static String Key_ViewDir = "pre_dir";
|
||||||
|
public static String Key_ISMAIN = "ismain";
|
||||||
public static String Key_Camera = "camera_data";
|
public static String Key_Camera = "camera_data";
|
||||||
|
public static PaintingApp app;
|
||||||
public static String APP_KEY = "";
|
public static String APP_KEY = "";
|
||||||
|
private static Context context;
|
||||||
|
public static final String AD_BROADCAST = "on_success_action";
|
||||||
|
private static final String MAX_SDK = "27z51PI2aTeTbobe3ORmbnMCb97dZbW8zfHEBfRFzb2DlCRJaTQCNebHHVZ2aepZGpqkvO1J7noD4s8W2UwJew";
|
||||||
|
public static Boolean initSDK = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
app = this;
|
||||||
|
context = getApplicationContext();
|
||||||
|
|
||||||
initSDk();
|
initSDk();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSDk() {
|
private void initSDk() {
|
||||||
// IronSource.init(this, APP_KEY, new InitializationListener() {
|
|
||||||
// @Override
|
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder(MAX_SDK, this)
|
||||||
// public void onInitializationComplete() {
|
.setMediationProvider(AppLovinMediationProvider.MAX)
|
||||||
// // ironSource SDK is initialized
|
.build();
|
||||||
// //加载插页广告
|
AppLovinSdk.getInstance(this).initialize(initConfig, new AppLovinSdk.SdkInitializationListener() {
|
||||||
// IronSourceAd.loadAd();
|
@Override
|
||||||
// }
|
public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig) {
|
||||||
// });
|
initSDK = true;
|
||||||
//
|
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(AD_BROADCAST));
|
||||||
// //验证集成的成功 ,release的时候需要删除
|
}
|
||||||
// IntegrationHelper.validateIntegration(this);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,21 +9,103 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Range;
|
import android.util.Range;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.camera.core.Camera;
|
import androidx.camera.core.Camera;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
|
import com.applovin.mediation.MaxAd;
|
||||||
|
import com.applovin.mediation.MaxAdListener;
|
||||||
|
import com.applovin.mediation.MaxError;
|
||||||
|
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||||
|
import com.draw.painting.test.Adcallback;
|
||||||
|
import com.draw.painting.test.PaintingApp;
|
||||||
|
import com.draw.painting.test.ui.ALaucherActivity;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
private static ArrayList<MaxInterstitialAd> adArrayList;
|
||||||
|
private static final String one_AD = "fd0f2d1eca71b3a1";
|
||||||
|
private static final String two_Ad = "f129bbb52cd84647";
|
||||||
|
private static final String three_ad = "b42153354e619004";
|
||||||
|
|
||||||
|
|
||||||
|
public static void setCallBcak(MaxInterstitialAd ad, Adcallback adcallback) {
|
||||||
|
ad.setListener(new MaxAdListener() {
|
||||||
|
@Override
|
||||||
|
public void onAdLoaded(@NonNull MaxAd maxAd) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdDisplayed(@NonNull MaxAd maxAd) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdHidden(@NonNull MaxAd maxAd) {
|
||||||
|
adcallback.onAdHidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdClicked(@NonNull MaxAd maxAd) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdLoadFailed(@NonNull String s, @NonNull MaxError maxError) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdDisplayFailed(@NonNull MaxAd maxAd, @NonNull MaxError maxError) {
|
||||||
|
adcallback.onShowFail(maxAd);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MaxInterstitialAd onCache(List<MaxInterstitialAd> list) {
|
||||||
|
Collections.shuffle(list);
|
||||||
|
for (MaxInterstitialAd ad : list) {
|
||||||
|
if (ad.isReady()) {
|
||||||
|
return ad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<MaxInterstitialAd> getAllAd() {
|
||||||
|
if (adArrayList == null) {
|
||||||
|
adArrayList = new ArrayList<>();
|
||||||
|
adArrayList.add(createAd(one_AD, PaintingApp.app));
|
||||||
|
adArrayList.add(createAd(two_Ad, PaintingApp.app));
|
||||||
|
adArrayList.add(createAd(three_ad, PaintingApp.app));
|
||||||
|
}
|
||||||
|
for (MaxInterstitialAd ad : adArrayList) {
|
||||||
|
if (!ad.isReady()) {
|
||||||
|
ad.loadAd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return adArrayList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MaxInterstitialAd createAd(String adUnitId, Context context) {
|
||||||
|
MaxInterstitialAd ad = new MaxInterstitialAd(adUnitId, context);
|
||||||
|
return ad;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int getRange(Camera camera) {
|
public static int getRange(Camera camera) {
|
||||||
Range<Integer> exposureCompensationRange = camera.getCameraInfo().getExposureState().getExposureCompensationRange();
|
Range<Integer> exposureCompensationRange = camera.getCameraInfo().getExposureState().getExposureCompensationRange();
|
||||||
Integer upper = exposureCompensationRange.getUpper();
|
Integer upper = exposureCompensationRange.getUpper();
|
||||||
@ -53,6 +135,7 @@ public class Utils {
|
|||||||
point.y = height;
|
point.y = height;
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkPermission(Context context, String[] permissions) {
|
public static boolean checkPermission(Context context, String[] permissions) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
for (String per : permissions) {
|
for (String per : permissions) {
|
||||||
@ -63,6 +146,7 @@ public class Utils {
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap loadImageFromAssets(Context context, String fileName) {
|
public static Bitmap loadImageFromAssets(Context context, String fileName) {
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
AssetManager assetManager = context.getAssets();
|
AssetManager assetManager = context.getAssets();
|
||||||
|
|||||||
@ -1,23 +1,32 @@
|
|||||||
package com.draw.painting.test.ui;
|
package com.draw.painting.test.ui;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.draw.painting.test.R;
|
import com.applovin.mediation.MaxAd;
|
||||||
|
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||||
|
import com.draw.painting.test.Adcallback;
|
||||||
|
import com.draw.painting.test.PaintingApp;
|
||||||
import com.draw.painting.test.databinding.ActivityAlaucherBinding;
|
import com.draw.painting.test.databinding.ActivityAlaucherBinding;
|
||||||
import com.draw.painting.test.manager.Utils;
|
import com.draw.painting.test.manager.Utils;
|
||||||
|
|
||||||
import kotlin.Unit;
|
import java.util.List;
|
||||||
import kotlin.jvm.functions.Function0;
|
|
||||||
|
|
||||||
public class ALaucherActivity extends AppCompatActivity {
|
public class ALaucherActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private ActivityAlaucherBinding binding;
|
private ActivityAlaucherBinding binding;
|
||||||
private long time = 2000;
|
private long time = 11000;
|
||||||
private CountDownTimer countDownTimer;
|
private CountDownTimer countDownTimer;
|
||||||
|
private static List<MaxInterstitialAd> adsList;
|
||||||
|
public static boolean isAlreadyShow = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -26,28 +35,73 @@ public class ALaucherActivity extends AppCompatActivity {
|
|||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
Utils.setStatusBarTextColor(this, true);
|
Utils.setStatusBarTextColor(this, true);
|
||||||
|
|
||||||
// countDownTimer = IronSourceAd.showWelComeAd(time, ALaucherActivity.this, IronSourceAd.adPlace1, new Function0<Unit>() {
|
|
||||||
// @Override
|
|
||||||
// public Unit invoke() {
|
|
||||||
// enterMain();
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
countDownTimer = new CountDownTimer(time, 200) {
|
countDownTimer = new CountDownTimer(time, 200) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
|
if (!isAlreadyShow) {
|
||||||
|
showAdOrStartView(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
enterMain();
|
if (!isAlreadyShow) {
|
||||||
|
showAdOrStartView(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
registerBroadcastReceiver();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAdOrStartView(boolean go) {
|
||||||
|
MaxInterstitialAd cachedAd = Utils.onCache(adsList);
|
||||||
|
if (cachedAd == null) {
|
||||||
|
isAlreadyShow = false;
|
||||||
|
if (go) {
|
||||||
|
enterMain();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isAlreadyShow = true;
|
||||||
|
Utils.setCallBcak(cachedAd, new Adcallback() {
|
||||||
|
@Override
|
||||||
|
public void onShowFail(MaxAd ad) {
|
||||||
|
isAlreadyShow = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdHidden() {
|
||||||
|
isAlreadyShow = true;
|
||||||
|
enterMain();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cachedAd.showAd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerBroadcastReceiver() {
|
||||||
|
if (!PaintingApp.initSDK) {
|
||||||
|
BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
loadAndStartAd();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LocalBroadcastManager.getInstance(this).registerReceiver(receiver, new IntentFilter(PaintingApp.AD_BROADCAST));
|
||||||
|
} else {
|
||||||
|
loadAndStartAd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadAndStartAd() {
|
||||||
|
adsList = Utils.getAllAd();
|
||||||
countDownTimer.start();
|
countDownTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void enterMain() {
|
private void enterMain() {
|
||||||
Intent intent = new Intent(ALaucherActivity.this, HomeActivity.class);
|
Intent intent = new Intent(ALaucherActivity.this, HomeActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|||||||
@ -32,11 +32,16 @@ import android.widget.ImageView;
|
|||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.applovin.mediation.MaxAd;
|
||||||
|
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||||
|
import com.draw.painting.test.Adcallback;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.draw.painting.test.PaintingApp;
|
import com.draw.painting.test.PaintingApp;
|
||||||
import com.draw.painting.test.R;
|
import com.draw.painting.test.R;
|
||||||
import com.draw.painting.test.manager.Utils;
|
import com.draw.painting.test.manager.Utils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CameraActivity extends AppCompatActivity implements View.OnTouchListener, View.OnClickListener {
|
public class CameraActivity extends AppCompatActivity implements View.OnTouchListener, View.OnClickListener {
|
||||||
private CameraSelector cameraSelector;
|
private CameraSelector cameraSelector;
|
||||||
private String[] permissions;
|
private String[] permissions;
|
||||||
@ -66,6 +71,9 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
|||||||
|
|
||||||
private String curBitmapPath;
|
private String curBitmapPath;
|
||||||
private boolean hasPermission = false;
|
private boolean hasPermission = false;
|
||||||
|
private boolean isMain;
|
||||||
|
private String ismain;
|
||||||
|
private static List<MaxInterstitialAd> adsList;
|
||||||
private ActivityResultLauncher<Intent> intentActivityResultLauncher;
|
private ActivityResultLauncher<Intent> intentActivityResultLauncher;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,6 +81,15 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_camera);
|
setContentView(R.layout.activity_camera);
|
||||||
Utils.setStatusBarTextColor(this, true);
|
Utils.setStatusBarTextColor(this, true);
|
||||||
|
|
||||||
|
adsList = Utils.getAllAd();
|
||||||
|
Intent intent = getIntent();
|
||||||
|
isMain = intent.getBooleanExtra(PaintingApp.Key_ISMAIN, false);
|
||||||
|
|
||||||
|
|
||||||
|
showAd();
|
||||||
|
|
||||||
|
|
||||||
previewView = findViewById(R.id.preview);
|
previewView = findViewById(R.id.preview);
|
||||||
imageView = findViewById(R.id.image);
|
imageView = findViewById(R.id.image);
|
||||||
imBack = findViewById(R.id.back);
|
imBack = findViewById(R.id.back);
|
||||||
@ -97,6 +114,26 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
|||||||
initClick();
|
initClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showAd() {
|
||||||
|
MaxInterstitialAd cachedAd = Utils.onCache(adsList);
|
||||||
|
if (cachedAd == null) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Utils.setCallBcak(cachedAd, new Adcallback() {
|
||||||
|
@Override
|
||||||
|
public void onShowFail(MaxAd ad) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdHidden() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cachedAd.showAd(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void onInitIm(float imW, float imH) {
|
private void onInitIm(float imW, float imH) {
|
||||||
Point screen = Utils.getScreen(this);
|
Point screen = Utils.getScreen(this);
|
||||||
float newX = screen.x / 2f - imW / 2;
|
float newX = screen.x / 2f - imW / 2;
|
||||||
@ -164,7 +201,14 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (v.equals(imBack)) {
|
if (v.equals(imBack)) {
|
||||||
|
|
||||||
|
if (isMain) {
|
||||||
|
showAd();
|
||||||
finish();
|
finish();
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!hasPermission) {
|
if (!hasPermission) {
|
||||||
showNoPermission();
|
showNoPermission();
|
||||||
@ -294,4 +338,15 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
|||||||
private void showNoPermission() {
|
private void showNoPermission() {
|
||||||
Toast.makeText(this, getString(R.string.permission_fail), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getString(R.string.permission_fail), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
super.onBackPressed();
|
||||||
|
if (isMain) {
|
||||||
|
showAd();
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -66,6 +66,7 @@ public class HomeFragment extends Fragment implements onClickListener {
|
|||||||
}else {
|
}else {
|
||||||
intent = new Intent(requireContext(), CameraActivity.class);
|
intent = new Intent(requireContext(), CameraActivity.class);
|
||||||
intent.putExtra(PaintingApp.Key_Camera,dir);
|
intent.putExtra(PaintingApp.Key_Camera,dir);
|
||||||
|
intent.putExtra(PaintingApp.Key_ISMAIN,true);
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,9 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.applovin.mediation.MaxAd;
|
||||||
|
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||||
|
import com.draw.painting.test.Adcallback;
|
||||||
import com.draw.painting.test.PaintingApp;
|
import com.draw.painting.test.PaintingApp;
|
||||||
import com.draw.painting.test.adapter.PreViewAdapter;
|
import com.draw.painting.test.adapter.PreViewAdapter;
|
||||||
import com.draw.painting.test.databinding.ActivityPreViewBinding;
|
import com.draw.painting.test.databinding.ActivityPreViewBinding;
|
||||||
@ -18,6 +21,7 @@ public class PreViewActivity extends AppCompatActivity {
|
|||||||
private ActivityPreViewBinding preViewBinding;
|
private ActivityPreViewBinding preViewBinding;
|
||||||
|
|
||||||
private String dirStr;
|
private String dirStr;
|
||||||
|
private static List<MaxInterstitialAd> adsList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -27,6 +31,9 @@ public class PreViewActivity extends AppCompatActivity {
|
|||||||
Utils.setStatusBarTextColor(this, true);
|
Utils.setStatusBarTextColor(this, true);
|
||||||
dirStr = getIntent().getStringExtra(PaintingApp.Key_ViewDir);
|
dirStr = getIntent().getStringExtra(PaintingApp.Key_ViewDir);
|
||||||
preViewBinding.categoryName.setText(dirStr.substring(dirStr.lastIndexOf("_") + 1));
|
preViewBinding.categoryName.setText(dirStr.substring(dirStr.lastIndexOf("_") + 1));
|
||||||
|
|
||||||
|
adsList = Utils.getAllAd();
|
||||||
|
|
||||||
onInitList();
|
onInitList();
|
||||||
onInitClick();
|
onInitClick();
|
||||||
}
|
}
|
||||||
@ -44,9 +51,34 @@ public class PreViewActivity extends AppCompatActivity {
|
|||||||
preViewBinding.back.setOnClickListener(new View.OnClickListener() {
|
preViewBinding.back.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
showAd();
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showAd() {
|
||||||
|
MaxInterstitialAd cachedAd = Utils.onCache(adsList);
|
||||||
|
if (cachedAd == null) {
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Utils.setCallBcak(cachedAd, new Adcallback() {
|
||||||
|
@Override
|
||||||
|
public void onShowFail(MaxAd ad) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdHidden() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cachedAd.showAd(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
super.onBackPressed();
|
||||||
|
showAd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -5,3 +5,8 @@ plugins {
|
|||||||
id("com.google.gms.google-services") version "4.3.15" apply false
|
id("com.google.gms.google-services") version "4.3.15" apply false
|
||||||
id ("com.google.firebase.crashlytics") version "2.9.2" apply false
|
id ("com.google.firebase.crashlytics") version "2.9.2" apply false
|
||||||
}
|
}
|
||||||
|
buildscript{
|
||||||
|
dependencies{
|
||||||
|
classpath("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,6 +3,8 @@ pluginManagement {
|
|||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
|
||||||
|
maven { url = uri("https://artifacts.applovin.com/android") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
@ -10,11 +12,10 @@ dependencyResolutionManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
// maven ("https://android-sdk.is.com/")
|
|
||||||
// //Mintegral
|
maven { url = uri("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea") }
|
||||||
// maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
maven { url = uri("https://artifact.bytedance.com/repository/pangle") }
|
||||||
// //Pangle
|
|
||||||
// maven ("https://artifact.bytedance.com/repository/pangle")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user