Skip to content

Commit

Permalink
Merge pull request #9 from droid-lover/sachin/easy_analytics_android1…
Browse files Browse the repository at this point in the history
…2_support

Updated project to android12
  • Loading branch information
droid-lover authored Feb 28, 2022
2 parents b758ad2 + 395bd94 commit 50e973a
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 26 deletions.
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ dependencies {


//Room
def roomVersion = "2.2.2"
def roomVersion = "2.4.0"
implementation "androidx.room:room-runtime:$roomVersion"
implementation "androidx.room:room-ktx:$roomVersion"
kapt "androidx.room:room-compiler:$roomVersion"
Expand All @@ -111,9 +111,12 @@ dependencies {
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
implementation 'androidx.fragment:fragment-ktx:1.2.5'
implementation 'com.chibatching.kotpref:kotpref:2.13.1'
//Splash screen Api
implementation 'androidx.core:core-splashscreen:1.0.0-beta01'

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


}
24 changes: 9 additions & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,27 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme">

<activity
android:name="com.example.sampleapp.views.activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar"
android:exported="false"
/>
<activity
android:name="com.example.sampleapp.views.activities.NewsDetailActivity"
android:label="@string/title_activity_news_detail"
android:theme="@style/AppTheme.NoActionBar"
android:exported="false"/>
<activity
android:name="com.example.sampleapp.views.activities.SplashScreenActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.Design.Light.NoActionBar"
android:exported="true">
android:exported="true"
android:theme="@style/SplashScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name="com.example.sampleapp.views.activities.NewsDetailActivity"
android:exported="false"
android:label="@string/title_activity_news_detail"
android:theme="@style/AppTheme.NoActionBar" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.example.sampleapp.R
import com.example.sampleapp.utils.SampleAppPrefs
import com.example.sampleapp.views.fragments.NewsFragment
Expand All @@ -25,6 +26,7 @@ import kotlinx.android.synthetic.main.layout_toolbar_view.view.*
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
<item name="android:windowBackground">@null</item>
</style>

<style name="SplashScreenTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/white</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_analytics_app_icon</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>


<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.10"
ext.kotlin_version = "1.5.30"
ext.hilt_version='2.28-alpha'
ext.lifecycle_version='2.2.0'
ext.retrofit_version = "2.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import com.vs.easyanalytics.reports.ui.EasyAnalyticsReportsActivity
import com.vs.easyanalytics.reports.db.EasyAnalyticsDatabase
import com.vs.easyanalytics.utils.AppPrefs
import com.vs.easyanalytics.utils.Utils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext

/**
* Created by Sachin.
* https://iamsachinrajput.medium.com/
Expand Down Expand Up @@ -61,9 +64,9 @@ object EasyAnalytics {
val logger = EasyAnalyticsLogger(screenAction,dataConsumedInLastActionValue, Utils.getCurrentTime())

runBlocking {
launch {
EasyAnalyticsDatabase.getDatabase(context).easyAnalyticsDao().insertAnalyticLog(logger)
}
withContext(Dispatchers.IO) {
EasyAnalyticsDatabase.getDatabase(context).easyAnalyticsDao().insertAnalyticLog(logger)
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import com.vs.easyanalytics.entity.EasyAnalyticsLogger
interface EasyAnalyticsDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertAnalyticLog(easyAnalyticsLogger: EasyAnalyticsLogger)
fun insertAnalyticLog(easyAnalyticsLogger: EasyAnalyticsLogger)

@Query("Select * from EasyAnalyticsLogger")
suspend fun getAnalytics(): List<EasyAnalyticsLogger>
fun getAnalytics(): List<EasyAnalyticsLogger>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import com.vs.easyanalytics.R
import com.vs.easyanalytics.entity.EasyAnalyticsLogger
import com.vs.easyanalytics.reports.db.EasyAnalyticsDatabase
import kotlinx.android.synthetic.main.activity_easy_analytical_reports.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext

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

runBlocking {
launch {
val eaAnalyticsValues = EasyAnalyticsDatabase.getDatabase(this@EasyAnalyticsReportsActivity).easyAnalyticsDao().getAnalytics()
Log.e(TAG, "inside_get ${eaAnalyticsValues.size}")
if(!eaAnalyticsValues.isNullOrEmpty()){
showEasyAnalyticsReports(eaAnalyticsValues)
withContext(Dispatchers.IO) {
val eaAnalyticsValues =
EasyAnalyticsDatabase.getDatabase(this@EasyAnalyticsReportsActivity)
.easyAnalyticsDao().getAnalytics()
Log.e(TAG, "inside_get ${eaAnalyticsValues.size}")
if (!eaAnalyticsValues.isNullOrEmpty()) {
showEasyAnalyticsReports(eaAnalyticsValues)
}
}
}
}
Expand Down

0 comments on commit 50e973a

Please sign in to comment.