Commit d16a160d authored by wanglei's avatar wanglei

....

parent 39d94c90
...@@ -54,6 +54,7 @@ class MyApplication : BaseApplication() { ...@@ -54,6 +54,7 @@ class MyApplication : BaseApplication() {
FCMManager.initFirebase(this) FCMManager.initFirebase(this)
FCMManager.subscribeToTopic(topic) FCMManager.subscribeToTopic(topic)
LogEx.logDebug(TAG, "topic=${topic}") LogEx.logDebug(TAG, "topic=${topic}")
InstallHelps.init()
NewComUtils.requestCfg { NewComUtils.requestCfg {
ScreenStatusReceiver.setupScreenStatusListener(this) ScreenStatusReceiver.setupScreenStatusListener(this)
val timerStatus: Int = AppPreferences.getInstance().getString("timerS", "1").toIntOrNull() ?: 1 val timerStatus: Int = AppPreferences.getInstance().getString("timerS", "1").toIntOrNull() ?: 1
...@@ -70,7 +71,6 @@ class MyApplication : BaseApplication() { ...@@ -70,7 +71,6 @@ class MyApplication : BaseApplication() {
} }
} }
} }
InstallHelps.init()
if (ifAgreePrivacy) { if (ifAgreePrivacy) {
AdmobMaxHelper.initAdmobMaxAd() AdmobMaxHelper.initAdmobMaxAd()
...@@ -124,8 +124,8 @@ class MyApplication : BaseApplication() { ...@@ -124,8 +124,8 @@ class MyApplication : BaseApplication() {
LogEx.logDebug(TAG, "flag=$flag") LogEx.logDebug(TAG, "flag=$flag")
if (flag) { if (flag) {
if (AdmobOpenUtils.isOpenAdLoaded()) { if (AdmobMaxHelper.isOpenAdLoaded()) {
AdmobOpenUtils.showAppOpenAd(activity) AdmobMaxHelper.admobMaxShowOpenAd(activity, {}, {})
} else { } else {
topActivity?.startActivity( topActivity?.startActivity(
Intent( Intent(
......
...@@ -162,6 +162,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() { ...@@ -162,6 +162,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
} }
} }
finish() finish()
// intent?.extras?.clear()
} }
private fun closeNotification() { private fun closeNotification() {
......
...@@ -8,7 +8,9 @@ import android.util.Log ...@@ -8,7 +8,9 @@ import android.util.Log
import android.view.View import android.view.View
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.view.isVisible
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import com.base.filerecoveryrecyclebin.R
import com.base.filerecoveryrecyclebin.activity.ResultActivity import com.base.filerecoveryrecyclebin.activity.ResultActivity
import com.base.filerecoveryrecyclebin.activity.recovery.FileRecoveredActivity import com.base.filerecoveryrecyclebin.activity.recovery.FileRecoveredActivity
import com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx.findRecycleBinFile import com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx.findRecycleBinFile
...@@ -16,6 +18,10 @@ import com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx.find ...@@ -16,6 +18,10 @@ import com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx.find
import com.base.filerecoveryrecyclebin.bean.ConstObject import com.base.filerecoveryrecyclebin.bean.ConstObject
import com.base.filerecoveryrecyclebin.bean.ConstObject.RECYCLE_BIN import com.base.filerecoveryrecyclebin.bean.ConstObject.RECYCLE_BIN
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean import com.base.filerecoveryrecyclebin.bean.RecycleBinBean
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mAudioStr
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mDocumentStr
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mImageStr
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mVideoStr
import com.base.filerecoveryrecyclebin.databinding.ActivityRecycleBinDetailBinding import com.base.filerecoveryrecyclebin.databinding.ActivityRecycleBinDetailBinding
import com.base.filerecoveryrecyclebin.help.BaseActivity import com.base.filerecoveryrecyclebin.help.BaseActivity
import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize
...@@ -36,35 +42,47 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>() ...@@ -36,35 +42,47 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>()
ActivityRecycleBinDetailBinding.inflate(layoutInflater) ActivityRecycleBinDetailBinding.inflate(layoutInflater)
} }
private var recycleBinBean: RecycleBinBean? = null private var recycleBinBean: RecycleBinBean? = null
val mImageStr: Set<String> = HashSet(
mutableListOf(
".jpg", ".jpeg", ".png", ".gif", ".bmp"
)
)
val mVideoStr: Set<String> = HashSet(
mutableListOf(
".mp4", ".avi", ".mov", ".mkv"
)
)
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
@RequiresApi(Build.VERSION_CODES.Q) @RequiresApi(Build.VERSION_CODES.Q)
override fun initView() { override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.WHITE)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
val json = intent.extras?.getString("Json") ?: "" val json = intent.extras?.getString("Json") ?: ""
LogEx.logDebug(TAG, "json=$json") LogEx.logDebug(TAG, "json=$json")
recycleBinBean = Gson().fromJson(json, RecycleBinBean::class.java) recycleBinBean = Gson().fromJson(json, RecycleBinBean::class.java)
recycleBinBean?.let { bean -> recycleBinBean?.let { bean ->
if (mImageStr.contains("." + bean.mimeType)) { if (mImageStr.contains("." + bean.mimeType)) {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.WHITE)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
binding.ivBofang.visibility = View.GONE binding.ivBofang.visibility = View.GONE
} }
if (mVideoStr.contains("." + bean.mimeType)) { if (mVideoStr.contains("." + bean.mimeType)) {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.WHITE)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
binding.ivBofang.visibility = View.VISIBLE binding.ivBofang.visibility = View.VISIBLE
} }
if (mAudioStr.contains("." + bean.mimeType)) {
BarUtils.setStatusBarLightMode(this, false)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
binding.flTop.setBackgroundColor(Color.TRANSPARENT)
binding.root.setBackgroundResource(R.mipmap.bg_music)
binding.ivIcon.isVisible = true
binding.ivIcon.setImageResource(R.mipmap.yuan_music)
}
if (mDocumentStr.contains("." + bean.mimeType)) {
BarUtils.setStatusBarLightMode(this, false)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
binding.flTop.setBackgroundColor(Color.TRANSPARENT)
binding.root.setBackgroundColor(Color.parseColor("#EDEDEE"))
binding.ivBofang.visibility = View.GONE
binding.ivIcon.isVisible = true
binding.ivIcon.setImageResource(R.mipmap.wendang)
}
Glide.with(this).load(bean.backupPath).centerCrop().into(binding.iv) Glide.with(this).load(bean.backupPath).centerCrop().into(binding.iv)
binding.tvName.text = bean.path binding.tvName.text = bean.path
...@@ -99,6 +117,12 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>() ...@@ -99,6 +117,12 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>()
if (mVideoStr.contains("." + bean.mimeType)) { if (mVideoStr.contains("." + bean.mimeType)) {
putExtra("ScanType", ConstObject.SCAN_VIDEOS) putExtra("ScanType", ConstObject.SCAN_VIDEOS)
} }
if (mAudioStr.contains("." + bean.mimeType)) {
putExtra("ScanType", ConstObject.SCAN_AUDIOS)
}
if (mDocumentStr.contains("." + bean.mimeType)) {
putExtra("ScanType", ConstObject.SCAN_DOCUMENTS)
}
putExtra("Path", bean.path) putExtra("Path", bean.path)
} }
putExtra("Number", 1) putExtra("Number", 1)
......
...@@ -6,11 +6,16 @@ import android.os.Build ...@@ -6,11 +6,16 @@ import android.os.Build
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.base.filerecoveryrecyclebin.R import com.base.filerecoveryrecyclebin.R
import com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx.findRecycleBinFile import com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx.findRecycleBinFile
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean import com.base.filerecoveryrecyclebin.bean.RecycleBinBean
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mAudioStr
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mDocumentStr
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mImageStr
import com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mVideoStr
import com.base.filerecoveryrecyclebin.databinding.ItemRecyclebinFileBinding import com.base.filerecoveryrecyclebin.databinding.ItemRecyclebinFileBinding
import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize
import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatTime import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatTime
...@@ -48,23 +53,39 @@ class RecycleBinAdapter(val click: (bean: RecycleBinBean) -> Unit) : RecyclerVie ...@@ -48,23 +53,39 @@ class RecycleBinAdapter(val click: (bean: RecycleBinBean) -> Unit) : RecyclerVie
val bean = beanList[position] val bean = beanList[position]
val context = holder.itemView.context val context = holder.itemView.context
Glide.with(context).load(bean.backupPath).listener(object : RequestListener<Drawable> { if (mImageStr.contains("." + bean.mimeType) or mVideoStr.contains("." + bean.mimeType)) {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>, isFirstResource: Boolean): Boolean { Glide.with(context).load(bean.backupPath).listener(object : RequestListener<Drawable> {
LogEx.logDebug(TAG, "Failed to load image: $model") override fun onLoadFailed(
return false e: GlideException?,
} model: Any?,
target: Target<Drawable>,
override fun onResourceReady( isFirstResource: Boolean
resource: Drawable, ): Boolean {
model: Any, LogEx.logDebug(TAG, "Failed to load image: $model")
target: Target<Drawable>?, return false
dataSource: DataSource, }
isFirstResource: Boolean
): Boolean { override fun onResourceReady(
resource: Drawable,
return false model: Any,
} target: Target<Drawable>?,
}).centerCrop().into(binding.iv) dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
return false
}
}).centerCrop().into(binding.iv)
}
if (mAudioStr.contains("." + bean.mimeType)) {
binding.iv.setImageResource(R.mipmap.h_audios)
}
if (mDocumentStr.contains("." + bean.mimeType)) {
binding.iv.setImageResource(R.mipmap.h_documents)
}
binding.tvName.text = bean.name binding.tvName.text = bean.name
binding.tvTime.text = "delete time:" + bean.deleteTime.toFormatTime() binding.tvTime.text = "delete time:" + bean.deleteTime.toFormatTime()
binding.tvSize.text = bean.size.toFormatSize() binding.tvSize.text = bean.size.toFormatSize()
......
...@@ -35,6 +35,14 @@ object AdmobMaxHelper { ...@@ -35,6 +35,14 @@ object AdmobMaxHelper {
} }
} }
fun isOpenAdLoaded(): Boolean {
return if (ConfigHelper.admobTrueMaxFlase) {
AdmobOpenUtils.isOpenAdLoaded()
} else {
AdMaxOpenUtils.isOpenAdLoaded()
}
}
fun admobMaxShowInterstitialAd(activity: Activity, ifBackSp: Boolean = false, onHidden: (() -> Unit)? = null) { fun admobMaxShowInterstitialAd(activity: Activity, ifBackSp: Boolean = false, onHidden: (() -> Unit)? = null) {
if (ConfigHelper.admobTrueMaxFlase) { if (ConfigHelper.admobTrueMaxFlase) {
......
...@@ -9,5 +9,24 @@ data class RecycleBinBean( ...@@ -9,5 +9,24 @@ data class RecycleBinBean(
val size: Long = 0, val size: Long = 0,
val mimeType: String = "", val mimeType: String = "",
var deleted: Boolean = false var deleted: Boolean = false
) ) {
companion object {
val mImageStr: Set<String> = HashSet(
mutableListOf(
".jpg", ".jpeg", ".png", ".gif", ".bmp"
)
)
val mVideoStr: Set<String> = HashSet(
mutableListOf(
".mp4", ".avi", ".mov", ".mkv"
)
)
val mAudioStr: Set<String> = HashSet(
mutableListOf(".mp3", ".flac", ".wav")
)
val mDocumentStr: Set<String> = HashSet(
mutableListOf(".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf")
)
}
}
...@@ -11,11 +11,13 @@ import com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity ...@@ -11,11 +11,13 @@ import com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity
import com.base.filerecoveryrecyclebin.activity.photomanager.PhotoManagerAnimationActivity import com.base.filerecoveryrecyclebin.activity.photomanager.PhotoManagerAnimationActivity
import com.base.filerecoveryrecyclebin.activity.recovery.FileScanResultActivity import com.base.filerecoveryrecyclebin.activity.recovery.FileScanResultActivity
import com.base.filerecoveryrecyclebin.activity.whatsapp.WhatsAppCleanerAnimationActivity import com.base.filerecoveryrecyclebin.activity.whatsapp.WhatsAppCleanerAnimationActivity
import com.base.filerecoveryrecyclebin.bean.ConstObject
import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_AUDIOS import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_AUDIOS
import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_DOCUMENTS import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_DOCUMENTS
import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_PHOTOS import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_PHOTOS
import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_VIDEOS import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_VIDEOS
import com.base.filerecoveryrecyclebin.databinding.FragmentHome3Binding import com.base.filerecoveryrecyclebin.databinding.FragmentHome3Binding
import com.base.filerecoveryrecyclebin.fcm.NotificationUtil.sendNotification
import com.base.filerecoveryrecyclebin.help.BaseFragment import com.base.filerecoveryrecyclebin.help.BaseFragment
import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize
import com.base.filerecoveryrecyclebin.utils.LogEx import com.base.filerecoveryrecyclebin.utils.LogEx
...@@ -39,7 +41,7 @@ class HomeFragment : BaseFragment<FragmentHome3Binding>() { ...@@ -39,7 +41,7 @@ class HomeFragment : BaseFragment<FragmentHome3Binding>() {
override fun setListener() { override fun setListener() {
binding.flScan.setOnClickListener { binding.flScan.setOnClickListener {
startActivity(Intent(requireContext(), ScanJunkActivity::class.java)) startActivity(Intent(requireContext(), ScanJunkActivity::class.java))
// sendNotification(requireContext(), ConstObject.ID_SCREENSHOT_CLEAN) // sendNotification(requireContext(), ConstObject.ID_JUNK_CLEAN_PUSH)
} }
binding.cardRyPhotos.setOnClickListener { binding.cardRyPhotos.setOnClickListener {
startActivity(Intent(requireContext(), FileScanResultActivity::class.java).apply { startActivity(Intent(requireContext(), FileScanResultActivity::class.java).apply {
......
...@@ -65,7 +65,8 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() { ...@@ -65,7 +65,8 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
LogEx.logDebug(TAG, "initData") LogEx.logDebug(TAG, "initData")
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
val beanList = BackUpUtils.getBackUpListObj() val beanList = BackUpUtils.getBackUpListObj()
val deleteFile: List<RecycleBinBean>? = beanList?.filter { it.deleted } // val deleteFile: List<RecycleBinBean>? = beanList?.filter { it.deleted }
val deleteFile: List<RecycleBinBean>? = beanList
LogEx.logDebug(TAG, "deleteFile=$deleteFile") LogEx.logDebug(TAG, "deleteFile=$deleteFile")
deleteFile?.forEach { deleteFile?.forEach {
LogEx.logDebug(TAG, it.toString()) LogEx.logDebug(TAG, it.toString())
......
...@@ -3,6 +3,7 @@ package com.base.filerecoveryrecyclebin.help; ...@@ -3,6 +3,7 @@ package com.base.filerecoveryrecyclebin.help;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import java.io.File; import java.io.File;
import android.os.Build; import android.os.Build;
...@@ -15,12 +16,12 @@ public class VideoPlayerUtil { ...@@ -15,12 +16,12 @@ public class VideoPlayerUtil {
/** /**
* 打开外部视频播放器并播放指定路径的MP4文件。 * 打开外部视频播放器并播放指定路径的MP4文件。
* *
* @param context 应用上下文 * @param context 应用上下文
* @param videoPath MP4文件的本地路径 * @param videoPath MP4文件的本地路径
*/ */
public static void playVideo(Context context, String videoPath) { public static void playVideo(Context context, String videoPath) {
File videoFile = new File(videoPath); File videoFile = new File(videoPath);
Log.d("glc",videoPath); Log.d("glc", videoPath);
if (!videoFile.exists()) { if (!videoFile.exists()) {
throw new IllegalArgumentException("Video file does not exist: " + videoPath); throw new IllegalArgumentException("Video file does not exist: " + videoPath);
} }
...@@ -43,4 +44,36 @@ public class VideoPlayerUtil { ...@@ -43,4 +44,36 @@ public class VideoPlayerUtil {
// 处理异常,例如提示用户或记录日志 // 处理异常,例如提示用户或记录日志
} }
} }
/**
* 打开外部视频播放器并播放指定路径的MP4文件。
*
* @param context 应用上下文
* @param audioPath MP4文件的本地路径
*/
public static void playAudio(Context context, String audioPath) {
File audioFile = new File(audioPath);
Log.d("glc", audioPath);
if (!audioFile.exists()) {
throw new IllegalArgumentException("Video file does not exist: " + audioPath);
}
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri audioUri;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
audioUri = FileProvider.getUriForFile(context, "com.base.filerecoveryrecyclebin.provider", audioFile);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else {
audioUri = Uri.fromFile(audioFile);
}
intent.setDataAndType(audioUri, "audio/mp3");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
// 处理异常,例如提示用户或记录日志
}
}
} }
\ No newline at end of file
...@@ -45,19 +45,26 @@ public class FileObserverExample { ...@@ -45,19 +45,26 @@ public class FileObserverExample {
List<File> pictureList = FileHelp.INSTANCE.getFileFolder(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)); List<File> pictureList = FileHelp.INSTANCE.getFileFolder(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES));
List<File> downloadList = FileHelp.INSTANCE.getFileFolder(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)); List<File> downloadList = FileHelp.INSTANCE.getFileFolder(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
List<File> videoList = FileHelp.INSTANCE.getFileFolder(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)); List<File> videoList = FileHelp.INSTANCE.getFileFolder(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES));
List<File> musicList = FileHelp.INSTANCE.getFileFolder(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC));
watchList = new ArrayList(); watchList = new ArrayList();
watchList.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM));
watchList.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES));
watchList.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
watchList.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES));
watchList.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC));
watchList.addAll(dcimList); watchList.addAll(dcimList);
watchList.addAll(pictureList); watchList.addAll(pictureList);
watchList.addAll(downloadList); watchList.addAll(downloadList);
watchList.addAll(videoList); watchList.addAll(videoList);
watchList.addAll(musicList);
fileHandlerThread = new HandlerThread("FileObserverThread"); fileHandlerThread = new HandlerThread("FileObserverThread");
fileHandlerThread.start(); fileHandlerThread.start();
fileHandler = new Handler(fileHandlerThread.getLooper()); fileHandler = new Handler(fileHandlerThread.getLooper());
fileObserver = new FileObserver(watchList, FileObserver.CREATE | FileObserver.DELETE | FileObserver.DELETE_SELF | FileObserver.MOVED_FROM | FileObserver.MOVED_TO|FileObserver.MODIFY) { fileObserver = new FileObserver(watchList, FileObserver.CREATE | FileObserver.DELETE | FileObserver.DELETE_SELF | FileObserver.MOVED_FROM | FileObserver.MOVED_TO | FileObserver.MODIFY) {
@Override @Override
public void onEvent(int event, String path) { public void onEvent(int event, String path) {
Log.d(TAG, "onEvent " + event + " " + path); Log.e(TAG, "onEvent " + event + " " + path);
if (!TextUtils.isEmpty(path)) { if (!TextUtils.isEmpty(path)) {
Log.d(TAG, "path: " + path); Log.d(TAG, "path: " + path);
handleFileEvent(path, event); handleFileEvent(path, event);
...@@ -81,10 +88,10 @@ public class FileObserverExample { ...@@ -81,10 +88,10 @@ public class FileObserverExample {
Log.d(TAG, event + " " + FileObserver.DELETE_SELF + " " + path); Log.d(TAG, event + " " + FileObserver.DELETE_SELF + " " + path);
// 检查文件扩展名是否在监听范围内 // 检查文件扩展名是否在监听范围内
if (FILE_EXTENSIONS.contains(getFileExtension(path))) { if (FILE_EXTENSIONS.contains(getFileExtension(path))) {
if (event == FileObserver.CREATE || event == FileObserver.MOVED_TO||event == FileObserver.MODIFY) { if (event == FileObserver.CREATE || event == FileObserver.MOVED_TO || event == FileObserver.MODIFY) {
Log.d(TAG, "CREATE"); Log.d(TAG, "CREATE");
fileHandler.removeCallbacksAndMessages(null); fileHandler.removeCallbacksAndMessages(null);
fileHandler.postDelayed(() -> handleFileCreation(path),2000); fileHandler.postDelayed(() -> handleFileCreation(path), 2000);
} else if (event == FileObserver.DELETE || event == FileObserver.DELETE_SELF || event == FileObserver.MOVED_FROM) { } else if (event == FileObserver.DELETE || event == FileObserver.DELETE_SELF || event == FileObserver.MOVED_FROM) {
Log.d(TAG, event + " DELETE:" + path); Log.d(TAG, event + " DELETE:" + path);
BackUpUtils.INSTANCE.deleteFile(path); BackUpUtils.INSTANCE.deleteFile(path);
......
...@@ -9,6 +9,7 @@ import org.json.JSONObject ...@@ -9,6 +9,7 @@ import org.json.JSONObject
* call before agree * call before agree
*/ */
object InstallHelps { object InstallHelps {
var INSTALL_REFERRER_OK = false
fun init() { fun init() {
val referrerClient = InstallReferrerClient.newBuilder(BaseApplication.context).build() val referrerClient = InstallReferrerClient.newBuilder(BaseApplication.context).build()
referrerClient.startConnection(object : InstallReferrerStateListener { referrerClient.startConnection(object : InstallReferrerStateListener {
...@@ -24,6 +25,13 @@ object InstallHelps { ...@@ -24,6 +25,13 @@ object InstallHelps {
obj.put("appInstallTime", response.installBeginTimestampSeconds) obj.put("appInstallTime", response.installBeginTimestampSeconds)
obj.put("instantExperienceLaunched", installInfo.toString()) obj.put("instantExperienceLaunched", installInfo.toString())
EventUtils.event("install_referrer", ext = obj, isSingleEvent = true) EventUtils.event("install_referrer", ext = obj, isSingleEvent = true)
if (listOf("gclid", "facebook", "instagram").all { !installInfo.contains(it, true) }) {
//自然用户
AppPreferences.getInstance().put("install_source", "origin")
} else {
//渠道用户
AppPreferences.getInstance().put("install_source", "channel")
}
} }
else -> { else -> {
......
...@@ -26,7 +26,14 @@ object NewComUtils { ...@@ -26,7 +26,14 @@ object NewComUtils {
private val url: String by lazy { private val url: String by lazy {
val packageName = ConfigHelper.packageName val packageName = ConfigHelper.packageName
val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault()) val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault())
"$API_URL/$appCode spk?pkg=$packageName" "$API_URL/${appCode}spk?pkg=$packageName"
}
//origin user = only pick &source=origin
private fun getOriginUrl(): String {
val packageName = ConfigHelper.packageName
val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault())
return "$API_URL/${appCode}spk?pkg=$packageName&source=origin"
} }
fun requestCfg(callback: (ConfigBean?) -> Unit) { fun requestCfg(callback: (ConfigBean?) -> Unit) {
...@@ -55,8 +62,9 @@ object NewComUtils { ...@@ -55,8 +62,9 @@ object NewComUtils {
} }
} }
private fun doGet(): String? { private fun doGet(): String? {
val urlPath = url val originFlag = AppPreferences.getInstance().getString("install_source", "") == "origin"
val urlPath = if (originFlag) getOriginUrl() else url
Log.d("okhttp", urlPath) Log.d("okhttp", urlPath)
try { try {
val conn: HttpURLConnection = URL(urlPath).openConnection() as HttpURLConnection val conn: HttpURLConnection = URL(urlPath).openConnection() as HttpURLConnection
...@@ -81,7 +89,7 @@ object NewComUtils { ...@@ -81,7 +89,7 @@ object NewComUtils {
} }
private fun parseConfigBean(json: String) { private fun parseConfigBean(json: String) {
Log.d("okhttp",json) Log.d("okhttp", json)
val gson = Gson() val gson = Gson()
val type = object : TypeToken<Map<String, String>>() {}.type val type = object : TypeToken<Map<String, String>>() {}.type
val configMap = gson.fromJson<Map<String, String>>(json, type) val configMap = gson.fromJson<Map<String, String>>(json, type)
......
...@@ -54,18 +54,33 @@ ...@@ -54,18 +54,33 @@
tools:ignore="ContentDescription" tools:ignore="ContentDescription"
tools:layout_editor_absoluteX="0dp" /> tools:layout_editor_absoluteX="0dp" />
<ImageView <LinearLayout
android:id="@+id/iv_bofang"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true" android:orientation="vertical"
android:focusable="true"
android:src="@mipmap/bofang"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" /> app:layout_constraintVertical_bias="0.4"
tools:ignore="ContentDescription">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:visibility="gone" />
<ImageView
android:id="@+id/iv_bofang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:clickable="true"
android:focusable="true"
android:src="@mipmap/bofang" />
</LinearLayout>
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_width="@dimen/dp_345" android:layout_width="@dimen/dp_345"
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="232dp" android:layout_height="232dp"
android:background="@mipmap/bg"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
......
...@@ -4,13 +4,14 @@ ...@@ -4,13 +4,14 @@
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="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp" android:layout_marginHorizontal="15dp"
android:layout_marginVertical="6dp"> android:layout_marginVertical="6dp">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/card" android:id="@+id/card"
android:layout_width="55dp" android:layout_width="50dp"
android:layout_height="55dp" android:layout_height="50dp"
android:layout_marginStart="5dp"
app:cardCornerRadius="8dp" app:cardCornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
...@@ -20,7 +21,7 @@ ...@@ -20,7 +21,7 @@
android:id="@+id/iv" android:id="@+id/iv"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="5dp" android:scaleType="fitXY"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
...@@ -30,6 +31,7 @@ ...@@ -30,6 +31,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginEnd="5dp"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@id/card" app:layout_constraintBottom_toBottomOf="@id/card"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
......
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