Skip to content

Commit

Permalink
base device info
Browse files Browse the repository at this point in the history
  • Loading branch information
lulululbj committed Jan 25, 2019
1 parent 3b6a726 commit e3c2299
Show file tree
Hide file tree
Showing 11 changed files with 615 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

Expand Down Expand Up @@ -36,6 +37,7 @@
<activity android:name=".ui.activity.CurrentActivity"/>
<activity android:name=".ui.setting.SettingActivity"/>
<activity android:name=".about.AboutActivity"/>
<activity android:name=".ui.device.DeviceInfoActivity"/>

<service
android:name=".service.BoxAccessibilityService"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/luyao/box/Constant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import luyao.box.adapter.MainAdapter
import luyao.box.bean.MainBean
import luyao.box.ui.activity.CurrentActivity
import luyao.box.ui.appManager.AppListActivity
import luyao.box.ui.device.DeviceInfoActivity
import java.io.File

/**
Expand All @@ -20,6 +21,7 @@ const val ISSUE_URL="https://github.com/lulululbj/Box/issues"
const val DEVELOPER_EMAIL="[email protected]"

val MAIN_LIST = mutableListOf(
MainBean(R.drawable.ic_menu_slideshow,"本机信息", DeviceInfoActivity::class.java),
MainBean(R.drawable.ic_menu_camera, "应用管理", AppListActivity::class.java),
MainBean(R.drawable.ic_menu_gallery, "Activity历史", CurrentActivity::class.java),
MainBean(R.drawable.ic_add_circle,"Coming Soon",MainAdapter::class.java)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/luyao/box/adapter/SpaceItemDecoration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ class SpaceItemDecoration(space: Int) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
outRect.left = mSpace
outRect.right = mSpace
outRect.top = mSpace
outRect.bottom = mSpace
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/luyao/box/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
private fun initNavView() {
nav_view.setNavigationItemSelectedListener(this)
val versionTv = nav_view.getHeaderView(0).findViewById<TextView>(R.id.versionNameTv)
versionTv.text = "V ${AppUtils.getAppVersionName(this, packageName)}"
versionTv.text=String.format("V %s",AppUtils.getAppVersionName(this, packageName))
}

private fun initRecycleView() {
Expand Down
74 changes: 74 additions & 0 deletions app/src/main/java/luyao/box/ui/device/DeviceInfoActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package luyao.box.ui.device

import android.Manifest
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.os.Build
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import kotlinx.android.synthetic.main.activity_device_info.*
import kotlinx.android.synthetic.main.title_layout.*
import luyao.box.R
import luyao.box.common.base.BaseActivity
import luyao.box.common.util.DeviceUtils

/**
* Created by luyao
* on 2019/1/25 16:17
*/
class DeviceInfoActivity : BaseActivity() {

private val permission = Manifest.permission.READ_PHONE_STATE


override fun getLayoutResId() = R.layout.activity_device_info

override fun initView() {
mToolbar.title = getString(R.string.device_ifo)
}

override fun initData() {
checkPermissions()
setDeviceInfo()
}

private fun setDeviceInfo() {
brand.text = DeviceUtils.getBrand()
display.text = DeviceUtils.getDisplay()
product.text = DeviceUtils.getProduct()
device.text = DeviceUtils.getDevice()
board.text = DeviceUtils.getBoard()
model.text = DeviceUtils.getModel()
manufacturer.text = DeviceUtils.getManufacturer()
bootloader.text = DeviceUtils.getBootloader()
hardware.text = DeviceUtils.getHardware()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
abis.text = DeviceUtils.getSupportedAbis()!!.contentToString()
}
radioVersion.text = Build.getRadioVersion()
api.text = DeviceUtils.getSDK().toString()
version.text = DeviceUtils.getVersion()
os.text = DeviceUtils.getKernelVersion()
macAddress.text = DeviceUtils.getMacAddress()
}

private fun checkPermissions() {
if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(permission), 1001)
} else {
imei.text = DeviceUtils.getIMEI(this)
meid.text = DeviceUtils.getMEID(this)
sn.text = DeviceUtils.getSN()
}
}

@SuppressLint("MissingPermission")
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (grantResults[0] == PackageManager.PERMISSION_GRANTED){
imei.text = DeviceUtils.getIMEI(this)
meid.text = DeviceUtils.getMEID(this)
sn.text = DeviceUtils.getSN()
}
}
}
259 changes: 259 additions & 0 deletions app/src/main/res/layout/activity_device_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<include layout="@layout/title_layout"/>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp">


<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</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
style="@style/Device_Text"
android:layout_width="100dp"
android:text="@string/hardware"/>

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>


<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</LinearLayout>

<LinearLayout style="@style/Device_Lin">

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

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

</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/radio_version"/>

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

</LinearLayout>

</LinearLayout>
</ScrollView>
</LinearLayout>
Loading

0 comments on commit e3c2299

Please sign in to comment.