Commit 9be61a4a authored by mengcuiguang's avatar mengcuiguang

添加topon广告

parent 99429a9b
......@@ -132,6 +132,12 @@ android {
dirs 'libs'
}
}
sourceSets {
main {
res.srcDirs += 'topon_res'
}
}
}
dependencies {
......@@ -221,8 +227,12 @@ dependencies {
// 移动安全联盟
implementation(name: 'msa_mdid_1.0.13', ext: 'aar')
// 优量汇
implementation(name: 'GDTSDK.unionNormal.4.232.1102', ext: 'aar')
// implementation(name: 'GDTSDK.unionNoPlugin.4.270.1140', ext: 'aar')
// TopOn
api fileTree(include: ['*.jar','*.aar'], dir: 'topon_libs')
api 'androidx.browser:browser:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
......
......@@ -410,3 +410,29 @@
# ======================= 高德地图 END ================
# ===================== TopOn START ================
-keep class com.androidquery.callback.** {*;}
-keep class com.ss.sys.ces.* {*;}
-keep class com.bytedance.sdk.openadsdk.** { *; }
-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}
-keep class com.pgl.sys.ces.* {*;}
-keep class com.qq.e.** {
public protected *;
}
-keep class android.support.v4.**{
public *;
}
-keep class android.support.v7.**{
public *;
}
-keep class MTT.ThirdAppInfoNew {
*;
}
-keep class com.tencent.** {
*;
}
-dontwarn dalvik.**
-dontwarn com.tencent.smtt.**
# ======================= TopOn END ================
\ No newline at end of file
......@@ -76,7 +76,7 @@
android:value="${SHARE_SECRET}" />
<activity
android:name=".ui.activitys.SplashYlhActivity"
android:name=".ui.activitys.SplashAdShowActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:theme="@style/AppTheme.TranslucentSplish">
<intent-filter>
......@@ -86,13 +86,10 @@
</intent-filter>
</activity>
<activity
android:name=".ui.activitys.SplashADActivity"
android:name=".ui.activitys.SplashBackActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:theme="@style/AppTheme.TranslucentSplish">
</activity>
<activity
android:name=".ui.activitys.SplashActivity"
android:theme="@style/AppTheme.TranslucentSplish"/>
<activity android:name="com.mints.xunmi.ui.activitys.GuideActivity" />
<activity
android:name=".ui.activitys.LoginActivity"
......@@ -261,20 +258,46 @@
<uses-library
android:name="org.apache.http.legacy"
android:required="false" /> <!-- 声明SDK所需要的组件 -->
<service
android:name="com.qq.e.comm.DownloadService"
<!-- <service-->
<!-- android:name="com.qq.e.comm.DownloadService"-->
<!-- android:exported="false" />-->
<!-- <activity-->
<!-- android:name="com.qq.e.ads.ADActivity"-->
<!-- android:configChanges="keyboard|keyboardHidden|orientation|screenSize" />-->
<!-- <activity-->
<!-- android:name="com.qq.e.ads.PortraitADActivity"-->
<!-- android:configChanges="keyboard|keyboardHidden|orientation|screenSize"-->
<!-- android:screenOrientation="portrait" />-->
<!-- <activity-->
<!-- android:name="com.qq.e.ads.LandscapeADActivity"-->
<!-- tools:replace="android:screenOrientation"-->
<!-- android:configChanges="keyboard|keyboardHidden|orientation|screenSize"-->
<!-- android:screenOrientation="landscape" />-->
<provider
android:name="com.bytedance.sdk.openadsdk.multipro.TTMultiProvider"
android:authorities="${applicationId}.TTMultiProvider"
android:exported="false" />
<activity
android:name="com.qq.e.ads.ADActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" />
<activity
android:name="com.qq.e.ads.PortraitADActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity
android:name="com.qq.e.ads.LandscapeADActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape" />
<provider
android:name="com.bytedance.sdk.openadsdk.TTFileProvider"
android:authorities="${applicationId}.TTFileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/anythink_bk_tt_file_path" />
</provider>
<!-- network type: china/network_sdk/gdt/AndroidManifest.xml-->
<provider
android:name="com.qq.e.comm.GDTFileProvider"
android:authorities="${applicationId}.gdt.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/anythink_bk_gdt_file_path" />
</provider>
</application>
</manifest>
\ No newline at end of file
......@@ -3,6 +3,8 @@ package com.mints.xunmi;
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.webkit.WebView;
import androidx.annotation.NonNull;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
......@@ -18,6 +20,7 @@ import com.mints.xunmi.R;
import com.mints.xunmi.common.AppConfig;
import com.mints.xunmi.common.Constant;
import com.mints.xunmi.manager.MiitHelper;
import com.mints.xunmi.manager.TopOnManager;
import com.mints.xunmi.net.LoanService;
import com.mints.xunmi.utils.ForegroundOrBackground;
import com.mints.xunmi.utils.LogUtil;
......@@ -136,6 +139,14 @@ public class MintsApplication extends MultiDexApplication {
e.printStackTrace();
}
//Android 9 or above must be set
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
String processName = getProcessName();
if (!getPackageName().equals(processName)) {
WebView.setDataDirectorySuffix(processName);
}
}
// 机型适配
initRudenessScreen();
......@@ -161,7 +172,11 @@ public class MintsApplication extends MultiDexApplication {
initJLogin();
// 优量汇
initYlh();
// initYlh();
// topOn
TopOnManager.INSTANCE.init(this);
}
/**
......
package com.mints.xunmi.ad
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import com.anythink.core.api.ATAdConst
import com.anythink.core.api.ATAdInfo
import com.anythink.core.api.AdError
import com.anythink.nativead.api.*
import com.mints.xunmi.manager.TopOnManager
import com.mints.xunmi.ui.widgets.NativeDemoRender
import com.mints.xunmi.utils.LogUtil
import java.util.*
/**
* TopOn 信息流
*/
object TopOnNativeAd {
private val TAG = TopOnNativeAd::class.java.simpleName
var atNatives: ATNative? = null
var mNativeAd: NativeAd? = null
var anyThinkNativeAdView: ATNativeAdView? = null
var padding: Int = 0
var containerHeight: Int = 0
/**
* 应用初始化
*/
fun init(context: Context) {
atNatives = ATNative(context, TopOnManager.INFORMATION_ID, object : ATNativeNetworkListener {
override fun onNativeAdLoaded() {
LogUtil.e(TAG, "onNativeAdLoaded")
}
override fun onNativeAdLoadFail(adError: AdError) {
LogUtil.e(TAG, "onNativeAdLoadFail" + adError.desc)
}
})
padding = dip2px(context, 10f)
containerHeight = dip2px(context, 290f)
val adViewWidth: Int = context.getResources().getDisplayMetrics().widthPixels - 2 * padding
val adViewHeight = containerHeight - 2 * padding
val localMap: MutableMap<String, Any> = HashMap()
// since v5.6.4
localMap[ATAdConst.KEY.AD_WIDTH] = adViewWidth
localMap[ATAdConst.KEY.AD_HEIGHT] = adViewHeight
atNatives?.setLocalExtra(localMap)
if (anyThinkNativeAdView == null) {
anyThinkNativeAdView = ATNativeAdView(context)
}
anyThinkNativeAdView?.setPadding(padding, padding, padding, padding)
anyThinkNativeAdView?.setVisibility(View.GONE)
}
/**
* 预加载
*/
fun loadNativeAd(context: Context, frameLayout: FrameLayout?) {
atNatives?.makeAdRequest()
showNativeAd(context,frameLayout)
}
/**
* 显示
*/
fun showNativeAd(context: Context, frameLayout: FrameLayout?) {
val nativeAd = atNatives?.nativeAd
nativeAd?.let {
if (mNativeAd != null) {
mNativeAd!!.destory()
}
mNativeAd = nativeAd
// mNativeAd?.setNativeEventListener(object : ATNativeEventListener {
// override fun onAdVideoStart(view: ATNativeAdView) {
//
// }
//
// override fun onAdVideoProgress(view: ATNativeAdView, progress: Int) {
//
// }
//
// override fun onAdClicked(view: ATNativeAdView, entity: ATAdInfo) {
//
// }
//
// override fun onAdVideoEnd(view: ATNativeAdView) {
//
// }
//
// override fun onAdImpressed(view: ATNativeAdView, entity: ATAdInfo) {
//
// }
//
// })
mNativeAd?.let {
it.setDislikeCallbackListener(object : ATNativeDislikeListener() {
override fun onAdCloseButtonClick(view: ATNativeAdView, entity: ATAdInfo) {
if (view.parent != null) {
(view.parent as ViewGroup).removeView(view)
}
}
})
val anyThinkRender = NativeDemoRender(context)
try {
it.renderAdView(anyThinkNativeAdView, anyThinkRender)
} catch (e: Exception) {
}
anyThinkNativeAdView?.visibility = View.VISIBLE
it.prepare(anyThinkNativeAdView, anyThinkRender.getClickView(), null)
if (anyThinkNativeAdView != null && anyThinkNativeAdView!!.parent == null) {
frameLayout?.addView(anyThinkNativeAdView, FrameLayout.LayoutParams(context.getResources().getDisplayMetrics().widthPixels, containerHeight))
}
}
}
}
fun dip2px(context: Context, dipValue: Float): Int {
val scale: Float = context.getResources().getDisplayMetrics().density
return (dipValue * scale + 0.5f).toInt()
}
fun onResume() {
mNativeAd?.onResume()
}
fun onPause() {
mNativeAd?.onPause()
}
fun onDestroy() {
mNativeAd?.destory()
}
}
\ No newline at end of file
package com.mints.xunmi.manager
import android.app.Application
import android.content.Context
import com.anythink.core.api.ATSDK
import com.mints.xunmi.BuildConfig
object TopOnManager {
const val APP_ID = "a5fa16abbe82fd"
const val APP_KEY = "bff09f0aeb7e83af8611e5442bef8f33"
// 开屏
const val SPLASH_ID = "b5fa16e6f079e9"
// 信息流
const val INFORMATION_ID = "b5fa21527d2cb0"
fun init(context: Context) {
ATSDK.setNetworkLogDebug(BuildConfig.DEBUG)
ATSDK.init(context, APP_ID, APP_KEY);
}
}
\ No newline at end of file
......@@ -119,27 +119,27 @@ public class MainActivity extends BaseActivity implements MainView {
clickTab1Layout();
break;
case R.id.tab_iv_position:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
new RxPermissions(MainActivity.this)
.request(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
.subscribe(granted -> {
if (granted) {
// clickTab2Layout();
} else {
showMissingPermissionDialog("位置 权限");
}
});
} else {
new RxPermissions(MainActivity.this)
.request(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
.subscribe(granted -> {
if (granted) {
// clickTab2Layout();
} else {
showMissingPermissionDialog("位置 权限");
}
});
}
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// new RxPermissions(MainActivity.this)
// .request(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
// .subscribe(granted -> {
// if (granted) {
//// clickTab2Layout();
// } else {
// showMissingPermissionDialog("位置 权限");
// }
// });
// } else {
// new RxPermissions(MainActivity.this)
// .request(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
// .subscribe(granted -> {
// if (granted) {
//// clickTab2Layout();
// } else {
// showMissingPermissionDialog("位置 权限");
// }
// });
// }
clickTab2Layout();
......
package com.mints.xunmi.ui.activitys;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.anythink.core.api.ATAdInfo;
import com.anythink.core.api.ATMediationRequestInfo;
import com.anythink.core.api.AdError;
import com.anythink.splashad.api.ATSplashAd;
import com.anythink.splashad.api.ATSplashAdListener;
import com.mints.xunmi.R;
import com.mints.xunmi.common.Constant;
import com.mints.xunmi.common.DeviceInfo;
import com.mints.xunmi.manager.TopOnManager;
import com.mints.xunmi.ui.activitys.base.BaseActivity;
import com.mints.xunmi.utils.PreferencesService;
/**
* topon 开屏启动
*/
public class SplashAdShowActivity extends BaseActivity implements ATSplashAdListener {
ATSplashAd splashAd;
private PreferencesService ps;
private FrameLayout container;
@Override
protected int getContentViewLayoutID() {
return R.layout.splash_ad_show;
}
@Override
protected void initViewsAndEvents() {
if (!isTaskRoot()) {
//点击Home键后再点击App图标,会回到原来的界面。今天重新打包后,但是在Debug模式下,一切正常,
// 但是把打完包的apk(Release)安装在其他手机上时,回到桌面后点击图标会重新打开启动页
finish();
return;
}
container = findViewById(R.id.splash_ad_container);
ViewGroup.LayoutParams layoutParams = container.getLayoutParams();
/**You should set size to the layout param.**/
layoutParams.width = getResources().getDisplayMetrics().widthPixels;
layoutParams.height = (int) (getResources().getDisplayMetrics().heightPixels * 0.85);
ps = PreferencesService.getInstance(getApplicationContext());
pretreatmentVersion();
// 校验APP签名
checkAppSign();
}
/**
* 校验App签名
*/
private void checkAppSign() {
DeviceInfo deviceInfo = DeviceInfo.getDeviceInfo(getContext());
if (!deviceInfo.getSignInfo()) {
getBaseApplication().exitApp();
} else {
ATMediationRequestInfo atMediationRequestInfo = null;
splashAd = new ATSplashAd(this, container, TopOnManager.SPLASH_ID, atMediationRequestInfo, this);
}
}
/**
* 版本预处理
*/
private void pretreatmentVersion() {
PreferencesService.getInstance(getApplicationContext()).putInt(Constant.CUSTOM_VERSION, 1);
}
@Override
protected boolean isApplyKitKatTranslucency() {
return false;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (splashAd != null) {
splashAd.onDestory();
}
}
@Override
public void onAdLoaded() {
Log.i("SplashAdShowActivity", "onAdLoaded---------");
}
@Override
public void onNoAdError(AdError adError) {
Log.i("SplashAdShowActivity", "onNoAdError---------:" + adError.printStackTrace());
jumpToMainActivity();
}
@Override
public void onAdShow(ATAdInfo entity) {
Log.i("SplashAdShowActivity", "onAdShow:\n" + entity.toString());
}
private void skipViewSetting() {
final TextView skipView = findViewById(R.id.splash_ad_skip);
CountDownTimer countDownTimer = new CountDownTimer(5000L, 1000L) {
@Override
public void onTick(long millisUntilFinished) {
skipView.setText((millisUntilFinished / 1000) + " | 跳过");
}
@Override
public void onFinish() {
jumpToMainActivity();
}
};
countDownTimer.start();
skipView.setVisibility(View.VISIBLE);
skipView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
jumpToMainActivity();
}
});
}
@Override
public void onAdClick(ATAdInfo entity) {
Log.i("SplashAdShowActivity", "onAdClick:\n" + entity.toString());
}
@Override
public void onAdDismiss(ATAdInfo entity) {
Log.i("SplashAdShowActivity", "onAdDismiss:\n" + entity.toString());
jumpToMainActivity();
}
@Override
public void onAdTick(long millisUtilFinished) {
Log.i("SplashAdShowActivity", "onAdTick---------:" + millisUtilFinished);
}
boolean hasHandleJump = false;
public void jumpToMainActivity() {
if (!hasHandleJump) {
hasHandleJump = true;
int customVersion = ps.getInt(Constant.CUSTOM_VERSION);
boolean isFirstEnter = ps.getBoolean(Constant.ISFIRSTENTER + customVersion, true);
if (isFirstEnter) {
//跳转到引导界面
readyGoThenKill(GuideActivity.class);
} else {
//跳转到首页
readyGoThenKill(MainActivity.class);
}
}
}
}
package com.mints.xunmi.ui.activitys;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.anythink.core.api.ATAdInfo;
import com.anythink.core.api.ATMediationRequestInfo;
import com.anythink.core.api.AdError;
import com.anythink.splashad.api.ATSplashAd;
import com.anythink.splashad.api.ATSplashAdListener;
import com.mints.library.net.netstatus.NetUtils;
import com.mints.xunmi.R;
import com.mints.xunmi.common.Constant;
import com.mints.xunmi.common.DeviceInfo;
import com.mints.xunmi.manager.TopOnManager;
import com.mints.xunmi.ui.activitys.base.BaseActivity;
import com.mints.xunmi.utils.PreferencesService;
/**
* topon 开屏启动
*/
public class SplashBackActivity extends BaseActivity implements ATSplashAdListener {
ATSplashAd splashAd;
private FrameLayout container;
@Override
protected int getContentViewLayoutID() {
return R.layout.splash_ad_show;
}
@Override
protected void initViewsAndEvents() {
container = findViewById(R.id.splash_ad_container);
ViewGroup.LayoutParams layoutParams = container.getLayoutParams();
/**You should set size to the layout param.**/
layoutParams.width = getResources().getDisplayMetrics().widthPixels;
layoutParams.height = (int) (getResources().getDisplayMetrics().heightPixels * 0.85);
if (!NetUtils.isNetworkConnected(getContext())) {
finish();
} else {
ATMediationRequestInfo atMediationRequestInfo = null;
splashAd = new ATSplashAd(this, container, TopOnManager.SPLASH_ID, atMediationRequestInfo, this);
}
}
@Override
protected boolean isApplyKitKatTranslucency() {
return false;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (splashAd != null) {
splashAd.onDestory();
}
}
@Override
public void onAdLoaded() {
Log.i("SplashAdShowActivity", "onAdLoaded---------");
}
@Override
public void onNoAdError(AdError adError) {
Log.i("SplashAdShowActivity", "onNoAdError---------:" + adError.printStackTrace());
jumpToMainActivity();
}
@Override
public void onAdShow(ATAdInfo entity) {
Log.i("SplashAdShowActivity", "onAdShow:\n" + entity.toString());
}
private void skipViewSetting() {
final TextView skipView = findViewById(R.id.splash_ad_skip);
CountDownTimer countDownTimer = new CountDownTimer(5000L, 1000L) {
@Override
public void onTick(long millisUntilFinished) {
skipView.setText((millisUntilFinished / 1000) + " | 跳过");
}
@Override
public void onFinish() {
jumpToMainActivity();
}
};
countDownTimer.start();
skipView.setVisibility(View.VISIBLE);
skipView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
jumpToMainActivity();
}
});
}
@Override
public void onAdClick(ATAdInfo entity) {
Log.i("SplashAdShowActivity", "onAdClick:\n" + entity.toString());
}
@Override
public void onAdDismiss(ATAdInfo entity) {
Log.i("SplashAdShowActivity", "onAdDismiss:\n" + entity.toString());
jumpToMainActivity();
}
@Override
public void onAdTick(long millisUtilFinished) {
Log.i("SplashAdShowActivity", "onAdTick---------:" + millisUtilFinished);
}
boolean hasHandleJump = false;
public void jumpToMainActivity() {
if (!hasHandleJump) {
hasHandleJump = true;
finish();
}
}
}
......@@ -5,12 +5,14 @@ import android.os.Build
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import android.widget.FrameLayout
import androidx.recyclerview.widget.LinearLayoutManager
import com.mints.library.recyclerview.HeaderAndFooterRecyclerViewAdapter
import com.mints.library.recyclerview.RecyclerViewUtils
import com.mints.library.utils.nodoubleclick.AntiShake
import com.mints.xunmi.BuildConfig
import com.mints.xunmi.R
import com.mints.xunmi.ad.TopOnNativeAd
import com.mints.xunmi.common.AppConfig
import com.mints.xunmi.common.Constant
import com.mints.xunmi.manager.JpushLoginManager
......@@ -65,11 +67,17 @@ class MainFragment : BaseFragment()
initManager()
context?.let {
TopOnNativeAd.init(it)
TopOnNativeAd.loadNativeAd(it, null)
}
linearLayoutManager = LinearLayoutManager(activity)
rvMain.layoutManager = linearLayoutManager
initLinstener()
//非首次打开弹出 五拆弹窗
// if (spUtil != null && spUtil!!.getBoolean(Constant.FIRST_DEVICE_FLAG, false) &&
// TextUtils.equals(spUtil!!.getString(Constant.PAY_PAGE_TYPE), "fourPrice")) {
......
......@@ -15,6 +15,7 @@ import com.mints.library.net.netstatus.NetUtils
import com.mints.library.utils.nodoubleclick.AntiShake
import com.mints.xunmi.BuildConfig
import com.mints.xunmi.R
import com.mints.xunmi.ad.TopOnNativeAd
import com.mints.xunmi.common.AppConfig
import com.mints.xunmi.common.Constant
import com.mints.xunmi.manager.JpushLoginManager
......@@ -34,6 +35,8 @@ import com.mints.xunmi.utils.SPUtil
import com.mints.xunmi.utils.TimeRender
import kotlinx.android.synthetic.main.fragment_main_my.*
import me.shaohui.bottomdialog.BottomDialog
import java.util.*
import kotlin.concurrent.schedule
/**
* 描述:我
......@@ -88,9 +91,16 @@ class MyFragment : BaseFragment()
} else {
myPresenter?.userLogin(context!!)
}
// context?.let { TopOnNativeAd.loadNativeAd(it, flMyAdContainer) }
}
}
override fun onPause() {
super.onPause()
TopOnNativeAd.onPause()
}
private fun setUserLoginStatus(isLogin: Boolean, data: UserBean) {
val idcode = data.consumer.idcode
if (isLogin) {
......@@ -158,6 +168,7 @@ class MyFragment : BaseFragment()
override fun onDestroy() {
super.onDestroy()
TopOnNativeAd.onDestroy()
myPresenter.detachView()
}
......@@ -174,7 +185,7 @@ class MyFragment : BaseFragment()
}
}
override fun getSysBaseMsg(msgNum: Int, notifyNum: Int,phone:String) {
override fun getSysBaseMsg(msgNum: Int, notifyNum: Int, phone: String) {
if (activity != null && !activity!!.isFinishing()) {
// if (msgNum >= 1) {
// ivMyFragmentNofity.setImageResource(R.mipmap.ic_main_msg_enable)
......
package com.mints.xunmi.ui.fragment
import android.Manifest
import android.app.AlertDialog
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
......@@ -24,6 +29,7 @@ import com.mints.xunmi.ui.activitys.CarePeopleActivity
import com.mints.xunmi.ui.activitys.MyLocusActivity
import com.mints.xunmi.utils.LogUtil
import com.mints.xunmi.utils.TimeRender
import com.tbruyelle.rxpermissions.RxPermissions
import kotlinx.android.synthetic.main.fragment_main_position.*
import java.util.*
......@@ -79,6 +85,27 @@ class PositionFragment : Fragment()
initMapStyle()
initListener()
initRxPermissions()
}
private fun initRxPermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
RxPermissions(activity!!)
.request(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
.subscribe { granted: Boolean ->
if (!granted) {
showMissingPermissionDialog("位置 权限")
}
}
} else {
RxPermissions(activity!!)
.request(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
.subscribe { granted: Boolean ->
if (granted) {
showMissingPermissionDialog("位置 权限")
}
}
}
}
override fun onHiddenChanged(hidden: Boolean) {
......@@ -208,4 +235,32 @@ class PositionFragment : Fragment()
}
startActivity(intent)
}
/**
* 显示提示信息
*
* @since 2.5.0
*/
protected fun showMissingPermissionDialog(msg: String) {
val builder = AlertDialog.Builder(activity)
builder.setTitle(R.string.notifyTitle)
builder.setMessage("""
当前应用缺少 ${msg}授权
请点击 设置-权限-打开所需权限
""".trimIndent())
builder.setNegativeButton(R.string.cancel
) { dialog, which ->
}
builder.setPositiveButton(R.string.setting
) { dialog, which ->
val intent = Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.parse("package:" + activity?.getPackageName())
startActivity(intent)
}
builder.setCancelable(false)
builder.show()
}
}
\ No newline at end of file
package com.mints.xunmi.ui.widgets;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.anythink.nativead.api.ATNativeAdRenderer;
import com.anythink.nativead.api.ATNativeImageView;
import com.anythink.nativead.unitgroup.api.CustomNativeAd;
import com.mints.xunmi.R;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Z on 2018/1/18.
*/
public class NativeDemoRender implements ATNativeAdRenderer<CustomNativeAd> {
Context mContext;
List<View> mClickView = new ArrayList<>();
public NativeDemoRender(Context context) {
mContext = context;
}
View mDevelopView;
int mNetworkType;
@Override
public View createView(Context context, int networkType) {
if (mDevelopView == null) {
mDevelopView = LayoutInflater.from(context).inflate(R.layout.native_ad_item, null);
}
mNetworkType = networkType;
if (mDevelopView.getParent() != null) {
((ViewGroup) mDevelopView.getParent()).removeView(mDevelopView);
}
return mDevelopView;
}
@Override
public void renderAdView(View view, CustomNativeAd ad) {
mClickView.clear();
TextView titleView = (TextView) view.findViewById(R.id.native_ad_title);
TextView descView = (TextView) view.findViewById(R.id.native_ad_desc);
TextView ctaView = (TextView) view.findViewById(R.id.native_ad_install_btn);
TextView adFromView = (TextView) view.findViewById(R.id.native_ad_from);
FrameLayout contentArea = (FrameLayout) view.findViewById(R.id.native_ad_content_image_area);
FrameLayout iconArea = (FrameLayout) view.findViewById(R.id.native_ad_image);
final ATNativeImageView logoView = (ATNativeImageView) view.findViewById(R.id.native_ad_logo);
titleView.setText("");
descView.setText("");
ctaView.setText("");
adFromView.setText("");
titleView.setText("");
contentArea.removeAllViews();
iconArea.removeAllViews();
logoView.setImageDrawable(null);
View mediaView = ad.getAdMediaView(contentArea, contentArea.getWidth());
if (ad.isNativeExpress()) {//是 个性化模板
titleView.setVisibility(View.GONE);
descView.setVisibility(View.GONE);
ctaView.setVisibility(View.GONE);
logoView.setVisibility(View.GONE);
iconArea.setVisibility(View.GONE);
if (mediaView.getParent() != null) {
((ViewGroup) mediaView.getParent()).removeView(mediaView);
}
contentArea.addView(mediaView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
return;
}
titleView.setVisibility(View.VISIBLE);
descView.setVisibility(View.VISIBLE);
ctaView.setVisibility(View.VISIBLE);
logoView.setVisibility(View.VISIBLE);
iconArea.setVisibility(View.VISIBLE);
View adiconView = ad.getAdIconView();
final ATNativeImageView iconView = new ATNativeImageView(mContext);
if (adiconView == null) {
iconArea.addView(iconView);
iconView.setImage(ad.getIconImageUrl());
mClickView.add(iconView);
} else {
iconArea.addView(adiconView);
}
if (!TextUtils.isEmpty(ad.getAdChoiceIconUrl())) {
logoView.setImage(ad.getAdChoiceIconUrl());
} else {
// logoView.setImageResource(R.drawable.ad_logo);
}
if (mediaView != null) {
if (mediaView.getParent() != null) {
((ViewGroup) mediaView.getParent()).removeView(mediaView);
}
contentArea.addView(mediaView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
} else {
ATNativeImageView imageView = new ATNativeImageView(mContext);
imageView.setImage(ad.getMainImageUrl());
ViewGroup.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
imageView.setLayoutParams(params);
contentArea.addView(imageView, params);
mClickView.add(imageView);
}
titleView.setText(ad.getTitle());
descView.setText(ad.getDescriptionText());
ctaView.setText(ad.getCallToActionText());
if (!TextUtils.isEmpty(ad.getAdFrom())) {
adFromView.setText(ad.getAdFrom() != null ? ad.getAdFrom() : "");
adFromView.setVisibility(View.VISIBLE);
} else {
adFromView.setVisibility(View.GONE);
}
mClickView.add(titleView);
mClickView.add(descView);
mClickView.add(ctaView);
}
public List<View> getClickView() {
return mClickView;
}
}
......@@ -7,10 +7,8 @@ import android.os.Bundle;
import android.text.TextUtils;
import com.mints.xunmi.common.AppConfig;
import com.mints.xunmi.manager.TrackManager;
import com.mints.xunmi.mvp.presenters.VersionUpdatePresenter;
import com.mints.xunmi.mvp.presenters.VersionUpdatePresenter;
import com.mints.xunmi.ui.activitys.SplashADActivity;
import com.mints.xunmi.ui.activitys.SplashBackActivity;
import java.lang.ref.WeakReference;
......@@ -93,7 +91,7 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
return;
String simpleName = activity.getClass().getSimpleName();
if (TextUtils.equals(simpleName, "SplashYlhActivity") ||
if (TextUtils.equals(simpleName, "SplashAdShowActivity") ||
TextUtils.equals(simpleName, "GuideActivity") ||
TextUtils.equals(simpleName, "CarePeopleActivity") ||
TextUtils.equals(simpleName, "VipActivity") ||
......@@ -104,7 +102,7 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
}
if (count == 0) {
activity.startActivity(new Intent(activity, SplashADActivity.class));
activity.startActivity(new Intent(activity, SplashBackActivity.class));
}
count++;
}
......
......@@ -384,6 +384,12 @@
android:layout_marginLeft="100pt"
android:background="#E1E1E1" />
<FrameLayout
android:id="@+id/flMyAdContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"></FrameLayout>
<ImageView
android:id="@+id/ivMyBanner"
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff">
<!--<TextView-->
<!--android:id="@+id/native_ad_install_btn"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_alignEnd="@+id/native_ad_content_image_area"-->
<!--android:layout_alignRight="@+id/native_ad_content_image_area"-->
<!--android:layout_below="@+id/native_ad_title"-->
<!--android:background="#888888"-->
<!--android:paddingBottom="5dp"-->
<!--android:paddingLeft="15dp"-->
<!--android:paddingRight="15dp"-->
<!--android:paddingTop="5dp"-->
<!--android:textColor="@android:color/white"-->
<!--android:textSize="11dp"-->
<!--android:visibility="gone"/>-->
<FrameLayout
android:id="@+id/native_ad_image"
android:layout_width="45dp"
android:layout_height="45dp"
android:scaleType="fitCenter"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_alignParentBottom="true"
>
</FrameLayout>
<TextView
android:id="@+id/native_ad_install_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/native_ad_image"
android:layout_alignBottom="@id/native_ad_image"
android:layout_alignParentRight="true"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_marginLeft="10dp"
android:background="#2095F1"
android:gravity="center"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/native_ad_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/native_ad_image"
android:layout_alignTop="@id/native_ad_image"
android:layout_toLeftOf="@id/native_ad_install_btn"
android:ellipsize="end"
android:textColor="#000000"
android:textSize="15dp"
android:textStyle="bold"
android:maxLines="1"/>
<TextView
android:id="@+id/native_ad_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/native_ad_image"
android:layout_toLeftOf="@id/native_ad_install_btn"
android:layout_alignBottom="@id/native_ad_image"
android:ellipsize="end"
android:maxLines="1"
android:textColor="#777777"
android:textSize="12dp"/>
<FrameLayout
android:id="@+id/native_ad_content_image_area"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/native_ad_image"
>
</FrameLayout>
<com.anythink.nativead.api.ATNativeImageView
android:id="@+id/native_ad_logo"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentRight="true"
android:visibility="gone" />
<ImageView
android:id="@+id/native_self_adlogo"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginLeft="2dp"/>
<TextView
android:id="@+id/native_ad_from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/native_ad_logo"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_toLeftOf="@id/native_self_adlogo"
android:background="#888888"
android:gravity="center"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textColor="#ffffff"
android:textSize="6dp" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<FrameLayout
android:id="@+id/splash_ad_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"></FrameLayout>
<TextView
android:id="@+id/splash_ad_skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textColor="#ffffff"
android:textSize="16dp"
android:visibility="gone"></TextView>
<LinearLayout
android:id="@+id/logo_area"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:padding="20dp"
android:orientation="horizontal"
android:gravity="center"
android:layout_below="@id/splash_ad_container"
>
<ImageView
android:id="@+id/app_logo"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@mipmap/ic_launcher"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:gravity="center_horizontal"
android:text="寻 | 蜜 | 守 | 护"
android:textColor="#000000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:gravity="center_horizontal"
android:layout_marginTop="6dp"
android:text="寻找幸福守护甜蜜"
android:textColor="@color/main_mints"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="gdt_sdk_download_path" path="GDTDOWNLOAD" />
<root-path name="root" path="" />
<external-cache-path
name="gdt_sdk_download_path1"
path="com_qq_e_download" />
<cache-path
name="gdt_sdk_download_path2"
path="com_qq_e_download" />
</paths>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="tt_external_root" path="." />
<external-path name="tt_external_download" path="Download" />
<external-files-path name="tt_external_files_download" path="Download" />
<files-path name="tt_internal_file_download" path="Download" />
<cache-path name="tt_internal_cache_download" path="Download" />
<root-path name="root" path="" />
</paths>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment