Commit b0079e29 authored by wanglei's avatar wanglei

+首页读取存储空间删掉

parent dca8081c
...@@ -13,7 +13,6 @@ import com.base.easyfilemanager.databinding.ActivityDeviceScanInfoBinding ...@@ -13,7 +13,6 @@ import com.base.easyfilemanager.databinding.ActivityDeviceScanInfoBinding
import com.base.easyfilemanager.helps.BaseActivity import com.base.easyfilemanager.helps.BaseActivity
import com.base.easyfilemanager.helps.KotlinExt.toFormatSize import com.base.easyfilemanager.helps.KotlinExt.toFormatSize
import com.base.easyfilemanager.helps.LogEx import com.base.easyfilemanager.helps.LogEx
import com.base.easyfilemanager.helps.StatFsHelper
import com.base.easyfilemanager.helps.ads.AdmobUtils import com.base.easyfilemanager.helps.ads.AdmobUtils
import com.base.easyfilemanager.utils.DeviceUtils import com.base.easyfilemanager.utils.DeviceUtils
import com.base.easyfilemanager.view.AFunOb import com.base.easyfilemanager.view.AFunOb
...@@ -40,7 +39,6 @@ class DeviceScanInfoActivity : BaseActivity<ActivityDeviceScanInfoBinding>() { ...@@ -40,7 +39,6 @@ class DeviceScanInfoActivity : BaseActivity<ActivityDeviceScanInfoBinding>() {
AdmobUtils.showInterstitialAd(this) { AdmobUtils.showInterstitialAd(this) {
binding.tvDeviceName.text = getDeviceName() binding.tvDeviceName.text = getDeviceName()
binding.tvAndroidVersion.text = "System Version: Android ${Build.VERSION.RELEASE}" binding.tvAndroidVersion.text = "System Version: Android ${Build.VERSION.RELEASE}"
initStorage()
binding.tvAbis.text = DeviceUtils.getABIs().toStringEx() binding.tvAbis.text = DeviceUtils.getABIs().toStringEx()
val cupInfo = cpuInfo() val cupInfo = cpuInfo()
cupInfo.forEach { cupInfo.forEach {
...@@ -89,16 +87,6 @@ class DeviceScanInfoActivity : BaseActivity<ActivityDeviceScanInfoBinding>() { ...@@ -89,16 +87,6 @@ class DeviceScanInfoActivity : BaseActivity<ActivityDeviceScanInfoBinding>() {
} else capitalize(manufacturer) + " " + model } 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> { private fun cpuInfo(): ArrayList<String> {
val cpuList: ArrayList<String> = arrayListOf() val cpuList: ArrayList<String> = arrayListOf()
try { try {
......
...@@ -17,8 +17,6 @@ import com.base.easyfilemanager.helps.BaseFragment ...@@ -17,8 +17,6 @@ import com.base.easyfilemanager.helps.BaseFragment
import com.base.easyfilemanager.helps.KotlinExt.toFormatSize import com.base.easyfilemanager.helps.KotlinExt.toFormatSize
import com.base.easyfilemanager.helps.PermissionHelp.checkStorePermission import com.base.easyfilemanager.helps.PermissionHelp.checkStorePermission
import com.base.easyfilemanager.helps.PermissionHelp.requestStorePermission import com.base.easyfilemanager.helps.PermissionHelp.requestStorePermission
import com.base.easyfilemanager.helps.StatFsHelper.availableSize
import com.base.easyfilemanager.helps.StatFsHelper.totalSize
import com.base.easyfilemanager.helps.ads.AdmobUtils import com.base.easyfilemanager.helps.ads.AdmobUtils
import com.base.easyfilemanager.utils.MediaStoreEx import com.base.easyfilemanager.utils.MediaStoreEx
import com.base.easyfilemanager.view.DialogViews.showGerPermission import com.base.easyfilemanager.view.DialogViews.showGerPermission
......
...@@ -20,7 +20,6 @@ import com.base.easyfilemanager.databinding.FragmentLayoutHomeBinding ...@@ -20,7 +20,6 @@ import com.base.easyfilemanager.databinding.FragmentLayoutHomeBinding
import com.base.easyfilemanager.helps.BaseFragment import com.base.easyfilemanager.helps.BaseFragment
import com.base.easyfilemanager.helps.KotlinExt.setOnClickListener import com.base.easyfilemanager.helps.KotlinExt.setOnClickListener
import com.base.easyfilemanager.helps.KotlinExt.toFormatSize import com.base.easyfilemanager.helps.KotlinExt.toFormatSize
import com.base.easyfilemanager.helps.StatFsHelper
import com.base.easyfilemanager.notificationclean.NotificationGuestActivity import com.base.easyfilemanager.notificationclean.NotificationGuestActivity
import com.base.easyfilemanager.utils.BarUtils import com.base.easyfilemanager.utils.BarUtils
...@@ -117,9 +116,6 @@ class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() { ...@@ -117,9 +116,6 @@ class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
private fun initStorage() { private fun initStorage() {
val totalSize = StatFsHelper.totalSize()
val availableSize = StatFsHelper.availableSize()
val usedSize = totalSize - availableSize
binding.idTvOccupied.text = "${usedSize.toFormatSize()} / ${totalSize.toFormatSize()}" binding.idTvOccupied.text = "${usedSize.toFormatSize()} / ${totalSize.toFormatSize()}"
} }
......
package com.base.easyfilemanager.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
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
<FrameLayout <FrameLayout
android:id="@+id/fl_back" android:id="@+id/fl_back"
android:padding="8dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
...@@ -142,17 +142,6 @@ ...@@ -142,17 +142,6 @@
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"> 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 <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
...@@ -205,18 +194,6 @@ ...@@ -205,18 +194,6 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ll_device_info"> 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 <TextView
android:id="@+id/tv_abis" android:id="@+id/tv_abis"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -75,34 +75,6 @@ ...@@ -75,34 +75,6 @@
</FrameLayout> </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 <androidx.cardview.widget.CardView
android:id="@+id/id_clean_up" android:id="@+id/id_clean_up"
android:layout_width="match_parent" 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