Commit edf81826 authored by wanglei's avatar wanglei

...

parent ffc4928f
......@@ -11,6 +11,11 @@ object ConstObject {
const val YANDEX = "Yandex"
const val BAIDU = "Baidu"
const val ID_JUNK_CLEANER = 12001
const val ID_NEWS = 12002
const val ID_SCAN_CODE = 12003
const val ID_APP_PROCESS = 12004
const val JUNK_CLEANER = "Junk Cleaner"
// const val REPEAT_PHOTOS = "Repeat Photos"
// const val SCREENSHOT_CLEANER = "Screenshot Cleaner"
......
......@@ -16,8 +16,10 @@ import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
import androidx.core.graphics.drawable.IconCompat
import com.base.browserwhite.R
import com.base.browserwhite.service.StayNotificationService.Companion.startStayNotification
import com.base.browserwhite.bean.ConstObject
import com.base.browserwhite.ui.activity.MainActivity
import com.base.browserwhite.ui.activity.SplashActivity
import com.base.browserwhite.utils.EventUtils
import kotlin.random.Random
......@@ -32,7 +34,6 @@ class StayNotificationService : Service() {
var isRunning = false
fun Context.startStayNotification() {
val intent = Intent(this, StayNotificationService::class.java)
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
......@@ -57,9 +58,18 @@ class StayNotificationService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (intent == null) {
EventUtils.event("onStartCommand", "Foreground System auto launch intent=null isRunning=$isRunning")
return START_NOT_STICKY
}
if (!isRunning) {
startForeground()
val notification = createPermanentNotification(applicationContext)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(1, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
} else {
startForeground(1, notification)
}
isRunning = true
}
return START_STICKY
......@@ -95,50 +105,41 @@ class StayNotificationService : Service() {
val expendView = RemoteViews(context.packageName, R.layout.stay_notification_big)
val requestCode1 = Random.nextInt(1800)
val intent0 = Intent(context, MainActivity::class.java).apply {
val intent0 = Intent(context, SplashActivity::class.java).apply {
putExtra("actionId", ConstObject.ID_JUNK_CLEANER)
}
val pendingIntent0 =
val pendingIntent1 =
PendingIntent.getActivity(context, requestCode1, intent0, PendingIntent.FLAG_IMMUTABLE)
contentView.setOnClickPendingIntent(R.id.id_ll_clean, pendingIntent0)
expendView.setOnClickPendingIntent(R.id.id_ll_clean, pendingIntent0)
contentView.setOnClickPendingIntent(R.id.ll_1, pendingIntent1)
expendView.setOnClickPendingIntent(R.id.ll_1, pendingIntent1)
val requestCode2 = Random.nextInt(1800)
val intent2 = Intent(context, MainActivity::class.java).apply {
// putExtra("actionId", ConstObject.ID_RECOVERY_PHOTOS)
// putExtra("ScanType", SCAN_PHOTOS)
val intent2 = Intent(context, SplashActivity::class.java).apply {
putExtra("actionId", ConstObject.ID_NEWS)
}
val pendingIntent2 =
PendingIntent.getActivity(context, requestCode2, intent2, PendingIntent.FLAG_IMMUTABLE)
contentView.setOnClickPendingIntent(R.id.id_recovery_photos, pendingIntent2)
expendView.setOnClickPendingIntent(R.id.id_recovery_photos, pendingIntent2)
contentView.setOnClickPendingIntent(R.id.ll_2, pendingIntent2)
expendView.setOnClickPendingIntent(R.id.ll_2, pendingIntent2)
val requestCode3 = Random.nextInt(1800)
val intent3 = Intent(context, MainActivity::class.java).apply {
// putExtra("actionId", ConstObject.ID_RECOVERY_VIDEOS)
// putExtra("ScanType", SCAN_VIDEOS)
val intent3 = Intent(context, SplashActivity::class.java).apply {
putExtra("actionId", ConstObject.ID_SCAN_CODE)
}
val pendingIntent3 =
PendingIntent.getActivity(context, requestCode3, intent3, PendingIntent.FLAG_IMMUTABLE)
contentView.setOnClickPendingIntent(R.id.id_recovery_videos, pendingIntent3)
expendView.setOnClickPendingIntent(R.id.id_recovery_videos, pendingIntent3)
contentView.setOnClickPendingIntent(R.id.ll_3, pendingIntent3)
expendView.setOnClickPendingIntent(R.id.ll_3, pendingIntent3)
// val intent4 = Intent()
// val serviceComponent = ComponentName(context, FlashlightService::class.java)
// intent4.component = serviceComponent
// val pendingIntent4 =
// PendingIntent.getService(context, 0, intent4, PendingIntent.FLAG_IMMUTABLE)
// contentView.setOnClickPendingIntent(R.id.id_screenshot, pendingIntent4)
// expendView.setOnClickPendingIntent(R.id.id_screenshot, pendingIntent4)
val requestCode4 = Random.nextInt(1800)
val intent4 = Intent(context, MainActivity::class.java).apply {
// putExtra("actionId", ConstObject.ID_RECOVERY_DOCUMENTS)
// putExtra("ScanType", SCAN_DOCUMENTS)
val intent4 = Intent(context, SplashActivity::class.java).apply {
putExtra("actionId", ConstObject.ID_APP_PROCESS)
}
val pendingIntent4 =
PendingIntent.getActivity(context, requestCode4, intent4, PendingIntent.FLAG_IMMUTABLE)
contentView.setOnClickPendingIntent(R.id.id_recovery_documents, pendingIntent4)
expendView.setOnClickPendingIntent(R.id.id_recovery_documents, pendingIntent4)
contentView.setOnClickPendingIntent(R.id.ll_4, pendingIntent4)
expendView.setOnClickPendingIntent(R.id.ll_4, pendingIntent4)
val nfIntent = Intent(context, MainActivity::class.java)
val pendingIntent =
......
......@@ -9,8 +9,14 @@ import android.text.Spanned
import android.text.style.UnderlineSpan
import android.view.View
import androidx.lifecycle.lifecycleScope
import com.base.browserwhite.bean.ConstObject.ID_APP_PROCESS
import com.base.browserwhite.bean.ConstObject.ID_JUNK_CLEANER
import com.base.browserwhite.bean.ConstObject.ID_NEWS
import com.base.browserwhite.bean.ConstObject.ID_SCAN_CODE
import com.base.browserwhite.bean.ConstObject.ifAgreePrivacy
import com.base.browserwhite.databinding.ActivitySplashBinding
import com.base.browserwhite.service.StayNotificationService.Companion.startStayNotification
import com.base.browserwhite.ui.activity.cleanjunk.ScanJunkActivity
import com.base.browserwhite.utils.BarUtils
import com.base.browserwhite.utils.ConfigHelper
import com.base.browserwhite.utils.LogEx
......@@ -43,15 +49,11 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
// if (MyApplication.isInterOpenShowing) {
// finish()
// return
// }
// startStayNotification()
startStayNotification()
// NotificationUtil.stopNotificationHandler()
// actionId = intent?.extras?.getInt("actionId") ?: -1
actionId = intent?.extras?.getInt("actionId") ?: -1
// closeNotification()
progressCollect()
......@@ -103,67 +105,31 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
return
}
jumped = true
// LogEx.logDebug(TAG, "jumpNext actionId=$actionId")
LogEx.logDebug(TAG, "jumpNext actionId=$actionId")
when (actionId) {
// ID_JUNK_CLEAN_PUSH -> {
// startActivity(Intent(this, ScanJunkActivity::class.java))
// }
//
// ID_SIMILAR_IMAGE -> {
// startActivity(Intent(this, PhotoManagerAnimationActivity::class.java))
// }
//
// ID_SCREENSHOT_CLEAN -> {
// startActivity(Intent(this, PhotoManagerAnimationActivity::class.java))
// }
//
// ID_RECOVERY_PHOTOS -> {
// startActivity(Intent(this, FileScanResultActivity::class.java).apply {
// putExtra("ScanType", ConstObject.SCAN_PHOTOS)
// })
// }
//
// ID_RECOVERY_VIDEOS -> {
// startActivity(Intent(this, FileScanResultActivity::class.java).apply {
// putExtra("ScanType", ConstObject.SCAN_VIDEOS)
// })
// }
//
// ID_RECOVERY_DOCUMENTS -> {
// startActivity(Intent(this, FileScanResultActivity::class.java).apply {
// putExtra("ScanType", ConstObject.SCAN_DOCUMENTS)
// })
// }
//
// ID_WHATSAPP -> {
// startActivity(Intent(this, WhatsAppCleanerAnimationActivity::class.java))
// }
//
// ID_APP_PROCESS -> {
// startActivity(Intent(this, AppProcessAnimationActivity::class.java))
// }
//
// ID_APP_MANAGER -> {
// startActivity(Intent(this, AppManagerAnimationActivity::class.java))
// }
//
// ID_BATTERY_INFO -> {
// startActivity(Intent(this, BatteryInfoAnimationActivity::class.java))
// }
ID_JUNK_CLEANER -> {
startActivity(Intent(this, ScanJunkActivity::class.java))
}
ID_NEWS -> {
}
ID_SCAN_CODE -> {
}
ID_APP_PROCESS -> {
}
else -> {
val isHotLaunch = intent?.extras?.getBoolean("isHotLaunch", false) ?: false
// if (!isHotLaunch) {
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
// if (!isGuide) {
// startActivity(Intent(this@SplashActivity, GuideActivity::class.java))
// isGuide = true
// } else {
// startActivity(Intent(this@SplashActivity, MainActivity::class.java))
// }
// }
if (!isHotLaunch) {
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
}
}
}
finish()
......
......@@ -37,7 +37,7 @@ class NewsDetailActivity : BaseActivity<ActivityNewsDetailBinding>() {
}
private fun addNewWebSite(uri: String) {
val myFragment = WebViewFragment(uri)
val myFragment = WebViewFragment().apply { url = uri }
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
transaction.replace(R.id.container, myFragment)
transaction.commit()
......
......@@ -163,7 +163,7 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
}
private fun addNewWebSite(uri: String) {
val myFragment = WebViewFragment(uri)
val myFragment = WebViewFragment().apply { url=uri }
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
transaction.replace(R.id.container, myFragment)
transaction.commit()
......
......@@ -34,7 +34,7 @@ class NewsAdapter(
}
override fun onBindViewHolder(holder: NewsViewHolder, position: Int, item: NewsBean?) {
LogEx.logDebug(TAG, "onBindViewHolder")
// LogEx.logDebug(TAG, "onBindViewHolder")
if (item == null) {
return
}
......
package com.base.browserwhite.ui.fragment
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Intent
import android.view.KeyEvent
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.base.browserwhite.R
import com.base.browserwhite.bean.ConstObject.BAIDU
import com.base.browserwhite.bean.ConstObject.BING
......@@ -144,6 +148,8 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
}
}
var i = 0
var lastClickTime = 0L
override fun setListener() {
super.setListener()
binding.llWeather.setOnClickListener {
......@@ -207,6 +213,31 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
binding.flScan.setOnClickListener {
requireContext().startActivity(Intent(requireContext(), ScanQRCActivity::class.java))
}
binding.tvName.setOnClickListener {
if (System.currentTimeMillis() - lastClickTime > 5 * 1000 && i != 0) {
lastClickTime = 0
i = 0
}
if (i == 20) {
copyUuidGid()
i = 0
}
i++
lastClickTime = System.currentTimeMillis()
}
}
private fun copyUuidGid() {
val uuid = AppPreferences.getInstance().getString("uuid", "")
val gid = AppPreferences.getInstance().getString("gid", "")
// 获取系统服务ClipboardManager
val clipboard: ClipboardManager =
requireContext().getSystemService(AppCompatActivity.CLIPBOARD_SERVICE) as ClipboardManager
// 创建一个ClipData对象,其中包含要复制的文本
val clip = ClipData.newPlainText("uuid", "uuid=$uuid gid=$gid")
// 将ClipData对象设置到剪贴板中
clipboard.setPrimaryClip(clip)
Toast.makeText(requireContext(), "copy", Toast.LENGTH_SHORT).show()
}
......
......@@ -25,10 +25,11 @@ import kotlinx.coroutines.launch
import kotlin.random.Random
class WebViewFragment(val url: String) : BaseFragment<FragmentWebViewBinding>() {
class WebViewFragment : BaseFragment<FragmentWebViewBinding>() {
private val TAG = "WebViewFragment"
private var job: Job? = null
var url: String = ""
override val binding: FragmentWebViewBinding by lazy {
FragmentWebViewBinding.inflate(layoutInflater)
......
package com.base.browserwhite.utils
import android.os.Build
import com.base.browserwhite.BuildConfig
import com.base.browserwhite.utils.ReportUtils.doPost
import org.json.JSONException
import org.json.JSONObject
object EventUtils {
private val TAG = "EventUtils"
fun event(
key: String,
value: String? = null,
ext: JSONObject? = null,
isSingleEvent: Boolean = false
) {
if (isSingleEvent) {
val stringSet = AppPreferences.getInstance().getStringSet("singleEvent", setOf())
if (stringSet.contains(key)) {
return
}
}
Thread {
var paramJson: String? = ""
try {
val pkg = ConfigHelper.packageName
val s = JSONObject()
.put("action", key)
.put("value", value)
.put("ext", ext)
val s2 = JSONObject()
.put("${pkg}_3", AppPreferences.getInstance().getString("Equipment", ""))
.put("${pkg}_4", AppPreferences.getInstance().getString("Manufacturer", ""))
// .put("${pkg}_5", AppPreferences.getInstance().getString("svn", ""))
.put("${pkg}_5", Build.VERSION.SDK_INT)
.put("${pkg}_9", AppPreferences.getInstance().getString("uuid", ""))
.put("${pkg}_10", AppPreferences.getInstance().getString("gid", ""))
.put("${pkg}_13", "android")
.put("${pkg}_15", "google")
.put("${pkg}_14", BuildConfig.VERSION_CODE)
.put("${pkg}_8", BuildConfig.VERSION_NAME)
.put("${pkg}_24", BuildConfig.BUILD_TYPE)
val data = JSONObject()
.put("data", s)
.put("bp", s2)
.toString()
LogEx.logDebug(TAG, "data=${AppPreferences.getInstance().getString("uuid", "")}")
paramJson = AESHelper.encrypt(data)
} catch (e: JSONException) {
paramJson = ""
}
LogEx.logDebug(TAG, "report!")
doPost(
url,
HashMap(),
paramJson
)
}.start()
}
private val url by lazy {
val pkg = ConfigHelper.packageName
val url = StringBuilder(
"${ConfigHelper.eventUrl}/${
pkg.filter { it.isLowerCase() }.substring(4, 9)
}sp"
)
url.append("?pkg=$pkg")
url.toString()
}
}
\ No newline at end of file
package com.base.browserwhite.utils;
import android.text.TextUtils;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
public class ReportUtils {
private static String TAG = "ReportUtils";
public static String doPost(String urlPath, Map<String, String> paramsMap, String json) {
try {
HttpURLConnection conn = (HttpURLConnection) new URL(urlPath).openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setConnectTimeout(600000);
if (!TextUtils.isEmpty(json)) {
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Content-Length", Integer.toString(json.getBytes().length));
conn.getOutputStream().write(json.getBytes());
}
StringBuilder result = new StringBuilder();
for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
result.append("&").append(entry.getKey()).append("=").append(entry.getValue());
}
if (result.length() > 0) {
conn.getOutputStream().write(result.substring(1).getBytes());
} else {
// conn.getOutputStream().write(result.substring(0).getBytes());
}
if (conn.getResponseCode() == 200) {
String s = new BufferedReader(new InputStreamReader(conn.getInputStream())).readLine();
if (!TextUtils.isEmpty(s)) {
} else {
s = "";
}
LogEx.INSTANCE.logDebug(TAG, "code=200", false);
return s;
} else {
LogEx.INSTANCE.logDebug(TAG, "code!=200", false);
}
} catch (Exception e) {
e.printStackTrace();
}
return "{ \"success\": false,\n \"errorMsg\": \"后台服务器开小差了!\",\n \"result\":{}}";
}
}
......@@ -3,13 +3,11 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_ffffff_10"
android:paddingVertical="4dp"
tools:ignore="DisableBaselineAlignment">
<!--清理-->
<LinearLayout
android:id="@+id/id_ll_clean"
android:id="@+id/ll_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......@@ -26,7 +24,7 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="2dp"
android:src="@mipmap/news"
android:src="@mipmap/notifi_cleanjunk"
tools:ignore="ContentDescription" />
<ImageView
......@@ -47,9 +45,8 @@
tools:ignore="HardcodedText" />
</LinearLayout>
<!--恢复照片-->
<LinearLayout
android:id="@+id/id_recovery_photos"
android:id="@+id/ll_2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......@@ -61,21 +58,20 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="6dp"
android:src="@mipmap/news"
android:src="@mipmap/notifi_news"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Photos"
android:text="News"
android:textColor="#666666"
android:textSize="12sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<!--恢复视频-->
<LinearLayout
android:id="@+id/id_recovery_videos"
android:id="@+id/ll_3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......@@ -87,21 +83,20 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="6dp"
android:src="@mipmap/news"
android:src="@mipmap/notifi_scancode"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Videos"
android:text="Scan Code"
android:textColor="#666666"
android:textSize="12sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<!--恢复文档-->
<LinearLayout
android:id="@+id/id_recovery_documents"
android:id="@+id/ll_4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......@@ -114,13 +109,13 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="6dp"
android:src="@mipmap/news"
android:src="@mipmap/notifi_process"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Documents"
android:text="Process"
android:textColor="#666666"
android:textSize="12sp"
tools:ignore="HardcodedText" />
......
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