Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion AndroidInfoLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-reflect:1.7.10"

implementation 'androidx.appcompat:appcompat:1.5.1'

// Network
Expand All @@ -39,7 +41,6 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:4.9.3"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.3"


testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ interface DeviceInformation {
fun getBatteryInformation(): BatteryInformation

fun getSARInformation(): SARInformation

fun getInfoById(id: Int, context: Context): Map<String, Any?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.udfsoft.androidinfo.lib

import android.Manifest
import android.annotation.SuppressLint
import android.content.Context
import androidx.annotation.RequiresPermission
import androidx.annotation.WorkerThread
Expand All @@ -30,6 +31,7 @@ import com.udfsoft.androidinfo.lib.command.codecs.GetCodecsInformationCommand
import com.udfsoft.androidinfo.lib.command.cpu.GetCpuInformationCommand
import com.udfsoft.androidinfo.lib.command.design.GetNetworkDesignInformationCommand
import com.udfsoft.androidinfo.lib.command.display.GetDisplayInformationCommand
import com.udfsoft.androidinfo.lib.command.entity.MenuIds
import com.udfsoft.androidinfo.lib.command.general.GetGeneralInformationCommand
import com.udfsoft.androidinfo.lib.command.gpu.GetGPUInformationCommand
import com.udfsoft.androidinfo.lib.command.network.GetNetworkTechnologiesInformationCommand
Expand All @@ -44,6 +46,7 @@ import com.udfsoft.androidinfo.lib.di.NetworkFactory
import com.udfsoft.androidinfo.lib.entity.CPUInformation
import com.udfsoft.androidinfo.lib.entity.OSInformation
import com.udfsoft.androidinfo.lib.entity.RAMInformation
import com.udfsoft.androidinfo.lib.util.asMap

@WorkerThread
object DeviceInformationFactory : DeviceInformation {
Expand Down Expand Up @@ -112,4 +115,30 @@ object DeviceInformationFactory : DeviceInformation {
override fun getBatteryInformation() = GetBatteryInformationCommand(api).invoke(Unit)

override fun getSARInformation() = GetSARInformationCommand(api).invoke(Unit)

@SuppressLint("MissingPermission")
override fun getInfoById(id: Int, context: Context): Map<String, Any?> =
when (MenuIds.findMenuIdByIndex(id)) {
MenuIds.MENU_ID_GENERAL -> getGeneralInformation().asMap()
MenuIds.MENU_ID_DESIGN -> getDesignInformation().asMap()
MenuIds.MENU_ID_SIM -> getSIMCardInformation(context).asMap()
MenuIds.MENU_ID_MOBILE_NETWORK -> getNetworkTechnologiesInformation(context).asMap()
MenuIds.MENU_ID_OS -> getOSInformation().asMap()
MenuIds.MENU_ID_PROCESSOR -> getCPUInformation().asMap()
MenuIds.MENU_ID_GPU -> getGPUInformation().asMap()
MenuIds.MENU_ID_MEMORY -> getRAMInformation(context).asMap()
MenuIds.MENU_ID_STORAGE -> getStorageInformation().asMap()
MenuIds.MENU_ID_DISPLAY -> getDisplayInformation(context).asMap()
MenuIds.MENU_ID_SENSORS -> getSensorsInformation().asMap()
MenuIds.MENU_ID_REAR_CAMERA -> getRearCameraInformation().asMap()
MenuIds.MENU_ID_FRONT_CAMERA -> getFrontCameraInformation().asMap()
MenuIds.MENU_ID_AUDIO -> getAudioInformation().asMap()
MenuIds.MENU_ID_WIRELESS -> getWirelessInformation().asMap()
MenuIds.MENU_ID_USB -> getUSBInformation().asMap()
MenuIds.MENU_ID_BROWSER -> getBrowserInformation().asMap()
MenuIds.MENU_ID_CODECS -> getCodecsInformation().asMap()
MenuIds.MENU_ID_BATTERY -> getBatteryInformation().asMap()
MenuIds.MENU_ID_SAR -> getSARInformation().asMap()
else -> throw UnsupportedOperationException()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ enum class MenuIds(val menuId: Int) {
MENU_ID_BROWSER(22000),
MENU_ID_CODECS(23000),
MENU_ID_BATTERY(25000),
MENU_ID_SAR(26000),
MENU_ID_ADDITIONAL_FEATURES(27000)
MENU_ID_SAR(26000);

companion object {
fun findMenuIdByIndex(index: Int) = values().firstOrNull { it.ordinal == index }
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.udfsoft.androidinfo.lib.network.interceptor

import android.content.Context
import android.os.Build
import com.udfsoft.androidinfo.lib.BuildConfig
import com.udfsoft.androidinfo.lib.network.Headers.ACCEPT
import com.udfsoft.androidinfo.lib.network.Headers.ACCEPT_LANGUAGE
Expand All @@ -25,8 +25,8 @@ class StaticHeadersInterceptor : Interceptor {
.addHeader(CONTENT_TYPE, APPLICATION_JSON_CONTENT_TYPE)
.addHeader(USER_AGENT, userAgent)
.addHeader(ACCEPT_LANGUAGE, Locale.getDefault().language)
.addHeader(DEVICE_BRAND_KEY, "xiaomi")//Build.BRAND)
.addHeader(DEVICE_MODEL_KEY, "redmi note 7") //Build.MODEL)
.addHeader(DEVICE_BRAND_KEY, Build.BRAND)
.addHeader(DEVICE_MODEL_KEY, Build.MODEL)

return chain.proceed(requestBuilder.build())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.lib.util

import kotlin.reflect.full.memberProperties

inline fun <reified T : Any> T.asMap(): Map<String, Any?> {
val props = T::class.memberProperties.associateBy { it.name }
return props.keys.associateWith { props[it]?.get(this) }
}
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
# AndroidInfoLib
# AndroidInfoLib

This is a library that will help you get all the information from android

[![](https://jitpack.io/v/LiteSoftware/SectorProgressBar.svg)](https://jitpack.io/#LiteSoftware/SectorProgressBar)

<img src="screens/1_2.png" width="30%" /> <img src="screens/1_3.png" width="30%" />

## How to use
1. Add this in your root `build.gradle` at the end of `repositories` in `allprojects` section:
```groovy
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```

2. Then add this dependency to your **module-level** `build.gradle` in `dependencies` section:
```groovy
implementation 'com.github.LiteSoftware:SectorProgressBar:$version'
```

3. Call any of the methods below to get information about your android
```kotlin
DeviceInformationFactory.getGeneralInformation()
DeviceInformationFactory.getRAMInformation(context)
DeviceInformationFactory.getOSInformation()
DeviceInformationFactory.getCPUInformation()
DeviceInformationFactory.getSIMCardInformation(context)
DeviceInformationFactory.getDisplayInformation(context)
DeviceInformationFactory.getNetworkTechnologiesInformation(context)
DeviceInformationFactory.getDesignInformation()
DeviceInformationFactory.getStorageInformation()
DeviceInformationFactory.getGPUInformation()
DeviceInformationFactory.getSensorsInformation()
DeviceInformationFactory.getRearCameraInformation()
DeviceInformationFactory.getFrontCameraInformation()
DeviceInformationFactory.getAudioInformation()
DeviceInformationFactory.getWirelessInformation()
DeviceInformationFactory.getUSBInformation()
DeviceInformationFactory.getBrowserInformation()
DeviceInformationFactory.getCodecsInformation()
DeviceInformationFactory.getBatteryInformation()
DeviceInformationFactory.getSARInformation()
```

---

## License

```
Copyright 2022 Javavirys. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
12 changes: 9 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
dataBinding true
}
}

dependencies {
Expand All @@ -42,11 +46,13 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-livedata:2.5.1'

implementation "androidx.core:core-ktx:1.9.0"
implementation "androidx.activity:activity-ktx:1.6.0"
implementation "androidx.fragment:fragment-ktx:1.5.3"
implementation "androidx.activity:activity-ktx:1.6.1"
implementation "androidx.fragment:fragment-ktx:1.5.4"

// Widgets
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "com.google.android.material:material:1.7.0"

// Tests
testImplementation 'junit:junit:4.13.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.udfsoft.androidinfo.sample

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.commitNow
import com.udfsoft.androidinfo.sample.ui.main.MainFragment

class MainActivity : AppCompatActivity() {
Expand All @@ -26,9 +27,9 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
if (savedInstanceState == null) {
supportFragmentManager.beginTransaction()
.replace(R.id.container, MainFragment.newInstance())
.commitNow()
supportFragmentManager.commitNow {
replace(R.id.container, MainFragment.newInstance())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.sample.core.entity

import androidx.annotation.DrawableRes

data class MenuItem(
val id: Int,
val name: String,
@DrawableRes val logoId: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2022 Javavirys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.udfsoft.androidinfo.sample.core.entity

import androidx.annotation.DrawableRes
import com.udfsoft.androidinfo.sample.R

enum class MenuItemEnum(
val title: String,
@DrawableRes val logoId: Int
) {

General("General", R.drawable.ic_general),
Design("Design", R.drawable.ic_launcher_foreground),
SIMCard("SIM card", R.drawable.ic_launcher_foreground),
MobileNetworkTechnologies("Mobile network technologies", R.drawable.ic_launcher_foreground),
OperatingSystem("Operating system", R.drawable.ic_launcher_foreground),
CPU("CPU", R.drawable.ic_launcher_foreground),
GPU("GPU", R.drawable.ic_launcher_foreground),
RAM("RAM", R.drawable.ic_launcher_foreground),
Storage("Storage", R.drawable.ic_launcher_foreground),
Display("Display", R.drawable.ic_launcher_foreground),
Sensors("Sensors", R.drawable.ic_launcher_foreground),
RearCamera("Rear camera", R.drawable.ic_launcher_foreground),
FrontCamera("Front camera", R.drawable.ic_launcher_foreground),
Audio("Audio", R.drawable.ic_launcher_foreground),
WirelessTechnology("Wireless technology", R.drawable.ic_launcher_foreground),
USB("USB", R.drawable.ic_launcher_foreground),
Browser("Browser", R.drawable.ic_launcher_foreground);
}
Loading