Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.

Commit 0bcd296

Browse files
committed
[ADDED] [#16] Support to preview layout URL using webview.
FIxes #16
1 parent 95db8b7 commit 0bcd296

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ dependencies {
5454
// https://developer.android.com/topic/libraries/architecture/adding-components
5555
implementation "android.arch.lifecycle:extensions:$rootProject.archComponentVersion"
5656

57+
// https://developer.chrome.com/multidevice/android/customtabs
58+
compile "com.android.support:customtabs:$rootProject.supportLibraryVersion"
59+
5760
// ========================================================
5861
// 3rd party libraries
5962
// ========================================================

app/src/main/java/com/hossainkhan/android/demo/layoutpositioning/LayoutPositioningDemoActivity.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ package com.hossainkhan.android.demo.layoutpositioning
1818

1919
import android.content.Context
2020
import android.content.Intent
21+
import android.net.Uri
2122
import android.os.Bundle
2223
import android.support.annotation.LayoutRes
24+
import android.support.customtabs.CustomTabsIntent
2325
import android.support.v7.app.AppCompatActivity
2426
import android.view.Menu
2527
import android.view.MenuItem
@@ -94,6 +96,7 @@ class LayoutPositioningDemoActivity : AppCompatActivity() {
9496
override fun onActionTapped(bar: Flashbar) {
9597
Timber.d("Loading the XML for ")
9698
bar.dismiss()
99+
loadLayoutUrl()
97100
}
98101
})
99102
.negativeActionTapListener(object : Flashbar.OnActionTapListener {
@@ -110,6 +113,18 @@ class LayoutPositioningDemoActivity : AppCompatActivity() {
110113
}
111114
}
112115

116+
/**
117+
* Loads currently running layout from Github into chrome web view.
118+
*/
119+
fun loadLayoutUrl() {
120+
val layoutUrl = appDataStore.layoutStore.getLayoutUrl(layoutInformation.layoutResourceId)
121+
val builder = CustomTabsIntent.Builder()
122+
builder.setShowTitle(false)
123+
.addDefaultShareMenuItem()
124+
val customTabsIntent = builder.build()
125+
customTabsIntent.launchUrl(this, Uri.parse(layoutUrl))
126+
}
127+
113128

114129
//
115130
// Setup menu item on the action bar.

0 commit comments

Comments
 (0)