Skip to content

Commit

Permalink
Bug fixes and removal of redundant resources
Browse files Browse the repository at this point in the history
Fixed:
- permission handler not initialized
- location was null in GPS handler
- alarm handler for Android S update
- storage navigation from advanced fragment
- other minor issues

Added:
- build type to ignore firebase
- update to Kotlin 1.6.10
- moved from secure.properties to local.properties and secret gradle
  • Loading branch information
Foxpace committed Dec 19, 2021
1 parent 230f38a commit dc224d5
Show file tree
Hide file tree
Showing 71 changed files with 186 additions and 784 deletions.
3 changes: 3 additions & 0 deletions CountDownDialog/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
nfrelease{
initWith release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
3 changes: 1 addition & 2 deletions CountDownDialog/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.motionapps.countdowndialog">
<manifest package="com.motionapps.countdowndialog">

<application>
</application>
Expand Down
3 changes: 3 additions & 0 deletions WearOsLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
nfrelease{
initWith debug
}
}

compileOptions {
Expand Down
6 changes: 4 additions & 2 deletions WearOsLib/src/main/res/font/roboto_family.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font-family xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="@font/roboto_regular" />
android:font="@font/roboto_regular"
tools:targetApi="o" />

</font-family>
27 changes: 15 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,38 @@ apply plugin: 'kotlin-android'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'

if (getGradle().getStartParameter().getTaskRequests().toString().contains("Release")) {
apply plugin: 'com.google.firebase.crashlytics'
}

android {
compileSdkVersion 31
buildToolsVersion "30.0.2"
buildToolsVersion '31.0.0'


defaultConfig {
applicationId "motionapps.sensorbox"
minSdkVersion 19
targetSdkVersion 31
versionCode 63
versionName "4.2.4"
versionCode 65
versionName "4.2.5"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

def secureProps = new Properties()
if (file("../secure.properties").exists()) {
file("../secure.properties")?.withInputStream { secureProps.load(it) }
}
resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "")
signingConfig signingConfigs.debug
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}

nfrelease{
initWith release
}
}


