Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
2020-02-13 Version 1.1.0: Closed #1
Browse files Browse the repository at this point in the history
  • Loading branch information
fartem committed Feb 13, 2020
1 parent 1ee1915 commit 43e0dc2
Show file tree
Hide file tree
Showing 21 changed files with 112 additions and 48 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0.2"
versionName "1.1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -21,7 +21,7 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.material:material:1.2.0-alpha04'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class PageRunnerTest {
}

private fun swipeToLeft() {
onView(withId(R.id.info_pages)).perform(swipeLeft())
onView(withId(R.id.info_pages))
.perform(swipeLeft())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class MainActivity : AppCompatActivity() {

private fun saveGPUInfo() {
startActivityForResult(
Intent(this, DeviceGPUActivity::class.java),
Intent(
this,
DeviceGPUActivity::class.java
),
GPURequestCode().requestCode()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ import kotlinx.android.synthetic.main.fragment_list.*

abstract class BaseListInfoPage : Page2() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
info_list.adapter = InfoAdapter(infoItems())
private val infoItems = mutableListOf<InfoItem>()

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?
) {
infoItems.clear()
infoItems.addAll(infoItems())
info_list.adapter = InfoAdapter(infoItems)
}

abstract fun infoItems(): List<InfoItem>
abstract fun infoItems(): MutableList<InfoItem>

fun infoItemsListUpdate(
infoItems: MutableList<InfoItem>
) {
this.infoItems.clear()
this.infoItems.addAll(infoItems)
info_list.adapter?.notifyDataSetChanged()
}

override fun onCreateView(
inflater: LayoutInflater,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import android.os.BatteryManager
import com.smlnskgmail.jaman.deviceinfo.R
import com.smlnskgmail.jaman.deviceinfo.logic.info.api.BatteryInfo

class DeviceBatteryInfo(private val context: Context) :
BatteryInfo {
class DeviceBatteryInfo(
private val context: Context
) : BatteryInfo {

override fun health(): String {
val status = batteryData()!!.getIntExtra(BatteryManager.EXTRA_HEALTH, 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.battery

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle
import android.view.View
import com.smlnskgmail.jaman.deviceinfo.R
import com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.BaseListInfoPage
import com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.battery.recycler.BatteryActionInfoItem
Expand All @@ -10,24 +16,63 @@ import com.smlnskgmail.jaman.deviceinfo.logic.info.api.BatteryInfo

class DeviceBatteryPage : BaseListInfoPage() {

override fun infoItems(): List<InfoItem> {
val batteryInfo: BatteryInfo = DeviceBatteryInfo(context!!)
return listOf(
private var batteryInfo: BatteryInfo? = null

private val batteryReceiver = object : BroadcastReceiver() {
override fun onReceive(
context: Context?,
intent: Intent?
) {
infoItemsListUpdate(
batteryInfo()
)
}
}

override fun infoItems(): MutableList<InfoItem> {
return batteryInfo()
}

private fun batteryInfo(): MutableList<InfoItem> {
if (batteryInfo == null) {
batteryInfo = DeviceBatteryInfo(context!!)
}
return mutableListOf(
BatteryHealthInfoItem(
context!!,
batteryInfo
batteryInfo!!
),
BatteryActionInfoItem(
context!!,
batteryInfo
batteryInfo!!
),
BatteryPluggedInfoItem(
context!!,
batteryInfo
batteryInfo!!
)
)
}

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?
) {
super.onViewCreated(view, savedInstanceState)
activity!!.registerReceiver(
batteryReceiver,
IntentFilter(
Intent.ACTION_BATTERY_CHANGED
)
)
}

override fun onDestroyView() {
super.onDestroyView()
activity!!.unregisterReceiver(
batteryReceiver
)
}

override fun pageTitleResId() = R.string.page_title_battery

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import com.smlnskgmail.jaman.deviceinfo.logic.info.api.CPUInfo

class DeviceCPUPage : BaseListInfoPage() {

override fun infoItems(): List<InfoItem> {
override fun infoItems(): MutableList<InfoItem> {
val cpuInfo: CPUInfo = DeviceCPUInfo()
return listOf(
return mutableListOf(
CPUCoresInfoItem(
context!!,
cpuInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.cpu
class Ghz(private val mgz: Int) {

companion object {

private const val divider = 1_000_000f

}

fun value() = mgz / divider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.display

class DeviceDisplayPage : BaseListInfoPage() {

override fun infoItems(): List<InfoItem> {
val displayInfo: DisplayInfo =
DeviceDisplayInfo(
activity!!
)
return listOf(
override fun infoItems(): MutableList<InfoItem> {
val displayInfo: DisplayInfo = DeviceDisplayInfo(
activity!!
)
return mutableListOf(
DensityDpiInfoItem(
context!!,
displayInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.gpu.pre
import com.smlnskgmail.jaman.deviceinfo.logic.info.api.GPUIInfo
import com.smlnskgmail.jaman.deviceinfo.logic.preferences.impl.shared.StringPreference

class DeviceGPUIInfo(private val context: Context) :
GPUIInfo {
class DeviceGPUIInfo(
private val context: Context
) : GPUIInfo {

override fun vendor() = StringPreference(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import com.smlnskgmail.jaman.deviceinfo.logic.info.api.GPUIInfo

class DeviceGPUPage : BaseListInfoPage() {

override fun infoItems(): List<InfoItem> {
override fun infoItems(): MutableList<InfoItem> {
val gpuInfo: GPUIInfo = DeviceGPUIInfo(context!!)
return listOf(
return mutableListOf(
GPUModelInfoItem(
context!!,
gpuInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.gpu.pr

import com.smlnskgmail.jaman.deviceinfo.logic.preferences.api.PreferenceValue

class GPUModelPreferenceValue :
PreferenceValue<String> {
class GPUModelPreferenceValue : PreferenceValue<String> {

override fun key() = "gpu_model"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.gpu.pr

import com.smlnskgmail.jaman.deviceinfo.logic.preferences.api.PreferenceValue

class GPUVendorPreferenceValue :
PreferenceValue<String> {
class GPUVendorPreferenceValue : PreferenceValue<String> {

override fun key() = "gpu_vendor"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import android.content.Context
import com.smlnskgmail.jaman.deviceinfo.R
import com.smlnskgmail.jaman.deviceinfo.logic.info.api.JVMInfo

class DeviceJVMInfo(private val context: Context) :
JVMInfo {
class DeviceJVMInfo(
private val context: Context
) : JVMInfo {

override fun jvmName(): String {
val jvmName = System.getProperty("java.vm.version")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util.*

class DeviceJVMPage : BaseListInfoPage() {

override fun infoItems(): List<InfoItem> {
override fun infoItems(): MutableList<InfoItem> {
val jvmInfo: JVMInfo = DeviceJVMInfo(context!!)
return Collections.singletonList(
JVMNameInfoItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.ram
class BytesInMegabytes(private val bytes: Long) {

companion object {

private const val ONE_MEGABYTE_IN_BYTE = 1_048_576

}

fun result() = bytes / ONE_MEGABYTE_IN_BYTE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import com.smlnskgmail.jaman.deviceinfo.logic.info.api.RAMInfo

class DeviceRAMPage : BaseListInfoPage() {

override fun infoItems(): List<InfoItem> {
override fun infoItems(): MutableList<InfoItem> {
val ramInfo: RAMInfo = DeviceRAMInfo(context!!)
ramInfo.loadState()
return listOf(
return mutableListOf(
AvailableRAMInfoItem(
context!!,
ramInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.smlnskgmail.jaman.deviceinfo.R

class InfoAdapter(private val infoItems: List<InfoItem>) : RecyclerView.Adapter<InfoHolder>() {
class InfoAdapter(
private val infoItems: MutableList<InfoItem>
) : RecyclerView.Adapter<InfoHolder>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int)
=
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
InfoHolder(
LayoutInflater.from(parent.context)
.inflate(R.layout.item_info, parent, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import androidx.recyclerview.widget.RecyclerView
import com.smlnskgmail.jaman.deviceinfo.support.clipboard.ClipboardText
import kotlinx.android.synthetic.main.item_info.view.*

class InfoHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
class InfoHolder(
itemView: View
) : RecyclerView.ViewHolder(itemView) {

fun bind(infoItem: InfoItem) {
val data = infoItem.body()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import com.smlnskgmail.jaman.deviceinfo.logic.info.api.SystemInfo
import java.text.SimpleDateFormat
import java.util.*

class DeviceSystemInfo(private val context: Context) :
SystemInfo {
class DeviceSystemInfo(
private val context: Context
) : SystemInfo {

override fun model(): String = Build.MODEL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import com.smlnskgmail.jaman.deviceinfo.logic.info.impl.androidsdk.pages.system.

class DeviceSystemPage : BaseListInfoPage() {

override fun infoItems(): List<InfoItem> {
override fun infoItems(): MutableList<InfoItem> {
val systemInfo: SystemInfo = DeviceSystemInfo(context!!)
return listOf(
return mutableListOf(
ApiLevelInfoItem(
context!!,
systemInfo
Expand Down

0 comments on commit 43e0dc2

Please sign in to comment.