去除 广告
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@@ -156,5 +156,4 @@ dependencies {
|
|||||||
implementation project(':automator')
|
implementation project(':automator')
|
||||||
implementation project(':common')
|
implementation project(':common')
|
||||||
implementation project(':autojs')
|
implementation project(':autojs')
|
||||||
implementation (name: 'ads8', ext: 'aar')
|
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -6,17 +6,5 @@ package org.autojs.autojs;
|
|||||||
|
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
|
|
||||||
public static final int AD_TYPE_RANDOM = 0;
|
|
||||||
public static final int AD_TYPE_NEWS = 1;
|
|
||||||
public static final int AD_TYPE_SOCIAL = 2;
|
|
||||||
public static final int AD_TYPE_ANIMATION = 3;
|
|
||||||
public static final int AD_TYPE_GAMES = 4;
|
|
||||||
|
|
||||||
public static final int UMENG_ID_NEWS = 36787;
|
|
||||||
public static final int UMENG_ID_SOCIAL = 36785;
|
|
||||||
public static final int UMENG_ID_ANIMATION = 36781;
|
|
||||||
public static final int UMENG_ID_GAMES = 36615;
|
|
||||||
|
|
||||||
public static final int[] UMENG_IDS = {UMENG_ID_NEWS, UMENG_ID_SOCIAL, UMENG_ID_ANIMATION, UMENG_ID_GAMES};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ public class Pref {
|
|||||||
private static final SharedPreferences DISPOSABLE_BOOLEAN = GlobalAppContext.get().getSharedPreferences("DISPOSABLE_BOOLEAN", Context.MODE_PRIVATE);
|
private static final SharedPreferences DISPOSABLE_BOOLEAN = GlobalAppContext.get().getSharedPreferences("DISPOSABLE_BOOLEAN", Context.MODE_PRIVATE);
|
||||||
private static final String KEY_SERVER_ADDRESS = "KEY_SERVER_ADDRESS";
|
private static final String KEY_SERVER_ADDRESS = "KEY_SERVER_ADDRESS";
|
||||||
private static final String KEY_SHOULD_SHOW_ANNUNCIATION = "KEY_SHOULD_SHOW_ANNUNCIATION";
|
private static final String KEY_SHOULD_SHOW_ANNUNCIATION = "KEY_SHOULD_SHOW_ANNUNCIATION";
|
||||||
private static final String KEY_FIRST_SHOW_AD = "KEY_FIRST_SHOW_AD";
|
|
||||||
private static final String KEY_LAST_SHOW_AD_MILLIS = "KEY_LAST_SHOW_AD_MILLIS";
|
|
||||||
private static final String KEY_FLOATING_MENU_SHOWN = "KEY_FLOATING_MENU_SHOWN";
|
private static final String KEY_FLOATING_MENU_SHOWN = "KEY_FLOATING_MENU_SHOWN";
|
||||||
private static final String KEY_EDITOR_THEME = "editor.theme";
|
private static final String KEY_EDITOR_THEME = "editor.theme";
|
||||||
private static final String KEY_EDITOR_TEXT_SIZE = "editor.textSize";
|
private static final String KEY_EDITOR_TEXT_SIZE = "editor.textSize";
|
||||||
@@ -105,34 +103,6 @@ public class Pref {
|
|||||||
return getDisposableBoolean(KEY_SHOULD_SHOW_ANNUNCIATION, true);
|
return getDisposableBoolean(KEY_SHOULD_SHOW_ANNUNCIATION, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldShowAd() {
|
|
||||||
if (isFirstDay()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String adShowingMode = def().getString(getString(R.string.key_ad_showing_mode), "Default");
|
|
||||||
switch (adShowingMode) {
|
|
||||||
case "Default":
|
|
||||||
return true;
|
|
||||||
case "OncePerDay":
|
|
||||||
long lastShowMillis = def().getLong(KEY_LAST_SHOW_AD_MILLIS, 0);
|
|
||||||
if (System.currentTimeMillis() - lastShowMillis < TimeUnit.DAYS.toMillis(1)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
def().edit().putLong(KEY_LAST_SHOW_AD_MILLIS, System.currentTimeMillis()).apply();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getAdType() {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(def().getString(getString(R.string.key_ad_type), String.valueOf(Constants.AD_TYPE_RANDOM)));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return Constants.AD_TYPE_RANDOM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isFirstDay() {
|
private static boolean isFirstDay() {
|
||||||
long firstUsingMillis = def().getLong("firstUsingMillis", -1);
|
long firstUsingMillis = def().getLong("firstUsingMillis", -1);
|
||||||
if (firstUsingMillis == -1) {
|
if (firstUsingMillis == -1) {
|
||||||
@@ -142,16 +112,6 @@ public class Pref {
|
|||||||
return System.currentTimeMillis() - firstUsingMillis <= TimeUnit.DAYS.toMillis(1);
|
return System.currentTimeMillis() - firstUsingMillis <= TimeUnit.DAYS.toMillis(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFirstShowingAd() {
|
|
||||||
return getDisposableBoolean(KEY_FIRST_SHOW_AD, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isRecordWithRootEnabled() {
|
|
||||||
//always return true after version 3.0.0
|
|
||||||
//record without root has been deprecated
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isRecordToastEnabled() {
|
public static boolean isRecordToastEnabled() {
|
||||||
return def().getBoolean(getString(R.string.key_record_toast), true);
|
return def().getBoolean(getString(R.string.key_record_toast), true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,138 +1,62 @@
|
|||||||
package org.autojs.autojs.ui.splash;
|
package org.autojs.autojs.ui.splash;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.app.AppCompatDelegate;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.xcy8.ads.listener.LoadAdListener;
|
|
||||||
import com.xcy8.ads.view.FullScreenAdView;
|
|
||||||
|
|
||||||
import org.autojs.autojs.Constants;
|
|
||||||
import org.autojs.autojs.Pref;
|
|
||||||
import org.autojs.autojs.R;
|
import org.autojs.autojs.R;
|
||||||
import org.autojs.autojs.ui.BaseActivity;
|
import org.autojs.autojs.ui.BaseActivity;
|
||||||
import org.autojs.autojs.ui.main.MainActivity_;
|
import org.autojs.autojs.ui.main.MainActivity_;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/7/7.
|
* Created by Stardust on 2017/7/7.
|
||||||
*/
|
*/
|
||||||
public class SplashActivity extends BaseActivity {
|
public class SplashActivity extends BaseActivity {
|
||||||
|
|
||||||
public static final String NOT_START_MAIN_ACTIVITY = "notStartMainActivity";
|
|
||||||
public static final String FORCE_SHOW_AD = "forceShowAd";
|
|
||||||
|
|
||||||
private static final String LOG_TAG = SplashActivity.class.getSimpleName();
|
private static final String LOG_TAG = SplashActivity.class.getSimpleName();
|
||||||
private static final long INIT_TIMEOUT = 500;
|
private static final long INIT_TIMEOUT = 800;
|
||||||
|
|
||||||
|
|
||||||
private boolean mCanEnterNextActivity = false;
|
|
||||||
private boolean mNotStartMainActivity;
|
|
||||||
private boolean mAlreadyEnterNextActivity = false;
|
private boolean mAlreadyEnterNextActivity = false;
|
||||||
private boolean mAdLoading = false;
|
private boolean mPaused;
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
|
|
||||||
FullScreenAdView mFullScreenAdView;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
init();
|
init();
|
||||||
boolean forceShowAd = getIntent().getBooleanExtra(FORCE_SHOW_AD, false);
|
|
||||||
if (!forceShowAd && !Pref.shouldShowAd()) {
|
|
||||||
mFullScreenAdView.setVisibility(View.INVISIBLE);
|
|
||||||
} else {
|
|
||||||
if (checkPermission(Manifest.permission.READ_PHONE_STATE)) {
|
|
||||||
fetchSplashAD();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mHandler.postDelayed(SplashActivity.this::enterNextActivity, INIT_TIMEOUT);
|
mHandler.postDelayed(SplashActivity.this::enterNextActivity, INIT_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
setContentView(R.layout.activity_splash);
|
setContentView(R.layout.activity_splash);
|
||||||
mFullScreenAdView = findViewById(R.id.full_screen_view);
|
|
||||||
mHandler = new Handler();
|
mHandler = new Handler();
|
||||||
mNotStartMainActivity = getIntent().getBooleanExtra(NOT_START_MAIN_ACTIVITY, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void enterNextActivity() {
|
|
||||||
if (mAlreadyEnterNextActivity)
|
|
||||||
return;
|
|
||||||
mAlreadyEnterNextActivity = true;
|
|
||||||
if (!mNotStartMainActivity)
|
|
||||||
MainActivity_.intent(this).start();
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
//enterNextActivityIfNeeded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mCanEnterNextActivity = false;
|
mPaused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterNextActivityIfNeeded() {
|
@Override
|
||||||
if (mCanEnterNextActivity) {
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (mPaused) {
|
||||||
|
mPaused = false;
|
||||||
enterNextActivity();
|
enterNextActivity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void enterNextActivity() {
|
||||||
|
if (mAlreadyEnterNextActivity)
|
||||||
|
return;
|
||||||
|
if (mPaused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mCanEnterNextActivity = true;
|
mAlreadyEnterNextActivity = true;
|
||||||
|
MainActivity_.intent(this).start();
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
fetchSplashAD();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchSplashAD() {
|
|
||||||
mAdLoading = true;
|
|
||||||
mFullScreenAdView.setFullScreenListener(this::enterNextActivity);
|
|
||||||
mFullScreenAdView.setLoadAdListener(new LoadAdListener() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess() {
|
|
||||||
mAdLoading = false;
|
|
||||||
Log.d(LOG_TAG, "onAdLoadSuccess");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(String s) {
|
|
||||||
mAdLoading = false;
|
|
||||||
Log.e(LOG_TAG, "onAdLoadFailure: " + s);
|
|
||||||
enterNextActivity();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mHandler.postDelayed(() -> {
|
|
||||||
if (mAdLoading) {
|
|
||||||
enterNextActivity();
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
mFullScreenAdView.loadAd(getAdId(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getAdId() {
|
|
||||||
int type = Pref.getAdType();
|
|
||||||
int id = type >= 1 && type <= Constants.UMENG_IDS.length ? Constants.UMENG_IDS[type - 1]
|
|
||||||
: Constants.UMENG_IDS[new Random().nextInt(Constants.UMENG_IDS.length)];
|
|
||||||
return String.valueOf(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
mFullScreenAdView.clean();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
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"
|
||||||
android:background="@android:color/white"
|
android:background="@android:color/white"
|
||||||
@@ -13,11 +12,6 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<com.xcy8.ads.view.FullScreenAdView
|
|
||||||
android:id="@+id/full_screen_view"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<android.support.design.widget.AppBarLayout
|
<android.support.design.widget.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="AppTheme">
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<android.support.design.widget.AppBarLayout
|
<android.support.design.widget.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="AppTheme">
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
|
|||||||
Reference in New Issue
Block a user