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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package dev.hossain.ynaash.example.ui
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import dev.hossain.ynaash.example.R
import dev.hossain.ynaash.example.ui.demohighlightjs.HighlightJsDemoActivity
import dev.hossain.ynaash.example.ui.demoprismjs.PrismJsDemoActivity
Expand All @@ -14,9 +17,17 @@ import dev.hossain.ynaash.example.ui.demoprismjs.PrismJsComposeDemoActivity
*/
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

// Apply window insets to handle system bars
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main_container)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}

findViewById<Button>(R.id.highlightjs_demo_button).setOnClickListener {
startActivity(Intent(this, HighlightJsDemoActivity::class.java))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package dev.hossain.ynaash.example.ui.demohighlightjs

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import dev.hossain.ynaash.example.R
import dev.hossain.ynaash.example.ui.common.SampleSourceCode
import dev.hossain.ynaash.highlightjs.SyntaxHighlighterFragment
Expand All @@ -16,11 +19,19 @@ import dev.hossain.ynaash.highlightjs.SyntaxHighlighterWebView
*/
class HighlightJsDemoActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_demo_highlightjs)

supportActionBar?.title = "HighlightJS Demo"

// Apply window insets to handle system bars
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.demo_container)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}

loadSourceCodeFragment()
loadSourceCodeCustomView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.hossain.ynaash.example.ui.demoprismjs

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
Expand All @@ -23,6 +24,7 @@ import dev.hossain.ynaash.example.ui.common.SampleSourceCode
class PrismJsComposeDemoActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)

supportActionBar?.title = "PrismJS Compose Demo"
Expand All @@ -45,6 +47,7 @@ fun PrismJsComposeDemoScreen() {
Column(
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(WindowInsets.systemBars)
.padding(16.dp)
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(16.dp)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package dev.hossain.ynaash.example.ui.demoprismjs

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import dev.hossain.ynaash.example.R
import dev.hossain.ynaash.example.ui.common.SampleSourceCode
import dev.hossain.ynaash.prismjs.SyntaxHighlighterFragment
Expand All @@ -16,11 +19,19 @@ import dev.hossain.ynaash.prismjs.SyntaxHighlighterWebView
*/
class PrismJsDemoActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_demo_prismjs)

supportActionBar?.title = "PrismJS Demo"

// Apply window insets to handle system bars
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.demo_container)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}

loadSourceCodeFragment()
loadSourceCodeCustomView()
}
Expand Down
1 change: 1 addition & 0 deletions example/src/main/res/layout/activity_demo_highlightjs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/demo_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
Expand Down
1 change: 1 addition & 0 deletions example/src/main/res/layout/activity_demo_prismjs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/demo_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
Expand Down
1 change: 1 addition & 0 deletions example/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="24dp"
Expand Down
15 changes: 15 additions & 0 deletions example/src/main/res/values-v23/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<resources>
<!-- Base application theme for API 23+ -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<!-- Enable edge-to-edge display -->
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">true</item>
</style>

</resources>
19 changes: 19 additions & 0 deletions example/src/main/res/values-v29/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<resources>
<!-- Base application theme for API 29+ (Android 10) with enhanced edge-to-edge support -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<!-- Enable edge-to-edge display -->
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar">true</item>
<item name="android:enforceStatusBarContrast">false</item>
<item name="android:enforceNavigationBarContrast">false</item>
</style>

</resources>
5 changes: 4 additions & 1 deletion example/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<!-- Enable edge-to-edge display for supported devices -->
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="p">shortEdges</item>
</style>

</resources>