Expand Down Expand Up @@ -76,8 +79,8 @@ dependencies {
implementation 'com.google.android.gms:play-services-wearable:17.1.0'
implementation 'androidx.preference:preference-ktx:1.1.1'

implementation 'com.google.firebase:firebase-analytics-ktx:20.0.1'
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.2.6'
releaseImplementation 'com.google.firebase:firebase-analytics-ktx:20.0.2'
releaseImplementation 'com.google.firebase:firebase-crashlytics-ktx:18.2.6'

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2-native-mt'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2-native-mt'
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/maps_api_key" />
android:value="${MAPS_API_KEY}" />
<property
android:name="android.content.MEDIA_CAPABILITIES"
android:resource="@xml/media_capabilities" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.motionapps.sensorbox.activities

import android.annotation.SuppressLint
import android.app.Dialog
import android.content.BroadcastReceiver
import android.content.Context
Expand Down Expand Up @@ -206,7 +207,7 @@ class MeasurementActivity : AppCompatActivity() {
when(measurementState){
is MeasurementStates.OnTick -> {
findViewById<TextView>(R.id.measurement_time)?.let {
it.text = "${measurementState.tick} s"
it.text = getString(R.string.second_formater).format(measurementState.tick)
}
}
is MeasurementStates.OnEndMeasurement ->{
Expand Down Expand Up @@ -334,6 +335,7 @@ class MeasurementActivity : AppCompatActivity() {
/**
* Annotation dialog to add notes during measurement
*/
@SuppressLint("CheckResult")
private fun showDialogAnnotations(){
// gets info from sharedPreferences - customized in settings
val preferences = PreferenceManager.getDefaultSharedPreferences(this@MeasurementActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ open class HomeFragment : Fragment() {
private var dialog: MaterialDialog? = null
private val wearOsViews: ArrayList<View> = ArrayList() // storing Wear Os views - can be deleted
private val mainViewModel: MainViewModel by viewModels(ownerProducer = { requireActivity() })
protected lateinit var permissionHandler: PermissionHandler
protected var permissionHandler: PermissionHandler? = null
private var wearShown = false

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -106,19 +106,21 @@ open class HomeFragment : Fragment() {
// handling the button to add or remove to sensor for measurement
// sensorViewHandler manages all sensors to measure
imageButtons[i].setOnClickListener {

if(permissionHandler.checkHeartRateSensor(this, sensorsNeeds[i].id )){
return@setOnClickListener
}

sensorViewHandler.sensorsToRecord[sensorsNeeds[i].id] =
!sensorViewHandler.sensorsToRecord[sensorsNeeds[i].id]!!
if (sensorViewHandler.sensorsToRecord[sensorsNeeds[i].id]!!) {
imageButtons[i].setImageResource(R.drawable.ic_ok)
} else {
imageButtons[i].setImageResource(R.drawable.ic_circle)
permissionHandler?.let { permissionHandler ->

if(permissionHandler.checkHeartRateSensor(this, sensorsNeeds[i].id )){
return@setOnClickListener
}

sensorViewHandler.sensorsToRecord[sensorsNeeds[i].id] =
!sensorViewHandler.sensorsToRecord[sensorsNeeds[i].id]!!
if (sensorViewHandler.sensorsToRecord[sensorsNeeds[i].id]!!) {
imageButtons[i].setImageResource(R.drawable.ic_ok)
} else {
imageButtons[i].setImageResource(R.drawable.ic_circle)
}
checkSensorsToMeasure()
}
checkSensorsToMeasure()
}

// for refresh reasons - button is updated by sensorViewHandler from ViewModel
Expand Down Expand Up @@ -185,11 +187,13 @@ open class HomeFragment : Fragment() {
}
} else {
infoButton.setOnClickListener {
if(permissionHandler.checkHeartRateSensor(this, sensorNeeds.id)){
return@setOnClickListener
permissionHandler?.let { permissionHandler ->
if (permissionHandler.checkHeartRateSensor(this, sensorNeeds.id)) {
return@setOnClickListener
}
val action: NavDirections = HomeFragmentDirections.homeInfoAction(resourceName)
Navigation.findNavController(requireView()).navigate(action)
}
val action: NavDirections = HomeFragmentDirections.homeInfoAction(resourceName)
Navigation.findNavController(requireView()).navigate(action)
}
}

Expand All @@ -214,12 +218,13 @@ open class HomeFragment : Fragment() {
val infoButton: ImageButton = view.findViewById(R.id.sensorrow_info)

infoButton.setOnClickListener {

if(!permissionHandler.checkGPSPermission(this)){
return@setOnClickListener
permissionHandler?.let { permissionHandler ->
if(!permissionHandler.checkGPSPermission(this)){
return@setOnClickListener
}
val action: NavDirections = HomeFragmentDirections.homeInfoAction(SensorNeeds.GPS)
Navigation.findNavController(requireView()).navigate(action)
}
val action: NavDirections = HomeFragmentDirections.homeInfoAction(SensorNeeds.GPS)
Navigation.findNavController(requireView()).navigate(action)
}

icon.setImageResource(R.drawable.ic_gps)
Expand All @@ -232,19 +237,19 @@ open class HomeFragment : Fragment() {
}

imageButton.setOnClickListener {

if(!permissionHandler.checkGPSPermission(this)){
return@setOnClickListener
}

sensorViewHandler.gpsMeasurement = !sensorViewHandler.gpsMeasurement
if (sensorViewHandler.gpsMeasurement) {
imageButton.setImageResource(R.drawable.ic_ok)
} else {
imageButton.setImageResource(R.drawable.ic_circle)
permissionHandler?.let { permissionHandler ->
if(!permissionHandler.checkGPSPermission(this)){
return@setOnClickListener
}

sensorViewHandler.gpsMeasurement = !sensorViewHandler.gpsMeasurement
if (sensorViewHandler.gpsMeasurement) {
imageButton.setImageResource(R.drawable.ic_ok)
} else {
imageButton.setImageResource(R.drawable.ic_circle)
}
checkSensorsToMeasure()
}
checkSensorsToMeasure()

}
container?.addView(view)
}
Expand All @@ -260,7 +265,11 @@ open class HomeFragment : Fragment() {
open fun initMainButton() {
mainButton?.setOnClickListener {

if(StorageFunctions.checkStorageAccess(this, permissionHandler)){
if(permissionHandler == null){
return@setOnClickListener
}

if(StorageFunctions.checkStorageAccess(this, permissionHandler!!)){
return@setOnClickListener
}

Expand Down Expand Up @@ -313,9 +322,7 @@ open class HomeFragment : Fragment() {
super.onDestroyView()
removeWearOs()

if(this::permissionHandler.isInitialized){
permissionHandler.onDestroy()
}
permissionHandler?.onDestroy()

dialog?.dismiss()
dialog = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class AdvancedFragment : HomeFragment() {
)
)
return@setOnClickListener
} else if(Build.VERSION_CODES.M <= Build.VERSION.SDK_INT){
permissionHandler.showDialogStorage(this)
} else if(Build.VERSION_CODES.M <= Build.VERSION.SDK_INT && permissionHandler != null){
permissionHandler?.showDialogStorage(this)
return@setOnClickListener
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.motionapps.sensorbox.intro

import android.Manifest
import android.content.Intent
import android.graphics.Color
import android.os.Build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ open class GraphUpdater @Inject constructor(): SensorEventListener{
}
}

fun restart(){
private fun restart(){
for(series in chartData){
series.resetData(arrayOf(DataPoint(0.0, 0.0)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.motionapps.sensorbox.uiHandlers
import android.content.Context
import com.motionapps.sensorservices.types.SensorNeeds
import dagger.hilt.android.qualifiers.ActivityContext
import dagger.hilt.android.scopes.ActivityScoped
import dagger.hilt.android.scopes.ViewModelScoped
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor(
private val savedStateHandle: SavedStateHandle,
private val repository: MainRepository
) : ViewModel(), CountDownInterface, WearOsListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.motionapps.wearoslib.WearOsConstants
import com.motionapps.wearoslib.WearOsListener
import com.motionapps.wearoslib.WearOsStates
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.scopes.ActivityRetainedScoped
import kotlinx.coroutines.*
import javax.inject.Inject

Expand Down
30 changes: 0 additions & 30 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

Loading

0 comments on commit dc224d5

Please sign in to comment.