Skip to content

garylparas/Android-App-TV-Remote

Repository files navigation

Universal IR TV Remote

A universal Infrared (IR) TV Remote Android application with priority support for Samsung TVs. Built with Kotlin and Jetpack Compose following modern Android development best practices.

Features

  • Universal TV Control - Support for Samsung, LG, Sony, Vizio, Panasonic, TCL, Hisense, and more
  • Samsung Priority - Comprehensive Samsung TV code coverage
  • Offline Operation - No internet connection required
  • Modern UI - Built with Jetpack Compose and Material Design 3
  • Secure - OWASP Mobile Security compliant, no unnecessary permissions
  • Clean Architecture - MVVM pattern with clean separation of concerns

Requirements

  • Android device with built-in IR blaster
  • Android 5.0 (API 21) or higher

Compatible Devices

Brand Models
Vivo Various models with IR blaster
Xiaomi Mi/Redmi series
Samsung Galaxy S4, S5, S6, Note series
Huawei Mate/P series (select models)
LG G3, G4, G5, V series

Supported TV Brands

Priority Support

  • Samsung (full remote functionality)

Universal Support

  • LG
  • Sony
  • Vizio
  • Panasonic
  • TCL
  • Hisense
  • Sharp
  • Toshiba
  • Philips
  • And more...

Building the Project

Choose your platform:


Linux / WSL Build

Quick Start (One Command)

Run the automated setup script:

cd /path/to/android-app-tv-remote
./setup-linux.sh

This script will:

  1. Install Java JDK 17
  2. Download and configure Android SDK
  3. Set environment variables
  4. Accept SDK licenses
  5. Build the APK

APK output: app/build/outputs/apk/debug/app-debug.apk


Manual Setup (Linux / WSL)

If you prefer manual installation:

Step 1: Install Java JDK 17

sudo apt update
sudo apt install -y openjdk-17-jdk unzip wget

# Verify installation
java -version

Step 2: Install Android SDK Command Line Tools

# Create Android SDK directory
mkdir -p ~/android-sdk/cmdline-tools
cd ~/android-sdk/cmdline-tools

# Download command line tools
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip

# Unzip and organize
unzip commandlinetools-linux-11076708_latest.zip
mv cmdline-tools latest
rm commandlinetools-linux-11076708_latest.zip

Step 3: Set Environment Variables

Add to your ~/.bashrc:

echo '' >> ~/.bashrc
echo '# Android SDK Environment Variables' >> ~/.bashrc
echo 'export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64' >> ~/.bashrc
echo 'export ANDROID_HOME=$HOME/android-sdk' >> ~/.bashrc
echo 'export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin' >> ~/.bashrc
echo 'export PATH=$PATH:$ANDROID_HOME/platform-tools' >> ~/.bashrc

# Apply changes
source ~/.bashrc

Step 4: Install SDK Components & Accept Licenses

# Accept all licenses
yes | sdkmanager --sdk_root=$ANDROID_HOME --licenses

# Install required components
sdkmanager --sdk_root=$ANDROID_HOME "platforms;android-34" "build-tools;34.0.0" "platform-tools"

Step 5: Configure Project

cd /path/to/android-app-tv-remote

# Create local.properties
echo "sdk.dir=$HOME/android-sdk" > local.properties

Step 6: Build APK

# Make gradlew executable (if needed)
chmod +x ./gradlew

# Build debug APK
./gradlew assembleDebug

Step 7: Find Your APK

app/build/outputs/apk/debug/app-debug.apk

Step 8: Install on Phone

Option A: Using ADB (phone connected via USB)

# Install directly
./gradlew installDebug

# Or manually
adb install app/build/outputs/apk/debug/app-debug.apk

Option B: Manual Transfer

  1. Copy APK to your phone (via USB, cloud, etc.)
  2. Open the APK file on your phone
  3. Enable "Install from Unknown Sources" if prompted
  4. Install and run

Windows Build (Using Android Studio)

Android Studio is recommended for Windows users.

Step 1: Install Android Studio

  1. Download from: https://developer.android.com/studio
  2. Run the installer
  3. During setup, ensure these are selected:
    • Android SDK
    • Android SDK Platform 34
    • Android Virtual Device (optional)

Step 2: Open the Project

  1. Launch Android Studio
  2. Click File → Open
  3. Navigate to the project folder and click OK
  4. Wait for Gradle sync to complete (5-10 minutes first time)

Step 3: Build the APK

Method A: Build Menu

  1. Go to Build → Build Bundle(s) / APK(s) → Build APK(s)
  2. Wait for build to complete
  3. Click "locate" in the notification popup

Method B: Keyboard Shortcut

  • Press Ctrl + F9

Step 4: Find Your APK

app\build\outputs\apk\debug\app-debug.apk

Step 5: Install on Phone

Option A: Direct Install via USB

  1. Connect your phone via USB
  2. Enable USB Debugging on your phone:
    • Settings → About Phone → Tap "Build Number" 7 times
    • Settings → Developer Options → Enable USB Debugging
  3. Click the green Run button (or Shift + F10)
  4. Select your device

Option B: Transfer APK

  1. Copy the APK to your phone
  2. Open and install on the phone

macOS Build

Option 1: Using Android Studio (Recommended)

Same as Windows instructions above. Download Android Studio for macOS.

Option 2: Command Line

# Install Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Java 17
brew install openjdk@17

# Set JAVA_HOME
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 17)' >> ~/.zshrc
source ~/.zshrc

# Install Android SDK via Homebrew
brew install --cask android-commandlinetools

# Set Android environment
echo 'export ANDROID_HOME=$HOME/Library/Android/sdk' >> ~/.zshrc
echo 'export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin' >> ~/.zshrc
echo 'export PATH=$PATH:$ANDROID_HOME/platform-tools' >> ~/.zshrc
source ~/.zshrc

# Install SDK components
sdkmanager "platforms;android-34" "build-tools;34.0.0" "platform-tools"
yes | sdkmanager --licenses

# Build
cd /path/to/android-app-tv-remote
echo "sdk.dir=$ANDROID_HOME" > local.properties
./gradlew assembleDebug

Build Commands Reference

Command Description
./gradlew assembleDebug Build debug APK (signed, ready to install)
./gradlew assembleRelease Build release APK (unsigned, smaller)
./gradlew installDebug Build and install on connected device
./gradlew clean Clean build files
./gradlew test Run unit tests

Build Output Locations

Build Type Location Notes
Debug APK app/build/outputs/apk/debug/app-debug.apk Ready to install
Release APK app/build/outputs/apk/release/app-release-unsigned.apk Requires signing

Debug vs Release APK

Feature Debug Release
Size ~17 MB ~7 MB
Signed Yes (debug key) No (unsigned)
Install directly Yes No (needs signing)
Debugging Enabled Disabled
ProGuard/R8 Disabled Enabled (minified)

For personal use: Use the debug APK - it's signed and ready to install.

For distribution: Sign the release APK using the instructions below.


Signing Release APK (Optional)

To create a signed release APK for distribution:

Step 1: Generate a Keystore

keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-key-alias

You'll be prompted for:

  • Keystore password
  • Key password
  • Your name, organization, etc.

Step 2: Create signing config

Create or edit keystore.properties in the project root:

storeFile=../my-release-key.jks
storePassword=your_keystore_password
keyAlias=my-key-alias
keyPassword=your_key_password

Step 3: Sign manually (alternative)

# Sign the APK
apksigner sign --ks my-release-key.jks --out app-release-signed.apk app/build/outputs/apk/release/app-release-unsigned.apk

# Verify signature
apksigner verify app-release-signed.apk

Security Note: Never commit keystore files or passwords to version control.


Troubleshooting

Issue Platform Solution
SDK location not found All Create local.properties with sdk.dir=/path/to/sdk
JAVA_HOME not set Linux/Mac Add export JAVA_HOME=/path/to/jdk to shell config
java: command not found Linux Run sudo apt install openjdk-17-jdk
gradlew: Permission denied Linux/Mac Run chmod +x ./gradlew
License not accepted All Run sdkmanager --licenses
Gradle sync failed All Check internet, try File → Invalidate Caches (Android Studio)
adb: command not found Linux Ensure platform-tools is in PATH

Project Structure

app/
├── src/main/
│   ├── java/com/example/tvremote/
│   │   ├── TvRemoteApp.kt              # Application class
│   │   ├── MainActivity.kt             # Main entry point
│   │   ├── di/                         # Dependency injection
│   │   ├── data/
│   │   │   ├── ir/                     # IR hardware abstraction
│   │   │   ├── database/               # Room database
│   │   │   └── repository/             # Data repositories
│   │   ├── domain/
│   │   │   ├── model/                  # Domain models
│   │   │   ├── repository/             # Repository interfaces
│   │   │   └── usecase/                # Business logic
│   │   └── ui/
│   │       ├── remote/                 # Remote control UI
│   │       ├── setup/                  # Device setup
│   │       ├── components/             # Reusable components
│   │       └── theme/                  # App theming
│   ├── assets/ir_codes/                # IR code databases
│   └── res/                            # Android resources
└── build.gradle.kts

Architecture

The app follows Clean Architecture with MVVM pattern:

┌─────────────────────────────────────────┐
│           Presentation Layer            │
│    (Compose UI + ViewModels + States)   │
├─────────────────────────────────────────┤
│             Domain Layer                │
│      (Use Cases + Repositories)         │
├─────────────────────────────────────────┤
│              Data Layer                 │
│  (Room DB + IR Hardware + JSON Assets)  │
└─────────────────────────────────────────┘

Tech Stack

Category Technology
Language Kotlin 1.9
UI Jetpack Compose + Material 3
Architecture MVVM + Clean Architecture
DI Hilt
Database Room
Async Kotlin Coroutines + Flow
Build Gradle Kotlin DSL

Security

This app is built with security as a priority:

  • Minimal Permissions - Only TRANSMIT_IR permission required
  • Offline First - No network access, no data collection
  • Input Validation - All IR codes validated before transmission
  • Code Obfuscation - ProGuard/R8 enabled for release builds
  • No WebViews - Eliminates web-based attack vectors
  • Secure Storage - EncryptedSharedPreferences for user data

Usage

  1. Launch the app on your IR-enabled device
  2. Select your TV brand (Samsung recommended first)
  3. Point your phone at the TV's IR receiver
  4. Test the power button to verify connectivity
  5. Use the remote to control your TV

Tips

  • Keep the phone within 3 meters of the TV
  • Point directly at the TV's IR sensor (usually near the power LED)
  • If buttons don't work, try alternative code sets for your brand

Contributing

Contributions are welcome! Please read the development plan in DEVELOPMENT_PLAN.md.

Adding New TV Codes

  1. Add IR codes to app/src/main/assets/ir_codes/
  2. Follow the existing JSON schema
  3. Test on actual hardware before submitting

License

This project is for personal and educational use.

Acknowledgments

  • IR code patterns from open-source LIRC database
  • Android ConsumerIrManager documentation
  • Material Design 3 guidelines

Note: This app requires a physical IR blaster. Software-based IR emulation is not supported as it requires specialized hardware.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published