Skip to content

Commit

Permalink
Merge pull request #53 from ringpublishing/feature/NEWSYST243-7-andro…
Browse files Browse the repository at this point in the history
…id-platform-modules-target-sdk-android-15-

Feature/newsyst243 7 android platform modules target sdk android 15
  • Loading branch information
danielcalka committed Sep 20, 2024
2 parents 3fb4738 + 81e4f21 commit 69bd047
Show file tree
Hide file tree
Showing 15 changed files with 253 additions and 203 deletions.
15 changes: 15 additions & 0 deletions Changelogs/1.5.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
1.5.1 Release notes (2024-09-12)
=============================================================

* Added SDK 35 support

### Changes

* Bumped Gradle version to 8.7
* Bumped Gradle Plugin version to 8.6.0
* Bumped Target SDK version to 35
* Bumped Compile SDK version to 35
* Bumped Build Tools version to 35.0.0
* Updated demo application views and styles
* Disabled html escaping during parsing requests

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal class ApiClient(private val apiKey: String, private val apiUrl: URL, pr
.addConverterFactory(
GsonConverterFactory.create(
GsonBuilder()
.disableHtmlEscaping()
.registerTypeAdapter(IdsMap::class.java, IdsMapDeserializer())
.create()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

package com.ringpublishing.tracking.internal.keepalive

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import com.google.gson.Gson
import com.ringpublishing.tracking.data.ContentMetadata
import com.ringpublishing.tracking.internal.EventsReporter
Expand All @@ -24,7 +22,7 @@ internal class KeepAliveReporter(
screenSizeInfo: ScreenSizeInfo,
private val lifecycleOwner: LifecycleOwner,
gson: Gson
) : KeepAliveSendTimerCallback, LifecycleObserver
) : KeepAliveSendTimerCallback, DefaultLifecycleObserver
{

private val timer = KeepAliveTimer(this)
Expand Down Expand Up @@ -176,39 +174,37 @@ internal class KeepAliveReporter(
}
}

@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onEnterForeground()
{
if (contentMetadata == null || isPaused || !isInBackground)
{
Logger.debug("KeepAliveReporter: onEnterForeground() ignored")
return
}
override fun onStart(owner: LifecycleOwner)
{
if (contentMetadata == null || isPaused || !isInBackground)
{
Logger.debug("KeepAliveReporter: onEnterForeground() ignored")
return
}

isInBackground = false
isInBackground = false

Logger.debug("KeepAliveReporter: onEnterForeground()")
Logger.debug("KeepAliveReporter: onEnterForeground()")

timer.resumeBackground()
timer.resumeBackground()

takeMeasurements(KeepAliveMeasureType.DOCUMENT_ALIVE)
takeMeasurements(KeepAliveMeasureType.DOCUMENT_ALIVE)

timer.scheduleActivityTimer()
timer.scheduleSendTimer()
}
timer.scheduleActivityTimer()
timer.scheduleSendTimer()
}

@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
fun onEnterBackground()
{
if (contentMetadata == null || isPaused)
{
Logger.warn("KeepAliveReporter: onEnterBackground() ignored")
return
}
Logger.debug("KeepAliveReporter: onEnterBackground()")
override fun onStop(owner: LifecycleOwner)
{
if (contentMetadata == null || isPaused)
{
Logger.warn("KeepAliveReporter: onEnterBackground() ignored")
return
}
Logger.debug("KeepAliveReporter: onEnterBackground()")

timer.pauseBackground()
takeMeasurements(KeepAliveMeasureType.DOCUMENT_INACTIVE)
isInBackground = true
}
timer.pauseBackground()
takeMeasurements(KeepAliveMeasureType.DOCUMENT_INACTIVE)
isInBackground = true
}
}
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript

dependencies
{
classpath "com.android.tools.build:gradle:8.1.0"
classpath "com.android.tools.build:gradle:8.6.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0"
}
}
Expand All @@ -28,7 +28,7 @@ allprojects

