V1.0.1(2)接入topon和firebase
This commit is contained in:
parent
5c38587a1b
commit
50b8c55755
@ -3,8 +3,10 @@ import java.util.Date
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application)
|
alias(libs.plugins.android.application)
|
||||||
|
id("com.google.gms.google-services")
|
||||||
|
id("com.google.firebase.crashlytics")
|
||||||
}
|
}
|
||||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
val timestamp: String = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||||
android {
|
android {
|
||||||
namespace = "com.key.keyboardstyle"
|
namespace = "com.key.keyboardstyle"
|
||||||
compileSdk = 34
|
compileSdk = 34
|
||||||
@ -13,11 +15,11 @@ android {
|
|||||||
applicationId = "com.key.keyboardstyle"
|
applicationId = "com.key.keyboardstyle"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 1
|
versionCode = 2
|
||||||
versionName = "1.0.0"
|
versionName = "1.0.1"
|
||||||
setProperty(
|
setProperty(
|
||||||
"archivesBaseName",
|
"archivesBaseName",
|
||||||
"Keyboard Style_" + versionName + "(${versionCode})_$timestamp"
|
"Keyboard Style_V" + versionName + "(${versionCode})_$timestamp"
|
||||||
)
|
)
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@ -59,5 +61,105 @@ dependencies {
|
|||||||
|
|
||||||
implementation("com.github.omicronapps:7-Zip-JBinding-4Android:Release-16.02-2.02")
|
implementation("com.github.omicronapps:7-Zip-JBinding-4Android:Release-16.02-2.02")
|
||||||
|
|
||||||
|
// Import the BoM for the Firebase platform
|
||||||
|
implementation(platform("com.google.firebase:firebase-bom:33.7.0"))
|
||||||
|
|
||||||
|
// Add the dependencies for the Crashlytics and Analytics libraries
|
||||||
|
// When using the BoM, you don't specify versions in Firebase library dependencies
|
||||||
|
implementation("com.google.firebase:firebase-crashlytics")
|
||||||
|
implementation("com.google.firebase:firebase-analytics")
|
||||||
|
implementation("com.google.firebase:firebase-config")
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------TopOn(Mintegral、Pangle、UnitAds、Digital Turbine(Fyber)、Chartboost&Helium、Ironsource、Liftoff(Vungle)、Inmobi、Start.io、Appnext、Bigo)
|
||||||
|
|
||||||
|
//Anythink (Necessary)
|
||||||
|
implementation("com.anythink.sdk:core-tpn:6.4.07")
|
||||||
|
implementation("com.anythink.sdk:nativead-tpn:6.4.07")
|
||||||
|
implementation("com.anythink.sdk:banner-tpn:6.4.07")
|
||||||
|
implementation("com.anythink.sdk:interstitial-tpn:6.4.07")
|
||||||
|
implementation("com.anythink.sdk:rewardedvideo-tpn:6.4.07")
|
||||||
|
implementation("com.anythink.sdk:splash-tpn:6.4.07")
|
||||||
|
|
||||||
|
//Androidx (Necessary)
|
||||||
|
implementation("androidx.appcompat:appcompat:1.1.0")
|
||||||
|
implementation("androidx.browser:browser:1.4.0")
|
||||||
|
|
||||||
|
//StartApp
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-startapp:6.4.07")
|
||||||
|
implementation("com.startapp:inapp-sdk:5.0.2")
|
||||||
|
|
||||||
|
//Appnext
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-appnext:6.4.07")
|
||||||
|
implementation("com.appnext.sdk:ads:2.7.1.473")
|
||||||
|
implementation("com.appnext.sdk:banners:2.7.1.473")
|
||||||
|
implementation("com.appnext.sdk:native-ads2:2.7.1.473")
|
||||||
|
implementation("com.appnext.sdk:actions:2.4.6.472")
|
||||||
|
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
|
||||||
|
|
||||||
|
//Vungle
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-vungle:6.4.07")
|
||||||
|
implementation("com.vungle:vungle-ads:7.4.0")
|
||||||
|
implementation("com.google.android.gms:play-services-basement:18.1.0")
|
||||||
|
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||||
|
|
||||||
|
//UnityAds
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-unityads:6.4.07")
|
||||||
|
implementation("com.unity3d.ads:unity-ads:4.12.2")
|
||||||
|
|
||||||
|
//Ironsource
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-ironsource:6.4.07")
|
||||||
|
implementation("com.ironsource.sdk:mediationsdk:8.2.1")
|
||||||
|
implementation("com.google.android.gms:play-services-appset:16.0.2")
|
||||||
|
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||||
|
implementation("com.google.android.gms:play-services-basement:18.1.0")
|
||||||
|
|
||||||
|
//Bigo
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-bigo:6.4.07")
|
||||||
|
implementation("com.bigossp:bigo-ads:4.9.0")
|
||||||
|
|
||||||
|
//Pangle
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-pangle-nonchina:6.4.07")
|
||||||
|
implementation("com.pangle.global:ads-sdk:6.1.0.9")
|
||||||
|
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||||
|
|
||||||
|
//Inmobi
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-inmobi:6.4.07")
|
||||||
|
implementation("com.inmobi.monetization:inmobi-ads-kotlin:10.7.5")
|
||||||
|
|
||||||
|
//Mintegral
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.4.07")
|
||||||
|
implementation("com.mbridge.msdk.oversea:reward:16.8.11")
|
||||||
|
implementation("com.mbridge.msdk.oversea:newinterstitial:16.8.11")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbnative:16.8.11")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.8.11")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbsplash:16.8.11")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbbanner:16.8.11")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbbid:16.8.11")
|
||||||
|
implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||||
|
|
||||||
|
//Chartboost
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-chartboost:6.4.07")
|
||||||
|
implementation("com.chartboost:chartboost-sdk:9.7.0")
|
||||||
|
implementation("com.chartboost:chartboost-mediation-sdk:4.9.1")
|
||||||
|
implementation("com.chartboost:chartboost-mediation-adapter-chartboost:4.9.7.0.0")
|
||||||
|
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0")
|
||||||
|
implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
|
||||||
|
implementation("com.squareup.okhttp3:okhttp:4.10.0")
|
||||||
|
implementation("com.squareup.retrofit2:converter-scalars:2.9.0")
|
||||||
|
implementation("com.squareup.retrofit2:retrofit:2.9.0")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
|
||||||
|
|
||||||
|
//Fyber
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-fyber:6.4.07")
|
||||||
|
implementation("com.fyber:marketplace-sdk:8.3.0")
|
||||||
|
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||||
|
|
||||||
|
// Debugger UI Tools
|
||||||
|
// implementation ("com.anythink.sdk:debugger-ui:1.1.0")
|
||||||
|
|
||||||
|
//----------------------------------------------TopOn
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
29
app/google-services.json
Normal file
29
app/google-services.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "575246954400",
|
||||||
|
"project_id": "keyboard-style",
|
||||||
|
"storage_bucket": "keyboard-style.firebasestorage.app"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:575246954400:android:98bd81507bed5724fefec5",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.key.keyboardstyle"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAIVO6raaa2k7knhKLUgFxLql9MY4MFsLk"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
||||||
138
app/proguard-rules.pro
vendored
138
app/proguard-rules.pro
vendored
@ -28,9 +28,139 @@
|
|||||||
-keepclassmembers class * {
|
-keepclassmembers class * {
|
||||||
@androidx.room.Query <methods>;
|
@androidx.room.Query <methods>;
|
||||||
}
|
}
|
||||||
-keep class com.key.keyboardstyle.room.AppDatabase { *; }
|
-keep class com.key.keyboardstyle.database.room.AppDatabase { *; }
|
||||||
-keep class com.key.keyboardstyle.room.KeyboardWallpaper { *; }
|
-keep class com.key.keyboardstyle.database.room.KeyboardWallpaper { *; }
|
||||||
-keep class com.key.keyboardstyle.room.KeyboardWallpaperDao { *; }
|
-keep class com.key.keyboardstyle.database.room.KeyboardWallpaperDao { *; }
|
||||||
-keep class com.key.keyboardstyle.room.Category { *; }
|
-keep class com.key.keyboardstyle.database.room.Category { *; }
|
||||||
-keep class com.omicronapplications.** { *; }
|
-keep class com.omicronapplications.** { *; }
|
||||||
-keep class net.sf.sevenzipjbinding.** { *; }
|
-keep class net.sf.sevenzipjbinding.** { *; }
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------Topon
|
||||||
|
-keep class com.startapp.** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class com.truenet.** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile,
|
||||||
|
LineNumberTable, *Annotation*, EnclosingMethod
|
||||||
|
-dontwarn android.webkit.JavascriptInterface
|
||||||
|
-dontwarn com.startapp.**
|
||||||
|
|
||||||
|
-dontwarn org.jetbrains.annotations.**
|
||||||
|
-keep class com.appnext.** { *; }
|
||||||
|
-dontwarn com.appnext.**
|
||||||
|
# Vungle
|
||||||
|
-dontwarn com.vungle.ads.**
|
||||||
|
-keepclassmembers class com.vungle.ads.** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
-keep class com.vungle.ads.**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Google
|
||||||
|
-keep class com.google.android.gms.** { *; }
|
||||||
|
-dontwarn com.google.android.gms.**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# START OkHttp + Okio
|
||||||
|
# JSR 305 annotations are for embedding nullability information.
|
||||||
|
-dontwarn javax.annotation.**
|
||||||
|
|
||||||
|
|
||||||
|
# A resource is loaded with a relative path so the package of this class must be preserved.
|
||||||
|
-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz
|
||||||
|
|
||||||
|
|
||||||
|
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
|
||||||
|
-dontwarn org.codehaus.mojo.animal_sniffer.*
|
||||||
|
|
||||||
|
|
||||||
|
# OkHttp platform used only on JVM and when Conscrypt and other security providers are available.
|
||||||
|
-dontwarn okhttp3.internal.platform.**
|
||||||
|
-dontwarn org.conscrypt.**
|
||||||
|
-dontwarn org.bouncycastle.**
|
||||||
|
-dontwarn org.openjsse.**
|
||||||
|
|
||||||
|
|
||||||
|
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
|
||||||
|
-dontwarn org.codehaus.mojo.animal_sniffer.*
|
||||||
|
|
||||||
|
|
||||||
|
# END OkHttp + Okio
|
||||||
|
|
||||||
|
|
||||||
|
# START Protobuf
|
||||||
|
-dontwarn com.google.protobuf.**
|
||||||
|
-keepclassmembers class com.google.protobuf.** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
|
||||||
|
|
||||||
|
|
||||||
|
# END Protobuf
|
||||||
|
-keepclassmembers class com.ironsource.sdk.controller.IronSourceWebView$JSInterface {
|
||||||
|
public *;
|
||||||
|
}
|
||||||
|
-keepclassmembers class * implements android.os.Parcelable {
|
||||||
|
public static final android.os.Parcelable$Creator *;
|
||||||
|
}
|
||||||
|
-keep public class com.google.android.gms.ads.** {
|
||||||
|
public *;
|
||||||
|
}
|
||||||
|
-keep class com.ironsource.adapters.** { *;
|
||||||
|
}
|
||||||
|
-dontwarn com.ironsource.mediationsdk.**
|
||||||
|
-dontwarn com.ironsource.adapters.**
|
||||||
|
-keepattributes JavascriptInterface
|
||||||
|
-keepclassmembers class * {
|
||||||
|
@android.webkit.JavascriptInterface <methods>;
|
||||||
|
}
|
||||||
|
-keep class com.bytedance.sdk.** { *; }
|
||||||
|
-keep class com.inmobi.** { *; }
|
||||||
|
-keep public class com.google.android.gms.**
|
||||||
|
-dontwarn com.google.android.gms.**
|
||||||
|
-dontwarn com.squareup.picasso.**
|
||||||
|
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{
|
||||||
|
public *;
|
||||||
|
}
|
||||||
|
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info{
|
||||||
|
public *;
|
||||||
|
}
|
||||||
|
# skip the Picasso library classes
|
||||||
|
-keep class com.squareup.picasso.** {*;}
|
||||||
|
-dontwarn com.squareup.okhttp.**
|
||||||
|
# skip Moat classes
|
||||||
|
-keep class com.moat.** {*;}
|
||||||
|
-dontwarn com.moat.**
|
||||||
|
# skip IAB classes
|
||||||
|
-keep class com.iab.** {*;}
|
||||||
|
-dontwarn com.iab.**
|
||||||
|
-keepattributes Signature
|
||||||
|
-keepattributes *Annotation*
|
||||||
|
-keep class com.mbridge.** {*; }
|
||||||
|
-keep interface com.mbridge.** {*; }
|
||||||
|
-keep class android.support.v4.** { *; }
|
||||||
|
-dontwarn com.mbridge.**
|
||||||
|
-keep class **.R$* { public static final int mbridge*; }
|
||||||
|
-keep public class com.mbridge.* extends androidx.** { *; }
|
||||||
|
-keep public class androidx.viewpager.widget.PagerAdapter{ *; }
|
||||||
|
-keep public class androidx.viewpager.widget.ViewPager.OnPageChangeListener{ *; }
|
||||||
|
-keep interface androidx.annotation.IntDef{ *; }
|
||||||
|
-keep interface androidx.annotation.Nullable{ *; }
|
||||||
|
-keep interface androidx.annotation.CheckResult{ *; }
|
||||||
|
-keep interface androidx.annotation.NonNull{ *; }
|
||||||
|
-keep public class androidx.fragment.app.Fragment{ *; }
|
||||||
|
-keep public class androidx.core.content.FileProvider{ *; }
|
||||||
|
-keep public class androidx.core.app.NotificationCompat{ *; }
|
||||||
|
-keep public class androidx.appcompat.widget.AppCompatImageView { *; }
|
||||||
|
-keep public class androidx.recyclerview.*{ *; }
|
||||||
|
-keep class com.chartboost.** { *; }
|
||||||
|
|
||||||
|
#---------------------------------------------Topon
|
||||||
@ -17,22 +17,22 @@
|
|||||||
android:theme="@style/Theme.KeyboardStyle"
|
android:theme="@style/Theme.KeyboardStyle"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.TestActivity"
|
android:name=".ui.activity.TestActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.DownloadActivity"
|
android:name=".ui.activity.DownloadActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.CategoryActivity"
|
android:name=".ui.activity.CategoryActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.SearchActivity"
|
android:name=".ui.activity.SearchActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.MainActivity"
|
android:name=".ui.activity.MainActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.SplashActivity"
|
android:name=".ui.activity.SplashActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@ -42,7 +42,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".keyboard.KeyboardService"
|
android:name=".inputmethod.InputMethodService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:permission="android.permission.BIND_INPUT_METHOD">
|
android:permission="android.permission.BIND_INPUT_METHOD">
|
||||||
|
|||||||
@ -3,7 +3,12 @@ package com.key.keyboardstyle;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.anythink.core.api.ATSDK;
|
||||||
|
import com.anythink.core.api.NetTrafficeCallback;
|
||||||
|
import com.google.firebase.FirebaseApp;
|
||||||
|
import com.key.keyboardstyle.topon.AdManager;
|
||||||
import com.key.keyboardstyle.utils.DatabaseUtils;
|
import com.key.keyboardstyle.utils.DatabaseUtils;
|
||||||
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@ -17,12 +22,29 @@ public class MyApplication extends Application {
|
|||||||
private static final String PREF_NAME = "preferences";
|
private static final String PREF_NAME = "preferences";
|
||||||
private static final String KEY_INITIALIZED = "init";
|
private static final String KEY_INITIALIZED = "init";
|
||||||
|
|
||||||
|
public static final String TAG = "-------------";
|
||||||
|
|
||||||
|
private static final String AppKey = "aaa211a418cfeb5dbe21e0279a9dc3f88";
|
||||||
|
private static final String APPId = "h678faa66f2e72";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
application = this;
|
application = this;
|
||||||
|
|
||||||
|
// //确保Firebase初始化
|
||||||
|
// FirebaseApp.initializeApp(this);
|
||||||
|
//
|
||||||
|
// // 输出日志以确认Firebase初始化
|
||||||
|
// if (!FirebaseApp.getApps(this).isEmpty()) {
|
||||||
|
// Log.d(TAG, "Firebase 初始化成功1");
|
||||||
|
// } else {
|
||||||
|
// Log.e(TAG, "Firebase 初始化失败0");
|
||||||
|
// }
|
||||||
|
|
||||||
|
initSdk();
|
||||||
|
|
||||||
SharedPreferences preferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
|
SharedPreferences preferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
|
||||||
boolean init = preferences.getBoolean(KEY_INITIALIZED, false);
|
boolean init = preferences.getBoolean(KEY_INITIALIZED, false);
|
||||||
|
|
||||||
@ -33,6 +55,31 @@ public class MyApplication extends Application {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initSdk() {
|
||||||
|
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResultCallback(boolean isEU) {
|
||||||
|
Log.e(TAG, "onResultCallback:" + isEU);
|
||||||
|
if (isEU && ATSDK.getGDPRDataLevel(MyApplication.this) == ATSDK.UNKNOWN) {
|
||||||
|
ATSDK.showGdprAuth(MyApplication.this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onErrorCallback(String errorMsg) {
|
||||||
|
Log.e(TAG, "onErrorCallback:" + errorMsg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ATSDK.init( this, APPId, AppKey);
|
||||||
|
AdManager.loadAllAd();
|
||||||
|
//测试工具
|
||||||
|
// ATDebuggerUITest.showDebuggerUI(this,debug_KEy);
|
||||||
|
// ATSDK.setNetworkLogDebug(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Application getApplication() {
|
public static Application getApplication() {
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.room;
|
package com.key.keyboardstyle.database.room;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.room;
|
package com.key.keyboardstyle.database.room;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.room;
|
package com.key.keyboardstyle.database.room;
|
||||||
|
|
||||||
|
|
||||||
import androidx.room.Entity;
|
import androidx.room.Entity;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.room;
|
package com.key.keyboardstyle.database.room;
|
||||||
|
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
@ -1,7 +1,6 @@
|
|||||||
package com.key.keyboardstyle.keyboard;
|
package com.key.keyboardstyle.inputmethod;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.inputmethodservice.InputMethodService;
|
|
||||||
import android.inputmethodservice.KeyboardView;
|
import android.inputmethodservice.KeyboardView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -11,21 +10,21 @@ import android.view.inputmethod.InputMethodManager;
|
|||||||
import com.key.keyboardstyle.R;
|
import com.key.keyboardstyle.R;
|
||||||
|
|
||||||
|
|
||||||
public class KeyboardService extends InputMethodService implements KeyboardView.OnKeyboardActionListener {
|
public class InputMethodService extends android.inputmethodservice.InputMethodService implements KeyboardView.OnKeyboardActionListener {
|
||||||
private final int[] viewXmlFiles = new int[4];
|
private final int[] viewXmlFiles = new int[4];
|
||||||
private MyKeyboard myKeyboard;
|
private MyKeyboard myKeyboard;
|
||||||
|
|
||||||
private int curImeAction;
|
private int curImeAction;
|
||||||
|
|
||||||
public KeyboardService() {
|
public InputMethodService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateInputView() {
|
public View onCreateInputView() {
|
||||||
viewXmlFiles[0] = R.xml.view_1;
|
viewXmlFiles[0] = R.xml.kb_lower;
|
||||||
viewXmlFiles[1] = R.xml.view_2;
|
viewXmlFiles[1] = R.xml.kb_num_sym;
|
||||||
viewXmlFiles[2] = R.xml.view_3;
|
viewXmlFiles[2] = R.xml.kb_more_sym;
|
||||||
viewXmlFiles[3] = R.xml.view_4;
|
viewXmlFiles[3] = R.xml.kb_upper;
|
||||||
|
|
||||||
View inputView = LayoutInflater.from(this).inflate(R.layout.keyboard_view, null, false);
|
View inputView = LayoutInflater.from(this).inflate(R.layout.keyboard_view, null, false);
|
||||||
myKeyboard = inputView.findViewById(R.id.keyboardView);
|
myKeyboard = inputView.findViewById(R.id.keyboardView);
|
||||||
@ -45,13 +44,12 @@ public class KeyboardService extends InputMethodService implements KeyboardView.
|
|||||||
|
|
||||||
private void setBackground() {
|
private void setBackground() {
|
||||||
curImeAction = getImeAction(getCurrentInputEditorInfo().imeOptions);
|
curImeAction = getImeAction(getCurrentInputEditorInfo().imeOptions);
|
||||||
myKeyboard.updateConfigView(this, curImeAction);
|
myKeyboard.updateInputMethodView(this, curImeAction);
|
||||||
myKeyboard.invalidate();
|
myKeyboard.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getImeAction(int imeOptions) {
|
public int getImeAction(int imeOptions) {
|
||||||
int i = imeOptions & EditorInfo.IME_MASK_ACTION;
|
return imeOptions & EditorInfo.IME_MASK_ACTION;
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,25 +57,25 @@ public class KeyboardService extends InputMethodService implements KeyboardView.
|
|||||||
switch (primaryCode) {
|
switch (primaryCode) {
|
||||||
case MyKeyboard.KeyBoard.KEYCODE_SHIFT:
|
case MyKeyboard.KeyBoard.KEYCODE_SHIFT:
|
||||||
if (myKeyboard.getShiftType() == 0) {
|
if (myKeyboard.getShiftType() == 0) {
|
||||||
changeView(3);
|
changeThem(3);
|
||||||
myKeyboard.setShiftType(1);
|
myKeyboard.setShiftType(1);
|
||||||
} else {
|
} else {
|
||||||
changeView(0);
|
changeThem(0);
|
||||||
myKeyboard.setShiftType(0);
|
myKeyboard.setShiftType(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MyKeyboard.KeyBoard.KEYCODE_MODE_CHANGE:
|
case MyKeyboard.KeyBoard.KEYCODE_MODE_CHANGE:
|
||||||
if (myKeyboard.getViewType() == 0) {
|
if (myKeyboard.getViewType() == 0) {
|
||||||
changeView(1);
|
changeThem(1);
|
||||||
} else {
|
} else {
|
||||||
changeView(0);
|
changeThem(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MyKeyboard.KeyBoard.KEYCODE_SHIFT_123:
|
case MyKeyboard.KeyBoard.KEYCODE_SHIFT_123:
|
||||||
changeView(1);
|
changeThem(1);
|
||||||
break;
|
break;
|
||||||
case MyKeyboard.KeyBoard.KEYCODE_SHIFT_MORE:
|
case MyKeyboard.KeyBoard.KEYCODE_SHIFT_MORE:
|
||||||
changeView(2);
|
changeThem(2);
|
||||||
break;
|
break;
|
||||||
case MyKeyboard.KeyBoard.KEYCODE_DELETE:
|
case MyKeyboard.KeyBoard.KEYCODE_DELETE:
|
||||||
getCurrentInputConnection().deleteSurroundingText(1, 0);
|
getCurrentInputConnection().deleteSurroundingText(1, 0);
|
||||||
@ -98,7 +96,7 @@ public class KeyboardService extends InputMethodService implements KeyboardView.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeView(int i) {
|
private void changeThem(int i) {
|
||||||
myKeyboard.setViewType(i);
|
myKeyboard.setViewType(i);
|
||||||
myKeyboard.setShiftType(i);
|
myKeyboard.setShiftType(i);
|
||||||
myKeyboard.setKeyboard(new MyKeyboard.KeyBoard(this, viewXmlFiles[i]));
|
myKeyboard.setKeyboard(new MyKeyboard.KeyBoard(this, viewXmlFiles[i]));
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.keyboard;
|
package com.key.keyboardstyle.inputmethod;
|
||||||
|
|
||||||
import static android.content.Context.MODE_PRIVATE;
|
import static android.content.Context.MODE_PRIVATE;
|
||||||
|
|
||||||
@ -25,26 +25,8 @@ import java.io.IOException;
|
|||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class CustomViewConfig {
|
public class InputMethodTheme {
|
||||||
private String Bg_action_normal = "btn_keyboard_key_functional_normal.9.png";
|
|
||||||
private String jpg_BG = "keyboard_background.jpg";
|
|
||||||
private String color_normal_key = "key_text_color_normal";
|
|
||||||
private String color_action_key = "key_text_color_functional";
|
|
||||||
private String Bg_pressed = "btn_keyboard_key_normal_pressed.9.png";
|
|
||||||
private String Bg_normal = "btn_keyboard_key_normal_normal.9.png";
|
|
||||||
private String path_drawxh = "/drawable-xhdpi-v4/";
|
|
||||||
private String path_drawxxh = "/drawable-xxhdpi-v4/";
|
|
||||||
private String path_color = "/colors.xml";
|
|
||||||
private String icon_del = "sym_keyboard_delete_normal.png";
|
|
||||||
private String icon_shift = "sym_keyboard_shift.png";
|
|
||||||
private String Bg_action_pressed = "btn_keyboard_key_functional_pressed.9.png";
|
|
||||||
private String icon_shift_lock = "sym_keyboard_shift_locked.png";
|
|
||||||
|
|
||||||
private String Bg_space_normal = "btn_keyboard_spacekey_normal_normal.9.png";
|
|
||||||
private String Bg_space_pressed = "btn_keyboard_spacekey_normal_pressed.9.png";
|
|
||||||
|
|
||||||
private Drawable BgActionDraw;
|
private Drawable BgActionDraw;
|
||||||
private Drawable BgSpaceDraw;
|
|
||||||
private Drawable BgNormalDraw;
|
private Drawable BgNormalDraw;
|
||||||
|
|
||||||
private Drawable iconShift = ContextCompat.getDrawable(MyApplication.getApplication(), android.R.drawable.stat_sys_upload);
|
private Drawable iconShift = ContextCompat.getDrawable(MyApplication.getApplication(), android.R.drawable.stat_sys_upload);
|
||||||
@ -52,7 +34,6 @@ public class CustomViewConfig {
|
|||||||
private Drawable BG = ContextCompat.getDrawable(MyApplication.getApplication(), R.color.black);
|
private Drawable BG = ContextCompat.getDrawable(MyApplication.getApplication(), R.color.black);
|
||||||
|
|
||||||
private int keyNormalColor = MyApplication.getApplication().getResources().getColor(R.color.white, null);
|
private int keyNormalColor = MyApplication.getApplication().getResources().getColor(R.color.white, null);
|
||||||
|
|
||||||
private int keyActionColor = MyApplication.getApplication().getResources().getColor(R.color.white, null);
|
private int keyActionColor = MyApplication.getApplication().getResources().getColor(R.color.white, null);
|
||||||
|
|
||||||
private Drawable iconShiftLock = ContextCompat.getDrawable(MyApplication.getApplication(), android.R.drawable.stat_sys_upload);
|
private Drawable iconShiftLock = ContextCompat.getDrawable(MyApplication.getApplication(), android.R.drawable.stat_sys_upload);
|
||||||
@ -70,10 +51,6 @@ public class CustomViewConfig {
|
|||||||
return BgNormalDraw;
|
return BgNormalDraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getBgSpaceDraw() {
|
|
||||||
return BgSpaceDraw;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Drawable getIconDel() {
|
public Drawable getIconDel() {
|
||||||
return iconDel;
|
return iconDel;
|
||||||
}
|
}
|
||||||
@ -90,16 +67,13 @@ public class CustomViewConfig {
|
|||||||
return keyNormalColor;
|
return keyNormalColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getKeyActionColor() {
|
public int getKeyActionColor() {
|
||||||
return keyActionColor;
|
return keyActionColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
private Drawable getKeysBackGround(Context context, String resDirPath, String drawName) {
|
||||||
}
|
String path_draw_xh = "/drawable-xhdpi-v4/";
|
||||||
|
String filePath = resDirPath + path_draw_xh + drawName;
|
||||||
private Drawable getKeyBackGround(Context context, String resDirPath, String drawName) {
|
|
||||||
String filePath = resDirPath + path_drawxh + drawName;
|
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return null;
|
return null;
|
||||||
@ -108,15 +82,18 @@ public class CustomViewConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getBackGround(Context context, String resDirPath) {
|
private Drawable getBackGround(Context context, String resDirPath) {
|
||||||
String filePath = resDirPath + path_drawxxh + jpg_BG;
|
String jpg_BG = "keyboard_background.jpg";
|
||||||
|
String path_draw_xxh = "/drawable-xxhdpi-v4/";
|
||||||
|
String filePath = resDirPath + path_draw_xxh + jpg_BG;
|
||||||
if (!new File(filePath).exists()) {
|
if (!new File(filePath).exists()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new BitmapDrawable(context.getResources(), BitmapFactory.decodeFile(filePath));
|
return new BitmapDrawable(context.getResources(), BitmapFactory.decodeFile(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateKeyColor(String resDirPath) {
|
private void updateKeysColor(String resDirPath) {
|
||||||
|
|
||||||
|
String path_color = "/colors.xml";
|
||||||
String colorXmlPath = resDirPath + path_color;
|
String colorXmlPath = resDirPath + path_color;
|
||||||
File file = new File(colorXmlPath);
|
File file = new File(colorXmlPath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
@ -131,10 +108,12 @@ public class CustomViewConfig {
|
|||||||
while (eventT != XmlPullParser.END_DOCUMENT) {
|
while (eventT != XmlPullParser.END_DOCUMENT) {
|
||||||
if (eventT == XmlPullParser.START_TAG && (Objects.equals(xmlPullParser.getName(), "color") || Objects.equals(xmlPullParser.getName(), "item"))) {
|
if (eventT == XmlPullParser.START_TAG && (Objects.equals(xmlPullParser.getName(), "color") || Objects.equals(xmlPullParser.getName(), "item"))) {
|
||||||
String value = xmlPullParser.getAttributeValue(null, "name");
|
String value = xmlPullParser.getAttributeValue(null, "name");
|
||||||
|
String color_normal_key = "key_text_color_normal";
|
||||||
if (value.equals(color_normal_key)) {
|
if (value.equals(color_normal_key)) {
|
||||||
keyNormalColor = Color.parseColor(xmlPullParser.nextText());
|
keyNormalColor = Color.parseColor(xmlPullParser.nextText());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
String color_action_key = "key_text_color_functional";
|
||||||
if (value.equals(color_action_key)) {
|
if (value.equals(color_action_key)) {
|
||||||
keyActionColor = Color.parseColor(xmlPullParser.nextText());
|
keyActionColor = Color.parseColor(xmlPullParser.nextText());
|
||||||
|
|
||||||
@ -151,24 +130,25 @@ public class CustomViewConfig {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateConfig(Context con) {
|
public void refreshKeyboardResources(Context context) {
|
||||||
String resDirPath = getSavedWallpaperPath(MyApplication.getContext());
|
String resDirPath = getWallpaperPath(MyApplication.getContext());
|
||||||
if (!resDirPath.isEmpty()) {
|
if (resDirPath.isEmpty()) {
|
||||||
updateKeyColor(resDirPath);
|
return;
|
||||||
BG = getBackGround(con, resDirPath);
|
|
||||||
BgNormalDraw = getKeyBackGround(con, resDirPath, Bg_normal);
|
|
||||||
BgActionDraw = getKeyBackGround(con, resDirPath, Bg_action_normal);
|
|
||||||
BgSpaceDraw = getKeyBackGround(con, resDirPath, Bg_space_normal);
|
|
||||||
iconDel = getKeyBackGround(con, resDirPath, icon_del);
|
|
||||||
iconShift = getKeyBackGround(con, resDirPath, icon_shift);
|
|
||||||
iconShiftLock = getKeyBackGround(con, resDirPath, icon_shift_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateKeysColor(resDirPath);
|
||||||
|
BG = getBackGround(context, resDirPath);
|
||||||
|
|
||||||
|
BgNormalDraw = getKeysBackGround(context, resDirPath, "btn_keyboard_key_normal_normal.9.png");
|
||||||
|
BgActionDraw = getKeysBackGround(context, resDirPath, "btn_keyboard_key_functional_normal.9.png");
|
||||||
|
iconDel = getKeysBackGround(context, resDirPath, "sym_keyboard_delete_normal.png");
|
||||||
|
iconShift = getKeysBackGround(context, resDirPath, "sym_keyboard_shift.png");
|
||||||
|
iconShiftLock = getKeysBackGround(context, resDirPath, "sym_keyboard_shift_locked.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSavedWallpaperPath(Context context) {
|
public String getWallpaperPath(Context context) {
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("keyboard_prefs", MODE_PRIVATE);
|
SharedPreferences sharedPreferences = context.getSharedPreferences("keyboard_prefs", MODE_PRIVATE);
|
||||||
return sharedPreferences.getString("wallpaper_path", "");
|
return sharedPreferences.getString("wallpaper_path", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.keyboard;
|
package com.key.keyboardstyle.inputmethod;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
@ -19,12 +19,12 @@ public class MyKeyboard extends KeyboardView {
|
|||||||
private Paint mPaint;
|
private Paint mPaint;
|
||||||
private int viewType = 0;
|
private int viewType = 0;
|
||||||
private int shiftType = 0;
|
private int shiftType = 0;
|
||||||
private CustomViewConfig config;
|
private InputMethodTheme inputMethodTheme;
|
||||||
private int curImeAction;
|
private int curImeAction;
|
||||||
|
|
||||||
public MyKeyboard(Context context, AttributeSet attrs) {
|
public MyKeyboard(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
initView();
|
initThem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class KeyBoard extends Keyboard {
|
public static class KeyBoard extends Keyboard {
|
||||||
@ -64,82 +64,69 @@ public class MyKeyboard extends KeyboardView {
|
|||||||
Keyboard.Key key = keys.get(r);
|
Keyboard.Key key = keys.get(r);
|
||||||
|
|
||||||
int code = key.codes[0];
|
int code = key.codes[0];
|
||||||
|
mPaint.setColor(inputMethodTheme.getKeyActionColor());
|
||||||
mPaint.setColor(config.getKeyActionColor());
|
|
||||||
|
|
||||||
if (code == KeyBoard.KEYCODE_MODE_CHANGE) {
|
if (code == KeyBoard.KEYCODE_MODE_CHANGE) {
|
||||||
|
getDrawKeyBackground(key, inputMethodTheme.getBgActionDraw(), canvas);
|
||||||
onDrawKeyBackground(key, config.getBgActionDraw(), canvas);
|
getDrawLabel(key, canvas, "");
|
||||||
onDrawLabel(key, canvas, "");
|
|
||||||
|
|
||||||
} else if (code == KeyBoard.KEYCODE_SHIFT) {
|
} else if (code == KeyBoard.KEYCODE_SHIFT) {
|
||||||
|
getDrawKeyBackground(key, inputMethodTheme.getBgActionDraw(), canvas);
|
||||||
onDrawKeyBackground(key, config.getBgActionDraw(), canvas);
|
|
||||||
KeyboardUtils.onDrawKeyIcon(key, getShiftDraw(), canvas, this);
|
KeyboardUtils.onDrawKeyIcon(key, getShiftDraw(), canvas, this);
|
||||||
|
|
||||||
} else if (code == KeyBoard.KEYCODE_SHIFT_123) {
|
} else if (code == KeyBoard.KEYCODE_SHIFT_123) {
|
||||||
|
getDrawKeyBackground(key, inputMethodTheme.getBgActionDraw(), canvas);
|
||||||
onDrawKeyBackground(key, config.getBgActionDraw(), canvas);
|
getDrawLabel(key, canvas, "");
|
||||||
onDrawLabel(key, canvas, "");
|
|
||||||
|
|
||||||
} else if (code == KeyBoard.KEYCODE_SHIFT_MORE) {
|
} else if (code == KeyBoard.KEYCODE_SHIFT_MORE) {
|
||||||
|
getDrawKeyBackground(key, inputMethodTheme.getBgActionDraw(), canvas);
|
||||||
onDrawKeyBackground(key, config.getBgActionDraw(), canvas);
|
getDrawLabel(key, canvas, "");
|
||||||
onDrawLabel(key, canvas, "");
|
|
||||||
|
|
||||||
} else if (code == KeyBoard.KEYCODE_DONE) {
|
} else if (code == KeyBoard.KEYCODE_DONE) {
|
||||||
|
getDrawKeyBackground(key, inputMethodTheme.getBgActionDraw(), canvas);
|
||||||
onDrawKeyBackground(key, config.getBgActionDraw(), canvas);
|
|
||||||
if (curImeAction == EditorInfo.IME_ACTION_SEARCH) {
|
if (curImeAction == EditorInfo.IME_ACTION_SEARCH) {
|
||||||
onDrawLabel(key, canvas, "Search");
|
getDrawLabel(key, canvas, "Search");
|
||||||
} else {
|
} else {
|
||||||
onDrawLabel(key, canvas, "");
|
getDrawLabel(key, canvas, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (code == KeyBoard.KEYCODE_DELETE) {
|
} else if (code == KeyBoard.KEYCODE_DELETE) {
|
||||||
|
getDrawKeyBackground(key, inputMethodTheme.getBgActionDraw(), canvas);
|
||||||
onDrawKeyBackground(key, config.getBgActionDraw(), canvas);
|
KeyboardUtils.onDrawKeyIcon(key, inputMethodTheme.getIconDel(), canvas, this);
|
||||||
KeyboardUtils.onDrawKeyIcon(key, config.getIconDel(), canvas, this);
|
getDrawLabel(key, canvas, "");
|
||||||
onDrawLabel(key, canvas, "");
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
mPaint.setColor(inputMethodTheme.getKeyNormalColor());
|
||||||
mPaint.setColor(config.getKeyNormalColor());
|
getDrawKeyBackground(key, inputMethodTheme.getBgNormalDraw(), canvas);
|
||||||
onDrawKeyBackground(key, config.getBgNormalDraw(), canvas);
|
getDrawLabel(key, canvas, "");
|
||||||
onDrawLabel(key, canvas, "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getShiftDraw() {
|
private Drawable getShiftDraw() {
|
||||||
|
|
||||||
if (shiftType == 0) {
|
if (shiftType == 0) {
|
||||||
return config.getIconShift();
|
return inputMethodTheme.getIconShift();
|
||||||
} else {
|
} else {
|
||||||
return config.getIconShiftLock();
|
return inputMethodTheme.getIconShiftLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initView() {
|
private void initThem() {
|
||||||
|
inputMethodTheme = new InputMethodTheme();
|
||||||
config = new CustomViewConfig();
|
|
||||||
mPaint = new Paint();
|
mPaint = new Paint();
|
||||||
config.init();
|
|
||||||
float texSize = KeyboardUtils.spToPpx(20f, this.getContext());
|
float texSize = KeyboardUtils.spToPpx(20f, this.getContext());
|
||||||
mPaint.setTextSize(texSize);
|
mPaint.setTextSize(texSize);
|
||||||
setPreviewEnabled(false);
|
setPreviewEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateConfigView(Context con, int ime) {
|
public void updateInputMethodView(Context con, int ime) {
|
||||||
|
|
||||||
curImeAction = ime;
|
curImeAction = ime;
|
||||||
config.updateConfig(con);
|
inputMethodTheme.refreshKeyboardResources(con);
|
||||||
setBackground(config.getBG());
|
setBackground(inputMethodTheme.getBG());
|
||||||
invalidateAllKeys();
|
invalidateAllKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDrawKeyBackground(Keyboard.Key myKey, Drawable keyBG, Canvas canvas) {
|
private void getDrawKeyBackground(Keyboard.Key myKey, Drawable keyBG, Canvas canvas) {
|
||||||
|
|
||||||
if (keyBG != null) {
|
if (keyBG != null) {
|
||||||
int left = myKey.x + getPaddingLeft();
|
int left = myKey.x + getPaddingLeft();
|
||||||
int top = myKey.y + getPaddingTop();
|
int top = myKey.y + getPaddingTop();
|
||||||
@ -152,8 +139,7 @@ public class MyKeyboard extends KeyboardView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDrawLabel(Keyboard.Key myKey, Canvas canvas, String customLabel) {
|
private void getDrawLabel(Keyboard.Key myKey, Canvas canvas, String customLabel) {
|
||||||
|
|
||||||
boolean b = myKey.label == null || myKey.label == "";
|
boolean b = myKey.label == null || myKey.label == "";
|
||||||
if (!b) {
|
if (!b) {
|
||||||
float y1 = myKey.y + myKey.height / 2f - (mPaint.descent() + mPaint.ascent()) / 2f;
|
float y1 = myKey.y + myKey.height / 2f - (mPaint.descent() + mPaint.ascent()) / 2f;
|
||||||
@ -161,12 +147,10 @@ public class MyKeyboard extends KeyboardView {
|
|||||||
x1 -= mPaint.measureText(myKey.label.toString()) / 2f;
|
x1 -= mPaint.measureText(myKey.label.toString()) / 2f;
|
||||||
|
|
||||||
if (!customLabel.isEmpty()) {
|
if (!customLabel.isEmpty()) {
|
||||||
|
|
||||||
float texSize = KeyboardUtils.spToPpx(14f, this.getContext());
|
float texSize = KeyboardUtils.spToPpx(14f, this.getContext());
|
||||||
mPaint.setTextSize(texSize);
|
mPaint.setTextSize(texSize);
|
||||||
canvas.drawText(customLabel, x1, y1, mPaint);
|
canvas.drawText(customLabel, x1, y1, mPaint);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
float texSize = KeyboardUtils.spToPpx(18f, this.getContext());
|
float texSize = KeyboardUtils.spToPpx(18f, this.getContext());
|
||||||
mPaint.setTextSize(texSize);
|
mPaint.setTextSize(texSize);
|
||||||
canvas.drawText(myKey.label.toString(), x1, y1, mPaint);
|
canvas.drawText(myKey.label.toString(), x1, y1, mPaint);
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.key.keyboardstyle.topon;
|
||||||
|
|
||||||
|
public interface AdListener {
|
||||||
|
void loadFail(String placeId);
|
||||||
|
void showSuccess();
|
||||||
|
|
||||||
|
void showFail();
|
||||||
|
|
||||||
|
void showClose();
|
||||||
|
}
|
||||||
245
app/src/main/java/com/key/keyboardstyle/topon/AdManager.java
Normal file
245
app/src/main/java/com/key/keyboardstyle/topon/AdManager.java
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
package com.key.keyboardstyle.topon;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.anythink.core.api.ATAdInfo;
|
||||||
|
import com.anythink.core.api.AdError;
|
||||||
|
import com.anythink.interstitial.api.ATInterstitial;
|
||||||
|
import com.anythink.interstitial.api.ATInterstitialListener;
|
||||||
|
import com.key.keyboardstyle.MyApplication;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AdManager {
|
||||||
|
|
||||||
|
private static final int type_no_cache = 0;
|
||||||
|
private static final int type_has_cache = 1;
|
||||||
|
private static final int type_show_success = 2;
|
||||||
|
private static final int type_show_close = 3;
|
||||||
|
private static final int type_show_fail = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Style_INST_3
|
||||||
|
n678faa86078c8
|
||||||
|
Style_INST_2
|
||||||
|
n678faa85c95ba
|
||||||
|
Style_INST_1
|
||||||
|
n678faa859a9bf
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final String place1Id = "n678faa859a9bf";
|
||||||
|
private static final String place2Id = "n678faa85c95ba";
|
||||||
|
private static final String place3Id = "n678faa86078c8";
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean place1LoadFail = false;
|
||||||
|
private static boolean place2LoadFail = false;
|
||||||
|
private static boolean place3LoadFail = false;
|
||||||
|
|
||||||
|
private static boolean alreadyShow = false;
|
||||||
|
|
||||||
|
private static final List<ATInterstitial> list = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
public static void loadAllAd() {
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
ATInterstitial mInterstitialAd1 = new ATInterstitial(MyApplication.getContext(), place1Id);
|
||||||
|
ATInterstitial mInterstitialAd2 = new ATInterstitial(MyApplication.getContext(), place2Id);
|
||||||
|
ATInterstitial mInterstitialAd3 = new ATInterstitial(MyApplication.getContext(), place3Id);
|
||||||
|
list.add(mInterstitialAd1);
|
||||||
|
list.add(mInterstitialAd2);
|
||||||
|
list.add(mInterstitialAd3);
|
||||||
|
}
|
||||||
|
for (ATInterstitial ad : list) {
|
||||||
|
if (!ad.isAdReady()) {
|
||||||
|
setCallBack(ad, new AdListener() {
|
||||||
|
@Override
|
||||||
|
public void loadFail(@NonNull String placeId) {
|
||||||
|
if (placeId.equals(place1Id)) {
|
||||||
|
place1LoadFail = true;
|
||||||
|
}
|
||||||
|
if (placeId.equals(place2Id)) {
|
||||||
|
place2LoadFail = true;
|
||||||
|
}
|
||||||
|
if (placeId.equals(place3Id)) {
|
||||||
|
place3LoadFail = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showSuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showFail() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showClose() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ad.load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ATInterstitial getReadyAd() {
|
||||||
|
Collections.shuffle(list);
|
||||||
|
for (ATInterstitial ad : list) {
|
||||||
|
if (ad.isAdReady()) {
|
||||||
|
Log.d(MyApplication.TAG, "-has Cache------------");
|
||||||
|
return ad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.d(MyApplication.TAG, "-No Cache------------");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setCallBack(ATInterstitial ad, AdListener listener) {
|
||||||
|
ad.setAdListener(new ATInterstitialListener() {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdLoaded() {
|
||||||
|
Log.d(MyApplication.TAG, "LoadLoaded " + ad.mPlacementId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdLoadFail(AdError adError) {
|
||||||
|
listener.loadFail(ad.mPlacementId);
|
||||||
|
Log.d(MyApplication.TAG, "LoadFail:--" + ad.mPlacementId + "--" + adError.getCode() + "---" + adError.getDesc());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdShow(ATAdInfo atAdInfo) {
|
||||||
|
Log.d(MyApplication.TAG, "AdShow " + atAdInfo.getShowId());
|
||||||
|
listener.showSuccess();
|
||||||
|
ad.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdClose(ATAdInfo atAdInfo) {
|
||||||
|
listener.showClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdVideoStart(ATAdInfo atAdInfo) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdVideoEnd(ATAdInfo atAdInfo) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdVideoError(AdError adError) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAlreadyShow() {
|
||||||
|
alreadyShow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CountDownTimer showWelcomeAd(
|
||||||
|
Activity activity,
|
||||||
|
Long totalTim,
|
||||||
|
CountAction countAction,
|
||||||
|
GoMainAction goMain
|
||||||
|
) {
|
||||||
|
return new CountDownTimer(totalTim, 100) {
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) {
|
||||||
|
countAction.onCount(millisUntilFinished);
|
||||||
|
if (!alreadyShow) {
|
||||||
|
showAD(activity, new AdStatusAction() {
|
||||||
|
@Override
|
||||||
|
public void onStatus(int adType) {
|
||||||
|
if (adType == type_has_cache) {
|
||||||
|
alreadyShow = true;
|
||||||
|
}
|
||||||
|
if (adType == type_show_close || adType == type_show_fail) {
|
||||||
|
goMain.onGo();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() {
|
||||||
|
if (!alreadyShow) {
|
||||||
|
showTopOn(activity, new onActionListener() {
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
goMain.onGo();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void showAD(Activity activity, AdStatusAction action) {
|
||||||
|
ATInterstitial readyAd = getReadyAd();
|
||||||
|
if (readyAd != null) {
|
||||||
|
action.onStatus(type_has_cache);
|
||||||
|
setCallBack(readyAd, new AdListener() {
|
||||||
|
@Override
|
||||||
|
public void loadFail(@NonNull String placeId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showSuccess() {
|
||||||
|
action.onStatus(type_show_success);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showFail() {
|
||||||
|
action.onStatus(type_show_fail);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showClose() {
|
||||||
|
action.onStatus(type_show_close);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
readyAd.show(activity);
|
||||||
|
} else {
|
||||||
|
action.onStatus(type_no_cache);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void showTopOn(Activity activity, onActionListener listener) {
|
||||||
|
showAD(activity, new AdStatusAction() {
|
||||||
|
@Override
|
||||||
|
public void onStatus(int adType) {
|
||||||
|
if (adType == type_no_cache || adType == type_show_close || adType == type_show_fail) {
|
||||||
|
listener.onAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.key.keyboardstyle.topon;
|
||||||
|
|
||||||
|
public interface AdStatusAction {
|
||||||
|
void onStatus(int adType);
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.key.keyboardstyle.topon;
|
||||||
|
|
||||||
|
public interface CountAction {
|
||||||
|
void onCount(long millisUntilFinished);
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.key.keyboardstyle.topon;
|
||||||
|
|
||||||
|
public interface GoMainAction {
|
||||||
|
void onGo();
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.key.keyboardstyle.topon;
|
||||||
|
|
||||||
|
public interface onActionListener {
|
||||||
|
|
||||||
|
void onAction();
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.activity;
|
package com.key.keyboardstyle.ui.activity;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
@ -11,9 +11,11 @@ import androidx.lifecycle.Observer;
|
|||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
|
||||||
import com.key.keyboardstyle.R;
|
import com.key.keyboardstyle.R;
|
||||||
import com.key.keyboardstyle.adapter.StyleAdapter;
|
import com.key.keyboardstyle.topon.AdManager;
|
||||||
|
import com.key.keyboardstyle.topon.onActionListener;
|
||||||
|
import com.key.keyboardstyle.ui.adapter.StyleAdapter;
|
||||||
import com.key.keyboardstyle.databinding.ActivityCategoryBinding;
|
import com.key.keyboardstyle.databinding.ActivityCategoryBinding;
|
||||||
import com.key.keyboardstyle.room.KeyboardWallpaper;
|
import com.key.keyboardstyle.database.room.KeyboardWallpaper;
|
||||||
import com.key.keyboardstyle.utils.DatabaseUtils;
|
import com.key.keyboardstyle.utils.DatabaseUtils;
|
||||||
import com.key.keyboardstyle.utils.ItemDecoration;
|
import com.key.keyboardstyle.utils.ItemDecoration;
|
||||||
|
|
||||||
@ -25,7 +27,6 @@ public class CategoryActivity extends AppCompatActivity {
|
|||||||
private ActivityCategoryBinding binding;
|
private ActivityCategoryBinding binding;
|
||||||
private StyleAdapter adapter;
|
private StyleAdapter adapter;
|
||||||
private String title;
|
private String title;
|
||||||
private KeyboardWallpaper keyboardWallpaper;
|
|
||||||
private DatabaseUtils databaseUtils;
|
private DatabaseUtils databaseUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,8 +48,15 @@ public class CategoryActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
|
AdManager.loadAllAd();
|
||||||
|
AdManager.showTopOn(this, new onActionListener() {
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
|
||||||
keyboardWallpaper = (KeyboardWallpaper) getIntent().getSerializableExtra("KeyboardWallpaper");
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
KeyboardWallpaper keyboardWallpaper = (KeyboardWallpaper) getIntent().getSerializableExtra("KeyboardWallpaper");
|
||||||
if (keyboardWallpaper == null) {
|
if (keyboardWallpaper == null) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
@ -1,10 +1,9 @@
|
|||||||
package com.key.keyboardstyle.activity;
|
package com.key.keyboardstyle.ui.activity;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
@ -19,11 +18,13 @@ import com.bumptech.glide.Glide;
|
|||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||||
import com.key.keyboardstyle.MyApplication;
|
import com.key.keyboardstyle.MyApplication;
|
||||||
import com.key.keyboardstyle.R;
|
import com.key.keyboardstyle.R;
|
||||||
import com.key.keyboardstyle.adapter.StyleAdapter;
|
import com.key.keyboardstyle.topon.AdManager;
|
||||||
|
import com.key.keyboardstyle.topon.onActionListener;
|
||||||
|
import com.key.keyboardstyle.ui.adapter.StyleAdapter;
|
||||||
import com.key.keyboardstyle.databinding.ActivityDownloadBinding;
|
import com.key.keyboardstyle.databinding.ActivityDownloadBinding;
|
||||||
import com.key.keyboardstyle.dialog.PermissionRequestDialog;
|
import com.key.keyboardstyle.ui.dialog.PermissionRequestDialog;
|
||||||
import com.key.keyboardstyle.room.AppDatabase;
|
import com.key.keyboardstyle.database.room.AppDatabase;
|
||||||
import com.key.keyboardstyle.room.KeyboardWallpaper;
|
import com.key.keyboardstyle.database.room.KeyboardWallpaper;
|
||||||
import com.key.keyboardstyle.utils.DatabaseUtils;
|
import com.key.keyboardstyle.utils.DatabaseUtils;
|
||||||
import com.key.keyboardstyle.utils.ItemDecoration;
|
import com.key.keyboardstyle.utils.ItemDecoration;
|
||||||
import com.key.keyboardstyle.utils.KeyboardUtils;
|
import com.key.keyboardstyle.utils.KeyboardUtils;
|
||||||
@ -58,6 +59,14 @@ public class DownloadActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
|
AdManager.loadAllAd();
|
||||||
|
AdManager.showTopOn(this, new onActionListener() {
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
keyboardWallpaper = (KeyboardWallpaper) getIntent().getSerializableExtra("KeyboardWallpaper");
|
keyboardWallpaper = (KeyboardWallpaper) getIntent().getSerializableExtra("KeyboardWallpaper");
|
||||||
if (keyboardWallpaper == null) {
|
if (keyboardWallpaper == null) {
|
||||||
finish();
|
finish();
|
||||||
@ -79,13 +88,32 @@ public class DownloadActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void initEvent() {
|
private void initEvent() {
|
||||||
|
|
||||||
binding.back.setOnClickListener(v -> finish());
|
binding.back.setOnClickListener(v -> {
|
||||||
|
AdManager.showTopOn(DownloadActivity.this, new onActionListener() {
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
binding.title.setText(keyboardWallpaper.getTitle());
|
binding.title.setText(keyboardWallpaper.getTitle());
|
||||||
binding.home.setOnClickListener(v -> {
|
binding.home.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(this, MainActivity.class);
|
AdManager.showTopOn(DownloadActivity.this, new onActionListener() {
|
||||||
startActivity(intent);
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
Intent intent = new Intent(DownloadActivity.this, MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
binding.download.setOnClickListener(v -> {
|
||||||
|
AdManager.showTopOn(DownloadActivity.this, new onActionListener() {
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
download();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
binding.download.setOnClickListener(v -> download());
|
|
||||||
loadDownloadImage();
|
loadDownloadImage();
|
||||||
loadRecommend();
|
loadRecommend();
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.activity;
|
package com.key.keyboardstyle.ui.activity;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -13,7 +13,8 @@ import androidx.core.view.WindowInsetsCompat;
|
|||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import com.google.android.material.tabs.TabLayoutMediator;
|
import com.google.android.material.tabs.TabLayoutMediator;
|
||||||
import com.key.keyboardstyle.R;
|
import com.key.keyboardstyle.R;
|
||||||
import com.key.keyboardstyle.adapter.MainAdapter;
|
import com.key.keyboardstyle.topon.AdManager;
|
||||||
|
import com.key.keyboardstyle.ui.adapter.MainAdapter;
|
||||||
import com.key.keyboardstyle.databinding.ActivityMainBinding;
|
import com.key.keyboardstyle.databinding.ActivityMainBinding;
|
||||||
import com.key.keyboardstyle.databinding.ItemTabLayoutCustomBinding;
|
import com.key.keyboardstyle.databinding.ItemTabLayoutCustomBinding;
|
||||||
|
|
||||||
@ -38,6 +39,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
|
AdManager.loadAllAd();
|
||||||
|
|
||||||
MainAdapter adapter = new MainAdapter(this);
|
MainAdapter adapter = new MainAdapter(this);
|
||||||
binding.viewPager2.setAdapter(adapter);
|
binding.viewPager2.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.activity;
|
package com.key.keyboardstyle.ui.activity;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
@ -12,9 +12,11 @@ import androidx.core.view.WindowInsetsCompat;
|
|||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
|
||||||
import com.key.keyboardstyle.R;
|
import com.key.keyboardstyle.R;
|
||||||
import com.key.keyboardstyle.adapter.StyleAdapter;
|
import com.key.keyboardstyle.topon.AdManager;
|
||||||
|
import com.key.keyboardstyle.topon.onActionListener;
|
||||||
|
import com.key.keyboardstyle.ui.adapter.StyleAdapter;
|
||||||
import com.key.keyboardstyle.databinding.ActivitySearchBinding;
|
import com.key.keyboardstyle.databinding.ActivitySearchBinding;
|
||||||
import com.key.keyboardstyle.room.KeyboardWallpaper;
|
import com.key.keyboardstyle.database.room.KeyboardWallpaper;
|
||||||
import com.key.keyboardstyle.utils.DatabaseUtils;
|
import com.key.keyboardstyle.utils.DatabaseUtils;
|
||||||
import com.key.keyboardstyle.utils.ItemDecoration;
|
import com.key.keyboardstyle.utils.ItemDecoration;
|
||||||
|
|
||||||
@ -45,6 +47,13 @@ public class SearchActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
|
AdManager.loadAllAd();
|
||||||
|
AdManager.showTopOn(this, new onActionListener() {
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
databaseUtils = new DatabaseUtils(this);
|
databaseUtils = new DatabaseUtils(this);
|
||||||
|
|
||||||
@ -1,9 +1,8 @@
|
|||||||
package com.key.keyboardstyle.activity;
|
package com.key.keyboardstyle.ui.activity;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -15,12 +14,13 @@ import com.bumptech.glide.Glide;
|
|||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||||
import com.key.keyboardstyle.R;
|
import com.key.keyboardstyle.R;
|
||||||
import com.key.keyboardstyle.databinding.ActivitySplashBinding;
|
import com.key.keyboardstyle.databinding.ActivitySplashBinding;
|
||||||
|
import com.key.keyboardstyle.topon.AdManager;
|
||||||
|
|
||||||
|
|
||||||
public class SplashActivity extends AppCompatActivity {
|
public class SplashActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private ActivitySplashBinding binding;
|
private ActivitySplashBinding binding;
|
||||||
private static final long TOTAL_TIME = 3000;
|
private static final long TOTAL_TIME = 11000;
|
||||||
private CountDownTimer countDownTimer;
|
private CountDownTimer countDownTimer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,23 +37,21 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AdManager.loadAllAd();
|
||||||
|
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.load(R.mipmap.ic_launcher)
|
.load(R.mipmap.ic_launcher)
|
||||||
.transform(new RoundedCorners(16))
|
.transform(new RoundedCorners(16))
|
||||||
.into(binding.splashImage);
|
.into(binding.splashImage);
|
||||||
|
|
||||||
countDownTimer = new CountDownTimer(TOTAL_TIME,100) {
|
AdManager.setAlreadyShow();
|
||||||
@Override
|
|
||||||
public void onTick(long millisUntilFinished) {
|
|
||||||
int percentage = (int) (100 - (float) millisUntilFinished / TOTAL_TIME * 100);
|
|
||||||
binding.progressBar.setProgress(percentage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
countDownTimer = AdManager.showWelcomeAd(this, TOTAL_TIME, millisUntilFinished -> {
|
||||||
public void onFinish() {
|
int percentage = (int) (100 - (float) millisUntilFinished / TOTAL_TIME * 100);
|
||||||
startMain();
|
binding.progressBar.setProgress(percentage);
|
||||||
}
|
},
|
||||||
};
|
this::startMain
|
||||||
|
);
|
||||||
|
|
||||||
countDownTimer.start();
|
countDownTimer.start();
|
||||||
}
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
package com.key.keyboardstyle.activity;
|
package com.key.keyboardstyle.ui.activity;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -1,13 +1,13 @@
|
|||||||
package com.key.keyboardstyle.adapter;
|
package com.key.keyboardstyle.ui.adapter;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||||
|
|
||||||
import com.key.keyboardstyle.fragment.CategoryFragment;
|
import com.key.keyboardstyle.ui.fragment.CategoryFragment;
|
||||||
import com.key.keyboardstyle.fragment.FavoriteFragment;
|
import com.key.keyboardstyle.ui.fragment.FavoriteFragment;
|
||||||
import com.key.keyboardstyle.fragment.SettingFragment;
|
import com.key.keyboardstyle.ui.fragment.SettingFragment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.adapter;
|
package com.key.keyboardstyle.ui.adapter;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@ -11,18 +11,14 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.DiffUtil;
|
|
||||||
import androidx.recyclerview.widget.ListAdapter;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Key;
|
|
||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||||
import com.key.keyboardstyle.R;
|
import com.key.keyboardstyle.R;
|
||||||
import com.key.keyboardstyle.activity.CategoryActivity;
|
import com.key.keyboardstyle.ui.activity.CategoryActivity;
|
||||||
import com.key.keyboardstyle.activity.DownloadActivity;
|
import com.key.keyboardstyle.ui.activity.DownloadActivity;
|
||||||
import com.key.keyboardstyle.room.AppDatabase;
|
import com.key.keyboardstyle.database.room.KeyboardWallpaper;
|
||||||
import com.key.keyboardstyle.room.KeyboardWallpaper;
|
|
||||||
import com.key.keyboardstyle.utils.DatabaseUtils;
|
import com.key.keyboardstyle.utils.DatabaseUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.dialog;
|
package com.key.keyboardstyle.ui.dialog;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.fragment;
|
package com.key.keyboardstyle.ui.fragment;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -11,10 +11,10 @@ import androidx.lifecycle.Observer;
|
|||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
import com.key.keyboardstyle.activity.SearchActivity;
|
import com.key.keyboardstyle.ui.activity.SearchActivity;
|
||||||
import com.key.keyboardstyle.adapter.StyleAdapter;
|
import com.key.keyboardstyle.ui.adapter.StyleAdapter;
|
||||||
import com.key.keyboardstyle.databinding.FragmentCategoryBinding;
|
import com.key.keyboardstyle.databinding.FragmentCategoryBinding;
|
||||||
import com.key.keyboardstyle.room.KeyboardWallpaper;
|
import com.key.keyboardstyle.database.room.KeyboardWallpaper;
|
||||||
import com.key.keyboardstyle.utils.DatabaseUtils;
|
import com.key.keyboardstyle.utils.DatabaseUtils;
|
||||||
import com.key.keyboardstyle.utils.ItemDecoration;
|
import com.key.keyboardstyle.utils.ItemDecoration;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.fragment;
|
package com.key.keyboardstyle.ui.fragment;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -9,9 +9,9 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
|
||||||
import com.key.keyboardstyle.adapter.StyleAdapter;
|
import com.key.keyboardstyle.ui.adapter.StyleAdapter;
|
||||||
import com.key.keyboardstyle.databinding.FragmentFavoriteBinding;
|
import com.key.keyboardstyle.databinding.FragmentFavoriteBinding;
|
||||||
import com.key.keyboardstyle.room.KeyboardWallpaper;
|
import com.key.keyboardstyle.database.room.KeyboardWallpaper;
|
||||||
import com.key.keyboardstyle.utils.DatabaseUtils;
|
import com.key.keyboardstyle.utils.DatabaseUtils;
|
||||||
import com.key.keyboardstyle.utils.ItemDecoration;
|
import com.key.keyboardstyle.utils.ItemDecoration;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.key.keyboardstyle.fragment;
|
package com.key.keyboardstyle.ui.fragment;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -4,10 +4,10 @@ import android.content.Context;
|
|||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
import com.key.keyboardstyle.room.AppDatabase;
|
import com.key.keyboardstyle.database.room.AppDatabase;
|
||||||
import com.key.keyboardstyle.room.Category;
|
import com.key.keyboardstyle.database.room.Category;
|
||||||
import com.key.keyboardstyle.room.KeyboardWallpaper;
|
import com.key.keyboardstyle.database.room.KeyboardWallpaper;
|
||||||
import com.key.keyboardstyle.room.KeyboardWallpaperDao;
|
import com.key.keyboardstyle.database.room.KeyboardWallpaperDao;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package com.key.keyboardstyle.utils;
|
package com.key.keyboardstyle.utils;
|
||||||
|
|
||||||
import com.key.keyboardstyle.MyApplication;
|
import com.key.keyboardstyle.MyApplication;
|
||||||
import com.key.keyboardstyle.room.Category;
|
import com.key.keyboardstyle.database.room.Category;
|
||||||
import com.key.keyboardstyle.room.KeyboardWallpaper;
|
import com.key.keyboardstyle.database.room.KeyboardWallpaper;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import com.key.keyboardstyle.MyApplication;
|
|||||||
import com.key.keyboardstyle.R;
|
import com.key.keyboardstyle.R;
|
||||||
import com.key.keyboardstyle.callback.DownloadCallback;
|
import com.key.keyboardstyle.callback.DownloadCallback;
|
||||||
import com.key.keyboardstyle.callback.UnzipCallback;
|
import com.key.keyboardstyle.callback.UnzipCallback;
|
||||||
import com.key.keyboardstyle.keyboard.MyKeyboard;
|
import com.key.keyboardstyle.inputmethod.MyKeyboard;
|
||||||
|
|
||||||
import net.sf.sevenzipjbinding.ArchiveFormat;
|
import net.sf.sevenzipjbinding.ArchiveFormat;
|
||||||
import net.sf.sevenzipjbinding.IInArchive;
|
import net.sf.sevenzipjbinding.IInArchive;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".activity.CategoryActivity">
|
tools:context=".ui.activity.CategoryActivity">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/back"
|
android:id="@+id/back"
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".activity.DownloadActivity">
|
tools:context=".ui.activity.DownloadActivity">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/back"
|
android:id="@+id/back"
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".activity.MainActivity">
|
tools:context=".ui.activity.MainActivity">
|
||||||
|
|
||||||
<androidx.viewpager2.widget.ViewPager2
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
android:id="@+id/view_pager2"
|
android:id="@+id/view_pager2"
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".activity.SearchActivity">
|
tools:context=".ui.activity.SearchActivity">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/back"
|
android:id="@+id/back"
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".activity.TestActivity">
|
tools:context=".ui.activity.TestActivity">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/back"
|
android:id="@+id/back"
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".fragment.CategoryFragment">
|
tools:context=".ui.fragment.CategoryFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".fragment.FavoriteFragment">
|
tools:context=".ui.fragment.FavoriteFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
tools:context=".fragment.SettingFragment">
|
tools:context=".ui.fragment.SettingFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text"
|
android:id="@+id/text"
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.key.keyboardstyle.keyboard.MyKeyboard
|
<com.key.keyboardstyle.inputmethod.MyKeyboard
|
||||||
android:id="@+id/keyboardView"
|
android:id="@+id/keyboardView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="210dp" />
|
android:layout_height="210dp" />
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application) apply false
|
alias(libs.plugins.android.application) 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
|
||||||
}
|
}
|
||||||
@ -19,6 +19,28 @@ dependencyResolutionManagement {
|
|||||||
|
|
||||||
maven("https://jitpack.io")
|
maven("https://jitpack.io")
|
||||||
|
|
||||||
|
//Anythink(Core)
|
||||||
|
maven ("https://jfrog.anythinktech.com/artifactory/overseas_sdk")
|
||||||
|
|
||||||
|
//Appnext
|
||||||
|
maven ("https://dl.appnext.com")
|
||||||
|
|
||||||
|
//Ironsource
|
||||||
|
maven ("https://android-sdk.is.com/")
|
||||||
|
|
||||||
|
//Pangle
|
||||||
|
maven ("https://artifact.bytedance.com/repository/pangle")
|
||||||
|
|
||||||
|
//Mintegral
|
||||||
|
maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
||||||
|
|
||||||
|
//Chartboost
|
||||||
|
maven ("https://cboost.jfrog.io/artifactory/chartboost-ads")
|
||||||
|
maven ("https://cboost.jfrog.io/artifactory/chartboost-mediation")
|
||||||
|
|
||||||
|
//TopOn集成测试工具
|
||||||
|
// maven ( "https://jfrog.anythinktech.com/artifactory/debugger")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user