Skip to content

Commit

Permalink
clear android code
Browse files Browse the repository at this point in the history
  • Loading branch information
irov committed Jan 6, 2025
1 parent fec4be2 commit 4a0b0ac
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 35 deletions.
2 changes: 1 addition & 1 deletion gradle/base.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
errorprone("com.google.errorprone:error_prone_core:2.36.0")
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.errorprone.enabled = true
options.errorprone.disableWarningsInGeneratedCode = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ public void onDestroy() {
List<MengineService> plugins = this.getPlugins();

for (MengineService p : plugins) {
p.setMengineActivity(null);
p.removeMengineActivity();
}

if (m_clipboard != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public static void setMengineApplication(@NonNull MengineApplication application
MengineAnalytics.m_application = application;
}

public static void removeMengineApplication() {
MengineAnalytics.m_application = null;
}

static private void assertContext(String key) {
if (BuildConfig.DEBUG == false) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ public String getAndroidId() {
return m_androidId;
}

public long getSaveVersion() {
return m_saveVersion;
}

public String getInstallKey() {
return m_installKey;
}
Expand Down Expand Up @@ -1193,8 +1197,8 @@ public void onTerminate() {
service.onFinalize(this);
}

MengineLog.setMengineApplication(null);
MengineAnalytics.setMengineApplication(null);
MengineLog.removeMengineApplication();
MengineAnalytics.removeMengineApplication();

MengineNative.AndroidNativePython_removePlugin("Application");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public static void setMengineApplication(@NonNull MengineApplication application
MengineLog.m_application = application;
}

public static void removeMengineApplication() {
MengineLog.m_application = null;
}

public static void initializeBaseServices() {
MengineLog.m_initializeBaseServices = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public void setMengineActivity(@NonNull MengineActivity activity) {
m_activity = activity;
}

public void removeMengineActivity() {
m_activity = null;
}

public MengineActivity getMengineActivity() {
return m_activity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,14 +936,23 @@ public static Display getDefaultDisplay(Context context) {
}
}

@SuppressWarnings("deprecation")
public static Rect getDeviceWindowRectQ(Context context, Display display) {
DisplayMetrics realMetrics = new DisplayMetrics();
display.getRealMetrics( realMetrics );

int width = realMetrics.widthPixels;
int height = realMetrics.heightPixels;

return new Rect(0, 0, width, height);
}

public static Rect getDeviceWindowRect(Context context, Display display)
{
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);

if (windowManager == null) {
return null;
return MengineUtils.getDeviceWindowRectQ(context, display);
}

WindowMetrics windowMetrics = windowManager.getCurrentWindowMetrics();
Expand All @@ -952,13 +961,7 @@ public static Rect getDeviceWindowRect(Context context, Display display)

return bounds;
} else {
DisplayMetrics realMetrics = new DisplayMetrics();
display.getRealMetrics( realMetrics );

int width = realMetrics.widthPixels;
int height = realMetrics.heightPixels;

return new Rect(0, 0, width, height);
return MengineUtils.getDeviceWindowRectQ(context, display);
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libraries/Mengine/src/main/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-keep public class * extends org.Mengine.Base.MenginePluginExtension {
-keep public class * extends org.Mengine.Base.MengineServiceInvalidInitializeException {
native <methods>;
public <methods>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static class NonetBanner {
protected Timer m_refreshTimer;

@Override
public void onAppCreate(MengineApplication application, MengineAppLovinPlugin plugin) throws MengineServiceInvalidInitializeException {
public void onAppCreate(@NonNull MengineApplication application, @NonNull MengineAppLovinPlugin plugin) throws MengineServiceInvalidInitializeException {
m_plugin = plugin;

m_banners = new ArrayList<>();
Expand Down Expand Up @@ -110,14 +110,14 @@ public void onAppCreate(MengineApplication application, MengineAppLovinPlugin pl
}

@Override
public void onAppTerminate(MengineApplication application, MengineAppLovinPlugin plugin) {
public void onAppTerminate(@NonNull MengineApplication application, @NonNull MengineAppLovinPlugin plugin) {
m_banners = null;

m_plugin = null;
}

@Override
public void onActivityCreate(MengineActivity activity) throws MengineServiceInvalidInitializeException {
public void onActivityCreate(@NonNull MengineActivity activity) throws MengineServiceInvalidInitializeException {
if (m_banners.isEmpty() == true) {
return;
}
Expand Down Expand Up @@ -215,23 +215,20 @@ protected void addNonetBanner(MengineApplication application, String image, Stri
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
view.setLayoutParams(params);

view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
m_plugin.logMessage("[NONET_BANNERS] click banner request: %d url: %s"
, m_requestId
, url
);
view.setOnClickListener(v -> {
m_plugin.logMessage("[NONET_BANNERS] click banner request: %d url: %s"
, m_requestId
, url
);

m_plugin.buildEvent("mng_ad_nonet_banners_clicked")
.addParameterString("url", url)
.addParameterLong("request_id", m_requestId)
.log();
m_plugin.buildEvent("mng_ad_nonet_banners_clicked")
.addParameterString("url", url)
.addParameterLong("request_id", m_requestId)
.log();

MengineActivity activity = m_plugin.getMengineActivity();
MengineActivity activity = m_plugin.getMengineActivity();

MengineUtils.openUrl(activity, url);
}
MengineUtils.openUrl(activity, url);
});

m_plugin.logMessage("[NONET_BANNERS] add banner url: %s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public void onError(@NonNull FacebookException exception) {
.addParameterString("url", link)
.addParameterString("hashtag", hashtag)
.addParameterString("quote", quote)
.addParameterString("error", error_message)
.addParameterException("exception", exception)
.log();

MengineFacebookPlugin.this.pythonCall("onFacebookShareError", ERROR_CODE_UNKNOWN, error_message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Map;

class MengineFirebasePerformanceTraceProvider implements MenginePerformanceTraceProvider {
private Trace m_trace;
private final Trace m_trace;

MengineFirebasePerformanceTraceProvider(String name, Map<String, String> attributes) {
m_trace = FirebasePerformance.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public void onCreate(@NonNull MengineActivity activity, Bundle savedInstanceStat
GamesSignInClient gamesSignInClient = PlayGames.getGamesSignInClient(activity);

gamesSignInClient.isAuthenticated().addOnCompleteListener(isAuthenticatedTask -> {
if (isAuthenticatedTask.isSuccessful() == false) {
boolean isAuthenticated = isAuthenticatedTask.isSuccessful();

if (isAuthenticated == false) {
Exception e = isAuthenticatedTask.getException();

this.logError("[ERROR] google game social isAuthenticated failed: %s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ protected void parseInternalLocalNotifications(MengineActivity activity) {

return;
} catch (final IOException e) {
this.logError("[LOCAL_NOTIFICATIOINS] XmlPullParserException: %s"
this.logError("[LOCAL_NOTIFICATIOINS] IOException: %s"
, e.getMessage()
);

Expand Down

0 comments on commit 4a0b0ac

Please sign in to comment.