Skip to content

Commit 50e973a

Browse files
authored
Merge pull request #9 from droid-lover/sachin/easy_analytics_android12_support
Updated project to android12
2 parents b758ad2 + 395bd94 commit 50e973a

File tree

8 files changed

+41
-26
lines changed

8 files changed

+41
-26
lines changed

app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ dependencies {
8484

8585

8686
//Room
87-
def roomVersion = "2.2.2"
87+
def roomVersion = "2.4.0"
8888
implementation "androidx.room:room-runtime:$roomVersion"
8989
implementation "androidx.room:room-ktx:$roomVersion"
9090
kapt "androidx.room:room-compiler:$roomVersion"
@@ -111,9 +111,12 @@ dependencies {
111111
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
112112
implementation 'androidx.fragment:fragment-ktx:1.2.5'
113113
implementation 'com.chibatching.kotpref:kotpref:2.13.1'
114+
//Splash screen Api
115+
implementation 'androidx.core:core-splashscreen:1.0.0-beta01'
114116

115117
//Easy Analytics
116118
implementation(project(":easyAnalytics"))
117119
// implementation 'com.github.myJarvis:EasyAnalytics:0.0.4'
118120

121+
119122
}

app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,27 @@
1313
android:icon="@mipmap/ic_launcher"
1414
android:label="@string/app_name"
1515
android:networkSecurityConfig="@xml/network_security_config"
16+
android:requestLegacyExternalStorage="true"
1617
android:roundIcon="@mipmap/ic_launcher_round"
1718
android:supportsRtl="true"
18-
android:requestLegacyExternalStorage="true"
1919
android:theme="@style/AppTheme">
2020

2121
<activity
2222
android:name="com.example.sampleapp.views.activities.MainActivity"
23-
android:theme="@style/AppTheme.NoActionBar"
24-
android:exported="false"
25-
/>
26-
<activity
27-
android:name="com.example.sampleapp.views.activities.NewsDetailActivity"
28-
android:label="@string/title_activity_news_detail"
29-
android:theme="@style/AppTheme.NoActionBar"
30-
android:exported="false"/>
31-
<activity
32-
android:name="com.example.sampleapp.views.activities.SplashScreenActivity"
33-
android:screenOrientation="portrait"
34-
android:theme="@style/Theme.Design.Light.NoActionBar"
35-
android:exported="true">
23+
android:exported="true"
24+
android:theme="@style/SplashScreenTheme">
3625
<intent-filter>
3726
<action android:name="android.intent.action.MAIN" />
38-
3927
<category android:name="android.intent.category.LAUNCHER" />
4028
</intent-filter>
4129
</activity>
4230

31+
<activity
32+
android:name="com.example.sampleapp.views.activities.NewsDetailActivity"
33+
android:exported="false"
34+
android:label="@string/title_activity_news_detail"
35+
android:theme="@style/AppTheme.NoActionBar" />
36+
4337
<provider
4438
android:name="androidx.core.content.FileProvider"
4539
android:authorities="${applicationId}.provider"

app/src/main/java/com/example/sampleapp/views/activities/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidx.appcompat.app.AlertDialog
1414
import androidx.appcompat.app.AppCompatActivity
1515
import androidx.core.app.ActivityCompat
1616
import androidx.core.content.ContextCompat
17+
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
1718
import com.example.sampleapp.R
1819
import com.example.sampleapp.utils.SampleAppPrefs
1920
import com.example.sampleapp.views.fragments.NewsFragment
@@ -25,6 +26,7 @@ import kotlinx.android.synthetic.main.layout_toolbar_view.view.*
2526
@AndroidEntryPoint
2627
class MainActivity : AppCompatActivity() {
2728
override fun onCreate(savedInstanceState: Bundle?) {
29+
installSplashScreen()
2830
super.onCreate(savedInstanceState)
2931
setContentView(R.layout.activity_main)
3032

app/src/main/res/values/styles.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
<item name="android:windowBackground">@null</item>
1616
</style>
1717

18+
<style name="SplashScreenTheme" parent="Theme.SplashScreen">
19+
<item name="windowSplashScreenBackground">@color/white</item>
20+
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_analytics_app_icon</item>
21+
<item name="postSplashScreenTheme">@style/AppTheme</item>
22+
</style>
23+
24+
1825
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
1926

2027
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
3-
ext.kotlin_version = "1.4.10"
3+
ext.kotlin_version = "1.5.30"
44
ext.hilt_version='2.28-alpha'
55
ext.lifecycle_version='2.2.0'
66
ext.retrofit_version = "2.9.0"

easyAnalytics/src/main/java/com/vs/easyanalytics/EasyAnalytics.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ import com.vs.easyanalytics.reports.ui.EasyAnalyticsReportsActivity
1313
import com.vs.easyanalytics.reports.db.EasyAnalyticsDatabase
1414
import com.vs.easyanalytics.utils.AppPrefs
1515
import com.vs.easyanalytics.utils.Utils
16+
import kotlinx.coroutines.Dispatchers
1617
import kotlinx.coroutines.launch
1718
import kotlinx.coroutines.runBlocking
19+
import kotlinx.coroutines.withContext
20+
1821
/**
1922
* Created by Sachin.
2023
* https://iamsachinrajput.medium.com/
@@ -61,9 +64,9 @@ object EasyAnalytics {
6164
val logger = EasyAnalyticsLogger(screenAction,dataConsumedInLastActionValue, Utils.getCurrentTime())
6265

6366
runBlocking {
64-
launch {
65-
EasyAnalyticsDatabase.getDatabase(context).easyAnalyticsDao().insertAnalyticLog(logger)
66-
}
67+
withContext(Dispatchers.IO) {
68+
EasyAnalyticsDatabase.getDatabase(context).easyAnalyticsDao().insertAnalyticLog(logger)
69+
}
6770
}
6871

6972
}

easyAnalytics/src/main/java/com/vs/easyanalytics/reports/db/EasyAnalyticsDao.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import com.vs.easyanalytics.entity.EasyAnalyticsLogger
1313
interface EasyAnalyticsDao {
1414

1515
@Insert(onConflict = OnConflictStrategy.REPLACE)
16-
suspend fun insertAnalyticLog(easyAnalyticsLogger: EasyAnalyticsLogger)
16+
fun insertAnalyticLog(easyAnalyticsLogger: EasyAnalyticsLogger)
1717

1818
@Query("Select * from EasyAnalyticsLogger")
19-
suspend fun getAnalytics(): List<EasyAnalyticsLogger>
19+
fun getAnalytics(): List<EasyAnalyticsLogger>
2020
}

easyAnalytics/src/main/java/com/vs/easyanalytics/reports/ui/EasyAnalyticsReportsActivity.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import com.vs.easyanalytics.R
1010
import com.vs.easyanalytics.entity.EasyAnalyticsLogger
1111
import com.vs.easyanalytics.reports.db.EasyAnalyticsDatabase
1212
import kotlinx.android.synthetic.main.activity_easy_analytical_reports.*
13+
import kotlinx.coroutines.Dispatchers
1314
import kotlinx.coroutines.launch
1415
import kotlinx.coroutines.runBlocking
16+
import kotlinx.coroutines.withContext
1517

1618
/**
1719
* Created by Sachin.
@@ -27,10 +29,14 @@ class EasyAnalyticsReportsActivity : AppCompatActivity() {
2729

2830
runBlocking {
2931
launch {
30-
val eaAnalyticsValues = EasyAnalyticsDatabase.getDatabase(this@EasyAnalyticsReportsActivity).easyAnalyticsDao().getAnalytics()
31-
Log.e(TAG, "inside_get ${eaAnalyticsValues.size}")
32-
if(!eaAnalyticsValues.isNullOrEmpty()){
33-
showEasyAnalyticsReports(eaAnalyticsValues)
32+
withContext(Dispatchers.IO) {
33+
val eaAnalyticsValues =
34+
EasyAnalyticsDatabase.getDatabase(this@EasyAnalyticsReportsActivity)
35+
.easyAnalyticsDao().getAnalytics()
36+
Log.e(TAG, "inside_get ${eaAnalyticsValues.size}")
37+
if (!eaAnalyticsValues.isNullOrEmpty()) {
38+
showEasyAnalyticsReports(eaAnalyticsValues)
39+
}
3440
}
3541
}
3642
}

0 commit comments

Comments
 (0)