Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PrictureTranslate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bixing
PrictureTranslate
Commits
84bdb584
Commit
84bdb584
authored
Oct 20, 2023
by
bixing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加开屏广告
parent
4825f36f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
604 additions
and
2 deletions
+604
-2
build.gradle
app/build.gradle
+10
-0
proguard-rules.pro
app/proguard-rules.pro
+240
-1
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+6
-0
AppOpenAdManager.java
...n/java/com/ads/cal/picturetranslate/AppOpenAdManager.java
+227
-0
PictureApplication.java
...java/com/ads/cal/picturetranslate/PictureApplication.java
+6
-0
StaticEventId.java
...main/java/com/ads/cal/picturetranslate/StaticEventId.java
+14
-0
BaseActivity.java
.../java/com/ads/cal/picturetranslate/base/BaseActivity.java
+101
-1
No files found.
app/build.gradle
View file @
84bdb584
...
@@ -52,6 +52,7 @@ android {
...
@@ -52,6 +52,7 @@ android {
applicationId
"com.ads.cal.picturetranslate"
applicationId
"com.ads.cal.picturetranslate"
versionName
"1.0.0.0"
versionName
"1.0.0.0"
signingConfig
signingConfigs
.
toolsTest
signingConfig
signingConfigs
.
toolsTest
manifestPlaceholders
=
[
google_ad_app_id:
"ca-app-pub-3940256099942544~3347511713"
]
}
}
}
}
}
}
...
@@ -95,4 +96,13 @@ dependencies {
...
@@ -95,4 +96,13 @@ dependencies {
implementation
'pl.droidsonroids.gif:android-gif-drawable:1.2.27'
implementation
'pl.droidsonroids.gif:android-gif-drawable:1.2.27'
implementation
(
"org.greenrobot:eventbus:3.3.1"
)
implementation
(
"org.greenrobot:eventbus:3.3.1"
)
// Import the BoM for the Firebase platform
// implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
// Add the dependency for the Analytics library
// When using the BoM, you don't specify versions in Firebase library dependencies
// implementation("com.google.firebase:firebase-analytics")
implementation
'com.google.android.gms:play-services-ads:22.4.0'
implementation
'com.google.guava:guava:27.0.1-android'
}
}
\ No newline at end of file
app/proguard-rules.pro
View file @
84bdb584
...
@@ -18,4 +18,243 @@
...
@@ -18,4 +18,243 @@
# If you keep the line number information, uncomment this to
# If you keep the line number information, uncomment this to
# hide the original source file name.
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile
\ 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
-
dontpreverify
-
flattenpackagehierarchy
-
optimizationpasses
5
-
dontusemixedcaseclassnames
-
dontskipnonpubliclibraryclasses
-
verbose
-
useuniqueclassmembernames
-
ignorewarnings
#基础模板开始
# 保护注解
-
keepattributes
*
Annotation
*
-
keepattributes
*
JavascriptInterface
*
# 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
.
**
{
*
;}
#com.github
-
keep
class
com
.
github
.
**
{
*
;}
#com.google
-
keep
class
com
.
google
.
**
{
*
;}
#org.
-
keep
class
org
.
**
{
*
;
}
app/src/main/AndroidManifest.xml
View file @
84bdb584
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
<uses-permission
android:name=
"android.permission.READ_MEDIA_IMAGES"
/>
<uses-permission
android:name=
"android.permission.READ_MEDIA_IMAGES"
/>
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>-->
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>-->
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-feature
<uses-feature
...
@@ -38,6 +40,10 @@
...
@@ -38,6 +40,10 @@
android:name=
"com.google.mlkit.vision.DEPENDENCIES"
android:name=
"com.google.mlkit.vision.DEPENDENCIES"
android:value=
"ocr,ocr_chinese,ocr_devanagari,ocr_japanese,ocr_korean"
/>
android:value=
"ocr,ocr_chinese,ocr_devanagari,ocr_japanese,ocr_korean"
/>
<meta-data
android:name=
"com.google.android.gms.ads.APPLICATION_ID"
android:value=
"${google_ad_app_id}"
/>
<activity
<activity
android:name=
".activity.PictureTranslateStartActivity"
android:name=
".activity.PictureTranslateStartActivity"
android:exported=
"true"
android:exported=
"true"
...
...
app/src/main/java/com/ads/cal/picturetranslate/AppOpenAdManager.java
0 → 100644
View file @
84bdb584
package
com
.
ads
.
cal
.
picturetranslate
;
import
android.app.Activity
;
import
androidx.annotation.NonNull
;
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.appopen.AppOpenAd
;
import
java.util.Date
;
public
class
AppOpenAdManager
{
//
private
static
final
String
LOG_TAG
=
"AppOpenAdManager"
;
// private static final String AD_UNIT_ID = "ca-app-pub-3940256099942544/3419835294";
private
AppOpenAd
appOpenAd
=
null
;
private
boolean
isLoadingAd
=
false
;
private
boolean
isShowingAd
=
false
;
private
OnLoadAdCompleteListener
onLoadAdCompleteListener
;
private
OnShowAdCompleteListener
onShowAdCompleteListener
;
public
boolean
isShowingAd
()
{
return
isShowingAd
;
}
/**
* 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
AppOpenAdManager
()
{
}
private
static
final
class
AppOpenAdManagerHolder
{
static
final
AppOpenAdManager
appOpenAdManager
=
new
AppOpenAdManager
();
}
public
static
AppOpenAdManager
getInstance
()
{
return
AppOpenAdManagerHolder
.
appOpenAdManager
;
}
/**
* Load an ad.
*
*/
public
void
loadAd
()
{
// Do not load ad if there is an unused ad or one is already loading.
if
(
isLoadingAd
||
isAdAvailable
())
{
return
;
}
isLoadingAd
=
true
;
AdRequest
request
=
new
AdRequest
.
Builder
().
build
();
AppOpenAd
.
load
(
PictureApplication
.
getApplication
(),
""
,
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
;
isLoadingAd
=
false
;
loadTime
=
(
new
Date
()).
getTime
();
if
(
null
!=
onLoadAdCompleteListener
)
{
onLoadAdCompleteListener
.
onLoadAdComplete
();
onLoadAdCompleteListener
=
null
;
}
LogUtils
.
d
(
LOG_TAG
,
"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
(
LoadAdError
loadAdError
)
{
isLoadingAd
=
false
;
if
(
null
!=
onLoadAdCompleteListener
)
{
onLoadAdCompleteListener
.
onLoadAdFailed
(
loadAdError
.
getMessage
());
onLoadAdCompleteListener
=
null
;
}
LogUtils
.
d
(
LOG_TAG
,
"onAdFailedToLoad: "
+
loadAdError
.
getMessage
());
// FireBaseAnalyticsUtils.init().send(AD_OPEN_LOAD_FAILED);
}
});
// FireBaseAnalyticsUtils.init().send(AD_OPEN_START_LOAD);
}
/**
* Check if ad was loaded more than n hours ago.
*/
private
boolean
wasLoadTimeLessThanNHoursAgo
(
long
numHours
)
{
long
dateDifference
=
(
new
Date
()).
getTime
()
-
loadTime
;
long
numMilliSecondsPerHour
=
3600000
;
return
(
dateDifference
<
(
numMilliSecondsPerHour
*
numHours
));
}
/**
* 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
(
4
);
}
/**
* 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
(
isShowingAd
)
{
LogUtils
.
d
(
LOG_TAG
,
"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
())
{
LogUtils
.
d
(
LOG_TAG
,
"The app open ad is not ready yet."
);
loadAd
();
return
false
;
}
LogUtils
.
d
(
LOG_TAG
,
"Will show ad."
);
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
;
isShowingAd
=
false
;
LogUtils
.
d
(
LOG_TAG
,
"onAdDismissedFullScreenContent."
);
if
(
null
!=
onShowAdCompleteListener
)
{
onShowAdCompleteListener
.
onShowAdComplete
();
onShowAdCompleteListener
=
null
;
}
loadAd
();
// FireBaseAnalyticsUtils.init().send(AD_OPEN_CLOSE);
}
/** Called when fullscreen content failed to show. */
@Override
public
void
onAdFailedToShowFullScreenContent
(
@NonNull
AdError
adError
)
{
appOpenAd
=
null
;
isShowingAd
=
false
;
LogUtils
.
d
(
LOG_TAG
,
"onAdFailedToShowFullScreenContent: "
+
adError
.
getMessage
());
if
(
null
!=
onShowAdCompleteListener
)
{
onShowAdCompleteListener
.
onShowAdFailed
(
adError
.
getMessage
());
onShowAdCompleteListener
=
null
;
}
loadAd
();
// FireBaseAnalyticsUtils.init().send(AD_OPEN_SHOW_FAILED);
}
/** Called when fullscreen content is shown. */
@Override
public
void
onAdShowedFullScreenContent
()
{
LogUtils
.
d
(
LOG_TAG
,
"onAdShowedFullScreenContent."
);
}
@Override
public
void
onAdImpression
()
{
super
.
onAdImpression
();
LogUtils
.
d
(
LOG_TAG
,
"onAdImpression."
);
// FireBaseAnalyticsUtils.init().send(AD_OPEN_EXP);
}
@Override
public
void
onAdClicked
()
{
super
.
onAdClicked
();
// FireBaseAnalyticsUtils.init().send(AD_OPEN_CLK);
}
});
isShowingAd
=
true
;
appOpenAd
.
show
(
activity
);
return
true
;
}
public
interface
OnShowAdCompleteListener
{
void
onShowAdComplete
();
void
onShowAdFailed
(
String
errorMsg
);
}
public
interface
OnLoadAdCompleteListener
{
void
onLoadAdComplete
();
void
onLoadAdFailed
(
String
errorMsg
);
}
public
void
setOnLoadAdCompleteListener
(
OnLoadAdCompleteListener
onLoadAdCompleteListener
)
{
this
.
onLoadAdCompleteListener
=
onLoadAdCompleteListener
;
}
public
void
setOnShowAdCompleteListener
(
OnShowAdCompleteListener
onShowAdCompleteListener
)
{
this
.
onShowAdCompleteListener
=
onShowAdCompleteListener
;
}
}
app/src/main/java/com/ads/cal/picturetranslate/PictureApplication.java
View file @
84bdb584
...
@@ -7,10 +7,12 @@ import com.ads.cal.picturetranslate.db.DataBaseManager;
...
@@ -7,10 +7,12 @@ import com.ads.cal.picturetranslate.db.DataBaseManager;
public
class
PictureApplication
extends
Application
{
public
class
PictureApplication
extends
Application
{
private
static
DataBaseManager
dataBaseManager
;
private
static
DataBaseManager
dataBaseManager
;
private
static
Application
application
;
@Override
@Override
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
application
=
this
;
new
Thread
(()
->
{
new
Thread
(()
->
{
PictureTranslateUtils
.
init
();
PictureTranslateUtils
.
init
();
});
});
...
@@ -18,6 +20,10 @@ public class PictureApplication extends Application {
...
@@ -18,6 +20,10 @@ public class PictureApplication extends Application {
}
}
public
static
Application
getApplication
()
{
return
application
;
}
private
void
initDB
()
{
private
void
initDB
()
{
dataBaseManager
=
new
DataBaseManager
(
this
);
dataBaseManager
=
new
DataBaseManager
(
this
);
dataBaseManager
.
open
();
dataBaseManager
.
open
();
...
...
app/src/main/java/com/ads/cal/picturetranslate/StaticEventId.java
0 → 100644
View file @
84bdb584
package
com
.
ads
.
cal
.
picturetranslate
;
public
class
StaticEventId
{
public
static
final
String
LAUNCH_EXP
=
"launch_exp"
;
public
static
final
String
HOME_EXP
=
"home_exp"
;
public
static
final
String
ABOUT_EXP
=
"about_exp"
;
public
static
final
String
CAMERA_EXP
=
"camera_exp"
;
public
static
final
String
CUTOUT_EXP
=
"cutout_exp"
;
public
static
final
String
RESULT_EXP
=
"result_exp"
;
public
static
final
String
SHOW_EXP
=
"show_exp"
;
}
app/src/main/java/com/ads/cal/picturetranslate/base/BaseActivity.java
View file @
84bdb584
package
com
.
ads
.
cal
.
picturetranslate
.
base
;
package
com
.
ads
.
cal
.
picturetranslate
.
base
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.RatingBar
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.camera.core.ExperimentalGetImage
;
import
androidx.camera.core.ExperimentalGetImage
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.Fragment
;
...
@@ -9,12 +17,16 @@ import androidx.fragment.app.FragmentActivity;
...
@@ -9,12 +17,16 @@ import androidx.fragment.app.FragmentActivity;
import
androidx.fragment.app.FragmentManager
;
import
androidx.fragment.app.FragmentManager
;
import
androidx.fragment.app.FragmentTransaction
;
import
androidx.fragment.app.FragmentTransaction
;
import
com.ads.cal.picturetranslate.LogUtils
;
import
com.ads.cal.picturetranslate.R
;
import
com.ads.cal.picturetranslate.R
;
import
com.ads.cal.picturetranslate.activity.PictureTranslateStartActivity
;
import
com.ads.cal.picturetranslate.activity.PictureTranslateStartActivity
;
import
com.ads.cal.picturetranslate.adapter.PictureTranslateListAdapter
;
import
com.ads.cal.picturetranslate.adapter.PictureTranslateListAdapter
;
import
com.ads.cal.picturetranslate.bean.PictureTranslateBean
;
import
com.ads.cal.picturetranslate.bean.PictureTranslateBean
;
import
com.ads.cal.picturetranslate.fragment.LoadingFragment
;
import
com.ads.cal.picturetranslate.fragment.LoadingFragment
;
import
java.util.Locale
;
@ExperimentalGetImage
public
class
BaseActivity
extends
FragmentActivity
{
@ExperimentalGetImage
public
class
BaseActivity
extends
FragmentActivity
{
...
@@ -101,4 +113,92 @@ import com.ads.cal.picturetranslate.fragment.LoadingFragment;
...
@@ -101,4 +113,92 @@ import com.ads.cal.picturetranslate.fragment.LoadingFragment;
fragmentTransaction
.
hide
(
fragment
);
fragmentTransaction
.
hide
(
fragment
);
}
}
// private void refreshAd() {
// AdLoader.Builder builder = new AdLoader.Builder(this, ADMOB_AD_UNIT_ID);
// // OnLoadedListener implementation.
// builder.forNativeAd(nativeAd -> {
// // If this callback occurs after the activity is destroyed, you must call
// // destroy and return or you may get a memory leak.
// boolean isDestroyed = isDestroyed();
// if (isDestroyed || isFinishing() || isChangingConfigurations()) {
// nativeAd.destroy();
// return;
// }
// // You must call destroy on old ads when you are done with them,
// // otherwise you will have a memory leak.
// if (BaseActivity.this.nativeAd != null) {
// BaseActivity.this.nativeAd.destroy();
// }
// BaseActivity.this.nativeAd = nativeAd;
//// FrameLayout frameLayout = findViewById(R.id.ad_layout);
//// NativeAdView adView = (NativeAdView) getLayoutInflater().inflate(R.layout.ad_unified, frameLayout, false);
//// populateNativeAdView(nativeAd, adView);
//// frameLayout.removeAllViews();
//// frameLayout.addView(adView);
//// NativeTemplateStyle styles = null;
//// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
//// styles = new NativeTemplateStyle.Builder().withMainBackgroundColor(new ColorDrawable(getColor(R.color.white))).build();
//// } else {
//// styles = new NativeTemplateStyle.Builder().withMainBackgroundColor(new ColorDrawable(getResources().getColor(R.color.white))).build();
//// }
//// TemplateView template = findViewById(R.id.ad_layout);
//// template.setStyles(styles);
//// template.setNativeAd(nativeAd);
// });
//
// VideoOptions videoOptions = new VideoOptions.Builder().setStartMuted(false).build();
//
// NativeAdOptions adOptions = new NativeAdOptions.Builder().setVideoOptions(videoOptions).build();
//
// builder.withNativeAdOptions(adOptions);
//
// AdLoader adLoader = builder.withAdListener(new AdListener() {
// @Override
// public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
// String error = String.format(Locale.getDefault(), "domain: %s, code: %d, message: %s", loadAdError.getDomain(), loadAdError.getCode(), loadAdError.getMessage());
// LogUtils.d("home native onAdLoad Failed " + error);
//// FireBaseAnalyticsUtils.init().send(AD_HOME_NATIVE_LOAD_FAILED);
// }
//
// @Override
// public void onAdLoaded() {
// super.onAdLoaded();
// LogUtils.d("home native onAdLoaded");
//// FireBaseAnalyticsUtils.init().send(AD_HOME_NATIVE_LOAD_SUCCESS);
// }
//
// @Override
// public void onAdClicked() {
// super.onAdClicked();
// LogUtils.d("home native onAdClicked");
//// FireBaseAnalyticsUtils.init().send(AD_HOME_NATIVE_CLK);
// }
//
// @Override
// public void onAdClosed() {
// super.onAdClosed();
// LogUtils.d("home native onAdClosed");
//// FireBaseAnalyticsUtils.init().send(AD_HOME_NATIVE_CLOSE);
// }
//
// @Override
// public void onAdImpression() {
// super.onAdImpression();
// LogUtils.d("home native onAdImpression");
//// FireBaseAnalyticsUtils.init().send(AD_HOME_NATIVE_EXP);
// }
//
// @Override
// public void onAdOpened() {
// super.onAdOpened();
// }
//
// }).build();
//
// adLoader.loadAd(new AdRequest.Builder().build());
//// FireBaseAnalyticsUtils.init().send(AD_HOME_NATIVE_START_LOAD);
// LogUtils.d("home native onAdLoad start " );
// }
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment