Skip to content
Open
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
183 changes: 183 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
name: 🤖 Build Android App

on:
push:
branches:
- main
- 'rebrand/**'
tags:
- 'v*'
pull_request:
branches:
- main
workflow_dispatch:
inputs:
send_telegram:
description: 'Send the APKs to Telegram as well'
type: boolean
default: true

permissions:
contents: read

concurrency:
group: apk-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: 🧪 Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: All action steps are pinned to mutable major-version tags (@v7, @v6, @v4) rather than immutable commit SHAs. This CI job receives BOT_TOKEN and API_HASH as environment secrets — a tag can be silently re-pointed to malicious code that exfiltrates those credentials. Pin every third-party action to a full commit SHA (e.g., actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683).


- name: Set up JDK 21
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '21'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
with:
cache-read-only: ${{ github.event_name == 'pull_request' }}

- name: Run unit tests
run: ./gradlew --no-daemon testDebugUnitTest

build:
name: 📦 Build APK
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Set up JDK 21
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '21'

- name: Set up Android SDK
uses: android-actions/setup-android@v4
with:
packages: platform-tools
accept-android-sdk-licenses: true
log-accepted-android-sdk-licenses: false

# API 37 is published as extension versions (android-37.0 / 37.1 / 37.2),
# not a bare "android-37", so try the ids in order and let AGP pull whatever
# is still missing on its own.
- name: Install platform and build-tools for API 37
continue-on-error: true
run: |
for pkg in "platforms;android-37" "platforms;android-37.0" "build-tools;37.0.0"; do
echo "Installing $pkg"
sdkmanager "$pkg" || echo "::warning::$pkg is not available in this channel"
done

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
with:
cache-read-only: ${{ github.event_name == 'pull_request' }}

# Python is only needed for the Telegram upload; installed up front so the
# send step does no pip work of its own.
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.12'

- name: Install Telethon
run: python -m pip install --disable-pip-version-check "telethon>=1.34"

- name: 🔑 Write local.properties (TMDB credentials)
env:
TMDB_ACCESS_TOKEN: ${{ secrets.TMDB_ACCESS_TOKEN }}
TMDB_API_KEY: ${{ secrets.TMDB_API_KEY }}
run: |
set -eu
{
printf 'access_token=%s\n' "${TMDB_ACCESS_TOKEN:-}"
printf 'api_key=%s\n' "${TMDB_API_KEY:-}"
printf 'sdk.dir=%s\n' "${ANDROID_HOME:-$ANDROID_SDK_ROOT}"
} > local.properties
if [ -z "${TMDB_ACCESS_TOKEN:-}" ]; then
echo "::warning::TMDB_ACCESS_TOKEN is not set - the APK still builds, but API calls fail at runtime."
fi

- name: 🛠 Build debug and release APKs
run: ./gradlew --no-daemon --stacktrace assembleDebug assembleRelease

- name: 🏷 Collect the APKs
id: apk
env:
GH_SHA: ${{ github.sha }}
run: |
set -euo pipefail
short="${GH_SHA:0:7}"
out="$(pwd)/out"
mkdir -p "$out"
cp app/build/outputs/apk/debug/app-debug.apk "$out/OpenStream-debug-$short.apk"
# No signingConfig in app/build.gradle.kts, so the release APK is unsigned.
release_apk="$(find app/build/outputs/apk/release -name '*.apk' | head -n1)"
cp "$release_apk" "$out/OpenStream-release-$short.apk"
Comment on lines +125 to +126

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Crash Risk: find ... | head -n1 under set -euo pipefail can cause a spurious SIGPIPE (exit code 141) when find has more results than head consumes, which pipefail treats as a pipeline failure. Additionally, if find returns no APK (e.g., assembleRelease only produced app-release-unsigned.apk in a subdirectory), release_apk is empty and the subsequent cp "$release_apk" silently copies nothing with a confusing error. Use a || true to suppress the SIGPIPE and add an explicit check for an empty result.

Suggested change
release_apk="$(find app/build/outputs/apk/release -name '*.apk' | head -n1)"
cp "$release_apk" "$out/OpenStream-release-$short.apk"
release_apk="$(find app/build/outputs/apk/release -name '*.apk' | head -n1 || true)"
if [ -z "$release_apk" ]; then
echo "::error::No release APK found under app/build/outputs/apk/release"
exit 1
fi
cp "$release_apk" "$out/OpenStream-release-$short.apk"

ls -lh "$out"
printf 'dir=%s\n' "$out" >> "$GITHUB_OUTPUT"
printf 'sha=%s\n' "$short" >> "$GITHUB_OUTPUT"

- name: 📤 Upload APK artifacts
uses: actions/upload-artifact@v7
with:
name: OpenStream-APK-${{ github.sha }}
path: ${{ steps.apk.outputs.dir }}/*.apk
if-no-files-found: error
retention-days: 30

- name: 🧭 Decide whether to post to Telegram
# `secrets` is not available in step-level `if`, so presence is checked
# here and only a boolean leaves the step. Values are never printed.
id: tg
if: github.event_name != 'pull_request'
env:
TG_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TG_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
SEND: ${{ github.event.inputs.send_telegram }}
run: |
set -eu
if [ -z "${TG_BOT_TOKEN:-}" ] || [ -z "${TG_CHAT_ID:-}" ]; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
echo "TELEGRAM_BOT_TOKEN / TELEGRAM_CHAT_ID not configured - skipping the upload."
elif [ "${SEND:-}" = "false" ]; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
echo "Deselected at dispatch - skipping the upload."
else
echo "enabled=true" >> "$GITHUB_OUTPUT"
fi

- name: 📨 Send APKs to Telegram
if: steps.tg.outputs.enabled == 'true'
env:
API_ID: ${{ secrets.TELEGRAM_API_ID }}
API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TOPIC_ID: ${{ secrets.TELEGRAM_TOPIC_ID }}
APK_DIR: ${{ steps.apk.outputs.dir }}
APK_SHA: ${{ steps.apk.outputs.sha }}
# Branch names are attacker-controlled on PR events; passed via env so it
# is never interpolated into the script body.
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
python scripts/telegram_send.py \
--dir "$APK_DIR" \
--build-sha "$APK_SHA" \
--branch "$BRANCH_NAME" \
--run-url "$RUN_URL"

- name: 🧹 Remove local.properties
if: always()
run: rm -f local.properties
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2026 Ainul
Copyright (c) 2026 Ainul (original MovieDB project, https://github.com/ainulbedjo/owl)
Copyright (c) 2026 StudioAs Inc. (OpenStream modifications, lead developer @TheRealAshik)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
59 changes: 50 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
<div align="center">
<a href="https://github.com/ainulbedjo/owl">
<img src="https://raw.githubusercontent.com/ainulbedjo/owl/refs/heads/master/app/src/main/res/drawable/play_store_512.png" width="100" height="100">
<a href="https://github.com/synapseSRC/OpenStream">
<img src="https://raw.githubusercontent.com/ainulbedjo/owl/refs/heads/master/app/src/main/res/drawable/play_store_512.png" width="100" height="100" alt="OpenStream icon">
</a>
<h1>MovieDB</h1>
<h1>OpenStream</h1>
<p>An Android app for browsing movies from TMDB, built with Jetpack Compose and Material 3 Expressive.</p>
<p><sub>Developed by <strong>StudioAs Inc.</strong> · Lead developer <a href="https://github.com/TheRealAshik">@TheRealAshik</a></sub></p>
</div>

<table>
<tr>
<td>
<img src="https://raw.githubusercontent.com/ainulbedjo/owl/refs/heads/master/screenshot/home.png" alt="Home screenshot" width="100%" />
<img src="screenshot/home.png" alt="Home screenshot" width="100%" />
</td>
<td>
<img src="https://raw.githubusercontent.com/ainulbedjo/owl/refs/heads/master/screenshot/detail.png" alt="Detail screenshot" width="100%" />
<img src="screenshot/detail.png" alt="Detail screenshot" width="100%" />
</td>
<td>
<img src="https://raw.githubusercontent.com/ainulbedjo/owl/refs/heads/master/screenshot/favorites.png" alt="Favorites screenshot" width="100%" />
<img src="screenshot/favorites.png" alt="Favorites screenshot" width="100%" />
</td>
</tr>
<tr>
<td>
<img src="https://raw.githubusercontent.com/ainulbedjo/owl/refs/heads/master/screenshot/theme.png" alt="Theme screenshot" width="100%" />
<img src="screenshot/theme.png" alt="Theme screenshot" width="100%" />
</td>
<td>
<img src="https://raw.githubusercontent.com/ainulbedjo/owl/refs/heads/master/screenshot/offline.png" alt="Offline screenshot" width="100%" />
<img src="screenshot/offline.png" alt="Offline screenshot" width="100%" />
</td>
<td>
<img src="https://raw.githubusercontent.com/ainulbedjo/owl/refs/heads/master/screenshot/chucker.png" alt="Chucker screenshot" width="100%" />
<img src="screenshot/chucker.png" alt="Chucker screenshot" width="100%" />
</td>
</tr>
</table>
Expand All @@ -38,6 +39,38 @@
- **Appearance**: light, dark, or system mode and a choice of color palettes, saved between launches.
- **Offline**: only a lost connection opens a "No connection" sheet. Other errors stay in the section that failed.

## Build

```bash
# TMDB credentials go in local.properties (gitignored) — never committed.
echo "access_token=<TMDB read access token>" >> local.properties
echo "api_key=<TMDB v3 api key>" >> local.properties

./gradlew assembleDebug # app/build/outputs/apk/debug/
./gradlew assembleRelease # minified + shrunk, unsigned
./gradlew test # unit tests
```

Application id and namespace are `app.openstream`; the module list is in [`settings.gradle.kts`](settings.gradle.kts). Versions live in [`Deps.kt`](buildSrc/src/main/kotlin/Deps.kt).

## CI: build the APK and post it to Telegram

[` .github/workflows/android.yml `](.github/workflows/android.yml) builds both debug and release APKs on every push and pull request, uploads them as workflow artifacts, and sends them to a Telegram chat or forum topic with [`scripts/telegram_send.py`](scripts/telegram_send.py).

Repo **Settings → Secrets and variables → Actions** needs:

| Secret | Used for |
|---|---|
| `TMDB_ACCESS_TOKEN` | written into `local.properties` so the build has a working API token |
| `TMDB_API_KEY` | same, for the v3 key |
| `TELEGRAM_API_ID` | Telegram api_id from [my.telegram.org](https://my.telegram.org/) |
| `TELEGRAM_API_HASH` | Telegram api_hash |
| `TELEGRAM_BOT_TOKEN` | bot token from @BotFather |
| `TELEGRAM_CHAT_ID` | target chat, group, or channel id |
| `TELEGRAM_TOPIC_ID` | forum topic id; leave unset to post in General |

Uploads are skipped on `pull_request` runs (so fork code never touches the tokens) and whenever `TELEGRAM_BOT_TOKEN` or `TELEGRAM_CHAT_ID` is missing. `workflow_dispatch` has a `send_telegram` checkbox to skip the post while still building. The bot must be a member of the target chat, and `TELEGRAM_TOPIC_ID` only applies to forum-enabled supergroups.

## Libraries

| Area | Library |
Expand All @@ -58,6 +91,14 @@ Why each one was chosen is in [docs/libraries.md](docs/libraries.md). Versions a

MVVM with one-way data flow: the UI draws a `UiState`, a ViewModel owns it as a `StateFlow`, and repositories return `AppResult` values instead of throwing.

## Studio

OpenStream is maintained by **StudioAs Inc.**, with **@TheRealAshik** as lead developer. Planning notes and per-area decisions are in [docs/](docs/README.md).

## Credits and license

OpenStream is a rebranded build of the original **MovieDB** app by Ainul ([ainulbedjo/owl](https://github.com/ainulbedjo/owl)). That upstream project is MIT licensed and its copyright and permission notice are retained in [LICENSE](LICENSE), as the license requires; StudioAs Inc. holds the copyright on the OpenStream modifications.

## Resources
- [Material 3 Expressive](https://m3.material.io/blog/building-with-m3-expressive) | M3 Expressive design system
- [Moviebase.app](https://moviebase.app/) | Direct inspiration for research purposes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.moviedb
package app.openstream

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand All @@ -19,6 +19,6 @@ class ExampleInstrumentedTest {
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("app.moviedb", appContext.packageName)
assertEquals("app.openstream", appContext.packageName)
}
}
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Moviedb">
android:theme="@style/Theme.OpenStream">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Moviedb">
android:theme="@style/Theme.OpenStream">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.moviedb
package app.openstream

import android.app.Application
import dagger.hilt.android.HiltAndroidApp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package app.moviedb
package app.openstream

import androidx.compose.runtime.Composable
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import app.moviedb.core.model.ThemeSettings
import app.moviedb.detail.ui.DetailRoute
import app.moviedb.detail.ui.detailScreen
import app.moviedb.favorites.ui.FavoritesRoute
import app.moviedb.favorites.ui.favoritesScreen
import app.moviedb.home.ui.HomeRoute
import app.moviedb.home.ui.homeScreen
import app.openstream.core.model.ThemeSettings
import app.openstream.detail.ui.DetailRoute
import app.openstream.detail.ui.detailScreen
import app.openstream.favorites.ui.FavoritesRoute
import app.openstream.favorites.ui.favoritesScreen
import app.openstream.home.ui.HomeRoute
import app.openstream.home.ui.homeScreen


@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.moviedb
package app.openstream

import android.Manifest
import android.graphics.Color
Expand All @@ -15,10 +15,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import app.moviedb.core.BuildConfig
import app.moviedb.core.model.ThemeMode
import app.moviedb.core.model.ThemeSettings
import app.moviedb.designsystem.theme.MoviedbTheme
import app.openstream.core.BuildConfig
import app.openstream.core.model.ThemeMode
import app.openstream.core.model.ThemeSettings
import app.openstream.designsystem.theme.OpenStreamTheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand Down Expand Up @@ -50,7 +50,7 @@ class MainActivity : ComponentActivity() {
onDispose {}
}

MoviedbTheme(paletteId = theme.paletteId, darkTheme = dark) {
OpenStreamTheme(paletteId = theme.paletteId, darkTheme = dark) {
AppNavHost(
theme = theme,
onThemeChange = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package app.moviedb
package app.openstream

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import app.moviedb.core.data.repository.ThemeRepository
import app.moviedb.core.model.ThemeSettings
import app.openstream.core.data.repository.ThemeRepository
import app.openstream.core.model.ThemeSettings
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.SharingStarted
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">moviedb</string>
<string name="app_name">OpenStream</string>
</resources>
Loading
Loading