task clean(type: Delete)
{
delete rootProject.buildDir
delete(rootProject.layout.buildDirectory.get().asFile)
}

ext
Expand All @@ -37,9 +37,9 @@ ext
JAVA_VERSION = JavaVersion.VERSION_17

MIN_SDK_VERSION = 22
TARGET_SDK_VERSION = 34
COMPILE_SDK_VERSION = 34
BUILD_TOOLS_VERSION = '34.0.0'
TARGET_SDK_VERSION = 35
COMPILE_SDK_VERSION = 35
BUILD_TOOLS_VERSION = '35.0.0'
}

allprojects {
Expand Down
8 changes: 4 additions & 4 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.ringpublishing.tracking.demo">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
Expand All @@ -20,8 +20,7 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme.Main">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -31,7 +30,8 @@
</activity>

<activity
android:name=".ArticleActivity"/>
android:name=".ArticleActivity"
android:theme="@style/AppTheme.Article" />

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,40 @@ import com.ringpublishing.tracking.demo.extension.readArticlePosition
import com.ringpublishing.tracking.demo.extension.startArticleActivityFromPush
import com.ringpublishing.tracking.demo.fragment.ArticleFragment

class ArticleActivity : AppCompatActivity()
{

override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_article)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}

override fun onSupportNavigateUp(): Boolean
{
onBackPressed()
return true
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean
{
menuInflater.inflate(R.menu.article_action_bar_menu, menu)
return super.onCreateOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean
{
when (item.itemId)
{
R.id.articleMenuPush ->
{
startArticleActivityFromPush(readArticlePosition())
}
R.id.articleMenuModal ->
{
ArticleDialog().show(this)
}
R.id.articleMenuAddContent ->
{
getArticleFragment()?.addContent()
}
}
return super.onOptionsItemSelected(item)
}

private fun getArticleFragment() = (supportFragmentManager.findFragmentById(R.id.articleFragment) as ArticleFragment?)
class ArticleActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_article)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}

override fun onSupportNavigateUp(): Boolean {
onBackPressedDispatcher.onBackPressed()
return true
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.article_action_bar_menu, menu)
return super.onCreateOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.articleMenuPush -> {
startArticleActivityFromPush(readArticlePosition())
}

R.id.articleMenuModal -> {
ArticleDialog().show(this)
}

R.id.articleMenuAddContent -> {
getArticleFragment()?.addContent()
}
}
return super.onOptionsItemSelected(item)
}

private fun getArticleFragment() = (supportFragmentManager.findFragmentById(R.id.articleFragment) as ArticleFragment?)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.ringpublishing.tracking.demo

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.viewpager.widget.ViewPager
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.tabs.TabLayout
import com.ringpublishing.tracking.demo.adapter.MainPagerAdapter
import com.ringpublishing.tracking.demo.fragment.ActionsFragment
Expand All @@ -18,9 +23,12 @@ class MainActivity : AppCompatActivity()
{
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initTopInsets()

val tabViewpager = findViewById<ViewPager>(R.id.tab_viewpager)
val tabTabLayout = findViewById<TabLayout>(R.id.tab_tab_layout)
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)

tabViewpager.adapter = createAdapterWithFragments()
tabTabLayout.setupWithViewPager(tabViewpager)
Expand All @@ -36,4 +44,13 @@ class MainActivity : AppCompatActivity()
addFragment("PAID", PaidFragment())
}
}

private fun initTopInsets() {
val appBarLayout = findViewById<AppBarLayout>(R.id.app_bar_layout)
ViewCompat.setOnApplyWindowInsetsListener(appBarLayout) { v: View, insets: WindowInsetsCompat ->
val statusBarHeight = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top
v.setPadding(0, statusBarHeight, 0, 0)
WindowInsetsCompat.Builder(insets).build()
}
}
}
Loading

0 comments on commit 69bd047

Please sign in to comment.