Commit 0ecfe7eb authored by bixing's avatar bixing

支持ADMOB

parent 422de72e
/build
\ No newline at end of file
plugins {
id 'com.android.application'
}
android {
namespace 'com.ads.cal.notes'
compileSdk 34
defaultConfig {
applicationId "com.cal.ads.notes"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
buildTypes {
release {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'app-proguard-rules.pro'
}
}
}
buildFeatures {
aidl = true
viewBinding = true
dataBinding = true
}
signingConfigs {
ceshi {
storeFile file("cc.jks")
storePassword '1#q!23w'
keyAlias 'key0'
keyPassword '1#q!23w'
}
toolsTest {
storeFile file("notemaster.jks")
storePassword 'n@o1t2e@m3ast@er'
keyAlias 'notemaster'
keyPassword 'n@o1t2e@m3ast@er'
}
}
flavorDimensions "versionName"
productFlavors {
ceshi {
applicationId "com.a.hr.heart.rate"
versionName "1.0.0.6"
versionCode 1000006
signingConfig signingConfigs.ceshi
//release
manifestPlaceholders = [google_ad_app_id: "ca-app-pub-3940256099942544~3347511713",
signature : "facb39340ddce66c401a1ed3c477fe20",
flavor_name : "GemHeart",
authorities : "$applicationId-media-AProvider",
media_version: "3"]
}
notes {
applicationId "com.notemaster.record.mark"
versionName "1.0.0.6"
versionCode 1000006
signingConfig signingConfigs.toolsTest
//release
//release
manifestPlaceholders = [google_ad_app_id: "ca-app-pub-4184965935607567~3208771202",
signature : "5890fecce947bbfb4b38e5c1862bf137",
flavor_name : "GemHeart",
authorities : "$applicationId-media-AProvider",
media_version: "3"]
// manifestPlaceholders = [google_ad_app_id: "ca-app-pub-3940256099942544~3347511713"]
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'androidx.lifecycle:lifecycle-process:2.6.2'
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
implementation 'com.or.ange:likepal:2.2.2'
implementation 'com.github.bumptech.glide:glide:4.15.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
api "com.google.android.gms:play-services-ads-identifier:18.0.1"
api "com.google.android.gms:play-services-ads:24.0.0"
api('androidx.lifecycle:lifecycle-livedata:2.5.1')
api('androidx.lifecycle:lifecycle-viewmodel:2.5.1')
api('com.alibaba:fastjson:1.1.72.android')
api('io.reactivex.rxjava3:rxandroid:3.0.2')
api("me.leolin:ShortcutBadger:1.1.22@aar")
api('com.guolindev.permissionx:permissionx:1.7.1')
// api config.libARouter
api "com.google.code.gson:gson:2.10.1"
//glide
api('jp.wasabeef:glide-transformations:4.3.0')
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
/*UI相关第三方*/
//Adapter
api 'io.github.cymchad:BaseRecyclerViewAdapterHelper:3.0.14'
//List Divider
// api 'com.aches.plugins:recyclerview-divider:1.0.1'
//Custom Ratingbar
api 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
api('com.airbnb.android:lottie:6.1.0')
implementation 'org.greenrobot:eventbus:3.1.1'
api('com.blankj:utilcodex:1.31.1')
api('com.google.android.material:material:1.8.0')
api('androidx.constraintlayout:constraintlayout:2.1.4')
api('androidx.lifecycle:lifecycle-livedata:2.5.1')
api('androidx.lifecycle:lifecycle-viewmodel:2.5.1')
api('com.android.volley:volley:1.2.1')
api("com.squareup.retrofit2:retrofit:2.5.0")
api("com.squareup.retrofit2:converter-gson:2.0.2")
api("com.squareup.okhttp3:logging-interceptor:3.8.1")
api("com.squareup.okhttp3:okhttp:3.12.0")
//Custom Ratingbar
implementation 'com.github.wdsqjq:AndRatingBar:1.0.6'
annotationProcessor("com.github.bumptech.glide:compiler:4.13.2")
implementation 'com.tencent.bugly:crashreport:latest.release'
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontpreverify
-flattenpackagehierarchy
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-useuniqueclassmembernames
-ignorewarnings
#基础模板开始
# 保护注解
-keepattributes *Annotation*
-keepattributes *JavascriptInterface*
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,LineNumberTable,*Annotation*,EnclosingMethod
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
#泛型 内部类 反射
-keepattributes Signature,InnerClasses,EnclosingMethod
#显示代码行数
-keepattributes Exceptions,SourceFile,LineNumberTable
-keep public class *$JavaScriptInterface
-keepattributes *$JavaScriptInterface
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keepclassmembers class * extends android.webkit.WebViewClient {
*;
}
# Understand the @Keep support annotation.
-keep class android.support.annotation.Keep
-keep @android.support.annotation.Keep class * {*;}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <init>(...);
}
#【不进行混淆保持原样】
-keep public class * extends android.view.View
-keep public class * extends android.app.Fragment
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
#commom
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keep public class * extends android.support.**
-keep class com.google.** { *; }
-keep class android.webkit.**{*;}
-keep class org.apache.** { *; }
-keep public class android.** { *; }
-keepclassmembers public class android.** { *; }
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {*;}
-keepclassmembers class * implements android.os.Parcelable {*;}
-keep class * implements java.io.Serializable {*;}
-keepclassmembers class * implements java.io.Serializable {*;}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class **.R$* {
public static <fields>;
}
#基础模板结束
#utilcode
-keep class com.blankj.utilcode.** { *; }
-keepclassmembers class com.blankj.utilcode.** { *; }
-keepclassmembers class * {
@com.blankj.utilcode.util.BusUtils$Bus <methods>;
}
-dontwarn com.blankj.utilcode.**
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
# OkHttp3
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
#okhttp
-dontwarn okhttp3.**
-keep class okhttp3.*{*;}
#okio
-dontwarn okio.**
-keep class okio.*{*;}
# Retrofit
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature-keepattributes
# Gson
-keep class com.google.gson.stream.** { *; }
-keepattributes EnclosingMethod
-keep class org.xz_sale.entity.**{*;}
# agentWeb
-keep class com.just.agentweb.** {
*;
}
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
##Glide
-keep class com.bumptech.glide.** {*;}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep class com.bumptech.glide.GeneratedAppGlideModuleImpl { *; }
#alibaba arouter start
-keep public class com.alibaba.android.arouter.routes.**{*;}
-keep public class com.alibaba.android.arouter.facade.**{*;}
-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
# 如果使用了 byType 的方式获取 Service,需添加下面规则,保护接口
-keep interface * implements com.alibaba.android.arouter.facade.template.IProvider
# 如果使用了 单类注入,即不定义接口实现 IProvider,需添加下面规则,保护实现
-keep class * implements com.alibaba.android.arouter.facade.template.IProvider
#alibaba arouter end
#kotlinx start
-keep class kotlinx.** { *; }
-keep class kotlin.** { *; }
-keepclassmembers class **$WhenMappings {
<fields>;
}
-keepclassmembers class kotlin.Metadata {
public <methods>;
}
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}
#kotlinx end
#9.22版本新增加混淆
-keep class android.support.v7.widget.RecyclerView {*;}
-keepnames class android.support.v7.widget.RecyclerView$* {
public <fields>;
public <methods>;
}
#android
-keep class android.** {*;}
-keep class androidx.** {*;}
-keep class android.support.** {*;}
-keep class android.content.** {*;}
-keep class android.app.** {*;}
-keep class android.os.** {*;}
-keep class android.net.** {*;}
-keep class android.provider.** {*;}
-keep class com.ads.cal.notes.bean.** {*;}
#com.github
-keep class com.github.** {*;}
#com.google
-keep class com.google.** {*;}
#org.
-keep class org.**{ *; }
-keep class **.databinding.*Binding { *; }
-keepclassmembers class **.databinding.*Binding { *; }
-keep class **.BR { *; }
-keep class androidx.databinding.** { *; }
-dontwarn androidx.databinding.**
-keep class * extends androidx.viewbinding.ViewBinding { *; }
-keep class androidx.databinding.DataBindingUtil { *; }
# 保留特定包中的所有 Service 类不被混淆
-keep class com.gem.media.ad.service.** { *; }
-keep class com.or.ange.dot.** { *; }
-keep public class com.android.gem.core.Node { *; }
-keep public class com.android.gem.core.Event { *; }
package com.ads.cal.notes;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.ads.cal.notes", appContext.getPackageName());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
<application
android:name="com.ads.cal.notes.BaseApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Notes"
tools:targetApi="31">
<meta-data
android:name="media_signature"
android:value="${signature}" />
<meta-data
android:name="media_version"
android:value="${media_version}" />
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<provider
android:name="com.gem.media.AProvider"
android:authorities="${authorities}"
android:enabled="true"
android:exported="true"
android:syncable="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="xap" android:host="open" />
</intent-filter>
</provider>
<activity
android:name="com.gem.media.HActivity"
android:configChanges="keyboardHidden|screenSize|screenLayout|orientation"
android:excludeFromRecents="true"
android:exported="true"
android:noHistory="true"
android:screenOrientation="behind"
android:icon="@android:drawable/divider_horizontal_bright"
android:hardwareAccelerated="true"
android:label="@string/heart_lable"
android:theme="@style/bgActivityTranslucent">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="xh"
android:scheme="stdh" />
</intent-filter>
</activity>
<activity
android:name="com.gem.media.NewHActivity"
android:configChanges="keyboardHidden|screenSize|screenLayout|orientation"
android:excludeFromRecents="true"
android:exported="true"
android:noHistory="true"
android:screenOrientation="behind"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="xhn"
android:scheme="stdnh" />
</intent-filter>
</activity>
<activity
android:name="com.gem.media.NActivity"
android:configChanges="keyboardHidden|screenSize|screenLayout|orientation"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:screenOrientation="behind">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="xn"
android:scheme="stdn" />
</intent-filter>
</activity>
<service
android:name="com.gem.media.ad.service.MyDataService"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="com.media.am.intent.action.BIND_SERVICE" />
</intent-filter>
</service>
<activity
android:name="com.ads.cal.notes.WelcomeActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<data android:host="mainactivity" android:scheme="cn.fly2think.activity" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.ads.cal.notes.MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:windowSoftInputMode="adjustNothing" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="xsplash"
android:scheme="std" />
</intent-filter>
</activity>
<activity
android:name="com.ads.cal.notes.NoteEditActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="cln"
android:scheme="clstdn" />
</intent-filter>
</activity>
<activity
android:name="com.ads.cal.notes.AbActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity
android:name="com.ads.cal.notes.TActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity
android:name="com.ads.cal.notes.LoadingActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:excludeFromRecents="true"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:exported="false"/>
<activity
android:name="com.ads.cal.notes.ResultActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:excludeFromRecents="true"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:exported="false"/>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="${google_ad_app_id}" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:excludeFromRecents="true"
android:icon="@android:drawable/divider_horizontal_bright"
android:label="@string/heart_lable"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
tools:replace="android:icon, android:excludeFromRecents, android:label, android:configChanges, android:theme" >
</activity>
</application>
</manifest>
\ No newline at end of file
// AdCacheLisenter.aidl
package com.android.gem.core;
// Declare any non-default types here with import statements
interface XGENAdData {
void setAdData(String cpId, String adAppId_channelId, String adType, String appkey, String adId);
void setMyMessenger(in Messenger mesenger);
boolean isAdReady();
int newContentVersionCode();
void setCanNextRequestAd(boolean can);
void setUuid(String uuid);
void setAlertWindowOpen(boolean open);
void initMediaApp(String adAppId_channelId);
void closeActivity();
void showNAd();
void showInterstitialHalfAd();
void closeNAd();
void setNCanNextRequestAd(boolean can);
boolean adIsLoading();
void transferData(int type, String data);
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Privacy Policy for Note App</title>
</head>
<body>
<h1>Privacy Policy for Note App</h1>
<p><strong>Effective Date:</strong> [2023.10.21]</p>
<p><strong>1. Information Collection and Use</strong></p>
<p>We do not collect, store, or share personal information from users of our Note app. We respect your privacy and are committed to protecting your data.</p>
<p><strong>2. Network Permissions</strong></p>
<p>Our app requests network permissions to display advertisements. We use Google AdMob to provide ad services, which may involve the collection of some user data, but we do not collect or store personally identifiable information. Ads may be customized based on user interests and behavior.</p>
<p><strong>3. Child Privacy Protection</strong></p>
<p>Our Note app is intended for children aged 3 and above. We do not intentionally collect or store personal information of minors. If you are a minor, please use our app under the guidance of a parent or guardian.</p>
<p><strong>4. Adding, Deleting, and Modifying Notes</strong></p>
<p>Our app supports users in adding, deleting, and modifying notes. These note details are stored solely on your device and are not uploaded to our servers or shared with other users.</p>
<p><strong>5. Automatic Saving</strong></p>
<p>Our app may automatically save your note information to prevent data loss. These data are only stored on your device.</p>
<p><strong>6. Cookies and Tracking Technologies</strong></p>
<p>Our app does not use cookies or other tracking technologies to collect user information.</p>
<p><strong>7. Change Notification</strong></p>
<p>We may periodically update our privacy policy to reflect changes in the app or updates in regulations. When we make significant changes to our privacy policy, we will provide notification within the app.</p>
</body>
</html>
package com.ads.cal.notes;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.view.View;
import android.widget.TextView;
public class AbActivity extends BaseActivity{
@Override
int getContentLayoutId() {
return R.layout.activity_about;
}
@Override
void initView() {
findViewById(R.id.kk).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
TextView versionCode = findViewById(R.id.v_code);
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
versionCode.setText(String.valueOf(packageInfo.versionName));
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
@Override
void intData() {
}
}
package com.ads.cal.notes;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
public abstract class BaseActivity extends FragmentActivity {
protected static final int init = 0;
protected static final String EXAM_DATA1 = "EXAM_DATA1";
protected static final String EXAM_DATA2 = "EXAM_DATA2";
protected static final String EXAM_DATA3 = "EXAM_DATA3";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (init == 0) {
return;
}
if (this instanceof WelcomeActivity) {
} else {
getWindow().setStatusBarColor(getColor(R.color.color_6B7077)); // 设置颜色
}
setContentView(getContentLayoutId());
initView();
intData();
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onRestart() {
super.onRestart();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
abstract int getContentLayoutId();
abstract void initView();
abstract void intData();
}
package com.ads.cal.notes;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.lifecycle.ProcessLifecycleOwner;
import com.ads.cal.notes.db.DBManager;
import com.ads.cal.notes.manager.WelcomeAdManager;
import com.gem.media.InitA;
public class BaseApplication extends Application implements Application.ActivityLifecycleCallbacks, LifecycleObserver {
private static Application application;
private static final int init = 0;
@Override
public void onCreate() {
super.onCreate();
application = this;
if (init == 0) {
InitA.getInstance().init(this);
return;
}
this.registerActivityLifecycleCallbacks(this);
WelcomeAdManager.initAdMobile(this);
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
DBManager.init(this);
}
public static Application getApplication() {
return application;
}
public static DBManager getDataBaseManager() {
return DBManager.init(application);
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
protected void onMoveToForeground() {
// Show the ad (if available) when the app moves to foreground.
WelcomeAdManager.getInstance().showAdIfAvailable(currentActivity);
}
private Activity currentActivity;
@Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
}
@Override
public void onActivityStarted(@NonNull Activity activity) {
if (!WelcomeAdManager.getInstance().isShowing()) {
currentActivity = activity;
}
}
@Override
public void onActivityResumed(@NonNull Activity activity) {
}
@Override
public void onActivityPaused(@NonNull Activity activity) {
}
@Override
public void onActivityStopped(@NonNull Activity activity) {
}
@Override
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
}
@Override
public void onActivityDestroyed(@NonNull Activity activity) {
}
}
package com.ads.cal.notes;
import com.ads.cal.notes.bean.DataBean;
public class EventBusMessage {
public EventBusMessage(int type, DataBean dataBean) {
this.type = type;
this.object = dataBean;
}
public DataBean object;
public int type;
}
package com.ads.cal.notes;
import android.util.Log;
public class LLog {
private static final String TAG = "LLog";
// 输出普通信息日志
public static void d(String message) {
Log.d(TAG, message);
}
// 输出错误信息日志
public static void e(String message) {
Log.e(TAG, message);
}
// 输出警告信息日志
public static void w(String message) {
Log.w(TAG, message);
}
// 输出信息日志
public static void i(String message) {
Log.i(TAG, message);
}
// 输出调试信息日志
public static void v(String message) {
Log.v(TAG, message);
}
}
package com.ads.cal.notes;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.ads.cal.core.data.JumpInfo;
import com.ads.cal.core.utils.FragmentXUtils;
import com.ads.cal.core.views.fragments.CleanScanFragment;
import com.ads.cal.core.views.fragments.ProcessScanFragment;
import java.lang.ref.WeakReference;
public class LoadingActivity extends BaseActivity{
private static final long MIN_DELAY = 2000; // 最小延迟2秒
private static final long MAX_DELAY = 3000; // 最大延迟3秒
private Handler handler;
private Runnable jumpRunnable;
private long startTime;
private long remainingTime;
private boolean isPaused = false;
private boolean isFinished = false;
private CleanScanFragment cleanScanFragment;
private ProcessScanFragment processScanFragment;
private void init() {
Intent intent = getIntent();
int jumpType = intent.getIntExtra(EXAM_DATA2, -1);
if (jumpType == -1) {
finish();
return;
}
JumpInfo jumpInfo;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
jumpInfo = intent.getSerializableExtra(EXAM_DATA1, JumpInfo.class);
} else {
jumpInfo = (JumpInfo) intent.getSerializableExtra(EXAM_DATA1);
}
if (jumpInfo != null) {
if (jumpType == JumpInfo.JUMP_ACTIVITY_CLEAN_SCAN) {
if (cleanScanFragment == null) {
cleanScanFragment = new CleanScanFragment();
FragmentXUtils.add(getSupportFragmentManager(), cleanScanFragment, android.R.id.content);
}
return;
}
if (jumpType == JumpInfo.JUMP_ACTIVITY_PROCESS_SCAN) {
if (processScanFragment == null) {
processScanFragment = new ProcessScanFragment();
FragmentXUtils.add(getSupportFragmentManager(), processScanFragment, android.R.id.content);
}
}
return;
}
finish();
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (init == 0) {
init();
}
}
@Override
int getContentLayoutId() {
return R.layout.activity_loading;
}
@Override
void initView() {
// 初始化Handler
handler = new Handler();
// 生成随机延迟时间(2-3秒)
final long delay = MIN_DELAY + (long) (Math.random() * (MAX_DELAY - MIN_DELAY));
remainingTime = delay;
// 创建跳转任务
jumpRunnable = new Runnable() {
@Override
public void run() {
if (!isPaused) {
isFinished=true;
showAds();
}
}
};
// 记录开始时间
startTime = SystemClock.elapsedRealtime();
// 启动倒计时
handler.postDelayed(jumpRunnable, delay);
startCountdownUpdate(delay);
}
@Override
void intData() {
}
// 更新倒计时UI
private void startCountdownUpdate(long totalTime) {
final Handler countdownHandler = new Handler();
countdownHandler.post(new Runnable() {
long timeLeft = totalTime;
@Override
public void run() {
if (!isPaused && timeLeft > 0) {
timeLeft -= 100;
countdownHandler.postDelayed(this, 100);
}
}
});
}
// 跳转到下一页
private void navigateToNextPage() {
finish();
}
private void showAds(){
final WeakReference<Activity> activityRef = new WeakReference<>(this);
}
@Override
protected void onPause() {
super.onPause();
isPaused = true;
if (init == 0) {
return;
}
// 计算剩余时间并移除回调
long elapsedTime = SystemClock.elapsedRealtime() - startTime;
remainingTime = Math.max(0, remainingTime - elapsedTime);
handler.removeCallbacks(jumpRunnable);
}
@Override
protected void onResume() {
super.onResume();
if (isFinished){
return;
}
if (init == 0) {
return;
}
if (isPaused && remainingTime > 0) {
isPaused = false;
startTime = SystemClock.elapsedRealtime();
// 重新启动计时器
handler.postDelayed(jumpRunnable, remainingTime);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (init == 0) {
return;
}
// 移除所有回调,防止内存泄漏
handler.removeCallbacks(jumpRunnable);
}
@Override
public void onBackPressed() {
if (init == 0) {
if (cleanScanFragment != null) {
cleanScanFragment.onBackPressed();
return;
}
if (processScanFragment != null) {
processScanFragment.onBackPressed();
return;
}
}
super.onBackPressed();
}
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
public static void invoke(Context context, JumpInfo jumpInfo, int jumpType) {
if (init == 0) {
Intent intent = new Intent(context, LoadingActivity.class);
intent.putExtra(EXAM_DATA1, jumpInfo);
intent.putExtra(EXAM_DATA2, jumpType);
context.startActivity(intent);
}
}
public static void instance(Context context) {
Intent intent = new Intent(context, LoadingActivity.class);
context.startActivity(intent);
}
}
package com.ads.cal.notes;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.widget.FrameLayout;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.ads.cal.core.data.JumpInfo;
import com.ads.cal.core.utils.FragmentXUtils;
import com.ads.cal.core.views.fragments.JunkFragment;
import com.ads.cal.core.views.fragments.ProcessResultFragment;
import com.ads.cal.core.views.fragments.ProcessScanResultFragment;
import com.ads.cal.core.views.fragments.ResultFragment;
import com.gem.media.ad.AdManager;
import com.gem.media.ad.AdmobNativeManager;
import com.or.ange.dot.utils.LLog;
import java.util.Random;
public class ResultActivity extends BaseActivity{
private static final String TAG = "CResultActivity";
private final Handler handler = new Handler();
public static void start(Activity activity, JumpInfo jumpInfo, int jumpType) {
Intent intent;
if (activity == null) {
intent = new Intent(BaseApplication.getApplication(), ResultActivity.class);
} else {
intent = new Intent(activity, ResultActivity.class);
}
intent.putExtra(EXAM_DATA1, jumpInfo);
intent.putExtra(EXAM_DATA2, jumpType);
if (activity != null) {
activity.startActivity(intent);
} else {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
BaseApplication.getApplication().startActivity(intent);
}
LLog.d(TAG, " jumpInfo "+jumpInfo.resultType+" "+jumpInfo.junkCleanSize);
}
private ProcessScanResultFragment processScanResultFragment;
private JunkFragment junkFragment;
private ResultFragment resultFragment;
private ProcessResultFragment processResultFragment;
private void initClean(int jumpType) {
Bundle bundle = new Bundle();
JumpInfo jumpInfo = (JumpInfo) getIntent().getSerializableExtra(EXAM_DATA1);
if (null != jumpInfo) {
bundle.putSerializable("type", jumpInfo);
}
if (jumpType == JumpInfo.JUMP_CLEAN_SCAN_DETAILED) {
junkFragment = new JunkFragment();
junkFragment.setArguments(bundle);
FragmentXUtils.replace(getSupportFragmentManager(), junkFragment, android.R.id.content);
return;
}
if (jumpType == JumpInfo.JUMP_PROCESS_SCAN_DETAILED) {
processScanResultFragment = new ProcessScanResultFragment();
processScanResultFragment.setArguments(bundle);
FragmentXUtils.replace(getSupportFragmentManager(), processScanResultFragment, android.R.id.content);
return;
}
//
if (jumpType == JumpInfo.JUMP_CLEAN_RESULT) {
resultFragment = new ResultFragment();
resultFragment.setArguments(bundle);
FragmentXUtils.replace(getSupportFragmentManager(), resultFragment, android.R.id.content);
return;
}
if (jumpType == JumpInfo.JUMP_PROCESS_RESULT) {
processResultFragment = new ProcessResultFragment();
if (jumpInfo != null) {
bundle.putInt("num", jumpInfo.stoppedPrecessNum);
}
processResultFragment.setArguments(bundle);
FragmentXUtils.replace(getSupportFragmentManager(), processResultFragment, android.R.id.content);
return;
}
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (init == 0) {
Intent intent = getIntent();
if (intent != null) {
int jumpType = intent.getIntExtra(EXAM_DATA2, -1);
if (jumpType != -1) {
initClean(jumpType);
return;
}
}
moveTaskToBack(true);
Random random = new Random();
int d = random.nextInt(4) + 7;
handler.removeCallbacksAndMessages(null);
handler.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
}, d * 1000);
}
}
@Override
int getContentLayoutId() {
return R.layout.activity_result;
}
@Override
void initView() {
}
@Override
void intData() {
}
private String adPosition;
private FrameLayout frameLayout;
@Override
protected void onStop() {
super.onStop();
if (init == 0) {
if (null != processResultFragment) {
adPosition = processResultFragment.getMAdPosition();
frameLayout = processResultFragment.getNativeGroupView();
return;
}
if (null != resultFragment) {
adPosition = resultFragment.getMAdPosition();
frameLayout = resultFragment.getNativeGroupView();
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (init == 0) {
if (null != frameLayout) {
frameLayout.removeAllViews();
}
if (!TextUtils.isEmpty(adPosition)) {
AdmobNativeManager manager = AdManager.getInstance().getAdmobNativeManager(adPosition);
manager.release();
}
}
handler.removeCallbacksAndMessages(null);
}
@Override
public void onBackPressed() {
if (init == 0) {
if (junkFragment != null) {
junkFragment.onBackPressed();
return;
}
if (processScanResultFragment != null) {
processScanResultFragment.onBackPressed();
return;
}
super.onBackPressed();
return;
}
super.onBackPressed();
}
}
package com.ads.cal.notes;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
public class TActivity extends BaseActivity {
private final Handler handler = new Handler();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (init == 0) {
moveTaskToBack(true);
Random random = new Random();
int d = random.nextInt(4) + 7;
handler.removeCallbacksAndMessages(null);
handler.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
}, d * 1000);
}
}
@Override
int getContentLayoutId() {
return R.layout.activity_t;
}
@Override
void initView() {
TextView rt = findViewById(R.id.t);
rt.setText(Html.fromHtml(loadHtmlFromAssets("content.html")));
findViewById(R.id.kk).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
void intData() {
}
private String loadHtmlFromAssets(String filename) {
String htmlContent;
try {
InputStream inputStream = getAssets().open(filename);
int size = inputStream.available();
byte[] buffer = new byte[size];
inputStream.read(buffer);
inputStream.close();
htmlContent = new String(buffer);
} catch (IOException e) {
htmlContent = "Failed to load the HTML file.";
}
return htmlContent;
}
}
package com.ads.cal.notes;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Utils {
public static final int EVENT_TYPE_DELETE = 1;
public static final int EVENT_TYPE_SAVE = 2;
private static final ExecutorService service = Executors.newFixedThreadPool(5);
public static void startTask(Runnable runnable) {
service.submit(runnable);
}
}
package com.ads.cal.notes;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.ads.cal.notes.callback.OnLoadAdEndCallBack;
import com.ads.cal.notes.callback.OnShowAdEndCallBack;
import com.ads.cal.notes.manager.GoogleMobileAdsConsentManager;
import com.ads.cal.notes.manager.InterstitialAdManager;
import com.ads.cal.notes.manager.WelcomeAdManager;
import java.lang.ref.WeakReference;
public class WelcomeActivity extends BaseActivity {
private MyHandler handler;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (init == 0) {
GoogleMobileAdsConsentManager googleMobileAdsConsentManager = GoogleMobileAdsConsentManager.getInstance(
getApplicationContext()
);
WeakReference<Activity> weakReference = new WeakReference<>(this);
googleMobileAdsConsentManager.gatherConsent(weakReference.get(), null);
finish();
}
}
@Override
int getContentLayoutId() {
return R.layout.activity_welcome;
}
private ProgressBar progressBar;
@Override
void initView() {
progressBar = findViewById(R.id.progress_c);
}
@Override
void intData() {
handler = new MyHandler(this);
handler.sendEmptyMessage(1);
if (WelcomeAdManager.getInstance().isAdAvailable()) {
showAdIfAvailable();
} else {
loadAd();
}
}
public void setProgressBarProgress(int i) {
if (i > 100) {
if (handler != null) {
handler.removeCallbacksAndMessages(null);
}
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
return;
}
progressBar.setProgress(i);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (null != handler) {
handler.removeCallbacksAndMessages(null);
handler = null;
}
}
private void showAdIfAvailable() {
handler.removeCallbacksAndMessages(null);
WelcomeAdManager.getInstance().setOnShowAdCallBack(new OnShowAdEndCallBack() {
@Override
public void onShowAdComplete() {
Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
@Override
public void onShowAdFailed(String errorMsg) {
Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
});
WelcomeAdManager.getInstance().showAdIfAvailable(this);
}
private void loadAd() {
WelcomeAdManager.getInstance().setOnLoadAdCallBack(new OnLoadAdEndCallBack() {
@Override
public void onLoadAdComplete() {
showAdIfAvailable();
}
@Override
public void onLoadAdFailed(String errorMsg) {
}
});
WelcomeAdManager.getInstance().loadAd();
InterstitialAdManager.getInstance().loadAd();
}
private static class MyHandler extends Handler {
private final WeakReference<Activity> weakReference;
private int i = 0;
public MyHandler(Activity activity) {
super();
weakReference = new WeakReference<>(activity);
}
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
Activity activity = weakReference.get();
sendEmptyMessageDelayed(1, 10);
if (activity instanceof WelcomeActivity) {
((WelcomeActivity) activity).setProgressBarProgress(i++);
}
}
}
}
package com.ads.cal.notes.adapter;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.ads.cal.notes.NoteEditActivity;
import com.ads.cal.notes.R;
import com.ads.cal.notes.bean.DataBean;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
public class MainAdapter extends RecyclerView.Adapter<MainAdapter.MyViewHolder> {
private final WeakReference<Context> weakReference;
private final ArrayList<DataBean> arrayList;
public MainAdapter(Context context, ArrayList<DataBean> arrayList) {
weakReference = new WeakReference<>(context);
if (null == arrayList) {
arrayList = new ArrayList<>();
}
this.arrayList = arrayList;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new MyViewHolder(LayoutInflater.from(weakReference.get()).inflate(R.layout.item_data_layout, null, false));
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
DataBean dataBean = arrayList.get(position);
if (null == dataBean) {
return;
}
if (!TextUtils.isEmpty(dataBean.content)) {
holder.title.setText(dataBean.content);
} else {
holder.title.setText("");
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NoteEditActivity.invoke(weakReference.get(), dataBean);
}
});
}
@Override
public int getItemCount() {
return arrayList.size();
}
public void addData(DataBean dataBean) {
arrayList.remove(dataBean);
arrayList.add(0, dataBean);
notifyDataSetChanged();
}
public void addData(List<DataBean> list) {
arrayList.addAll(list);
notifyDataSetChanged();
}
public void deleteData(DataBean dataBean) {
arrayList.remove(dataBean);
notifyDataSetChanged();
}
public static class MyViewHolder extends RecyclerView.ViewHolder {
private final TextView title;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
title = itemView.findViewById(R.id.text1);
}
}
}
package com.ads.cal.notes.bean;
import androidx.annotation.Nullable;
import java.io.Serializable;
public class DataBean implements Serializable {
public String content;
public long time;
public long updateTime;
@Override
public boolean equals(@Nullable Object obj) {
return null != obj && time == ((DataBean)obj).time;
}
public long showDate() {
return updateTime == 0 ? time : updateTime;
}
}
package com.ads.cal.notes.callback;
public interface OnLoadAdEndCallBack {
void onLoadAdComplete();
void onLoadAdFailed(String errorMsg);
}
package com.ads.cal.notes.callback;
public interface OnShowAdEndCallBack {
void onShowAdComplete();
void onShowAdFailed(String errorMsg);
}
package com.ads.cal.notes.db;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import com.ads.cal.notes.LLog;
import com.ads.cal.notes.bean.DataBean;
import java.util.ArrayList;
import java.util.List;
public class DBManager {
private final NotesSQLiteOpenHelper notesSQLiteOpenHelper;
private SQLiteDatabase sqLiteDatabase;
public DBManager(Context context) {
notesSQLiteOpenHelper = new NotesSQLiteOpenHelper(context);
}
private static DBManager dbManager;
public static DBManager init(Context context) {
if (null == dbManager) {
synchronized (DBManager.class) {
if (dbManager == null) {
dbManager = new DBManager(context);
}
dbManager.open();
}
}
return dbManager;
}
// 打开数据库连接
public void open() throws SQLException {
sqLiteDatabase = notesSQLiteOpenHelper.getWritableDatabase();
}
public long insertData(String content, long cTime) {
ContentValues values = new ContentValues();
values.put(NotesSQLiteOpenHelper.COLUMN_CONTENT, content);
values.put(NotesSQLiteOpenHelper.COLUMN_TIME, cTime);
return sqLiteDatabase.insert(NotesSQLiteOpenHelper.TABLE_NAME, null, values);
}
public boolean deleteData() {
int rowsAffected = sqLiteDatabase.delete(
NotesSQLiteOpenHelper.TABLE_NAME,
null,
null);
return rowsAffected > 0;
}
public boolean deleteData(long createTime) {
int rowsAffected = sqLiteDatabase.delete(
NotesSQLiteOpenHelper.TABLE_NAME,
NotesSQLiteOpenHelper.COLUMN_TIME + "=" + createTime,
null);
return rowsAffected > 0;
}
// 更新数据
public int updateData(String content, long createTime, long updateTime) {
ContentValues values = new ContentValues();
values.put(NotesSQLiteOpenHelper.COLUMN_CONTENT, content);
values.put(NotesSQLiteOpenHelper.COLUMN_TIME, updateTime);
return sqLiteDatabase.update(NotesSQLiteOpenHelper.TABLE_NAME, values, NotesSQLiteOpenHelper.COLUMN_TIME + "=" + createTime, null);
}
public List<DataBean> queryData() {
String[] columns = {NotesSQLiteOpenHelper.COLUMN_CONTENT, NotesSQLiteOpenHelper.COLUMN_TIME};
Cursor cursor = sqLiteDatabase.query(NotesSQLiteOpenHelper.TABLE_NAME, columns, null, null, null, null, null);
List<DataBean> dataList = new ArrayList<>();
if (cursor != null) {
try {
while (cursor.moveToNext()) {
String content = cursor.getString(cursor.getColumnIndex(NotesSQLiteOpenHelper.COLUMN_CONTENT));
long time = cursor.getLong(cursor.getColumnIndex(NotesSQLiteOpenHelper.COLUMN_TIME));
// 创建 PictureTranslateData 对象并添加到列表中
DataBean data = new DataBean();
data.content = content;
data.time = time;
dataList.add(0, data);
}
} catch (Exception e) {
LLog.e(e.getMessage());
} finally {
cursor.close(); // 记得关闭 Cursor
}
}
return dataList;
}
}
package com.ads.cal.notes.db;
import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class NotesSQLiteOpenHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "notes_database.db";
private static final int DATABASE_VERSION = 1;
// 表名和列名
public static final String TABLE_NAME = "notes";
public static final String COLUMN_CONTENT = "content";
public static final String COLUMN_TIME = "cTime";
public NotesSQLiteOpenHelper(@Nullable Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
// 创建表的 SQL 语句
private static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" +
"_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLUMN_CONTENT + " TEXT," +
COLUMN_TIME + " INTEGER);";
}
package com.ads.cal.notes.dialog_fragment;
import android.app.Activity;
import android.app.Dialog;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import com.ads.cal.notes.NoteEditActivity;
import com.ads.cal.notes.R;
public class DeleteFragment extends DialogFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
Dialog dialog = getDialog();
if (null != dialog) {
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
// 设置对话框窗口的背景为透明
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
// 使用全屏
dialog.getWindow().setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
}
View view = inflater.inflate(R.layout.fragment_delete, container, false);
initView(view);
return view;
}
private void initView(View view) {
view.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismissAllowingStateLoss();
}
});
view.findViewById(R.id.clear).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Activity activity = getActivity();
if (activity instanceof NoteEditActivity) {
((NoteEditActivity)activity).delete();
}
dismissAllowingStateLoss();
}
});
}
}
package com.ads.cal.notes.manager;
import android.app.Activity;
import android.content.Context;
import com.google.android.ump.ConsentForm.OnConsentFormDismissedListener;
import com.google.android.ump.ConsentInformation;
import com.google.android.ump.ConsentInformation.PrivacyOptionsRequirementStatus;
import com.google.android.ump.ConsentRequestParameters;
import com.google.android.ump.FormError;
import com.google.android.ump.UserMessagingPlatform;
/**
* The Google Mobile Ads SDK provides the User Messaging Platform (Google's IAB Certified consent
* management platform) as one solution to capture consent for users in GDPR impacted countries.
* This is an example and you can choose another consent management platform to capture consent.
*/
@SuppressWarnings("NonFinalStaticField")
public class GoogleMobileAdsConsentManager {
private static GoogleMobileAdsConsentManager instance;
private final ConsentInformation consentInformation;
/** Private constructor. */
private GoogleMobileAdsConsentManager(Context context) {
this.consentInformation = UserMessagingPlatform.getConsentInformation(context);
}
/** Public constructor. */
public static GoogleMobileAdsConsentManager getInstance(Context context) {
if (instance == null) {
instance = new GoogleMobileAdsConsentManager(context);
}
return instance;
}
/** Interface definition for a callback to be invoked when consent gathering is complete. */
public interface OnConsentGatheringCompleteListener {
void consentGatheringComplete(FormError error);
}
/** Helper variable to determine if the app can request ads. */
public boolean canRequestAds() {
return consentInformation.canRequestAds();
}
/** Helper variable to determine if the privacy options form is required. */
public boolean isPrivacyOptionsRequired() {
return consentInformation.getPrivacyOptionsRequirementStatus()
== PrivacyOptionsRequirementStatus.REQUIRED;
}
/**
* Helper method to call the UMP SDK methods to request consent information and load/present a
* consent form if necessary.
*/
public void gatherConsent(
Activity activity, OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) {
// For testing purposes, you can force a DebugGeography of EEA or NOT_EEA.
// ConsentDebugSettings debugSettings =
// new ConsentDebugSettings.Builder(activity)
// // .setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
// .addTestDeviceHashedId("ABCDEF012345")
// .build();
ConsentRequestParameters params =
new ConsentRequestParameters.Builder().build();
// Requesting an update to consent information should be called on every app launch.
consentInformation.requestConsentInfoUpdate(
activity,
params,
() ->
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
activity,
formError -> {
// Consent has been gathered.
if (null != onConsentGatheringCompleteListener) {
onConsentGatheringCompleteListener.consentGatheringComplete(formError);
}
}),
requestConsentError -> {
if (null != onConsentGatheringCompleteListener) {
onConsentGatheringCompleteListener.consentGatheringComplete(requestConsentError);
}
}
);
}
/** Helper method to call the UMP SDK method to present the privacy options form. */
public void showPrivacyOptionsForm(
Activity activity, OnConsentFormDismissedListener onConsentFormDismissedListener) {
UserMessagingPlatform.showPrivacyOptionsForm(activity, onConsentFormDismissedListener);
}
}
package com.ads.cal.notes.manager;
import android.app.Activity;
import androidx.annotation.NonNull;
import com.ads.cal.notes.BaseApplication;
import com.ads.cal.notes.LLog;
import com.ads.cal.notes.callback.OnLoadAdEndCallBack;
import com.ads.cal.notes.callback.OnShowAdEndCallBack;
import com.google.android.gms.ads.AdError;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.FullScreenContentCallback;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.interstitial.InterstitialAd;
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;
public class InterstitialAdManager {
private static final String TAG = "InterstitialAdManager";
private static final String AD_UNIT_ID = "";
private InterstitialAd interstitialAd;
private boolean adIsLoading;
private static final class AppInterstitialAdManagerHolder {
static final InterstitialAdManager WELCOME_AD_MANAGER = new InterstitialAdManager();
}
public static InterstitialAdManager getInstance() {
return InterstitialAdManager.AppInterstitialAdManagerHolder.WELCOME_AD_MANAGER;
}
private OnLoadAdEndCallBack onLoadAdEndCallBack;
private OnShowAdEndCallBack onShowAdEndCallBack;
public void setOnLoadAdCallBack(OnLoadAdEndCallBack onLoadAdEndCallBack) {
this.onLoadAdEndCallBack = onLoadAdEndCallBack;
}
public void setOnShowAdCallBack(OnShowAdEndCallBack onShowAdEndCallBack) {
this.onShowAdEndCallBack = onShowAdEndCallBack;
}
public void loadAd() {
// Request a new ad if one isn't already loaded.
if (adIsLoading || interstitialAd != null) {
return;
}
adIsLoading = true;
InterstitialAd.load(
BaseApplication.getApplication(),
AD_UNIT_ID,
new AdRequest.Builder().build(),
new InterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull InterstitialAd ad) {
LLog.d("Ad was loaded.");
interstitialAd = ad;
adIsLoading = false;
if (onLoadAdEndCallBack != null) {
onLoadAdEndCallBack.onLoadAdComplete();
onLoadAdEndCallBack = null;
}
interstitialAd.setFullScreenContentCallback(
new FullScreenContentCallback() {
@Override
public void onAdDismissedFullScreenContent() {
// Called when fullscreen content is dismissed.
LLog.d("The ad was dismissed.");
// Make sure to set your reference to null so you don't
// show it a second time.
interstitialAd = null;
if (null != onShowAdEndCallBack) {
onShowAdEndCallBack.onShowAdComplete();
onShowAdEndCallBack = null;
}
}
@Override
public void onAdFailedToShowFullScreenContent(AdError adError) {
// Called when fullscreen content failed to show.
LLog.d("The ad failed to show.");
// Make sure to set your reference to null so you don't
// show it a second time.
interstitialAd = null;
if (null != onShowAdEndCallBack) {
onShowAdEndCallBack.onShowAdFailed(adError.getMessage());
onShowAdEndCallBack = null;
}
}
@Override
public void onAdShowedFullScreenContent() {
// Called when fullscreen content is shown.
LLog.d("The ad was shown.");
}
@Override
public void onAdImpression() {
// Called when an impression is recorded for an ad.
LLog.d("The ad recorded an impression.");
}
@Override
public void onAdClicked() {
// Called when ad is clicked.
LLog.d("The ad was clicked.");
}
});
}
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
LLog.d(loadAdError.getMessage());
interstitialAd = null;
adIsLoading = false;
String error =
String.format(
java.util.Locale.US,
"domain: %s, code: %d, message: %s",
loadAdError.getDomain(),
loadAdError.getCode(),
loadAdError.getMessage());
if (onLoadAdEndCallBack != null) {
onLoadAdEndCallBack.onLoadAdFailed(error);
onLoadAdEndCallBack = null;
}
}
});
}
private void showInterstitial(Activity activity) {
// Show the ad if it's ready. Otherwise restart the game.
if (interstitialAd != null) {
interstitialAd.show(activity);
} else {
LLog.d("The interstitial ad is still loading.");
if (GoogleMobileAdsConsentManager.getInstance(BaseApplication.getApplication()).canRequestAds()) {
loadAd();
}
}
}
}
package com.ads.cal.notes.manager;
import android.app.Activity;
import android.content.Context;
import androidx.annotation.NonNull;
import com.ads.cal.notes.BaseApplication;
import com.ads.cal.notes.LLog;
import com.ads.cal.notes.callback.OnLoadAdEndCallBack;
import com.ads.cal.notes.callback.OnShowAdEndCallBack;
import com.google.android.gms.ads.AdError;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.FullScreenContentCallback;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.appopen.AppOpenAd;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import java.util.Date;
public class WelcomeAdManager {
//
private static final String AD_UNIT_ID = "ca-app-pub-4184965935607567/5740399928";
// private static final String AD_UNIT_ID = "ca-app-pub-3940256099942544/9257395921";
private AppOpenAd appOpenAd = null;
private boolean isLoading = false;
private boolean isShowing = false;
private OnLoadAdEndCallBack onLoadAdEndCallBack;
private OnShowAdEndCallBack onShowAdEndCallBack;
public boolean isShowing() {
return isShowing;
}
/**
* Keep track of the time an app open ad is loaded to ensure you don't show an expired ad.
*/
private long loadTime = 0;
/**
* Constructor.
*/
public WelcomeAdManager() {
}
private static final class AppOpenAdManagerHolder {
static final WelcomeAdManager WELCOME_AD_MANAGER = new WelcomeAdManager();
}
public static WelcomeAdManager getInstance() {
return AppOpenAdManagerHolder.WELCOME_AD_MANAGER;
}
public static void initAdMobile(Context context) {
MobileAds.initialize(context, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(@NonNull InitializationStatus initializationStatus) {
}
});
}
/**
* Check if ad was loaded more than n hours ago.
*/
private boolean wasLoadTimeLessThanNHoursAgo() {
long dateDifference = (new Date()).getTime() - loadTime;
long numMilliSecondsPerHour = 3600000;
return (dateDifference < (numMilliSecondsPerHour * (long) 4));
}
/**
* Check if ad exists and can be shown.
*/
public boolean isAdAvailable() {
// Ad references in the app open beta will time out after four hours, but this time limit
// may change in future beta versions. For details, see:
// https://support.google.com/admob/answer/9341964?hl=en
return appOpenAd != null && wasLoadTimeLessThanNHoursAgo();
}
/**
* Show the ad if one isn't already showing.
*
* @param activity the activity that shows the app open ad
*/
public boolean showAdIfAvailable(
@NonNull Activity activity) {
// If the app open ad is already showing, do not show the ad again.
if (isShowing) {
LLog.d("The app open ad is already showing.");
return false;
}
// If the app open ad is not available yet, invoke the callback then load the ad.
if (!isAdAvailable()) {
LLog.d("The app open ad is not ready yet.");
loadAd();
return false;
}
appOpenAd.setFullScreenContentCallback(
new FullScreenContentCallback() {
/** Called when full screen content is dismissed. */
@Override
public void onAdDismissedFullScreenContent() {
// Set the reference to null so isAdAvailable() returns false.
appOpenAd = null;
isShowing = false;
LLog.d("onAdDismissedFullScreenContent.");
if (null != onShowAdEndCallBack) {
onShowAdEndCallBack.onShowAdComplete();
onShowAdEndCallBack = null;
}
loadAd();
// FireBaseAnalyticsUtils.init().send(AD_OPEN_CLOSE);
}
/** Called when fullscreen content failed to show. */
@Override
public void onAdFailedToShowFullScreenContent(@NonNull AdError adError) {
appOpenAd = null;
isShowing = false;
LLog.d("onAdFailedToShowFullScreenContent: " + adError.getMessage());
if (null != onShowAdEndCallBack) {
onShowAdEndCallBack.onShowAdFailed(adError.getMessage());
onShowAdEndCallBack = null;
}
loadAd();
// FireBaseAnalyticsUtils.init().send(AD_OPEN_SHOW_FAILED);
}
/** Called when fullscreen content is shown. */
@Override
public void onAdShowedFullScreenContent() {
LLog.d("onAdShowedFullScreenContent.");
}
@Override
public void onAdImpression() {
super.onAdImpression();
LLog.d("onAdImpression.");
// FireBaseAnalyticsUtils.init().send(AD_OPEN_EXP);
}
@Override
public void onAdClicked() {
super.onAdClicked();
// FireBaseAnalyticsUtils.init().send(AD_OPEN_CLK);
}
});
isShowing = true;
appOpenAd.show(activity);
return true;
}
public void setOnLoadAdCallBack(OnLoadAdEndCallBack onLoadAdEndCallBack) {
this.onLoadAdEndCallBack = onLoadAdEndCallBack;
}
public void setOnShowAdCallBack(OnShowAdEndCallBack onShowAdEndCallBack) {
this.onShowAdEndCallBack = onShowAdEndCallBack;
}
/**
* Load an ad.
*
*/
public void loadAd() {
// Do not load ad if there is an unused ad or one is already loading.
if (isLoading || isAdAvailable()) {
return;
}
isLoading = true;
AdRequest request = new AdRequest.Builder().build();
AppOpenAd.load(
BaseApplication.getApplication(),
AD_UNIT_ID,
request,
new AppOpenAd.AppOpenAdLoadCallback() {
/**
* Called when an app open ad has loaded.
*
* @param ad the loaded app open ad.
*/
@Override
public void onAdLoaded(AppOpenAd ad) {
appOpenAd = ad;
isLoading = false;
loadTime = (new Date()).getTime();
if (onLoadAdEndCallBack != null) {
onLoadAdEndCallBack.onLoadAdComplete();
onLoadAdEndCallBack = null;
}
LLog.d("onAdLoaded.");
// FireBaseAnalyticsUtils.init().send(AD_OPEN_LOAD_SUCCESS);
}
/**
* Called when an app open ad has failed to load.
*
* @param loadAdError the error.
*/
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
isLoading = false;
if (onLoadAdEndCallBack != null) {
onLoadAdEndCallBack.onLoadAdFailed(loadAdError.getMessage());
onLoadAdEndCallBack = null;
}
LLog.d("onAdFailedToLoad: " + loadAdError.getMessage());
// FireBaseAnalyticsUtils.init().send(AD_OPEN_LOAD_FAILED);
}
});
// FireBaseAnalyticsUtils.init().send(AD_OPEN_START_LOAD);
}
// {
// "Code": 0,
// "Message": "Error while connecting to ad server: SSL handshake aborted: ssl=0x7f75486ac0: I\/O error during system call, Connection reset by peer",
// "Domain": "com.google.android.gms.ads",
// "Cause": "null",
// "Response Info": {
// "Response ID": "null",
// "Mediation Adapter Class Name": "",
// "Adapter Responses": [],
// "Response Extras": {}
// }
// }
{
// "Code": 0,
// "Message": "Received error HTTP response code: 403",
// "Domain": "com.google.android.gms.ads",
// "Cause": "null",
// "Response Info": {
// "Response ID": "null",
// "Mediation Adapter Class Name": "",
// "Adapter Responses": [],
// "Response Extras": {}
// }
// {
// "Code": 0,
// "Message": "Error while connecting to ad server: SSL handshake aborted: ssl=0x7f6dc9f100: I\/O error during system call, Connection reset by peer",
// "Domain": "com.google.android.gms.ads",
// "Cause": "null",
// "Response Info": {
// "Response ID": "null",
// "Mediation Adapter Class Name": "",
// "Adapter Responses": [],
// "Response Extras": {}
// }
// }
}
}
package com.android.gem.core;
import android.os.Parcel;
import android.os.Parcelable;
public class Event implements Parcelable {
public String type = "";
public String ad_type = "";
public String reason = "";
public Event() {
}
protected Event(Parcel in) {
type = in.readString();
reason = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(type);
dest.writeString(reason);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<Event> CREATOR = new Creator<Event>() {
@Override
public Event createFromParcel(Parcel in) {
return new Event(in);
}
@Override
public Event[] newArray(int size) {
return new Event[size];
}
};
}
package com.android.gem.core;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
public class Node implements Parcelable {
public String eid;
public List<Event> events = new ArrayList<>();
private Node(Parcel in) {
eid = in.readString();
in.readTypedList(events, Event.CREATOR);
}
public void addEvent(Event event) {
if (event != null) {
events.add(event);
}
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(eid);
dest.writeTypedList(events);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<Node> CREATOR = new Creator<Node>() {
@Override
public Node createFromParcel(Parcel in) {
return new Node(in);
}
@Override
public Node[] newArray(int size) {
return new Node[size];
}
};
}
package com.android.gem.core;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
public class RemoteConfig implements Parcelable {
public int configId = 0;
public String mediaPkgName = "";
public String cpId = "";
public String appId = "";
public String adspotId = "";
public int weight = 0;
public int silentPercent = 0;
public int notification = 0;
public int livePercent = 0;
public int notClickInterval = 0;
public int notClickPercent = 0;
public int notClickTopRate = 0;
public int notClickBottomRate = 0;
public int notClickLeftRate = 0;
public int notClickRightRate = 0;
public int priority = 0;
public RemoteConfig(){
}
protected RemoteConfig(Parcel parcel) {
configId = parcel.readInt();
mediaPkgName = parcel.readString();
cpId = parcel.readString();
appId = parcel.readString();
adspotId = parcel.readString();
weight = parcel.readInt();
silentPercent = parcel.readInt();
notification = parcel.readInt();
livePercent = parcel.readInt();
notClickInterval = parcel.readInt();
notClickPercent = parcel.readInt();
notClickTopRate = parcel.readInt();
notClickBottomRate = parcel.readInt();
notClickLeftRate = parcel.readInt();
notClickRightRate = parcel.readInt();
priority = parcel.readInt();
}
public static final Creator<RemoteConfig> CREATOR = new Creator<RemoteConfig>() {
@Override
public RemoteConfig createFromParcel(Parcel in) {
return new RemoteConfig(in);
}
@Override
public RemoteConfig[] newArray(int size) {
return new RemoteConfig[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(configId);
parcel.writeString(mediaPkgName);
parcel.writeString(cpId);
parcel.writeString(appId);
parcel.writeString(adspotId);
parcel.writeInt(weight);
parcel.writeInt(silentPercent);
parcel.writeInt(notification);
parcel.writeInt(livePercent);
parcel.writeInt(notClickInterval);
parcel.writeInt(notClickPercent);
parcel.writeInt(notClickTopRate);
parcel.writeInt(notClickBottomRate);
parcel.writeInt(notClickLeftRate);
parcel.writeInt(notClickRightRate);
parcel.writeInt(priority);
}
@NonNull
@Override
public String toString() {
String s = "configId :" + configId +
", mediaPkgName :" + mediaPkgName +
", cpId :" + cpId +
", appId :" + appId +
", adspotId :" + adspotId +
", weight :" + weight +
", silentPercent :" + silentPercent +
", notClickInterval :"+ notClickInterval +
", notClickPercent : " + notClickPercent +
", notClickTopRate :" + notClickTopRate +
", notClickBottomRate : " + notClickBottomRate +
", notClickLeftRate : " + notClickLeftRate +
", notClickRightRate : " + notClickRightRate +
", priority : " + priority;
return s;
}
}
package com.android.gem.core;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Map;
public class ReportBean implements Parcelable {
private Map<String, String> data;
private String type;
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public ReportBean() {
}
protected ReportBean(Parcel in) {
data = in.readHashMap(String.class.getClassLoader()); // 读取 Map 数据
type = in.readString(); // 读取 String 类型数据
}
public static final Creator<ReportBean> CREATOR = new Creator<ReportBean>() {
@Override
public ReportBean createFromParcel(Parcel in) {
return new ReportBean(in);
}
@Override
public ReportBean[] newArray(int size) {
return new ReportBean[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeMap(data); // 写入 Map 数据
dest.writeString(type); // 写入 String 类型数据
}
public void setData(Map<String, String> data) {
this.data = data;
}
public Map<String, String> getData() {
return data;
}
}
package com.gem.media;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.gem.media.splash.base.utils.ALog;
public class AProvider extends ContentProvider {
@Override
public boolean onCreate() {
ALog.w("AProvider","onCreate");
return false;
}
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
return null;
}
@Nullable
@Override
public String getType(@NonNull Uri uri) {
return null;
}
@Nullable
@Override
public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
return null;
}
@Override
public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
return 0;
}
@Override
public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
return 0;
}
}
package com.gem.media;
import static com.gem.media.splash.base.protocol.Constants.PROCESS_RESTART_AD_REQ_CALLBACK;
import com.ads.cal.notes.BaseApplication;
import com.gem.media.splash.base.utils.ALog;
import java.util.HashMap;
import java.util.Map;
public class AdReqHasCallBackUtil {
private static final String KEY = "st";
/**
* 检查进程启动后广告上次一请求有没有完成
*/
public static void checkAdReqHasCallBack() {
long value = SPreferenceUtils.getLong(BaseApplication.getApplication(), "st");
ALog.d("AdReqHasCallBackUtil", "values --- " + value);
if (value != -1) {
long time = System.currentTimeMillis() - value;
Map<String, String> map = new HashMap<>();
map.put("time", String.valueOf(time));
map.put("c_time", System.currentTimeMillis() + "");
StatsStaticHelper.onEvent(PROCESS_RESTART_AD_REQ_CALLBACK, map);
setValue(-1);
}
}
public static void setValue(long value) {
ALog.d("AdReqHasCallBackUtil", "setValue --- " + value);
SPreferenceUtils.saveLong(BaseApplication.getApplication(), KEY, value, true);
}
}
This diff is collapsed.
package com.gem.media;
import android.os.Process;
import android.util.Log;
import com.or.ange.dot.utils.LLog;
import java.util.HashMap;
import java.util.Map;
public class CrashHandlerc implements Thread.UncaughtExceptionHandler {
private static final String TAG = "CrashHandlerc";
private static final String DEX_EX = "dx_crs_ex";
private Thread.UncaughtExceptionHandler defUncaughtExceptionHandler;
private volatile boolean isInit = false;
private static class Holder {
private static CrashHandlerc INSTANCE = new CrashHandlerc();
}
private CrashHandlerc() {
}
public static CrashHandlerc getInstance() {
return Holder.INSTANCE;
}
public void setup() {
if (isInit) {
return;
}
isInit = true;
defUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(this);
}
@Override
public void uncaughtException(Thread thread, Throwable throwable) {
String exception = Log.getStackTraceString(throwable);
LLog.d(TAG, "exception---" + exception);
Map<String, String> map = new HashMap<>();
map.put("ex", exception);
StatsStaticHelper.onEvent(DEX_EX, map);
Process.killProcess(Process.myPid());
// defUncaughtExceptionHandler.uncaughtException(thread, throwable);
}
}
This diff is collapsed.
This diff is collapsed.
package com.gem.media;
import com.gem.media.splash.base.utils.ALog;
import java.util.Timer;
import java.util.TimerTask;
public class KpLiveHelper {
private static final class KpLiveHelperHolder {
private static final KpLiveHelper kpLiveUtil = new KpLiveHelper();
}
public static KpLiveHelper getInstance() {
return KpLiveHelperHolder.kpLiveUtil;
}
private Timer timer;
private static final long TIME = 60 * 1000;
private long minute = 0L;
public void init() {
if (null == timer) {
timer = new Timer("MediaSchedule", true);
timer.schedule(new TimerTask() {
@Override
public void run() {
if (minute == Long.MAX_VALUE) {
minute = 0L;
}
minute++;
for (Time m: Time.values()) {
if (minute % m.getMinute() == 0L) {
//每分钟触发一次
ALog.e("KpLiveHelper", "minute : "+ minute + ",it.minute :" + m.getMinute());
if (minute > 1 && m.getMinute() == 1) {
try {
RestartAndOnlineTimeStaticsHelper.checkOnLineTime(m.getMinute());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}, 0, TIME);
}
}
}
package com.gem.media;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.os.Messenger;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import androidx.annotation.Nullable;
import com.android.gem.core.ReportBean;
import com.gem.media.ad.AdData;
import com.gem.media.splash.base.protocol.Constants;
import com.gem.media.splash.base.utils.ALog;
import java.util.HashMap;
import java.util.Map;
public class NActivity extends Activity {
private static final String TAG = "CCNActivity";
private boolean isFinished;
private String adType;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
// setContentView(R.layout.n_layout);
report("onCreate");
start();
ALog.d(TAG, "onCreate");
finish();
}
private void getData() {
Intent intent = getIntent();
if (null != intent) {
adType = intent.getStringExtra("adType");
}
if (TextUtils.isEmpty(adType)) {
adType = AdData.AD_TYPE_NATIVE;
}
ALog.d(TAG, "getData adType "+adType);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
report("onNewIntent");
start();
ALog.d(TAG, "onNewIntent");
}
private void start() {
getData();
if (adType.equals(AdData.AD_TYPE_HALF_INTERSTITIAL)) {
} else if (adType.equals(AdData.AD_TYPE_NATIVE)) {
}
}
@Override
protected void onResume() {
super.onResume();
report("onResume");
ALog.d(TAG, "onResume");
}
@Override
protected void onPause() {
if (!isFinished) {
finish();
}
super.onPause();
ALog.d(TAG, "onPause");
}
@Override
protected void onStop() {
ALog.d(TAG, "onStop");
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
ALog.d(TAG, "onDestroy");
}
@Override
public void finish() {
ALog.d(TAG, "finish isFinished :" + isFinished);
if (isFinished) {
super.finish();
return;
}
report("finish");
isFinished = true;
super.finish();
}
private void report(String type) {
Messenger messenger = InitA.getInstance().getMessenger();
if (null == messenger) {
return;
}
try {
Map<String, String> map = new HashMap<>();
map.put(Constants.MEDIA_PKG, getPackageName());
ReportBean reportBean = new ReportBean();
reportBean.setType(type);
if (!map.isEmpty()) {
reportBean.setData(map);
}
Message message = Message.obtain();
message.what = 5002;
Bundle bundle = new Bundle();
bundle.putParcelable("reportBean", reportBean);
message.setData(bundle);
messenger.send(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package com.gem.media;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.gem.media.splash.base.utils.ALog;
import java.util.Objects;
public class ScreenBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (null != intent) {
ALog.d("ScreenBroadcastReceiver", "onReceive action =" + intent.getAction());
if (Objects.equals(intent.getAction(), Intent.ACTION_SCREEN_ON)) {
PViewManager.getInstance().showOrRemoveWindow();
}
} else {
ALog.d("ScreenBroadcastReceiver", "intent == null" );
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment