Skip to content

Commit

Permalink
ASDK-1397: Create storyblock example app (#46)
Browse files Browse the repository at this point in the history
**What**
Create storyblock example app


**Why**
- ASDK-1397


**How**
Create app with single screen which hosts the Storyblock.

**Screenshots**
<!-- Before and After screenshots if it is a UI change -->

|  Collapsed   |   Fullscreen   |
|-----------|-----------|
|
![Screenshot2](https://user-images.githubusercontent.com/101661405/226871685-bada7179-1a4e-4dc4-9fb5-f42ae75ec85e.jpeg)
|
![Screenshot1](https://user-images.githubusercontent.com/101661405/226871689-de303036-a1a4-417a-b074-a4724a0fcb31.jpeg)
|
  • Loading branch information
OstapOpalynskyi-fw authored Mar 22, 2023
1 parent bef0856 commit 6564836
Show file tree
Hide file tree
Showing 36 changed files with 814 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/story_block.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Story Block CI

concurrency:
group: story_block:${{ github.head_ref }}
cancel-in-progress: true

on:
pull_request:
branches: [ "main" ]
paths: [ "story_block/**" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Build with Gradle
run: |
cd story_block
chmod +x ./gradlew
./gradlew build
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This repo holds the Firework Android SDK example applications.
* [Share Link](#share-link-example-app)
* [Picture In Picture](#picture-in-picture-example-app)
* [Jetpack Compose](#jetpack-compose-example-app)
* [Story Block](#story-block-example-app)

**Read more about the integration here** https://docs.firework.tv/

Expand Down Expand Up @@ -145,4 +146,17 @@ In this example app, the `FwVideoFeedView` is initialized for showing a discover
| ------------------------------------------------ | --------------------------------------------- |
| ![discovery Screenshot](compose/Screenshot1.png) | ![player Screenshot](compose/Screenshot2.png) |

---

## Story block example app

This example app demonstrates the usage of StoryBlock component.
This component allows to embed pager player directly in the host app's view hierarchy.

[Story block example app](story_block)

| Story block | Fullscreen Story Block |
|---------------------------------------------------------|-----------------------------------------------------------|
| ![Story block example app](story_block/Screenshot1.jpeg) | ![Story block example app](story_block/Screenshot2.jpeg) |

---
25 changes: 25 additions & 0 deletions story_block/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SOURCE: https://github.com/JetBrains/kotlin-playground/blob/master/.editorconfig
root = true


[*]
indent_style = space
indent_size = 4

max_line_length = 150

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

ij_continuation_indent_size = 4
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_spaces_around_equality_operators = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
46 changes: 46 additions & 0 deletions story_block/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SOURCE: https://github.com/github/gitignore/blob/master/Android.gitignore

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Log/OS Files
*.log

# Android Studio generated files and folders
captures/
.externalNativeBuild/
.cxx/
*.apk
*.ap_
*.aab
*.aar
output.json

# IntelliJ
*.iml
.idea/*
!.idea/codeStyles/
!.idea/detekt.xml
misc.xml
deploymentTargetDropDown.xml
render.experimental.xml

# Keystore files
# *.jks
# *.keystore

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Android Profiling
*.hprof

# Windows thumbnail db
Thumbs.db

# OSX files
.DS_Store
Binary file added story_block/Screenshot1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added story_block/Screenshot2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions story_block/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
84 changes: 84 additions & 0 deletions story_block/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jlleitschuh.gradle.ktlint")
id("io.gitlab.arturbosch.detekt")
}

android {
namespace = "com.firework.example.storyblock"

compileSdk = 33

defaultConfig {
applicationId = "com.firework.example.storyblock"

minSdk = 21
targetSdk = 33

versionCode = 1
versionName = "1.0.0"
}

buildTypes {
defaultConfig {
buildConfigField("String", "FW_CLIENT_ID", "\"f6d6ec1275217f178cdff91363825cb390e038c1168f64f6efa23cb95ec6b325\"")
buildConfigField("String", "FW_CHANNEL_ID", "\"7RXwK8k\"")
buildConfigField("String", "FW_PLAYLIST_ID", "\"g4lA0g\"")
}
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
allWarningsAsErrors = true
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

lint {
abortOnError = true
ignoreWarnings = false
warningsAsErrors = true
}

buildFeatures {
viewBinding = true
}
}

detekt {
allRules = true
config = files("$rootDir/config/detekt/detekt-config.yml")
baseline = file("detekt-baseline.xml")
buildUponDefaultConfig = true
}

dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

implementation("com.google.android.material:material:1.8.0")

implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.6.10"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

// Glide
implementation("com.github.bumptech.glide:glide:4.13.2")

// Firework SDK
val fireworkSdkVersion = "6.1.0"
implementation("com.firework:sdk:$fireworkSdkVersion")

// Glide (optional image loader)
implementation("com.firework.external.imageloading:glide:$fireworkSdkVersion")

// Picasso (optional image loader)
// implementation("com.firework.external.imageloading:picasso:$fireworkSdkVersion")
}
21 changes: 21 additions & 0 deletions story_block/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
26 changes: 26 additions & 0 deletions story_block/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

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

<application
android:name="com.firework.example.storyblock.ExampleApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.FireworkExample">

<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</application>

</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.firework.example.storyblock

import android.app.Application
import android.util.Log
import com.firework.example.storyblock.BuildConfig.FW_CLIENT_ID
import com.firework.imageloading.glide.GlideImageLoaderFactory
import com.firework.sdk.FireworkSdk
import com.firework.sdk.FireworkSdkConfig

class ExampleApplication : Application() {

override fun onCreate() {
super.onCreate()

// build Firework Android SDK v6 configuration
val config = FireworkSdkConfig.Builder(this)
.checksumRequired(false)
.clientId(FW_CLIENT_ID) // Client OAUTH Id
.userId("example app user ID") // User Id in your eco-system
.imageLoader(GlideImageLoaderFactory.createInstance()) // glide, picasso, or your implementation
.build()

// initialize Firework Android SDK v6
FireworkSdk.init(
fireworkSdkConfig = config,
onSuccess = {
Log.i("FireworkSDK", "Firework SDK initialized successfully")
},
onError = { initError ->
Log.e("FireworkSDK", "Error initializing Firework - $initError")
},
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.firework.example.storyblock

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.firework.common.PlayerMode
import com.firework.common.feed.FeedResource
import com.firework.example.storyblock.databinding.ActivityMainBinding
import com.firework.viewoptions.baseOptions
import com.firework.viewoptions.playerOptions
import com.firework.viewoptions.viewOptions

class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)

setContentView(binding.root)

binding.storyBlock.init(
supportFragmentManager,
lifecycle,
viewOptions {
baseOptions {
feedResource(FeedResource.Discovery)
}
playerOptions {
playerMode(PlayerMode.FIT_MODE)
}
},
binding.storyBlockContainer,
)
binding.storyBlock.setOnErrorListener {
Log.i("StoryBlock-Fragment", it.toString())
}
binding.btnPlay.setOnClickListener {
binding.storyBlock.play()
}

binding.btnPause.setOnClickListener {
binding.storyBlock.pause()
}
binding.storyBlock.setFeedLoadListener {
Log.i("StoryBlock", it.toString())
}
}
}
Loading

0 comments on commit 6564836

Please sign in to comment.