Skip to content

Commit

Permalink
update device info
Browse files Browse the repository at this point in the history
  • Loading branch information
lulululbj committed Mar 12, 2019
1 parent 5e586ee commit 5cdb7a2
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 64 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/luyao/box/Ext.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package luyao.box

import android.content.Context
import android.view.View
import android.widget.Toast
import luyao.box.common.util.AppUtils
import luyao.box.common.util.FileUtils.deleteFile
import luyao.box.common.util.HashUtils
import java.io.File

fun Context.toast(text: String) {
Expand Down Expand Up @@ -32,4 +35,13 @@ fun File.deleteAll() {
deleteFile(this)
}

fun ByteArray.md5() = AppUtils.byte2HexStr(HashUtils.hash(this, HashUtils.Hash.MD5))
fun ByteArray.sha1() = AppUtils.byte2HexStr(HashUtils.hash(this, HashUtils.Hash.SHA1))
fun ByteArray.sha256() = AppUtils.byte2HexStr(HashUtils.hash(this, HashUtils.Hash.SHA256))

fun View.click(){

}



44 changes: 44 additions & 0 deletions app/src/main/java/luyao/box/ext/LogExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package luyao.box.ext

import android.util.Log
import luyao.box.BuildConfig

/**
* Description: log相关,日志的开关和默认tag通过AndroidKtxConfig来配置
* Create by lxj, at 2018/12/5
*/

const val BOX="box"

private enum class LogLevel{
Verbose, Debug, Info, Warn, Error
}

fun String.v(tag: String = BOX){
intervalLog(LogLevel.Verbose, tag, this )
}

fun String.d(tag: String = BOX){
intervalLog(LogLevel.Debug, tag, this )
}
fun String.i(tag: String = BOX){
intervalLog(LogLevel.Info, tag, this )
}
fun String.w(tag: String = BOX){
intervalLog(LogLevel.Warn, tag, this )
}
fun String.e(tag: String = BOX){
intervalLog(LogLevel.Error, tag, this )
}

private fun intervalLog(level: LogLevel, tag: String, msg: String){
if(BuildConfig.DEBUG){
when (level) {
LogLevel.Verbose -> Log.v(tag, msg)
LogLevel.Debug -> Log.d(tag, msg)
LogLevel.Info -> Log.i(tag, msg)
LogLevel.Warn -> Log.w(tag, msg)
LogLevel.Error -> Log.e(tag, msg)
}
}
}
12 changes: 4 additions & 8 deletions app/src/main/java/luyao/box/ui/appManager/AppDetailActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import luyao.box.APK_PATH
import luyao.box.R
import luyao.box.*
import luyao.box.common.base.BaseActivity
import luyao.box.common.util.AppUtils
import luyao.box.common.util.HashUtils
import luyao.box.ui.editor.TextEditorActivity
import luyao.box.ui.editor.TextViewerActivity
import luyao.box.util.Utils
import luyao.parser.xml.XmlParser
Expand Down Expand Up @@ -46,7 +43,6 @@ class AppDetailActivity : BaseActivity() {
private fun initListener() {
detailRefresh.setOnRefreshListener { refresh() }
detailManifest.setOnClickListener {
// startActivity(TextEditorActivity::class.java, "sourceDir", sourceDir)
startActivity(TextViewerActivity::class.java,"filePath",filePath)
}
li_sigMD5.setOnClickListener { Utils.copy(this, sigMD5.text.toString()) }
Expand All @@ -56,9 +52,9 @@ class AppDetailActivity : BaseActivity() {

private fun refresh() {
val sig = AppUtils.getAppSignature(this, mPackageName)
sigMD5.text = AppUtils.byte2HexStr(HashUtils.hash(sig, HashUtils.Hash.MD5))
sigSHA1.text = AppUtils.byte2HexStr(HashUtils.hash(sig, HashUtils.Hash.SHA1))
sig256.text = AppUtils.byte2HexStr(HashUtils.hash(sig, HashUtils.Hash.SHA256))
sigMD5.text = sig.md5()
sigSHA1.text = sig.sha1()
sig256.text =sig.sha256()

CoroutineScope(Dispatchers.Main).launch {
val xmlAsync = async(Dispatchers.IO) {
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/luyao/box/ui/device/DeviceInfoActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.Manifest
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.os.Build
import android.os.Environment
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import kotlinx.android.synthetic.main.activity_device_info.*
Expand Down Expand Up @@ -50,6 +51,12 @@ class DeviceInfoActivity : BaseActivity() {
version.text = DeviceUtils.getVersion()
os.text = DeviceUtils.getKernelVersion()
macAddress.text = DeviceUtils.getMacAddress()

screen.text=String.format("%s * %s", DeviceUtils.getDeviceWidth(this), DeviceUtils.getDeviceHeight(this))
ram.text=DeviceUtils.getRamInfo(this)
rom.text=DeviceUtils.getRomInfo(this)


}

private fun checkPermissions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TextEditorActivity : BaseActivity() {
return@async xmlParser.parse()
}
}
textEdit.setText(xml.await()?.xmlContent)
textEdit.setText(xml.await()?.xmlContent ?: "")
}
}
}
13 changes: 6 additions & 7 deletions app/src/main/java/luyao/box/ui/editor/TextViewerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ class TextViewerActivity : BaseActivity() {
mToolbar.title = File(filePath).name
mToolbar.inflateMenu(R.menu.toolbar_search)

val webSettings = webView.settings
webSettings.javaScriptEnabled = true
webSettings.setAppCacheEnabled(true)
webSettings.setSupportZoom(true)
webSettings.defaultTextEncodingName = "utf-8"
webView.settings.run {
javaScriptEnabled=true
setAppCacheEnabled(true)
setSupportZoom(true)
defaultTextEncodingName="utf-8"
}
webView.webChromeClient = object : WebChromeClient() {
override fun onProgressChanged(view: WebView?, newProgress: Int) {
if (newProgress == 100) {
Expand All @@ -44,8 +45,6 @@ class TextViewerActivity : BaseActivity() {
}

override fun initData() {

// webView.loadData(File(filePath).readText(),"text/xml","utf-8")
webView.loadUrl("file:///$filePath")
}

Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/luyao/box/ui/setting/SettingFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import kotlinx.coroutines.launch
import luyao.box.BASE_PATH
import luyao.box.R
import luyao.box.common.util.FileUtils
import luyao.box.deleteAll
import java.io.File

/**
Expand Down Expand Up @@ -63,7 +62,6 @@ class SettingFragment : PreferenceFragmentCompat() {
FileUtils.deleteFile(file)
}
}

}

private val fileList = arrayListOf<File>()
Expand All @@ -74,7 +72,7 @@ class SettingFragment : PreferenceFragmentCompat() {
if (file.name.endsWith(".apk")) fileList.add(file)
} else if (file.listFiles().isNotEmpty()) {
for (subFile in file.listFiles()) {
subFile.deleteAll()
filter(subFile)
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/luyao/box/util/AccessibilityUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object AccessibilityUtils {
/*
* 不可用,高版本直接返回 Collections.emptyList()
*/
fun checkAccessibilityEnabled(serviceName: String, context: Context): Boolean {
private fun checkAccessibilityEnabled(serviceName: String, context: Context): Boolean {
val manager: AccessibilityManager =
context.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
val enabledAccessibilityServiceList =
Expand Down
97 changes: 67 additions & 30 deletions app/src/main/res/layout/activity_device_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

<TextView
style="@style/Device_Text"
android:layout_width="100dp"
android:text="@string/bootloader"/>

<TextView
android:id="@+id/bootloader"
style="@style/Device_Text"/>

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

<TextView
Expand Down Expand Up @@ -143,10 +156,36 @@
<TextView
style="@style/Device_Text"
android:layout_width="100dp"
android:text="@string/hardware"/>
android:text="@string/screen"/>

<TextView
android:id="@+id/hardware"
android:id="@+id/screen"
style="@style/Device_Text"/>

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

<TextView
style="@style/Device_Text"
android:layout_width="100dp"
android:text="@string/ram"/>

<TextView
android:id="@+id/ram"
style="@style/Device_Text"/>

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

<TextView
style="@style/Device_Text"
android:layout_width="100dp"
android:text="@string/rom"/>

<TextView
android:id="@+id/rom"
style="@style/Device_Text"/>

</LinearLayout>
Expand Down Expand Up @@ -178,6 +217,32 @@

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

<TextView
style="@style/Device_Text"
android:layout_width="100dp"
android:text="@string/abis"/>

<TextView
android:id="@+id/abis"
style="@style/Device_Text"/>

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

<TextView
style="@style/Device_Text"
android:layout_width="100dp"
android:text="@string/hardware"/>

<TextView
android:id="@+id/hardware"
style="@style/Device_Text"/>

</LinearLayout>


</LinearLayout>
</androidx.cardview.widget.CardView>
Expand Down Expand Up @@ -264,19 +329,6 @@
</LinearLayout>
</androidx.cardview.widget.CardView>

<LinearLayout style="@style/Device_Lin">

<TextView
style="@style/Device_Text"
android:layout_width="100dp"
android:text="@string/bootloader"/>

<TextView
android:id="@+id/bootloader"
style="@style/Device_Text"/>

</LinearLayout>


<LinearLayout style="@style/Device_Lin">

Expand All @@ -291,21 +343,6 @@

</LinearLayout>


<LinearLayout style="@style/Device_Lin">

<TextView
style="@style/Device_Text"
android:layout_width="100dp"
android:text="@string/abis"/>

<TextView
android:id="@+id/abis"
style="@style/Device_Text"/>

</LinearLayout>


</LinearLayout>
</ScrollView>
</LinearLayout>
25 changes: 14 additions & 11 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,28 @@
<string name="sdk_version">Sdk Version :</string>
<string name="version">App Version :</string>
<string name="device_ifo">设备信息</string>
<string name="brand">Brand</string>
<string name="display">Display</string>
<string name="product">Product</string>
<string name="device">Device</string>
<string name="board">Board</string>
<string name="brand">品牌</string>
<string name="display">版本号</string>
<string name="product">型号</string>
<string name="device">设备名称</string>
<string name="board">主板</string>
<string name="model">Model</string>
<string name="manufacturer">Manufacturer</string>
<string name="manufacturer">制造商</string>
<string name="bootloader">Bootloader</string>
<string name="hardware">Hardware</string>
<string name="abis">Supported ABIs</string>
<string name="radio_version">Radio Version</string>
<string name="abis">ABIs</string>
<string name="radio_version">Radio</string>
<string name="api">Api</string>
<string name="android_version">Android Version</string>
<string name="sdk">SDK</string>
<string name="android_version">Android 版本</string>
<string name="sdk">SDK 版本</string>
<string name="os_version">Base Os</string>
<string name="kernel_version">Kernel</string>
<string name="imei">IMEI</string>
<string name="meid">MEID</string>
<string name="sn">SN</string>
<string name="mac_address">Mac Adress</string>
<string name="mac_address">Mac Address</string>
<string name="screen">屏幕</string>
<string name="ram">内存</string>
<string name="rom">存储</string>

</resources>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.10'
ext.kotlin_version = '1.3.20'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
Loading

0 comments on commit 5cdb7a2

Please sign in to comment.