Commit f8cf95ff authored by wanglei's avatar wanglei

+首页读取存储空间删掉

parent 82335b05
......@@ -13,7 +13,6 @@ import com.test.easy.easycleanerjunk.databinding.ActivityDeviceScanInfoBinding
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import com.test.easy.easycleanerjunk.helps.LogEx
import com.test.easy.easycleanerjunk.helps.StatFsHelper
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import com.test.easy.easycleanerjunk.utils.DeviceUtils
import com.test.easy.easycleanerjunk.view.AFunOb
......@@ -37,7 +36,6 @@ class DeviceScanInfoActivity : BaseActivity<ActivityDeviceScanInfoBinding>() {
override fun initView() {
binding.tvDeviceName.text = getDeviceName()
binding.tvAndroidVersion.text = "System Version: Android ${Build.VERSION.RELEASE}"
initStorage()
binding.tvAbis.text = DeviceUtils.getABIs().toStringEx()
val cupInfo = cpuInfo()
cupInfo.forEach {
......@@ -82,15 +80,6 @@ class DeviceScanInfoActivity : BaseActivity<ActivityDeviceScanInfoBinding>() {
} else capitalize(manufacturer) + " " + model
}
@SuppressLint("SetTextI18n")
private fun initStorage() {
val stat = StatFs(Environment.getExternalStorageDirectory().path)
val totalSize = StatFsHelper.totalSize()
val availableSize = StatFsHelper.availableSize()
val usedSize = totalSize - availableSize
val usedPercentage = usedSize.toFloat() / totalSize * 100
binding.tvStorage.text = "${usedSize.toFormatSize()}/ ${totalSize.toFormatSize()}"
}
private fun cpuInfo(): ArrayList<String> {
val cpuList: ArrayList<String> = arrayListOf()
......
......@@ -19,7 +19,6 @@ import com.test.easy.easycleanerjunk.databinding.FragmentLayoutHomeBinding
import com.test.easy.easycleanerjunk.helps.BaseFragment
import com.test.easy.easycleanerjunk.helps.KotlinExt.setOnClickListener
import com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import com.test.easy.easycleanerjunk.helps.StatFsHelper
import com.test.easy.easycleanerjunk.notificationclean.NotificationGuestActivity
import com.test.easy.easycleanerjunk.utils.BarUtils
......@@ -114,9 +113,6 @@ class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() {
@SuppressLint("SetTextI18n")
private fun initStorage() {
val totalSize = StatFsHelper.totalSize()
val availableSize = StatFsHelper.availableSize()
val usedSize = totalSize - availableSize
binding.idTvOccupied.text = "${usedSize.toFormatSize()} / ${totalSize.toFormatSize()}"
}
......
package com.test.easy.easycleanerjunk.helps
import android.os.Environment
import android.os.StatFs
import android.util.Log
object StatFsHelper {
var totalsize = 0L
fun totalSize(): Long {
return if (totalsize > 0) {
totalsize
} else try {
val statFs = StatFs(Environment.getExternalStorageDirectory().path)
val statFs2 = StatFs(Environment.getRootDirectory().path)
Log.i(
"storeByteDebug",
"store1: " + statFs2.blockSizeLong * statFs2.blockCountLong + "====store2: " + statFs.blockSizeLong * statFs.blockCountLong
)
var blockSizeLong =
statFs2.blockSizeLong * statFs2.blockCountLong + statFs.blockSizeLong * statFs.blockCountLong
blockSizeLong = getClosestPowerOfTwo(blockSizeLong)
totalsize = blockSizeLong
blockSizeLong
} catch (e10: java.lang.Exception) {
0L
}
}
fun a(j10: Long): Long {
var tmep = j10
var i7 = 0L
while (true) {
val j11: Long = 1000
if (tmep < j11) {
break
}
tmep /= j11
i7++
}
for (i10 in 0 until i7) {
tmep *= 1024
}
return tmep
}
fun availableSize(): Long {
try {
val statFs = StatFs(Environment.getExternalStorageDirectory().path)
val statFs2 = StatFs(Environment.getRootDirectory().path)
val blackSize =
statFs2.blockSizeLong * statFs2.availableBlocksLong + statFs.blockSizeLong * statFs.availableBlocksLong
return a(blackSize)
} catch (e10: Exception) {
return 0L
}
}
fun getClosestPowerOfTwo(size: Long): Long {
var powerOfTwo: Long = 1
while (powerOfTwo < size) {
powerOfTwo *= 2
}
return powerOfTwo
}
}
\ No newline at end of file
......@@ -142,17 +142,6 @@
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="12dp"
android:text="Storage"
android:textColor="#666666"
android:textSize="14sp"
tools:ignore="HardcodedText,RtlSymmetry" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
......@@ -205,17 +194,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ll_device_info">
<TextView
android:id="@+id/tv_storage"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|end"
android:paddingEnd="12dp"
android:textColor="@color/black"
android:textSize="14sp"
tools:ignore="RtlSymmetry"
tools:text="20.29GB/116.63GB" />
<TextView
android:id="@+id/tv_abis"
......
......@@ -68,34 +68,6 @@
</FrameLayout>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="7dp"
android:text="Occupied storage"
android:textColor="#666666"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/id_tv_occupied"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold"
tools:text="13.58GB / 118GB" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.cardview.widget.CardView
android:id="@+id/id_clean_up"
android:layout_width="match_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