Migrate to FlatBuffers and unify Mobile/TV modules

This commit is contained in:
John Doe committed 2025-12-25 02:14:09 +00:00
commit 2a4ee357ce
133 files changed
+7284

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
+123
View File
@@ -0,0 +1,123 @@
name: Android CI
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
release:
types: [ published, created, edited ]
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Decode Keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > ${{ github.workspace }}/release.keystore
- name: Build Release APKs
run: ./gradlew assembleRelease
- name: Sign Mobile APK
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
run: |
$ANDROID_HOME/build-tools/34.0.0/apksigner sign --ks ${{ github.workspace }}/release.keystore \
--ks-key-alias "$KEY_ALIAS" \
--ks-pass "pass:$KEYSTORE_PASSWORD" \
--key-pass "pass:$KEY_PASSWORD" \
--out mobile/build/outputs/apk/release/mobile-release.apk \
mobile/build/outputs/apk/release/mobile-release-unsigned.apk
- name: Sign TV APK
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
run: |
$ANDROID_HOME/build-tools/34.0.0/apksigner sign --ks ${{ github.workspace }}/release.keystore \
--ks-key-alias "$KEY_ALIAS" \
--ks-pass "pass:$KEYSTORE_PASSWORD" \
--key-pass "pass:$KEY_PASSWORD" \
--out tv/build/outputs/apk/release/tv-release.apk \
tv/build/outputs/apk/release/tv-release-unsigned.apk
- name: Upload Mobile APK
uses: actions/upload-artifact@v4
with:
name: mobile-release
path: mobile/build/outputs/apk/release/mobile-release.apk
- name: Upload TV APK
uses: actions/upload-artifact@v4
with:
name: tv-release
path: tv/build/outputs/apk/release/tv-release.apk
- name: Get version
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "IS_TAG=true" >> $GITHUB_OUTPUT
else
echo "VERSION=latest" >> $GITHUB_OUTPUT
echo "IS_TAG=false" >> $GITHUB_OUTPUT
fi
- name: Create Release (Tag)
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
files: |
mobile/build/outputs/apk/release/mobile-release.apk
tv/build/outputs/apk/release/tv-release.apk
- name: Create Release (Latest)
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v2
with:
tag_name: latest
name: Latest Build
body: |
**Automated development build** from `${{ github.sha }}`
This is a pre-release build from the main branch and may be unstable.
**[View Changelog](https://github.com/haumlab/hyperion-android-reborn/blob/main/CHANGELOG.md)** for recent changes.
---
### Downloads
- **mobile-release.apk** - For phones and tablets
- **tv-release.apk** - For Android TV devices
draft: false
prerelease: true
files: |
mobile/build/outputs/apk/release/mobile-release.apk
tv/build/outputs/apk/release/tv-release.apk
Executable
+11
View File
@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/caches
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
+3
View File
@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>
+29
View File
@@ -0,0 +1,29 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="21" />
</component>
</project>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="mobile">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="tv">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>
Generated Executable
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/common" />
<option value="$PROJECT_DIR$/mobile" />
<option value="$PROJECT_DIR$/tv" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownSettings">
<option name="previewPanelProviderInfo">
<ProviderInfo name="Compose (experimental)" className="com.intellij.markdown.compose.preview.ComposePanelProvider" />
</option>
</component>
</project>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>
Generated Executable
+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="androidx.annotation.Nullable" />
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
Generated Executable
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+100
View File
@@ -0,0 +1,100 @@
# [v2.0.1]
### Changes
- APKs are now signed
---
# [v2.0]
### Changes
- Full Android 12+ (API 31+) compatibility
- Migrated from Android Support Library to AndroidX
- Updated to Gradle 8.4 and Android Gradle Plugin 8.2.1
- Updated to Kotlin 1.9.22
- Updated target SDK to 34 (Android 14)
- Added foreground service type declaration for media projection
- Added POST_NOTIFICATIONS permission for Android 13+
- Replaced deprecated AsyncTask with ExecutorService/Handler pattern
- Removed ButterKnife dependency (TV app)
- Updated Konfetti library to v2.0.4
- Updated Protobuf to 3.25.1 with protobuf-javalite
- Changed default message priority to 100
- Added proper PendingIntent immutability flags for Android 12+
### Fixed
- FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION error on Android 12+
- PendingIntent mutability crash on Android 12+
- Notification permission handling for Android 13+
- Resource reference issues with AGP 8.x namespace changes
## [v1.0]
### Changes
- OLD
## [v1.0]
- Arabic translation
### Fixed
- Possible NPE when stopping the grabber
## [v0.5-beta]
### Changes
- Added the ability to send only the average color of the screen
- French translation
- Norwegian translation
- Czech translation
- German translation
- Dutch translation
- Partial Russian translation
- Partial Spanish translation
- Removed openGL grabber option
- Added toggle grabber activity shortcut
- LEDs will now be cleared when rebooting or shutting down
### Fixed
- Lights now clear (if running) when shutting down
- Assertion bug in TV settings
- Possible null intent when starting grabber
- OOM bug
## [v0.4-alpha]
### Changes
- Start grabber on device boot
- Added some eye candy for when grabber is started
- General UI tweaks (tv & mobile)
- Reconnect behavior implemented for mobile build
- New connection wizard
- New settings/connection page (tv build)
- Quick settings tile to toggle grabber (mobile build)
- Screen orientation change updates grabber
- Configurable grabber image quality
- Pressing the notification will now return to the app's main activity
### Fixed
- Grabber would fail to resume when waking device
- OpenGL grabber sometimes halting immediately after starting screen grab
- Default grabber failing to send data the first time it is turned on
- Grabber not stopping when the host is unreachable
- Aspect ratio of grabbed image being slightly off
- OOM bug
## [v0.3-alpha]
### Changes
- Leanback launcher support (tv build)
- Revised layout (tv build)
- Reconnect if connection is lost to hyperion server (tv build)
## [v0.2-alpha]
### Changes
- App Icon
- Fancy toggle button
- Bug fixes
- New Grabber (old grabber can be enabled in the settings)
### Known Bugs
- OpenGL grabber will sometimes hang when started, making the lights unresponsive. Quitting the app and starting again generally fixes the problem.
- New grabber fails to send any data the first time it is initialized. Turning off and back on one more time seems to fix the problem.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Dave Anderson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+16
View File
@@ -0,0 +1,16 @@
<img width="1280" height="640" alt="logosz" src="https://github.com/user-attachments/assets/da6d5470-4d93-4497-82f9-a15d4c58729c" />
# Hyperion Android Reborn
Screen grabber for hyperion, updated for **Android 12** and **beyond**.
This application will send the content of the android screen to a hyperion instance to handle the image.
Info about hyperion can be found on their website:
https://hyperion-project.org/
---
# Download
Both **TV** and **Mobile** apps are within [releases page](https://github.com/haumlab/hyperion-android-reborn/releases)
Executable
+1
View File
@@ -0,0 +1 @@
/build
+50
View File
@@ -0,0 +1,50 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
}
apply from: project(':common').projectDir.absolutePath + '/variables.gradle'
android {
namespace 'com.hyperion.grabber'
compileSdk 34
defaultConfig {
applicationId "com.hyperion.grabber"
minSdk 21
targetSdk 34
versionCode 2013
versionName "2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
api project(path: ':common')
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "androidx.core:core-ktx:1.12.0"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.preference:preference-ktx:1.2.1"
implementation "androidx.localbroadcastmanager:localbroadcastmanager:1.1.0"
implementation "androidx.leanback:leanback:1.0.0"
implementation "androidx.leanback:leanback-preference:1.0.0"
implementation 'nl.dionsegijn:konfetti-xml:2.0.4'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Vendored Executable
+21
View File
@@ -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.
#
# 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
+98
View File
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<application
android:theme="@style/AppTheme"
android:banner="@drawable/banner"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true">
<activity android:name=".MainActivity"
android:launchMode="singleTop"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.hyperion.grabber.tv.activities.MainActivity"
android:launchMode="singleTop"
android:exported="true"
android:theme="@style/Theme.Leanback">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:label="@string/settings"
android:parentActivityName=".MainActivity"
android:exported="false">
<meta-data
android:name="androidx.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name="com.hyperion.grabber.tv.activities.NetworkScanActivity"
android:exported="true"
android:theme="@style/MyOnboardingTheme" />
<activity
android:name="com.hyperion.grabber.tv.activities.ScanResultActivity"
android:exported="true"/>
<activity
android:name="com.hyperion.grabber.tv.activities.ManualSetupActivity"
android:parentActivityName="com.hyperion.grabber.tv.activities.MainActivity"
android:exported="true"/>
<activity android:name="com.hyperion.grabber.common.BootActivity"
android:finishOnTaskLaunch ="true"
android:noHistory="true"
android:launchMode="singleInstance"
android:clearTaskOnLaunch="true"
android:exported="true"
tools:replace="android:exported">
</activity>
<activity
android:label="@string/toggle_activity_label"
android:name="com.hyperion.grabber.common.ToggleActivity"
android:icon="@drawable/ic_notification_icon"
android:theme="@style/Theme.Transparent"
android:launchMode="singleTop"
android:noHistory="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service
android:name=".HyperionGrabberTileService"
android:icon="@drawable/ic_notification_icon"
android:label="@string/quick_tile_label"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:exported="true">
<intent-filter>
<action
android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
</service>
</application>
</manifest>
@@ -0,0 +1,118 @@
package com.hyperion.grabber;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.core.app.NavUtils;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
/**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat.
*/
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
private AppCompatDelegate mDelegate;
@Override
protected void onCreate(Bundle savedInstanceState) {
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
getDelegate().onPostCreate(savedInstanceState);
}
public ActionBar getSupportActionBar() {
return getDelegate().getSupportActionBar();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
}
@Override
public void setContentView(@LayoutRes int layoutResID) {
getDelegate().setContentView(layoutResID);
}
@Override
public void setContentView(View view) {
getDelegate().setContentView(view);
}
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().setContentView(view, params);
}
@Override
public void addContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().addContentView(view, params);
}
@Override
protected void onPostResume() {
super.onPostResume();
getDelegate().onPostResume();
}
@Override
protected void onTitleChanged(CharSequence title, int color) {
super.onTitleChanged(title, color);
getDelegate().setTitle(title);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
getDelegate().onConfigurationChanged(newConfig);
}
@Override
protected void onStop() {
super.onStop();
getDelegate().onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
getDelegate().onDestroy();
}
public void invalidateOptionsMenu() {
getDelegate().invalidateOptionsMenu();
}
private AppCompatDelegate getDelegate() {
if (mDelegate == null) {
mDelegate = AppCompatDelegate.create(this, null);
}
return mDelegate;
}
}
@@ -0,0 +1,74 @@
package com.hyperion.grabber;
import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.util.TypedValue;
public class FadingImageView extends androidx.appcompat.widget.AppCompatImageView {
private Context c;
public FadingImageView(Context c, AttributeSet attrs, int defStyle) {
super(c, attrs, defStyle);
this.c = c;
init();
}
public FadingImageView(Context c, AttributeSet attrs) {
super(c, attrs);
this.c = c;
init();
}
public FadingImageView(Context c) {
super(c);
this.c = c;
init();
}
private void init() {
this.setHorizontalFadingEdgeEnabled(true);
this.setVerticalFadingEdgeEnabled(true);
this.setEdgeLength(80);
}
public void setEdgeLength(int length) {
this.setFadingEdgeLength(getPixels(length));
}
@Override
protected float getLeftFadingEdgeStrength() {
return 1.0f;
}
@Override
protected float getRightFadingEdgeStrength() {
return 1.0f;
}
@Override
protected float getTopFadingEdgeStrength() {
return 1.0f;
}
@Override
protected float getBottomFadingEdgeStrength() {
return 1.0f;
}
@Override
public boolean hasOverlappingRendering() {
return true;
}
@Override
public boolean onSetAlpha(int alpha) {
return false;
}
private int getPixels(int dipValue) {
Resources r = c.getResources();
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
dipValue, r.getDisplayMetrics());
}
}
@@ -0,0 +1,147 @@
package com.hyperion.grabber;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Handler;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import androidx.annotation.RequiresApi;
import androidx.core.app.TaskStackBuilder;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.widget.Toast;
import com.hyperion.grabber.common.BootActivity;
import com.hyperion.grabber.common.HyperionScreenService;
import com.hyperion.grabber.common.util.Preferences;
@RequiresApi(api = Build.VERSION_CODES.N)
public class HyperionGrabberTileService extends TileService {
private final int REMOVE_LISTENER_DELAY = 1000 * 10; // 10 second delay to remove listener
private static boolean mIsListening = false;
private Handler mHandle = new Handler();
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Tile tile = getQsTile();
boolean running = intent.getBooleanExtra(HyperionScreenService.BROADCAST_TAG, false);
String error = intent.getStringExtra(HyperionScreenService.BROADCAST_ERROR);
tile.setState(running ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.updateTile();
if (error != null) {
Toast.makeText(getBaseContext(), error, Toast.LENGTH_LONG).show();
}
}
};
@Override
public void onStartListening() {
super.onStartListening();
mHandle.removeCallbacksAndMessages(null);
if (!mIsListening) {
LocalBroadcastManager.getInstance(this).registerReceiver(
mMessageReceiver, new IntentFilter(HyperionScreenService.BROADCAST_FILTER));
mIsListening = true;
}
if (isServiceRunning()) {
Intent intent = new Intent(this, HyperionScreenService.class);
intent.setAction(HyperionScreenService.GET_STATUS);
startService(intent);
} else {
Tile tile = getQsTile();
tile.setState(Tile.STATE_INACTIVE);
tile.updateTile();
}
}
@Override
public void onStopListening() {
super.onTileRemoved();
mHandle.postDelayed(unregisterReceiverRunner, REMOVE_LISTENER_DELAY);
}
@Override
public void onDestroy() {
super.onDestroy();
mIsListening = false;
}
@Override
public void onClick() {
Tile tile = getQsTile();
tile.updateTile();
int tileState = tile.getState();
if (tileState == Tile.STATE_ACTIVE) {
Intent intent = new Intent(this, HyperionScreenService.class);
intent.setAction(HyperionScreenService.ACTION_EXIT);
startService(intent);
} else {
Runnable runner = () -> {
boolean setupStarted = startSetupIfNeeded();
if (!setupStarted){
final Intent i = new Intent(this, BootActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION
|Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(i);
}
};
if (isLocked()) {
unlockAndRun(runner);
} else {
runner.run();
}
}
}
private boolean isServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
assert manager != null;
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (HyperionScreenService.class.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
private Runnable unregisterReceiverRunner = () -> {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
mIsListening = false;
};
public static boolean isListening() { return mIsListening; }
/** Starts the Settings Activity if connection settings are missing
*
* @return true if setup was started
*/
private boolean startSetupIfNeeded(){
Preferences preferences = new Preferences(getApplicationContext());
if (TextUtils.isEmpty(preferences.getString(com.hyperion.grabber.common.R.string.pref_key_host, null)) || preferences.getInt(com.hyperion.grabber.common.R.string.pref_key_port, -1) == -1){
Intent settingsIntent = new Intent(this, SettingsActivity.class);
settingsIntent.putExtra(SettingsActivity.EXTRA_SHOW_TOAST_KEY, SettingsActivity.EXTRA_SHOW_TOAST_SETUP_REQUIRED_FOR_QUICK_TILE);
settingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Use TaskStackBuilder to make sure the MainActivity opens when the SettingsActivity is closed
TaskStackBuilder.create(this)
.addNextIntentWithParentStack(settingsIntent)
.startActivities();
Intent closeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeIntent);
return true;
}
return false;
}
}
+241
View File
@@ -0,0 +1,241 @@
package com.hyperion.grabber;
import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.media.projection.MediaProjectionManager;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import com.hyperion.grabber.common.BootActivity;
import com.hyperion.grabber.common.HyperionScreenService;
public class MainActivity extends AppCompatActivity implements ImageView.OnClickListener,
ImageView.OnFocusChangeListener {
public static final int REQUEST_MEDIA_PROJECTION = 1;
private static final int REQUEST_NOTIFICATION_PERMISSION = 2;
private static final String TAG = "DEBUG";
private boolean mRecorderRunning = false;
private static MediaProjectionManager mMediaProjectionManager;
private Intent mPendingProjectionData = null;
private int mPendingResultCode = 0;
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
boolean checked = intent.getBooleanExtra(HyperionScreenService.BROADCAST_TAG, false);
mRecorderRunning = checked;
String error = intent.getStringExtra(HyperionScreenService.BROADCAST_ERROR);
if (error != null &&
(Build.VERSION.SDK_INT < Build.VERSION_CODES.N ||
!HyperionGrabberTileService.isListening())) {
Toast.makeText(getBaseContext(), error, Toast.LENGTH_LONG).show();
}
setImageViews(checked, checked);
}
};
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMediaProjectionManager = (MediaProjectionManager)
getSystemService(Context.MEDIA_PROJECTION_SERVICE);
ImageView iv = findViewById(R.id.power_toggle);
iv.setOnClickListener(this);
iv.setOnFocusChangeListener(this);
iv.setFocusable(true);
iv.requestFocus();
View settingsButton = findViewById(R.id.settingsButton);
if (settingsButton != null) {
settingsButton.setOnClickListener(v -> {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
});
}
setImageViews(mRecorderRunning, false);
LocalBroadcastManager.getInstance(this).registerReceiver(
mMessageReceiver, new IntentFilter(HyperionScreenService.BROADCAST_FILTER));
checkForInstance();
// Request notification permission for Android 13+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
requestNotificationPermission();
}
}
private void requestNotificationPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.POST_NOTIFICATIONS},
REQUEST_NOTIFICATION_PERMISSION);
}
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onClick(View view) {
if (!mRecorderRunning) {
startActivityForResult(mMediaProjectionManager.createScreenCaptureIntent(),
REQUEST_MEDIA_PROJECTION);
} else {
stopScreenRecorder();
}
mRecorderRunning = !mRecorderRunning;
}
@Override
public void onFocusChange(View view, boolean focused) {
if (focused) {
((ImageView) view).setColorFilter(Color.argb(255, 0, 0, 150));
} else {
((ImageView) view).setColorFilter(Color.argb(255, 0, 0, 0));
}
}
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_MEDIA_PROJECTION) {
if (resultCode != Activity.RESULT_OK) {
Toast.makeText(this, com.hyperion.grabber.common.R.string.toast_must_give_permission, Toast.LENGTH_SHORT).show();
if (mRecorderRunning) {
stopScreenRecorder();
}
setImageViews(false, true);
return;
}
Log.i(TAG, "Starting screen capture");
startScreenRecorder(resultCode, (Intent) data.clone());
mRecorderRunning = true;
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_NOTIFICATION_PERMISSION) {
if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, "Notification permission is needed for the foreground service", Toast.LENGTH_LONG).show();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.settings) {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
private void checkForInstance() {
if (isServiceRunning()) {
Intent intent = new Intent(this, HyperionScreenService.class);
intent.setAction(HyperionScreenService.GET_STATUS);
startService(intent);
}
}
public void startScreenRecorder(int resultCode, Intent data) {
BootActivity.startScreenRecorder(this, resultCode, data);
}
public void stopScreenRecorder() {
if (mRecorderRunning) {
Intent intent = new Intent(this, HyperionScreenService.class);
intent.setAction(HyperionScreenService.ACTION_EXIT);
startService(intent);
}
}
private void setImageViews(boolean running, boolean animated) {
View rainbow = findViewById(R.id.sweepGradientView);
View message = findViewById(R.id.grabberStartedText);
View buttonImage = findViewById(R.id.power_toggle);
if (running) {
if (animated){
fadeView(rainbow, true);
fadeView(message, true);
} else {
rainbow.setVisibility(View.VISIBLE);
message.setVisibility(View.VISIBLE);
}
buttonImage.setAlpha((float) 1);
} else {
if (animated){
fadeView(rainbow, false);
fadeView(message, false);
} else {
rainbow.setVisibility(View.INVISIBLE);
message.setVisibility(View.INVISIBLE);
}
buttonImage.setAlpha((float) 0.25);
}
}
private boolean isServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
assert manager != null;
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (HyperionScreenService.class.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
private void fadeView(View view, boolean visible){
float alpha = visible ? 1f : 0f;
int endVisibility = visible ? View.VISIBLE : View.INVISIBLE;
view.setVisibility(View.VISIBLE);
view.animate()
.alpha(alpha)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(endVisibility);
}
})
.start();
}
}
@@ -0,0 +1,158 @@
package com.hyperion.grabber;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import androidx.appcompat.app.ActionBar;
import android.view.MenuItem;
import android.widget.Toast;
import java.lang.reflect.Field;
/**
* A {@link PreferenceActivity} that presents a set of application settings. On
* handset devices, settings are presented as a single list. On tablets,
* settings are split by category, with category headers shown to the left of
* the list of settings.
* <p>
* See <a href="http://developer.android.com/design/patterns/settings.html">
* Android Design: Settings</a> for design guidelines and the <a
* href="http://developer.android.com/guide/topics/ui/settings.html">Settings
* API Guide</a> for more information on developing a Settings UI.
*/
public class SettingsActivity extends AppCompatPreferenceActivity {
public static final String EXTRA_SHOW_TOAST_KEY = "extra_show_toast_key";
public static final int EXTRA_SHOW_TOAST_SETUP_REQUIRED_FOR_QUICK_TILE = 1;
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = (preference, value) -> {
final int prefResourceID = getResourceId(preference.getKey(), com.hyperion.grabber.common.R.string.class);
// verify we have a valid int value for the following preference keys
if (prefResourceID == com.hyperion.grabber.common.R.string.pref_key_port ||
prefResourceID == com.hyperion.grabber.common.R.string.pref_key_reconnect_delay ||
prefResourceID == com.hyperion.grabber.common.R.string.pref_key_priority ||
prefResourceID == com.hyperion.grabber.common.R.string.pref_key_x_led ||
prefResourceID == com.hyperion.grabber.common.R.string.pref_key_y_led ||
prefResourceID == com.hyperion.grabber.common.R.string.pref_key_framerate) {
try {
Integer.parseInt(value.toString());
} catch (NumberFormatException e) {
e.printStackTrace();
return false;
}
}
String stringValue = value.toString();
preference.setSummary(stringValue);
return true;
};
/**
* Returns the resource ID of the provided string
*/
public static int getResourceId(String resourceName, Class<?> c) {
try {
Field idField = c.getDeclaredField(resourceName);
return idField.getInt(idField);
} catch (Exception e) {
e.printStackTrace();
}
return -1;
}
/**
* Binds a preference's summary to its value. More specifically, when the
* preference's value is changed, its summary (line of text below the
* preference title) is updated to reflect the value. The summary is also
* immediately updated upon calling this method. The exact display format is
* dependent on the type of preference.
*
* @see #sBindPreferenceSummaryToValueListener
*/
private static void bindPreferenceSummaryToValue(Preference preference) {
if (preference == null) return;
// Set the listener to watch for value changes.
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
// Trigger the listener immediately with the preference's
// current value.
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getFragmentManager().beginTransaction().replace(android.R.id.content,
new GeneralPreferenceFragment()).commit();
Bundle extras = getIntent().getExtras();
if (extras != null && extras.containsKey(EXTRA_SHOW_TOAST_KEY)){
if (extras.getInt(EXTRA_SHOW_TOAST_KEY) == EXTRA_SHOW_TOAST_SETUP_REQUIRED_FOR_QUICK_TILE){
Toast.makeText(getApplicationContext(), R.string.quick_tile_toast_setup_required, Toast.LENGTH_SHORT).show();
}
}
setupActionBar();
}
/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
private void setupActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Show the Up button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
/**
* This fragment shows general preferences only. It is used when the
* activity is showing a two-pane settings UI.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static class GeneralPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(com.hyperion.grabber.common.R.xml.pref_general);
setHasOptionsMenu(true);
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
// to their values. When their values change, their summaries are
// updated to reflect the new value, per the Android Design
// guidelines.
bindPreferenceSummaryToValue(findPreference(getString(com.hyperion.grabber.common.R.string.pref_key_host)));
bindPreferenceSummaryToValue(findPreference(getString(com.hyperion.grabber.common.R.string.pref_key_port)));
bindPreferenceSummaryToValue(findPreference(getString(com.hyperion.grabber.common.R.string.pref_key_priority)));
bindPreferenceSummaryToValue(findPreference(getString(com.hyperion.grabber.common.R.string.pref_key_framerate)));
bindPreferenceSummaryToValue(findPreference(getString(com.hyperion.grabber.common.R.string.pref_key_reconnect_delay)));
bindPreferenceSummaryToValue(findPreference(getString(com.hyperion.grabber.common.R.string.pref_key_x_led)));
bindPreferenceSummaryToValue(findPreference(getString(com.hyperion.grabber.common.R.string.pref_key_y_led)));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
startActivity(new Intent(getActivity(), SettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
}
}
@@ -0,0 +1,10 @@
package com.hyperion.grabber.tv.activities;
import androidx.fragment.app.FragmentActivity;
public abstract class LeanbackActivity extends FragmentActivity {
@Override
public boolean onSearchRequested() {
return false;
}
}
@@ -0,0 +1,284 @@
package com.hyperion.grabber.tv.activities;
import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.media.projection.MediaProjectionManager;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.appcompat.app.AppCompatDelegate;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;
import com.hyperion.grabber.common.BootActivity;
import com.hyperion.grabber.common.HyperionScreenService;
import com.hyperion.grabber.common.util.Preferences;
import com.hyperion.grabber.R;
public class MainActivity extends LeanbackActivity implements ImageView.OnClickListener,
ImageView.OnFocusChangeListener {
public static final int REQUEST_MEDIA_PROJECTION = 1;
public static final int REQUEST_INITIAL_SETUP = 2;
private static final int REQUEST_NOTIFICATION_PERMISSION = 3;
public static final String BROADCAST_ERROR = "SERVICE_ERROR";
public static final String BROADCAST_TAG = "SERVICE_STATUS";
public static final String BROADCAST_FILTER = "SERVICE_FILTER";
private static final String TAG = "DEBUG";
private boolean mRecorderRunning = false;
private static MediaProjectionManager mMediaProjectionManager;
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
boolean checked = intent.getBooleanExtra(BROADCAST_TAG, false);
mRecorderRunning = checked;
String error = intent.getStringExtra(BROADCAST_ERROR);
if (error != null) {
Toast.makeText(getBaseContext(), error, Toast.LENGTH_SHORT).show();
}
setImageViews(checked, true);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!initIfConfigured()){
startSetup();
}
// Request notification permission for Android 13+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
requestNotificationPermission();
}
}
private void requestNotificationPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.POST_NOTIFICATIONS},
REQUEST_NOTIFICATION_PERMISSION);
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_NOTIFICATION_PERMISSION) {
if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, "Notification permission is needed for the foreground service", Toast.LENGTH_LONG).show();
}
}
}
/** @return whether the activity was initialized */
private boolean initIfConfigured() {
// Do we have a valid server config?
Preferences preferences = new Preferences(getApplicationContext());
String host = preferences.getString(com.hyperion.grabber.common.R.string.pref_key_host, null);
int port = preferences.getInt(com.hyperion.grabber.common.R.string.pref_key_port, -1);
if (host == null || port == -1){
return false;
}
initActivity();
return true;
}
private void startSetup() {
// Start onboarding (setup)
Intent intent = new Intent(this, NetworkScanActivity.class);
startActivityForResult(intent, REQUEST_INITIAL_SETUP);
}
// Prepare activity for display
private void initActivity() {
// assume the recorder is not running until we are notified otherwise
mRecorderRunning = false;
setContentView(R.layout.activity_main);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
mMediaProjectionManager = (MediaProjectionManager)
getSystemService(Context.MEDIA_PROJECTION_SERVICE);
ImageView iv = findViewById(R.id.power_toggle);
iv.setOnClickListener(this);
iv.setOnFocusChangeListener(this);
iv.setFocusable(true);
iv.requestFocus();
ImageButton ib = findViewById(R.id.settingsButton);
ib.setOnClickListener(this);
ib.setOnFocusChangeListener(this);
ib.setFocusable(true);
setImageViews(mRecorderRunning, false);
LocalBroadcastManager.getInstance(this).registerReceiver(
mMessageReceiver, new IntentFilter(BROADCAST_FILTER));
// request an update on the running status
checkForInstance();
}
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.power_toggle) {
if (!mRecorderRunning) {
startActivityForResult(mMediaProjectionManager.createScreenCaptureIntent(),
REQUEST_MEDIA_PROJECTION);
} else {
stopScreenRecorder();
}
mRecorderRunning = !mRecorderRunning;
} else if (id == R.id.settingsButton) {
startSettings();
}
}
@Override
public void onFocusChange(View view, boolean focused) {
int clr = Color.argb(255, 0, 0, 150);
if (!focused) {
clr = Color.argb(255, 0, 0, 0);
}
int id = view.getId();
if (id == R.id.power_toggle) {
((ImageView) view).setColorFilter(clr);
} else if (id == R.id.settingsButton) {
((ImageButton) view).setColorFilter(clr);
}
}
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_INITIAL_SETUP){
if (resultCode == RESULT_OK){
if (!initIfConfigured()){
startSetup();
}
} else {
finish();
}
return;
}
if (requestCode == REQUEST_MEDIA_PROJECTION) {
if (resultCode != Activity.RESULT_OK) {
Toast.makeText(this, com.hyperion.grabber.common.R.string.toast_must_give_permission, Toast.LENGTH_SHORT).show();
if (mRecorderRunning) {
stopScreenRecorder();
}
setImageViews(false, true);
return;
}
Log.i(TAG, "Starting screen capture");
startScreenRecorder(resultCode, (Intent) data.clone());
mRecorderRunning = true;
}
}
private void startSettings() {
stopScreenRecorder();
Intent intent = new Intent(this, ManualSetupActivity.class);
Bundle bundle =
ActivityOptionsCompat.makeSceneTransitionAnimation(this)
.toBundle();
startActivity(intent, bundle);
}
private void checkForInstance() {
if (isServiceRunning()) {
Intent intent = new Intent(this, HyperionScreenService.class);
intent.setAction(HyperionScreenService.GET_STATUS);
startService(intent);
}
}
private void setImageViews(boolean running, boolean animated) {
View rainbow = findViewById(R.id.sweepGradientView);
View message = findViewById(R.id.grabberStartedText);
if (running) {
if (animated){
fadeView(rainbow, true);
fadeView(message, true);
} else {
rainbow.setVisibility(View.VISIBLE);
message.setVisibility(View.VISIBLE);
}
} else {
if (animated){
fadeView(rainbow, false);
fadeView(message, false);
} else {
rainbow.setVisibility(View.INVISIBLE);
message.setVisibility(View.INVISIBLE);
}
}
}
public void startScreenRecorder(int resultCode, Intent data) {
BootActivity.startScreenRecorder(this, resultCode, data);
}
public void stopScreenRecorder() {
if (mRecorderRunning) {
Intent intent = new Intent(this, HyperionScreenService.class);
intent.setAction(HyperionScreenService.ACTION_EXIT);
startService(intent);
}
}
private boolean isServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
assert manager != null;
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (HyperionScreenService.class.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
private void fadeView(View view, boolean visible){
float alpha = visible ? 1f : 0f;
int endVisibility = visible ? View.VISIBLE : View.INVISIBLE;
view.setVisibility(View.VISIBLE);
view.animate()
.alpha(alpha)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(endVisibility);
}
})
.start();
}
}
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hyperion.grabber.tv.activities;
import android.os.Bundle;
import androidx.leanback.app.GuidedStepSupportFragment;
import androidx.fragment.app.FragmentActivity;
import com.hyperion.grabber.tv.fragments.settings.BasicSettingsStepFragment;
/**
* Allows to set all preferences manually
*/
public class ManualSetupActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (null == savedInstanceState) {
GuidedStepSupportFragment.addAsRoot(this, new BasicSettingsStepFragment(), android.R.id.content);
}
}
}
@@ -0,0 +1,105 @@
package com.hyperion.grabber.tv.activities;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.hyperion.grabber.common.network.NetworkScanner;
import com.hyperion.grabber.common.util.HyperionScannerTask;
import com.hyperion.grabber.R;
public class NetworkScanActivity extends LeanbackActivity implements HyperionScannerTask.Listener {
private boolean isScanning = false;
private Button startScanButton;
private Button manualSetupButton;
private ProgressBar progressBar;
private TextView descriptionText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_network_scan);
startScanButton = findViewById(R.id.startScanButton);
manualSetupButton = findViewById(R.id.manualSetupButton);
progressBar = findViewById(R.id.progressBar);
descriptionText = findViewById(R.id.scannerDescriptionText);
// only if back was pressed on this Activity will we not be configured when we finish
setResult(RESULT_OK);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == MainActivity.REQUEST_INITIAL_SETUP){
if (resultCode == RESULT_OK){
// when the setup completed successfully, we completed successfully.
setResult(RESULT_OK);
finish();
}
}
}
public void onClick(View v){
if (v.getId() == R.id.startScanButton){
if (!isScanning){
new HyperionScannerTask(this).execute();
}
} else if (v.getId() == R.id.manualSetupButton){
Intent intent = new Intent(this, ManualSetupActivity.class);
startActivityForResult(intent, MainActivity.REQUEST_INITIAL_SETUP);
}
}
@Override
public void onBackPressed() {
setResult(RESULT_CANCELED);
super.onBackPressed();
}
@SuppressLint("StringFormatInvalid")
@Override
public void onScannerProgress(float progress) {
if (!isScanning){
isScanning = true;
startScanButton.setText(com.hyperion.grabber.common.R.string.scanner_scan_in_progress_button);
descriptionText.setGravity(Gravity.CENTER);
descriptionText.setText(getString(com.hyperion.grabber.common.R.string.scanner_scan_in_progress_text, "\uD83D\uDD75️")); // todo: 🕵️
}
progressBar.setProgress(Math.round(progress * 100));
}
@SuppressLint("StringFormatInvalid")
@Override
public void onScannerCompleted(@Nullable String foundIpAddress) {
isScanning = false;
if (foundIpAddress == null){
startScanButton.setText(com.hyperion.grabber.common.R.string.scanner_retry_button);
manualSetupButton.requestFocus();
descriptionText.setText(getString(com.hyperion.grabber.common.R.string.scanner_no_results, "\uD83D\uDE29")); // 😩
} else {
Intent intent = new Intent(this, ScanResultActivity.class);
intent.putExtra(ScanResultActivity.EXTRA_RESULT_HOST_NAME, foundIpAddress);
intent.putExtra(ScanResultActivity.EXTRA_RESULT_PORT, String.valueOf(NetworkScanner.PORT));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish(); // Finish the current activity
}
}
}
@@ -0,0 +1,204 @@
package com.hyperion.grabber.tv.activities;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.TextView;
import com.hyperion.grabber.common.network.HyperionFlatBuffers;
import com.hyperion.grabber.common.util.Preferences;
import com.hyperion.grabber.R;
import java.io.IOException;
import java.util.Random;
import nl.dionsegijn.konfetti.xml.KonfettiView;
import nl.dionsegijn.konfetti.core.Party;
import nl.dionsegijn.konfetti.core.PartyFactory;
import nl.dionsegijn.konfetti.core.emitter.Emitter;
import nl.dionsegijn.konfetti.core.emitter.EmitterConfig;
import nl.dionsegijn.konfetti.core.models.Shape;
import nl.dionsegijn.konfetti.core.models.Size;
import java.util.concurrent.TimeUnit;
/** Shows the result of a network scan and allows to save the result to Preferences */
public class ScanResultActivity extends LeanbackActivity {
public static final String EXTRA_RESULT_HOST_NAME = "EXTRA_RESULT_HOST_NAME";
public static final String EXTRA_RESULT_PORT = "EXTRA_RESULT_PORT";
private KonfettiView konfettiView;
private TextView descriptionText;
private TextView hostNameText;
private TextView emojiText;
private String hostName;
private int port;
private final int ORANGE = Color.rgb(253, 104, 40);
private final int[] COLORS = {Color.RED, Color.BLUE, Color.CYAN, Color.GREEN, Color.YELLOW, ORANGE};
/** the amount of variation in R, G, B components of a confetti burst */
private final int BURST_COLOR_SPREAD = 200;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scan_result);
konfettiView = findViewById(R.id.konfetti);
descriptionText = findViewById(R.id.scanResultDescriptionText);
hostNameText = findViewById(R.id.scanResultHostName);
emojiText = findViewById(R.id.scanResultEmojiText);
emojiText.setText("\uD83D\uDC4F"); // 👏Clapping Hands
String partyPopper = "\uD83C\uDF89";
descriptionText.setText(getResources().getString(com.hyperion.grabber.common.R.string.scan_result_description, partyPopper));
Bundle extras = getIntent().getExtras();
if (extras != null){
hostName = extras.getString(EXTRA_RESULT_HOST_NAME);
port = Integer.parseInt(extras.getString(EXTRA_RESULT_PORT));
hostNameText.setText(hostName);
} else {
hostNameText.setText(com.hyperion.grabber.common.R.string.error_no_host_name_extra);
}
// Animate the appearance of the scan result
Animator fadeInAnimator = ObjectAnimator.ofFloat(hostNameText, "alpha", 0f, 1f);
Animator scaleXAnimator = ObjectAnimator
.ofFloat(hostNameText, "scaleX", .8f, 1f);
Animator scaleYAnimator = ObjectAnimator
.ofFloat(hostNameText, "scaleY", .8f, 1f);
AnimatorSet hostNameSet = new AnimatorSet();
hostNameSet.playTogether(fadeInAnimator, scaleXAnimator, scaleYAnimator);
hostNameSet.setInterpolator(new DecelerateInterpolator());
hostNameSet.setDuration(6000L);
hostNameSet.start();
konfettiView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
startKonfetti();
konfettiView.removeOnLayoutChangeListener(this);
}
});
}
@Override
protected void onPause() {
super.onPause();
setHyperionColor(hostName, port, Color.BLACK);
}
@Override
protected void onResume() {
super.onResume();
setHyperionColor(hostName, port, Color.MAGENTA);
}
public void onClick(View v){
if (v.getId() == R.id.confirmButton){
saveResult();
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish(); // call this to finish the current activity
} else if (v.getId() == R.id.changeColorButton){
int color = COLORS[new Random().nextInt(COLORS.length)];
setHyperionColor(hostName, port, color);
burstKonfetti(color);
}
}
/** Save scan result to Preferences */
private void saveResult() {
Preferences prefs = new Preferences(getApplicationContext());
prefs.putString(com.hyperion.grabber.common.R.string.pref_key_host, hostName);
prefs.putInt(com.hyperion.grabber.common.R.string.pref_key_port, port);
}
private void startKonfetti() {
EmitterConfig emitterConfig = new Emitter(Long.MAX_VALUE, TimeUnit.MILLISECONDS).perSecond(300);
Party party = new PartyFactory(emitterConfig)
.colors(java.util.Arrays.asList(Color.YELLOW, Color.GREEN, Color.MAGENTA))
.setSpeedBetween(1f, 5f)
.fadeOutEnabled(true)
.timeToLive(400L)
.shapes(java.util.Arrays.asList(Shape.Square.INSTANCE, Shape.Circle.INSTANCE))
.sizes(java.util.Arrays.asList(new Size(12, 5f, 0f)))
.position(-50f, konfettiView.getWidth() + 50f, -50f, -50f)
.build();
konfettiView.start(party);
}
/** Start a one-shot burst of confetti from a random location of a single color
*
* @param color a color int such as Color.RED, NOT a color resource
*/
private void burstKonfetti(int color){
int r = Color.red(color);
int g = Color.green(color);
int b = Color.blue(color);
Random random = new Random();
java.util.List<Integer> variations = new java.util.ArrayList<>();
int halfSpread = BURST_COLOR_SPREAD / 2;
for (int i = 0; i < 10; i++) {
variations.add(Color.rgb(
colorComponentClamp(r - halfSpread + random.nextInt(BURST_COLOR_SPREAD)),
colorComponentClamp(g - halfSpread + random.nextInt(BURST_COLOR_SPREAD)),
colorComponentClamp(b - halfSpread + random.nextInt(BURST_COLOR_SPREAD))
));
}
float posX = (float) (Math.random() * konfettiView.getWidth());
float posY = (float) (Math.random() * konfettiView.getHeight());
EmitterConfig emitterConfig = new Emitter(100, TimeUnit.MILLISECONDS).max(100);
Party party = new PartyFactory(emitterConfig)
.colors(variations)
.setSpeedBetween(1f, 5f)
.fadeOutEnabled(true)
.timeToLive(400L)
.shapes(java.util.Arrays.asList(Shape.Square.INSTANCE, Shape.Circle.INSTANCE))
.sizes(java.util.Arrays.asList(new Size(12, 5f, 0f)))
.position(posX, posY)
.build();
konfettiView.start(party);
}
/** A color int , or Color.BLACK to clear */
private void setHyperionColor(String hostName, int port, int color){
new Thread(() -> {
try {
HyperionFlatBuffers hyperion = new HyperionFlatBuffers(hostName, port, 50);
if (hyperion.isConnected()){
if (color == Color.BLACK){
hyperion.clear(50);
} else {
hyperion.setColor(color, 50);
}
}
hyperion.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
/** [0 -255] */
private static int colorComponentClamp(int value){
return Math.min(255, Math.max(0, value));
}
}
@@ -0,0 +1,335 @@
package com.hyperion.grabber.tv.fragments.settings
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.os.Bundle
import androidx.leanback.widget.GuidanceStylist
import androidx.leanback.widget.GuidedAction
import android.widget.Toast
import com.hyperion.grabber.common.network.HyperionFlatBuffers
import com.hyperion.grabber.R
import com.hyperion.grabber.common.R as CommonR
import java.lang.ref.WeakReference
import java.net.UnknownHostException
import java.util.concurrent.Executors
internal class BasicSettingsStepFragment : SettingsStepBaseFragment() {
/** The amount of times the connection was tested */
private var testCounter = 0
override fun onProvideTheme(): Int {
return R.style.Theme_HyperionGrabber_GuidedStep_First
}
override fun onCreateGuidance(savedInstanceState: Bundle?): GuidanceStylist.Guidance {
val title = getString(R.string.guidedstep_basic_settings_title)
val description = getString(R.string.guidedstep_basic_settings_description)
val icon = activity?.getDrawable(R.drawable.ic_qr_android_tv_remote_short)
return GuidanceStylist.Guidance(title, description, null, icon)
}
override fun onCreateActions(actions: MutableList<GuidedAction>, savedInstanceState: Bundle?) {
val enterHost = GuidedAction.Builder(context)
.id(ACTION_HOST_NAME)
.title(getString(CommonR.string.pref_title_host))
.description(prefs.getString(CommonR.string.pref_key_host, null))
.descriptionEditable(true)
.build()
val enterPort = unSignedNumberAction(
ACTION_PORT,
getString(CommonR.string.pref_title_port),
prefs.getInt(CommonR.string.pref_key_port).toString()
)
val enterHorizontalLEDCount = unSignedNumberAction(
ACTION_X_LED_COUNT,
getString(CommonR.string.pref_title_x_led),
prefs.getInt(CommonR.string.pref_key_x_led).toString()
)
val enterVerticalLEDCount = unSignedNumberAction(
ACTION_Y_LED_COUNT,
getString(CommonR.string.pref_title_y_led),
prefs.getInt(CommonR.string.pref_key_y_led).toString()
)
val startOnBootEnabled = prefs.getBoolean(CommonR.string.pref_key_boot)
val startOnBoot = GuidedAction.Builder(context)
.id(ACTION_START_ON_BOOT)
.title(getString(CommonR.string.pref_title_boot))
.description(CommonR.string.pref_summary_boot)
.checkSetId(GuidedAction.CHECKBOX_CHECK_SET_ID)
.checked(startOnBootEnabled)
.build()
val advancedInfo = GuidedAction.Builder(context)
.title(R.string.guidedstep_section_advanced_title)
.description(R.string.guidedstep_section_advanced_description)
.multilineDescription(true)
.focusable(false)
.infoOnly(true)
.enabled(false)
.build()
val priority = unSignedNumberAction(
ACTION_MESSAGE_PRIORITY,
getString(CommonR.string.pref_title_priority),
prefs.getString(CommonR.string.pref_key_priority, "100")
)
val reconnectEnabled = prefs.getBoolean(CommonR.string.pref_key_reconnect)
val reconnect = GuidedAction.Builder(context)
.id(ACTION_RECONNECT)
.title(getString(CommonR.string.pref_title_reconnect))
.checkSetId(GuidedAction.CHECKBOX_CHECK_SET_ID)
.checked(reconnectEnabled)
.build()
val reconnectDelay = unSignedNumberAction(
ACTION_RECONNECT_DELAY,
getString(CommonR.string.pref_title_reconnect_delay),
prefs.getInt(CommonR.string.pref_key_reconnect_delay).toString()
)
val reconnectDescription =
if (prefs.contains(CommonR.string.pref_key_reconnect)){
if (reconnectEnabled){
CommonR.string.enabled
} else {
CommonR.string.disabled
}
} else {
CommonR.string.pref_summary_reconnect
}
val reconnectGroup = GuidedAction.Builder(context)
.id(ACTION_RECONNECT_GROUP)
.title(getString(CommonR.string.pref_title_reconnect))
.description(reconnectDescription)
.subActions(listOf(reconnect, reconnectDelay))
.build()
val frameRateLabels = resources.getStringArray(CommonR.array.pref_list_framerate)
val frameRateValues = resources.getStringArray(CommonR.array.pref_list_framerate_values)
val selectedCaptureRate = prefs.getString(CommonR.string.pref_key_framerate, "30")
val captureRateDescription =
if (prefs.contains(CommonR.string.pref_key_framerate)){
frameRateLabels[frameRateValues.indexOf(selectedCaptureRate)]
} else {
getString(CommonR.string.pref_summary_framerate)
}
val captureRate = radioListAction(
ACTION_CAPTURE_RATE,
getString(CommonR.string.pref_title_framerate),
captureRateDescription,
ACTION_CAPTURE_RATE_SET_ID,
frameRateLabels,
frameRateValues,
selectedCaptureRate
)
val averageColor = GuidedAction.Builder(context)
.id(ACTION_AVERAGE_COLOR)
.title(getString(CommonR.string.pref_title_use_avg_color))
.description(CommonR.string.pref_summary_use_avg_color)
.checkSetId(GuidedAction.CHECKBOX_CHECK_SET_ID)
.checked(prefs.getBoolean(CommonR.string.pref_key_use_avg_color))
.build()
actions.add(enterHost)
actions.add(enterPort)
actions.add(enterHorizontalLEDCount)
actions.add(enterVerticalLEDCount)
actions.add(startOnBoot)
actions.add(advancedInfo)
actions.add(priority)
actions.add(reconnectGroup)
actions.add(captureRate)
actions.add(averageColor)
}
override fun onCreateButtonActions(actions: MutableList<GuidedAction>, savedInstanceState: Bundle?) {
actions.add(continueAction())
actions.add(GuidedAction.Builder(context)
.id(ACTION_TEST)
.title(getString(R.string.guidedstep_test))
.description(R.string.guidedstep_test_description)
.build()
)
actions.add(backAction())
}
override fun onGuidedActionClicked(action: GuidedAction) {
if (action.id == SettingsStepBaseFragment.CONTINUE) {
try {
val host = assertStringValue(ACTION_HOST_NAME)
val port = assertIntValue(ACTION_PORT)
val xLED = assertIntValue(ACTION_X_LED_COUNT)
val yLED = assertIntValue(ACTION_Y_LED_COUNT)
val startOnBootEnabled = findActionById(ACTION_START_ON_BOOT).isChecked
val priority = assertIntValue(ACTION_MESSAGE_PRIORITY)
val frameRate = assertSubActionValue(ACTION_CAPTURE_RATE, String::class.java)
val reconnect = findSubActionById(ACTION_RECONNECT)!!.isChecked
val reconnectDelay = assertIntValue(ACTION_RECONNECT_DELAY)
val useAverageColor = findActionById(ACTION_AVERAGE_COLOR)!!.isChecked
prefs.putString(CommonR.string.pref_key_host, host)
prefs.putInt(CommonR.string.pref_key_port, port)
prefs.putInt(CommonR.string.pref_key_x_led, xLED)
prefs.putInt(CommonR.string.pref_key_y_led, yLED)
prefs.putBoolean(CommonR.string.pref_key_boot, startOnBootEnabled)
prefs.putInt(CommonR.string.pref_key_priority, priority)
prefs.putInt(CommonR.string.pref_key_reconnect_delay, reconnectDelay)
prefs.putString(CommonR.string.pref_key_framerate, frameRate)
prefs.putBoolean(CommonR.string.pref_key_reconnect, reconnect)
prefs.putBoolean(CommonR.string.pref_key_use_avg_color, useAverageColor)
val activity = activity
activity?.setResult(Activity.RESULT_OK)
finishGuidedStepSupportFragments()
} catch (ignored: AssertionError) {
}
return
} else if (action.id == ACTION_TEST){
val colorIdx = testCounter % TEST_COLORS.size
val color = TEST_COLORS[colorIdx]
testCounter++
try {
val host = assertStringValue(ACTION_HOST_NAME)
val port = assertIntValue(ACTION_PORT)
val priority = assertIntValue(ACTION_MESSAGE_PRIORITY)
testHyperionColor(host, port, priority, color)
} catch (ignored: AssertionError) {
}
return
}
super.onGuidedActionClicked(action)
}
override fun onSubGuidedActionClicked(action: GuidedAction): Boolean {
when {
action.id == ACTION_RECONNECT -> {
val newDescription = if(action.isChecked){
getString(CommonR.string.enabled)
} else getString(CommonR.string.disabled)
findActionById(ACTION_RECONNECT_GROUP)
.description = newDescription
notifyActionIdChanged(ACTION_RECONNECT_GROUP)
return !action.isChecked
}
action is ValueGuidedAction && action.parentId != null -> {
findActionById(action.parentId).description = action.title
notifyActionIdChanged(action.parentId)
}
}
return super.onSubGuidedActionClicked(action)
}
/** tries to connect to Hyperion and sets the given color for 5 seconds */
private fun testHyperionColor(hostName: String, port: Int, priority: Int, color: Int) {
TestTask(requireContext()).execute(TestSpec(hostName, port, priority, color))
}
companion object {
private const val ACTION_HOST_NAME = 100L
private const val ACTION_PORT = 110L
private const val ACTION_START_ON_BOOT = 120L
private const val ACTION_X_LED_COUNT = 130L
private const val ACTION_Y_LED_COUNT = 140L
private const val ACTION_RECONNECT_GROUP = 200L
private const val ACTION_RECONNECT = 210L
private const val ACTION_RECONNECT_DELAY = 220L
private const val ACTION_MESSAGE_PRIORITY = 300L
private const val ACTION_CAPTURE_RATE = 400L
private const val ACTION_CAPTURE_RATE_SET_ID = 1500
private const val ACTION_AVERAGE_COLOR = 600L
private const val ACTION_TEST = 700L
private val TEST_COLORS = intArrayOf(Color.RED, Color.GREEN, Color.BLUE, Color.WHITE)
/**
* Tries to connect to Hyperion and set all LEDs to a single color
*/
class TestTask(context: Context) {
private val contextRef = WeakReference(context)
private val executor = Executors.newSingleThreadExecutor()
private val mainHandler = android.os.Handler(android.os.Looper.getMainLooper())
fun execute(spec: TestSpec) {
executor.execute {
val result = doInBackground(spec)
mainHandler.post { onPostExecute(result) }
}
}
private fun doInBackground(spec: TestSpec): Int {
try {
val (host, port, priority, color) = spec
val hyperion = HyperionFlatBuffers(host, port, priority)
if (hyperion.isConnected) {
hyperion.setColor(color, priority, 3000)
} else {
return RESULT_UNREACHABLE
}
hyperion.disconnect()
return RESULT_OK
} catch (e: UnknownHostException) {
return RESULT_UNREACHABLE
} catch (e: Exception){
return RESULT_UNKNOWN_ERROR
}
}
private fun onPostExecute(result: Int) {
contextRef.get()?.run {
val messageRes = when(result){
RESULT_OK -> R.string.guidedstep_test_success
RESULT_UNREACHABLE -> R.string.guidedstep_test_host_unreachable
else -> R.string.guidedstep_test_unknown_error
}
Toast.makeText(this, messageRes, Toast.LENGTH_SHORT).show()
}
}
companion object {
const val RESULT_OK = 1
const val RESULT_UNREACHABLE = -1
const val RESULT_UNKNOWN_ERROR = -100
}
}
data class TestSpec(val host: String, val port: Int, val priority: Int, val color: Int)
}
}
@@ -0,0 +1,208 @@
package com.hyperion.grabber.tv.fragments.settings
import android.content.Context
import android.os.Bundle
import androidx.leanback.app.GuidedStepSupportFragment
import androidx.leanback.widget.GuidanceStylist
import androidx.leanback.widget.GuidedAction
import android.text.InputType
import android.widget.Toast
import com.hyperion.grabber.common.util.Preferences
import com.hyperion.grabber.R
import com.hyperion.grabber.common.R as CommonR
/** Base class for Settings Fragments. Defines utilities for creating [GuidedAction]s and
* assertions on action values
*/
internal abstract class SettingsStepBaseFragment : GuidedStepSupportFragment() {
lateinit var prefs: Preferences
override fun onCreate(savedInstanceState: Bundle?) {
prefs = Preferences(requireContext())
super.onCreate(savedInstanceState)
}
override fun onCreateGuidanceStylist(): GuidanceStylist {
return SettingsStepStylist()
}
/** Default implementation handles backAction only*/
override fun onGuidedActionClicked(action: GuidedAction) {
if (action.id == BACK) {
finishGuidedStepSupportFragments()
}
}
protected fun continueAction(): GuidedAction {
return GuidedAction.Builder(context)
.id(CONTINUE)
.title(getString(R.string.guidedstep_save))
.description(R.string.guidedstep_letsdoit)
.build()
}
protected fun backAction(): GuidedAction {
return GuidedAction.Builder(context)
.id(BACK)
.title(getString(R.string.guidedstep_cancel))
.description(R.string.guidedstep_nevermind)
.build()
}
protected fun unSignedNumberAction(id: Long, title: String, description: CharSequence?): GuidedAction {
return GuidedAction.Builder(context)
.id(id)
.title(title)
.description(description)
.descriptionEditable(true)
.descriptionInputType(InputType.TYPE_CLASS_NUMBER)
.descriptionEditInputType(InputType.TYPE_CLASS_NUMBER)
.build()
}
protected fun radioListAction(id: Long, title: String, description: String?, setId: Int, optionLabels: Array<String>, optionValues: Array<out Any>, selected: Any?): GuidedAction {
val subActions = optionLabels.zip(optionValues).map {
ValueGuidedAction.Companion.Builder(requireContext())
.parentId(id)
.checkSetId(setId)
.title(it.first)
.value(it.second)
.checked(it.second == selected)
.build()
}
return GuidedAction.Builder(context)
.id(id)
.title(title)
.description(description)
.subActions(subActions)
.build()
}
/** makes sure a value is filled for the GuidedAction and
* returns that value. If it is not filled, a toast is shown and this
* fun @throws a [AssertionError]
*/
@Throws(AssertionError::class)
protected fun assertStringValue(actionId: Long): String {
with(stringValueForAction(actionId)){
if (isEmpty()){
notifyRequired(actionId)
throw AssertionError("$actionId has no value")
}
return this
}
}
/** makes sure a value is filled for the GuidedAction and
* returns that value. If it is not filled, a toast is shown and this
* fun @throws a [AssertionError]
*/
@Throws(AssertionError::class)
protected fun assertIntValue(actionId: Long): Int {
return assertStringValue(actionId).let{
try {
Integer.parseInt(it)
} catch (ignored: Exception){
showToast(getString(CommonR.string.pref_error_invalid_field, it, getString(CommonR.string.pref_title_reconnect_delay)))
throw AssertionError("$actionId is not a valid int")
}
}
}
protected fun findActionByIdRecursive(actionId: Long) =
findActionById(actionId) ?: findSubActionById(actionId)
protected fun findSubActionById(subActionId: Long): GuidedAction? {
actions.forEach { mainAction ->
mainAction.subActions?.find {
if (it.id == subActionId) {
return it
} else false
}
}
return null
}
/** makes sure a value is filled for the GuidedAction and
* returns that value. If it is not filled, a toast is shown and this
* fun @throws an [AssertionError]
*/
protected fun <T: Any> assertSubActionValue(actionId: Long, type: Class<T>): T {
with(findActionByIdRecursive(actionId)!!){
val selected = subActions.find { it.isChecked }
if (selected is ValueGuidedAction){
return selected.value as T
}
if (selected == null) {
notifyRequired(actionId)
throw AssertionError("$actionId has no value")
}
return selected.title.toString() as T
}
}
protected fun notifyActionIdChanged(id: Long){
notifyActionChanged(findActionPositionById(id))
}
/** Returns empty string if not set */
private fun stringValueForAction(actionId: Long): String =
findActionByIdRecursive(actionId)?.description?.toString() ?: ""
protected fun showToast(message: CharSequence){
Toast.makeText(activity, message, Toast.LENGTH_SHORT).show()
}
private fun notifyRequired(actionId: Long){
showToast(getString(CommonR.string.pref_error_missing_field, findActionById(actionId).title))
}
companion object {
const val CONTINUE = -1303L
const val BACK = -1304L
}
class ValueGuidedAction(
val value: Any? = null,
val parentId: Long? = null
) : GuidedAction() {
companion object {
class Builder(context: Context) : GuidedAction.BuilderBase<Builder>(context){
var value: Any? = null
var parentId: Long? = null
fun value(value: Any?): Builder {
this.value = value
return this
}
fun parentId(parentId: Long?): Builder {
this.parentId = parentId
return this
}
fun build(): ValueGuidedAction{
val action = ValueGuidedAction(value, parentId)
applyValues(action)
return action
}
}
}
}
}
@@ -0,0 +1,10 @@
package com.hyperion.grabber.tv.fragments.settings
import androidx.leanback.widget.GuidanceStylist
import com.hyperion.grabber.R
class SettingsStepStylist : GuidanceStylist() {
override fun onProvideLayoutId(): Int {
return R.layout.settings_guidance
}
}
@@ -0,0 +1,83 @@
package com.hyperion.grabber.tv.views;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import androidx.leanback.widget.GuidanceStylist;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
/**
* Relative layout implementation that lays out child views based on provided keyline percent(
* distance of TitleView baseline from the top).
*
* Repositioning child views in PreDraw callback in {@link GuidanceStylist} was interfering with
* fragment transition. To avoid that, we do that in the onLayout pass.
*
* Nino: Copied from Leanback code, changed to align icon bottom with description bottom
*/
class SettingsRelativeLayout extends RelativeLayout {
private float mTitleKeylinePercent;
public SettingsRelativeLayout(Context context) {
this(context, null);
}
public SettingsRelativeLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public SettingsRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mTitleKeylinePercent = getKeyLinePercent(context);
}
public static float getKeyLinePercent(Context context) {
TypedArray ta = context.getTheme().obtainStyledAttributes(
androidx.leanback.R.styleable.LeanbackGuidedStepTheme);
float percent = ta.getFloat(androidx.leanback.R.styleable.LeanbackGuidedStepTheme_guidedStepKeyline, 40);
ta.recycle();
return percent;
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
View mTitleView = getRootView().findViewById(androidx.leanback.R.id.guidance_title);
View mBreadcrumbView = getRootView().findViewById(androidx.leanback.R.id.guidance_breadcrumb);
View mDescriptionView = getRootView().findViewById(
androidx.leanback.R.id.guidance_description);
ImageView mIconView = getRootView().findViewById(androidx.leanback.R.id.guidance_icon);
int mTitleKeylinePixels = (int) (getMeasuredHeight() * mTitleKeylinePercent / 100);
if (mTitleView != null && mTitleView.getParent() == this) {
int titleViewBaseline = mTitleView.getBaseline();
int mBreadcrumbViewHeight = mBreadcrumbView == null ? 0 : mBreadcrumbView.getMeasuredHeight();
int guidanceTextContainerTop = mTitleKeylinePixels
- titleViewBaseline - mBreadcrumbViewHeight - mTitleView.getPaddingTop();
int offset = guidanceTextContainerTop - (mBreadcrumbView == null ? 0 : mBreadcrumbView.getTop());
if (mBreadcrumbView != null && mBreadcrumbView.getParent() == this) {
mBreadcrumbView.offsetTopAndBottom(offset);
}
mTitleView.offsetTopAndBottom(offset);
if (mDescriptionView != null && mDescriptionView.getParent() == this) {
mDescriptionView.offsetTopAndBottom(offset);
}
}
if (mIconView != null && mIconView.getParent() == this) {
Drawable drawable = mIconView.getDrawable();
if (drawable != null && mDescriptionView != null) {
int iconOffset = mDescriptionView.getBottom() - mIconView.getBottom();
mIconView.offsetTopAndBottom(
iconOffset);
}
}
}
}
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@android:color/white">
<item>
<shape>
<solid android:color="#aaa"/>
<corners android:radius="10dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>
</item>
</ripple>
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="120dp"
android:height="120dp"
android:viewportWidth="348.6"
android:viewportHeight="349">
<path
android:fillColor="@color/lb_tv_white"
android:pathData="M208.2,162.3c-4,1.9-6.6,3.9-7.1,9.1c-1.1,10.7-8.6,17.7-19,19.5c-10,1.7-20-3.3-24.5-12.4c-4.2-8.4-2.4-19.8,4.1-26.6 c6.9-7.2,18-9.5,27-4.5c4.1,2.3,6.7,2.2,10.3-0.6c7.7-6,15.9-11.4,23.9-17c-14-20.8-47.3-28.7-73-17.6 c-27.5,11.8-42.4,39.2-38.2,69.8c3.6,26.3,26.3,48.8,54.1,52.5c28.8,3.9,52.3-8.4,73.8-26c2.1-1.7,4-3.6,6.5-6 c-8.9,27.9-41.1,47.8-75,46.9c-32.9-0.8-62.8-25.4-71.7-58.8c-8.7-32.6,5.7-68.3,34.6-86.1c28.6-17.6,70-18.1,102,16.1 c9.4-6.7,18.9-13.5,28.9-20.6c-24.6-29.1-54.9-44-92.4-43.3C110,58.1,61,107.5,59.7,170c-1.2,57.7,44.7,108.3,101.6,115.4 c56.4,7,111.3-34.7,132.5-80.2c2.7-5.8,5-11.7,7.8-18.1c-1.7,37.5-32.1,92.8-94.8,109.1C146,311.9,83.5,281.6,57,223.7 c-25.3-55.2-6.5-122.6,43.6-157.9C152,29.7,227.9,33.6,276.8,91.6c7.6-5.4,15.3-10.8,23.5-16.5c-25.5-31.6-57.6-51.6-97-58.2 c-90.6-15.1-171.1,41-187,131.5C1.5,232.6,57.2,315.6,144.6,331.9c53.6,10.1,99.9-6,141-40.9c32.8-27.8,53.8-61.8,60.7-104.4 c0.2-1.1,0.5-2.2,0.9-3.2c0.3-0.7,0.8-1.2,1.4-2c-4.3,84.4-65.2,153-146.9,165.6C119.9,359.6,39,312.4,11,235.6 c-28.9-79.1,0.8-165.6,72.3-209.8c70.5-43.7,167.9-33,228.7,40.7c3.8-2.4,12.1-7.8,12.1-7.8l15.3,23.1L208.2,162.3z" />
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:tint="#CCCCCC"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M7.77,6.76L6.23,5.48 0.82,12l5.41,6.52 1.54,-1.28L3.42,12l4.35,-5.24zM7,13h2v-2L7,11v2zM17,11h-2v2h2v-2zM11,13h2v-2h-2v2zM17.77,5.48l-1.54,1.28L20.58,12l-4.35,5.24 1.54,1.28L23.18,12l-5.41,-6.52z" />
</vector>
+85
View File
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hyperion.grabber.tv.activities.MainActivity">
<com.hyperion.grabber.common.views.SweepGradientView
android:id="@+id/sweepGradientView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/grabberStartedText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:background="@drawable/pill_background"
android:drawablePadding="8dp"
android:drawableStart="@drawable/ic_info_white_24dp"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingEnd="10dp"
android:paddingStart="8dp"
android:paddingTop="8dp"
android:text="@string/message_service_started"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_toggle_image_middle" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/power_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="12dp"
android:adjustViewBounds="true"
android:background="@drawable/image_button_background"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toTopOf="@+id/sweepGradientView"
app:layout_constraintEnd_toStartOf="@+id/settingsButton"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/sweepGradientView"
app:layout_constraintTop_toBottomOf="@+id/sweepGradientView"
app:srcCompat="@drawable/ic_power_black_72dp" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/settingsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/image_button_background"
android:focusable="true"
app:layout_constraintBottom_toTopOf="@+id/sweepGradientView"
app:layout_constraintEnd_toStartOf="@+id/sweepGradientView"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/power_toggle"
app:layout_constraintTop_toBottomOf="@+id/sweepGradientView"
app:srcCompat="@drawable/ic_settings_black_72dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
tools:context=".activities.NetworkScanActivity">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.15" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.85" />
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/scanner_title"
android:textSize="28sp"
android:gravity="center"
app:layout_constraintBottom_toTopOf="@+id/networkScanIcon"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/networkScanIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@id/textView"
app:layout_constraintBottom_toTopOf="@id/scannerDescriptionText"
app:srcCompat="@drawable/ic_network_scan"
/>
<TextView
android:id="@+id/scannerDescriptionText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/scanner_description"
android:textSize="22sp"
app:layout_constraintBottom_toTopOf="@+id/progressBar"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@+id/networkScanIcon" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
app:layout_constraintBottom_toTopOf="@id/startScanButton"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@+id/scannerDescriptionText"
/>
<Button
android:id="@+id/startScanButton"
style="@style/Widget.Leanback.DetailsActionButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/scanner_start_scan_button"
android:onClick="onClick"
android:scaleX="1.1"
android:scaleY="1.1"
app:layout_constraintBottom_toTopOf="@+id/manualSetupButton"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@+id/progressBar" />
<Button
android:id="@+id/manualSetupButton"
style="@style/Widget.Leanback.DetailsActionButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/scanner_manual_setup_button"
android:onClick="onClick"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@id/startScanButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimaryDark"
tools:context=".activities.ScanResultActivity">
<nl.dionsegijn.konfetti.xml.KonfettiView
android:id="@+id/konfetti"
android:alpha="0.5"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.2" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.8" />
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/scan_result_title"
android:textSize="28sp"
android:gravity="center"
app:layout_constraintBottom_toTopOf="@+id/scanResultEmojiText"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"/>
<TextView
android:id="@+id/scanResultEmojiText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="48sp"
android:gravity="center"
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@id/textView"
app:layout_constraintBottom_toTopOf="@id/scanResultHostName"
tools:text="applauseEmoji"/>
<TextView
android:id="@+id/scanResultHostName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32sp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@id/scanResultEmojiText"
app:layout_constraintBottom_toTopOf="@id/scanResultDescriptionText"
tools:text="192.168.100.104"
/>
<TextView
android:id="@+id/scanResultDescriptionText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/scan_result_description"
android:textSize="22sp"
android:gravity="center"
app:layout_constraintBottom_toTopOf="@+id/progressBar"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@+id/scanResultHostName" />
<Space
android:id="@+id/progressBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:background="?android:attr/listDivider"
app:layout_constraintBottom_toTopOf="@id/confirmButton"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@+id/scanResultDescriptionText"
/>
<Button
android:id="@+id/confirmButton"
style="@style/Widget.Leanback.OnboardingStartButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/scan_result_confirm_button_text"
android:onClick="onClick"
app:layout_constraintBottom_toTopOf="@+id/changeColorButton"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@+id/progressBar" />
<Button
android:id="@+id/changeColorButton"
style="@style/Widget.Leanback.DetailsActionButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/scan_result_alternative_color_button_text"
android:onClick="onClick"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/guideEnd"
app:layout_constraintStart_toStartOf="@id/guideStart"
app:layout_constraintTop_toBottomOf="@id/confirmButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.hyperion.grabber.tv.views.SettingsRelativeLayout
android:id="@+id/guidance_container"
style="?attr/guidanceContainerStyle" >
<ImageView
android:id="@+id/guidance_icon"
style="?attr/guidanceIconStyle"
tools:ignore="ContentDescription"/>
<TextView
android:id="@+id/guidance_breadcrumb"
style="?attr/guidanceBreadcrumbStyle"
/>
<TextView
android:id="@+id/guidance_title"
style="?attr/guidanceTitleStyle"/>
<TextView
android:id="@+id/guidance_description"
style="?attr/guidanceDescriptionStyle"/>
</com.hyperion.grabber.tv.views.SettingsRelativeLayout>
</FrameLayout>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/settings"
android:title="@string/settings" />
</menu>
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_basic_settings_title">تلميح</string>
<string name="guidedstep_basic_settings_description">قم بتنزيل تطبيق Android TV Remote الرسمي على هاتفك لإدخال الأرقام والنصوص بسهولة</string>
<string name="guidedstep_second_title">اختبار الاتصال</string>
<string name="guidedstep_section_advanced_title">إعدادات متقدمة</string>
<string name="guidedstep_section_advanced_description">يمكن أن تترك الإعدادات أدناه بأمان في الإعدادات الافتراضية</string>
<string name="guidedstep_save">حفظ</string>
<string name="guidedstep_test">اختبار</string>
<string name="guidedstep_test_description">تألق</string>
<string name="guidedstep_test_success">النتيجة: حسنًا. المصابيح لا تضيء؟ جرب قيمة أولوية أقل</string>
<string name="guidedstep_test_host_unreachable">النتيجة: تعذر الاتصال. يرجى التحقق من المضيف والمنفذ</string>
<string name="guidedstep_test_unknown_error">النتيجة: خطأ غير معروف</string>
<string name="guidedstep_continue">استمر</string>
<string name="guidedstep_letsdoit">دعونا نفعل ذلك</string>
<string name="guidedstep_nevermind">لا بأس</string>
<string name="guidedstep_cancel">إلغاء</string>
<string name="guidedstep_required">مطلوب</string>
<!--This is the title for a custom launcher activity - hence including the app's name, with the action noted (toggle the grabber)-->
<string name="toggle_activity_label">Hyperion Grabber (Toggle)</string>
</resources>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_basic_settings_title">Tip</string>
<string name="guidedstep_basic_settings_description">Stáhněte si oficiální aplikaci Android TV Remote do telefonu pro snadné zadávání čísel a textu</string>
<string name="guidedstep_second_title">Test připojení</string>
<string name="guidedstep_section_advanced_title">Pokročilé nastavení</string>
<string name="guidedstep_section_advanced_description">Níže uvedená nastavení mohou být bezpečně ponechána na výchozích hodnotách</string>
<string name="guidedstep_save">Uložit</string>
<string name="guidedstep_test">Test</string>
<string name="guidedstep_test_description">Rozsvítit</string>
<string name="guidedstep_test_success">Výsledek: OK. LED nesvítí? Zkuste nižší hodnotu priority</string>
<string name="guidedstep_test_host_unreachable">Výsledek: Nelze se připojit. Zkontrolujte prosím položky Host a Port</string>
<string name="guidedstep_test_unknown_error">Výsledek: neznámá chyba</string>
<string name="guidedstep_continue">Pokračovat</string>
<string name="guidedstep_letsdoit">Pojďme na to</string>
<string name="guidedstep_nevermind">Nevadí</string>
<string name="guidedstep_cancel">Zrušit</string>
<string name="guidedstep_required">Vyžadováno</string>
</resources>
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_basic_settings_title">Tip</string>
<string name="guidedstep_basic_settings_description">Lade dir die offizielle Android TV App auf dein Smartphone um Zahlen und Text besser eingeben zu können</string>
<string name="guidedstep_second_title">Verbindungstest</string>
<string name="guidedstep_section_advanced_title">Erweiterte Einstellungen</string>
<string name="guidedstep_section_advanced_description">Die nachfolgenden Einstellungen können auf ihren Standardwerten belassen werden</string>
<string name="guidedstep_save">Speichern</string>
<string name="guidedstep_test">Test</string>
<string name="guidedstep_test_description">Licht an</string>
<string name="guidedstep_test_success">Ergebnis: OK. LEDs leuchten nicht? Versuch es mit einer niedrigeren Priorität</string>
<string name="guidedstep_test_host_unreachable">Ergebnis: Verbindungsfehler. Bitte überprüfe IP und Port Nummer</string>
<string name="guidedstep_test_unknown_error">Ergebnis: Unbekannter Fehler</string>
<string name="guidedstep_continue">Weiter</string>
<string name="guidedstep_letsdoit">So soll es sein</string>
<string name="guidedstep_nevermind">Vergiss es</string>
<string name="guidedstep_cancel">Abbrechen</string>
<string name="guidedstep_required">Benötigt</string>
<!--This is the title for a custom launcher activity - hence including the app's name, with the action noted (toggle the grabber)-->
<string name="toggle_activity_label">Hyperion Grabber (Umschalten)</string>
</resources>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_basic_settings_title">Consejo</string>
<string name="guidedstep_second_title">Prueba de conexión</string>
<string name="guidedstep_section_advanced_title">Configuración avanzada</string>
<string name="guidedstep_save">Guardar</string>
<string name="guidedstep_test">Prueba</string>
<string name="guidedstep_test_host_unreachable">Resultado: No se pudo conectar. Por favor, compruebe el host y el puerto</string>
<string name="guidedstep_test_unknown_error">Resultado: error desconocido</string>
<string name="guidedstep_continue">Continuar</string>
<string name="guidedstep_nevermind">No importa</string>
<string name="guidedstep_cancel">Cancelar</string>
</resources>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_basic_settings_title">Astuce</string>
<string name="guidedstep_basic_settings_description">Téléchargez l\'application officielle \"Android TV Remote\" sur votre téléphone pour une saisie simplifié des numéros et du texte.</string>
<string name="guidedstep_second_title">Test de connexion</string>
<string name="guidedstep_section_advanced_title">Paramètres avancés</string>
<string name="guidedstep_section_advanced_description">Les paramètres ci-dessous peuvent être laissés à leurs valeurs par défaut</string>
<string name="guidedstep_save">Sauvegarder</string>
<string name="guidedstep_test">Tester</string>
<string name="guidedstep_test_description">Allumer</string>
<string name="guidedstep_test_success">Résultat: OK. Les LEDs ne s\'allument pas? Essayez une valeur de priorité inférieure</string>
<string name="guidedstep_test_host_unreachable">Résultat : Impossible de se connecter. Veuillez vérifier l\'hôte et le port</string>
<string name="guidedstep_test_unknown_error">Résultat : erreur inconnue</string>
<string name="guidedstep_continue">Continuer</string>
<string name="guidedstep_letsdoit">Allons-y</string>
<string name="guidedstep_nevermind">Cela ne fait rien</string>
<string name="guidedstep_cancel">Annuler</string>
<string name="guidedstep_required">Obligatoire</string>
</resources>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_basic_settings_title">Suggerimento</string>
<string name="guidedstep_basic_settings_description">Scarica l\'app ufficiale Android TV Remote sul telefono per inserire facilmente numeri e testo</string>
<string name="guidedstep_second_title">Test di connessione</string>
<string name="guidedstep_section_advanced_title">Impostazioni avanzate</string>
<string name="guidedstep_section_advanced_description">Le impostazioni seguenti per sicurezza possono essere lasciate ai loro valori predefiniti</string>
<string name="guidedstep_save">Salva</string>
<string name="guidedstep_test">Test</string>
<string name="guidedstep_test_description">Brilla</string>
<string name="guidedstep_test_success">Risultato: OK. I LED non si accendono? Prova un valore di priorità più basso</string>
<string name="guidedstep_test_host_unreachable">Risultato: impossibile connettersi. Si prega di controllare l\'host e la porta</string>
<string name="guidedstep_test_unknown_error">Risultato: errore sconosciuto</string>
<string name="guidedstep_continue">Continua</string>
<string name="guidedstep_letsdoit">Facciamolo</string>
<string name="guidedstep_nevermind">Non importa</string>
<string name="guidedstep_cancel">Annulla</string>
<string name="guidedstep_required">Obbligatorio</string>
</resources>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_basic_settings_title">Tip</string>
<string name="guidedstep_basic_settings_description">Download de officiële Android TV Remote app op uw telefoon om nummers en tekst eenvoudig in te voeren</string>
<string name="guidedstep_second_title">Verbindingstest</string>
<string name="guidedstep_section_advanced_title">Geavanceerde instellingen</string>
<string name="guidedstep_section_advanced_description">De onderstaande instellingen staan voor de meeste situaties al goed</string>
<string name="guidedstep_save">Opslaan</string>
<string name="guidedstep_test">Test</string>
<string name="guidedstep_test_description">Laat ze stralen</string>
<string name="guidedstep_test_success">Resultaat: OK. Lichten de LED\'s niet op? Probeer een lagere prioriteitswaarde</string>
<string name="guidedstep_test_host_unreachable">Resultaat: Kon geen verbinding maken. Controleer de host en poort</string>
<string name="guidedstep_test_unknown_error">Resultaat: onbekende fout</string>
<string name="guidedstep_continue">Doorgaan</string>
<string name="guidedstep_letsdoit">Lekker bezig!</string>
<string name="guidedstep_nevermind">Laat maar</string>
<string name="guidedstep_cancel">Annuleren</string>
<string name="guidedstep_required">Vereist</string>
</resources>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_basic_settings_title">Tips</string>
<string name="guidedstep_basic_settings_description">Last ned den offisielle Android TV Remote appen på telefonen for enkel inntasting av tall og tekst</string>
<string name="guidedstep_second_title">Test tilkoblingen</string>
<string name="guidedstep_section_advanced_title">Avanserte innstillinger</string>
<string name="guidedstep_section_advanced_description">Innstillingene nedenfor kan trygt kjøres på sine standardverdier</string>
<string name="guidedstep_save">Lagre</string>
<string name="guidedstep_test">Test</string>
<string name="guidedstep_test_description">Kjør på</string>
<string name="guidedstep_test_success">Resultat: OK. Ingen lys? Prøv en lavere prioritetsverdi</string>
<string name="guidedstep_test_host_unreachable">Resultat: Kunne ikke koble til. Vennligst sjekk vertsnavn og port</string>
<string name="guidedstep_test_unknown_error">Resultat: ukjent feil</string>
<string name="guidedstep_continue">Fortsett</string>
<string name="guidedstep_letsdoit">La oss gjøre det</string>
<string name="guidedstep_nevermind">Glem det</string>
<string name="guidedstep_cancel">Avbryt</string>
<string name="guidedstep_required">Påkrevd</string>
</resources>
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="guidedstep_second_title">Проверка соединения</string>
<string name="guidedstep_section_advanced_title">Дополнительные параметры</string>
<string name="guidedstep_save">Сохранить</string>
<string name="guidedstep_test">Тест</string>
<string name="guidedstep_test_description">Да будет свет</string>
<string name="guidedstep_test_unknown_error">Результат: неизвестная ошибка</string>
<string name="guidedstep_continue">Продолжать</string>
<string name="guidedstep_cancel">Отмена</string>
<string name="guidedstep_required">Требуется</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#607D8B</color>
<color name="colorPrimaryDark">#455A64</color>
<color name="colorPrimaryExtraDark">#324249</color>
<color name="colorPrimarySuperDark">#303030</color>
<color name="colorPrimaryLight">#CFD8DC</color>
<color name="colorAccent">#FF5722</color>
<color name="primary_text">#212121</color>
<color name="secondary_text">#757575</color>
<color name="icons">#FFFFFF</color>
<color name="divider">#BDBDBD</color>
</resources>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_basic_settings_title">Tip</string>
<string name="guidedstep_basic_settings_description">Download the official Android TV Remote app on your phone for easy entry of numbers and text</string>
<string name="guidedstep_second_title">Connection test</string>
<string name="guidedstep_section_advanced_title">Advanced settings</string>
<string name="guidedstep_section_advanced_description">The settings below can safely be left at their defaults</string>
<string name="guidedstep_save">Save</string>
<string name="guidedstep_test">Test</string>
<string name="guidedstep_test_description">Shine on</string>
<string name="guidedstep_test_success">Result: OK. LEDs not lighting up? Try a lower priority value</string>
<string name="guidedstep_test_host_unreachable">Result: Could not connect. Please check host and port</string>
<string name="guidedstep_test_unknown_error">Result: unknown error</string>
<string name="guidedstep_continue">Continue</string>
<string name="guidedstep_letsdoit">Let\'s do it</string>
<string name="guidedstep_nevermind">Never mind</string>
<string name="guidedstep_cancel">Cancel</string>
<string name="guidedstep_required">Required</string>
<!--This is the title for a custom launcher activity - hence including the app's name, with the action noted (toggle the grabber)-->
<string name="toggle_activity_label">Hyperion Grabber (Toggle)</string>
<string name="settings">Settings</string>
<string name="quick_tile_label">Hyperion Grabber</string>
<string name="quick_tile_toast_setup_required">Please complete the setup in the app first</string>
</resources>
+47
View File
@@ -0,0 +1,47 @@
<resources>
<!-- 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>
</style>
<style name="LeanbackPreferences" parent="Theme.Leanback">
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Leanback</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<!--<item name="android:colorPrimary">@color/pref_background</item>-->
</style>
<style name="MyOnboardingTheme" parent="Theme.Leanback.Onboarding">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="Widget.HyperionGrabber.GuidedActionItemDescriptionStyle" parent="Widget.Leanback.GuidedActionItemDescriptionStyle">
<item name="android:textColor">@color/primary_text</item>
</style>
<style name="Widget.HyperionGrabber.GuidanceIconStyle" parent="Widget.Leanback.GuidanceIconStyle">
<item name="android:background">@color/colorPrimaryDark</item>
</style>
<style name="Widget.HyperionGrabber.FirstStepGuidanceIconStyle" parent="Widget.HyperionGrabber.GuidanceIconStyle">
<item name="android:background">#fff</item>
</style>
<style name="Theme.HyperionGrabber.GuidedStep" parent="Theme.Leanback.GuidedStep">
<item name="guidedStepBackground">@color/colorPrimaryDark</item>
<item name="guidedActionsBackground">@color/colorPrimaryExtraDark</item>
<item name="guidedActionsBackgroundDark">@color/colorPrimarySuperDark</item>
<item name="guidanceIconStyle">@style/Widget.HyperionGrabber.GuidanceIconStyle</item>
</style>
<style name="Theme.HyperionGrabber.GuidedStep.First" parent="@style/Theme.HyperionGrabber.GuidedStep">
<item name="guidanceIconStyle">@style/Widget.HyperionGrabber.FirstStepGuidanceIconStyle</item>
</style>
</resources>
@@ -0,0 +1,17 @@
package com.hyperion.grabber;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
Executable
+27
View File
@@ -0,0 +1,27 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.9.22'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
+1
View File
@@ -0,0 +1 @@
/build
+49
View File
@@ -0,0 +1,49 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
}
apply from: project(':common').projectDir.absolutePath + '/variables.gradle'
android {
namespace 'com.hyperion.grabber.common'
compileSdk 34
defaultConfig {
minSdk 21
targetSdk 34
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.core:core-ktx:1.12.0"
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.preference:preference-ktx:1.2.1"
implementation "androidx.localbroadcastmanager:localbroadcastmanager:1.1.0"
implementation 'com.google.flatbuffers:flatbuffers-java:23.5.26'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
+44
View File
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:targetApi="lollipop">
<service
android:name="com.hyperion.grabber.common.HyperionScreenService"
android:exported="true"
android:foregroundServiceType="mediaProjection">
<intent-filter>
<action android:name="com.hyperion.grabber.common.HyperionScreenService" />
<action android:name="com.hyperion.grabber.service.ACTION_START" />
<action android:name="com.hyperion.grabber.service.ACTION_STOP" />
<action android:name="com.hyperion.grabber.service.ACTION_STATUS" />
<action android:name="com.hyperion.grabber.service.ACTION_EXIT" />
</intent-filter>
</service>
<receiver
android:name=".HyperionGrabberBootReceiver"
android:exported="true"
android:label="HyperionGrabberBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity android:name=".BootActivity" android:theme="@style/Theme.Transparent" android:exported="true"/>
</application>
</manifest>
@@ -0,0 +1,9 @@
namespace hyperionnet;
table Reply {
error:string;
video:int = -1;
registered:int = -1;
}
root_type Reply;
@@ -0,0 +1,46 @@
namespace hyperionnet;
// A priority value of -1 clears all priorities
table Register {
origin:string (required);
priority:int;
}
table RawImage {
data:[ubyte];
width:int = -1;
height:int = -1;
}
table NV12Image {
data_y:[ubyte];
data_uv:[ubyte];
width:int;
height:int;
stride_y:int = 0;
stride_uv:int = 0;
}
union ImageType {RawImage, NV12Image}
table Image {
data:ImageType (required);
duration:int = -1;
}
table Clear {
priority:int;
}
table Color {
data:int = -1;
duration:int = -1;
}
union Command {Color, Image, Clear, Register}
table Request {
command:Command (required);
}
root_type Request;
@@ -0,0 +1,51 @@
package com.hyperion.grabber.common;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.projection.MediaProjectionManager;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
public class BootActivity extends AppCompatActivity {
public static final int REQUEST_MEDIA_PROJECTION = 1;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MediaProjectionManager manager = (MediaProjectionManager)
getSystemService(Context.MEDIA_PROJECTION_SERVICE);
if (manager != null) {
startActivityForResult(manager.createScreenCaptureIntent(), REQUEST_MEDIA_PROJECTION);
} else {
finish();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_MEDIA_PROJECTION) {
if (resultCode == Activity.RESULT_OK) {
startScreenRecorder(this, resultCode, data);
}
finish();
}
}
public static void startScreenRecorder(Context context, int resultCode, Intent data) {
Intent intent = new Intent(context, HyperionScreenService.class);
intent.setAction(HyperionScreenService.ACTION_START);
intent.putExtra(HyperionScreenService.EXTRA_RESULT_CODE, resultCode);
intent.putExtras(data);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intent);
} else {
context.startService(intent);
}
}
}
@@ -0,0 +1,28 @@
package com.hyperion.grabber.common;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import androidx.annotation.RequiresApi;
import com.hyperion.grabber.common.util.Preferences;
public class HyperionGrabberBootReceiver extends BroadcastReceiver {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Preferences preferences = new Preferences(context);
if (preferences.getBoolean(R.string.pref_key_boot)) {
final Intent i = new Intent(context, BootActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION
|Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|Intent.FLAG_ACTIVITY_NO_HISTORY
|Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
}
@@ -0,0 +1,108 @@
package com.hyperion.grabber.common;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
public class HyperionNotification {
private final String NOTIFICATION_CHANNEL_ID = "com.hyperion.grabber.notification";
private final String NOTIFICATION_CHANNEL_LABEL;
private final String NOTIFICATION_TITLE;
private final String NOTIFICATION_DESCRIPTION;
private final int PENDING_INTENT_REQUEST_CODE = 0;
private final NotificationManager mNotificationManager;
private final Context mContext;
private Notification.Action mAction = null;
HyperionNotification (Context ctx, NotificationManager manager) {
mNotificationManager = manager;
mContext = ctx;
NOTIFICATION_TITLE = mContext.getString(R.string.app_name);
NOTIFICATION_DESCRIPTION = mContext.getString(R.string.notification_description);
NOTIFICATION_CHANNEL_LABEL = mContext.getString(R.string.notification_channel_label);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mNotificationManager.createNotificationChannel(makeChannel());
}
}
private int getPendingIntentFlags() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
return PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
} else {
return PendingIntent.FLAG_UPDATE_CURRENT;
}
}
public void setAction(int code, String label, Intent intent) {
PendingIntent pendingIntent = PendingIntent.getService(mContext, code,
intent, getPendingIntentFlags());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mAction = new Notification.Action.Builder(
Icon.createWithResource(mContext, R.drawable.ic_notification_icon),
label,
pendingIntent
).build();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
mAction = new Notification.Action.Builder(
R.drawable.ic_notification_icon,
label,
pendingIntent
).build();
}
}
public Notification buildNotification() {
PendingIntent pIntent = null;
Intent intent = mContext.getPackageManager().getLaunchIntentForPackage(mContext.getPackageName());
if (intent != null) {
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
pIntent = PendingIntent.getActivity(mContext, PENDING_INTENT_REQUEST_CODE,
intent, getPendingIntentFlags());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Notification.Builder builder = new Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
.setOngoing(true)
.setSmallIcon(R.drawable.ic_notification_icon)
.setContentTitle(NOTIFICATION_TITLE)
.setContentText(NOTIFICATION_DESCRIPTION);
if (mAction != null) {
builder.addAction(mAction);
}
if (pIntent != null) {
builder.setContentIntent(pIntent);
}
return builder.build();
} else {
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext, NOTIFICATION_CHANNEL_ID)
.setVibrate(null)
.setSound(null)
.setOngoing(true)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setSmallIcon(R.drawable.ic_notification_icon)
.setContentTitle(NOTIFICATION_TITLE)
.setContentText(NOTIFICATION_DESCRIPTION);
if (pIntent != null) {
builder.setContentIntent(pIntent);
}
return builder.build();
}
}
@RequiresApi(api = Build.VERSION_CODES.O)
private NotificationChannel makeChannel() {
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
NOTIFICATION_CHANNEL_LABEL, NotificationManager.IMPORTANCE_DEFAULT);
notificationChannel.setDescription(NOTIFICATION_CHANNEL_LABEL);
notificationChannel.enableVibration(false);
notificationChannel.setSound(null,null);
return notificationChannel;
}
}
@@ -0,0 +1,352 @@
package com.hyperion.grabber.common;
import android.annotation.TargetApi;
import android.graphics.PixelFormat;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.media.Image;
import android.media.ImageReader;
import android.media.MediaCodec;
import android.media.projection.MediaProjection;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import androidx.annotation.RequiresApi;
import android.util.Log;
import com.hyperion.grabber.common.network.HyperionThread;
import com.hyperion.grabber.common.util.BorderProcessor;
import com.hyperion.grabber.common.util.HyperionGrabberOptions;
import java.nio.ByteBuffer;
public class HyperionScreenEncoder extends HyperionScreenEncoderBase {
private static final String TAG = "HyperionScreenEncoder";
private static final boolean DEBUG = false;
private static final int MAX_IMAGE_READER_IMAGES = 2;
private static final int MAX_CAPTURE_WIDTH = 128;
private static final int MAX_CAPTURE_HEIGHT = 72;
private VirtualDisplay mVirtualDisplay;
private ImageReader mImageReader;
private HandlerThread mCaptureThread;
private Handler mCaptureHandler;
private volatile boolean mRunning = false;
private int mCaptureWidth;
private int mCaptureHeight;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
HyperionScreenEncoder(final HyperionThread.HyperionThreadListener listener,
final MediaProjection projection, final int width, final int height,
final int density, HyperionGrabberOptions options) {
super(listener, projection, width, height, density, options);
// Calculate capture dimensions maintaining aspect ratio
// Use very small resolution to minimize HDR tonemapping overhead
float aspectRatio = (float) width / height;
if (aspectRatio >= 1.0f) {
// Landscape
mCaptureWidth = Math.min(MAX_CAPTURE_WIDTH, getGrabberWidth());
mCaptureHeight = Math.max(1, (int) (mCaptureWidth / aspectRatio));
} else {
// Portrait
mCaptureHeight = Math.min(MAX_CAPTURE_HEIGHT, getGrabberHeight());
mCaptureWidth = Math.max(1, (int) (mCaptureHeight * aspectRatio));
}
// Ensure dimensions are even (required by some devices)
mCaptureWidth = (mCaptureWidth / 2) * 2;
mCaptureHeight = (mCaptureHeight / 2) * 2;
if (mCaptureWidth < 2) mCaptureWidth = 2;
if (mCaptureHeight < 2) mCaptureHeight = 2;
if (DEBUG) {
Log.d(TAG, "Capture dimensions: " + mCaptureWidth + "x" + mCaptureHeight);
}
try {
prepare();
} catch (MediaCodec.CodecException e) {
e.printStackTrace();
}
}
@TargetApi(Build.VERSION_CODES.M)
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void prepare() throws MediaCodec.CodecException {
if (DEBUG) Log.d(TAG, "Preparing encoder");
mCaptureThread = new HandlerThread(TAG + "-Capture", android.os.Process.THREAD_PRIORITY_BACKGROUND);
mCaptureThread.start();
mCaptureHandler = new Handler(mCaptureThread.getLooper());
int displayFlags = DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;
mImageReader = ImageReader.newInstance(
mCaptureWidth,
mCaptureHeight,
PixelFormat.RGBA_8888,
MAX_IMAGE_READER_IMAGES
);
mVirtualDisplay = mMediaProjection.createVirtualDisplay(
TAG,
mCaptureWidth, mCaptureHeight, mDensity,
displayFlags,
mImageReader.getSurface(),
mDisplayCallback,
mHandler);
startCaptureLoop();
}
private void startCaptureLoop() {
mRunning = true;
setCapturing(true);
final long frameIntervalNs = 1_000_000_000L / mFrameRate;
mCaptureHandler.post(new Runnable() {
@Override
public void run() {
if (!mRunning || !isCapturing()) {
return;
}
long startTime = System.nanoTime();
Image img = null;
try {
img = mImageReader.acquireLatestImage();
if (img != null) {
sendImage(img);
}
} catch (Exception e) {
if (DEBUG) Log.w(TAG, "Frame capture error: " + e.getMessage());
} finally {
if (img != null) {
try {
img.close();
} catch (Exception ignored) {}
}
}
long elapsed = System.nanoTime() - startTime;
long delayMs = Math.max(1, (frameIntervalNs - elapsed) / 1_000_000L);
if (mRunning && mCaptureHandler != null) {
mCaptureHandler.postDelayed(this, delayMs);
}
}
});
}
@Override
public void stopRecording() {
if (DEBUG) Log.i(TAG, "stopRecording Called");
mRunning = false;
setCapturing(false);
if (mCaptureHandler != null) {
mCaptureHandler.removeCallbacksAndMessages(null);
}
if (mVirtualDisplay != null) {
mVirtualDisplay.release();
mVirtualDisplay = null;
}
if (mCaptureThread != null) {
mCaptureThread.quitSafely();
mCaptureThread = null;
mCaptureHandler = null;
}
mHandler.getLooper().quit();
clearAndDisconnect();
if (mImageReader != null) {
mImageReader.close();
mImageReader = null;
}
}
@Override
public void resumeRecording() {
if (DEBUG) Log.i(TAG, "resumeRecording Called");
if (!isCapturing() && mImageReader != null) {
startCaptureLoop();
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void setOrientation(int orientation) {
if (mVirtualDisplay != null && orientation != mCurrentOrientation) {
mCurrentOrientation = orientation;
int temp = mCaptureWidth;
mCaptureWidth = mCaptureHeight;
mCaptureHeight = temp;
mRunning = false;
setCapturing(false);
if (mCaptureHandler != null) {
mCaptureHandler.removeCallbacksAndMessages(null);
}
mVirtualDisplay.resize(mCaptureWidth, mCaptureHeight, mDensity);
if (mImageReader != null) {
mImageReader.close();
}
mImageReader = ImageReader.newInstance(
mCaptureWidth,
mCaptureHeight,
PixelFormat.RGBA_8888,
MAX_IMAGE_READER_IMAGES
);
mVirtualDisplay.setSurface(mImageReader.getSurface());
startCaptureLoop();
}
}
private VirtualDisplay.Callback mDisplayCallback = new VirtualDisplay.Callback() {
@Override
public void onPaused() {
if (DEBUG) Log.d(TAG, "VirtualDisplay paused");
mRunning = false;
setCapturing(false);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
@Override
public void onResumed() {
if (DEBUG) Log.d(TAG, "VirtualDisplay resumed");
if (!mRunning) {
startCaptureLoop();
}
}
@Override
public void onStopped() {
if (DEBUG) Log.d(TAG, "VirtualDisplay stopped");
mRunning = false;
setCapturing(false);
}
};
private byte[] getPixels(ByteBuffer buffer, int width, int height, int rowStride,
int pixelStride, int firstX, int firstY) {
int effectiveWidth = width - firstX * 2;
int effectiveHeight = height - firstY * 2;
if (effectiveWidth <= 0 || effectiveHeight <= 0) {
effectiveWidth = width;
effectiveHeight = height;
firstX = 0;
firstY = 0;
}
byte[] pixels = new byte[effectiveWidth * effectiveHeight * 3];
int pixelIndex = 0;
for (int y = firstY; y < height - firstY; y++) {
int rowOffset = y * rowStride;
for (int x = firstX; x < width - firstX; x++) {
int offset = rowOffset + x * pixelStride;
pixels[pixelIndex++] = (byte) (buffer.get(offset) & 0xff); // R
pixels[pixelIndex++] = (byte) (buffer.get(offset + 1) & 0xff); // G
pixels[pixelIndex++] = (byte) (buffer.get(offset + 2) & 0xff); // B
}
}
return pixels;
}
private byte[] getAverageColor(ByteBuffer buffer, int width, int height, int rowStride,
int pixelStride, int firstX, int firstY) {
long totalRed = 0, totalGreen = 0, totalBlue = 0;
int pixelCount = 0;
int startY = Math.max(0, firstY);
int endY = Math.min(height, height - firstY);
int startX = Math.max(0, firstX);
int endX = Math.min(width, width - firstX);
for (int y = startY; y < endY; y++) {
int rowOffset = y * rowStride;
for (int x = startX; x < endX; x++) {
int offset = rowOffset + x * pixelStride;
totalRed += buffer.get(offset) & 0xff;
totalGreen += buffer.get(offset + 1) & 0xff;
totalBlue += buffer.get(offset + 2) & 0xff;
pixelCount++;
}
}
byte[] avgColor = new byte[3];
if (pixelCount > 0) {
avgColor[0] = (byte) (totalRed / pixelCount);
avgColor[1] = (byte) (totalGreen / pixelCount);
avgColor[2] = (byte) (totalBlue / pixelCount);
}
return avgColor;
}
private void sendImage(Image img) {
if (img == null) return;
Image.Plane[] planes = img.getPlanes();
if (planes == null || planes.length == 0) return;
Image.Plane plane = planes[0];
ByteBuffer buffer = plane.getBuffer();
if (buffer == null) return;
int width = img.getWidth();
int height = img.getHeight();
int pixelStride = plane.getPixelStride();
int rowStride = plane.getRowStride();
int firstX = 0;
int firstY = 0;
if (mRemoveBorders || mAvgColor) {
mBorderProcessor.parseBorder(buffer, width, height, rowStride, pixelStride);
BorderProcessor.BorderObject border = mBorderProcessor.getCurrentBorder();
if (border != null && border.isKnown()) {
firstX = border.getHorizontalBorderIndex();
firstY = border.getVerticalBorderIndex();
}
}
try {
if (mAvgColor) {
mListener.sendFrame(
getAverageColor(buffer, width, height, rowStride, pixelStride, firstX, firstY),
1,
1
);
} else {
int effectiveWidth = width - firstX * 2;
int effectiveHeight = height - firstY * 2;
if (effectiveWidth > 0 && effectiveHeight > 0) {
mListener.sendFrame(
getPixels(buffer, width, height, rowStride, pixelStride, firstX, firstY),
effectiveWidth,
effectiveHeight
);
}
}
} catch (Exception e) {
if (DEBUG) Log.w(TAG, "Error sending frame: " + e.getMessage());
}
}
}
@@ -0,0 +1,144 @@
package com.hyperion.grabber.common;
import android.content.res.Configuration;
import android.media.projection.MediaProjection;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Process;
import android.util.Log;
import com.hyperion.grabber.common.network.HyperionThread;
import com.hyperion.grabber.common.util.BorderProcessor;
import com.hyperion.grabber.common.util.HyperionGrabberOptions;
public class HyperionScreenEncoderBase {
static final boolean DEBUG = false;
private static final String TAG = "ScreenEncoderBase";
private final int CLEAR_COMMAND_DELAY_MS = 100;
private final int INIT_ORIENTATION;
final boolean mRemoveBorders = false; // enables detecting borders for standard grabbing - disabled for now
final boolean mAvgColor;
final int mWidthScaled;
final int mFrameRate;
final int mHeightScaled;
final int mDensity;
boolean mIsCapturing = false;
int mCurrentOrientation;
BorderProcessor mBorderProcessor;
Handler mHandler;
MediaProjection mMediaProjection;
HyperionThread.HyperionThreadListener mListener;
HyperionScreenEncoderBase(final HyperionThread.HyperionThreadListener listener,
final MediaProjection projection, int width, int height,
final int density, HyperionGrabberOptions options) {
if (DEBUG) Log.d(TAG, "Encoder starting");
mListener = listener;
mMediaProjection = projection;
mDensity = density;
mFrameRate = options.getFrameRate();
mAvgColor = options.useAverageColor();
int blackThreshold = options.getBlackThreshold();
mBorderProcessor = new BorderProcessor(blackThreshold);
mCurrentOrientation = INIT_ORIENTATION = width > height ? Configuration.ORIENTATION_LANDSCAPE :
Configuration.ORIENTATION_PORTRAIT;
if (DEBUG) {
Log.d(TAG, "Density: " + String.valueOf(mDensity));
Log.d(TAG, "Frame Rate: " + String.valueOf(mFrameRate));
Log.d(TAG, "Original Width: " + String.valueOf(width));
Log.d(TAG, "Original Height: " + String.valueOf(height));
Log.d(TAG, "Average Color Only: " + String.valueOf(mAvgColor));
Log.d(TAG, "Black Pixel Threshold: " + String.valueOf(blackThreshold));
}
int divisor = options.findDivisor(width, height);
mHeightScaled = (height / divisor);
mWidthScaled = (width / divisor);
if (DEBUG) {
Log.d(TAG, "Common Divisor: " + String.valueOf(divisor));
Log.d(TAG, "Scaled Width: " + String.valueOf(mWidthScaled));
Log.d(TAG, "Scaled Height: " + String.valueOf(mHeightScaled));
}
final HandlerThread thread = new HandlerThread(TAG, Process.THREAD_PRIORITY_DISPLAY);
thread.start();
mHandler = new Handler(thread.getLooper());
if (DEBUG) Log.d(TAG, "Encoder ready");
}
private Runnable clearAndDisconnectRunner = new Runnable() {
public void run() {
if (DEBUG) Log.d(TAG, "Clearing LEDs and disconnecting");
try {
Thread.sleep(CLEAR_COMMAND_DELAY_MS);
} catch (InterruptedException e) {
e.printStackTrace();
}
mListener.clear();
mListener.disconnect();
}
};
private Runnable clearLightsRunner = new Runnable() {
public void run() {
if (DEBUG) Log.d(TAG, "Clearing LEDs");
try {
Thread.sleep(CLEAR_COMMAND_DELAY_MS);
} catch (InterruptedException e) {
e.printStackTrace();
}
mListener.clear();
}
};
public void clearLights() {
new Thread(clearLightsRunner).start();
}
void clearAndDisconnect() {
new Thread(clearAndDisconnectRunner).start();
}
public boolean isCapturing() {
return mIsCapturing;
}
public void setCapturing(boolean isCapturing) {
mIsCapturing = isCapturing;
}
public void sendStatus() {
if (mListener != null) {
mListener.sendStatus(isCapturing());
}
}
public void stopRecording() {
throw new RuntimeException("Stub!");
}
public void resumeRecording() {
throw new RuntimeException("Stub!");
}
int getGrabberWidth() {
return INIT_ORIENTATION != mCurrentOrientation ? mHeightScaled : mWidthScaled;
}
int getGrabberHeight() {
return INIT_ORIENTATION != mCurrentOrientation ? mWidthScaled : mHeightScaled;
}
public void setOrientation(int orientation) {
mCurrentOrientation = orientation;
}
}
@@ -0,0 +1,340 @@
package com.hyperion.grabber.common;
import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ServiceInfo;
import android.media.projection.MediaProjection;
import android.media.projection.MediaProjectionManager;
import android.os.Build;
import android.os.IBinder;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.app.ServiceCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
import com.hyperion.grabber.common.network.HyperionThread;
import com.hyperion.grabber.common.util.HyperionGrabberOptions;
import com.hyperion.grabber.common.util.Preferences;
import java.util.Objects;
public class HyperionScreenService extends Service {
public static final String BROADCAST_ERROR = "SERVICE_ERROR";
public static final String BROADCAST_TAG = "SERVICE_STATUS";
public static final String BROADCAST_FILTER = "SERVICE_FILTER";
private static final boolean DEBUG = false;
private static final String TAG = "HyperionScreenService";
private static final String BASE = "com.hyperion.grabber.service.";
public static final String ACTION_START = BASE + "ACTION_START";
public static final String ACTION_STOP = BASE + "ACTION_STOP";
public static final String ACTION_EXIT = BASE + "ACTION_EXIT";
public static final String GET_STATUS = BASE + "ACTION_STATUS";
public static final String EXTRA_RESULT_CODE = BASE + "EXTRA_RESULT_CODE";
private static final int NOTIFICATION_ID = 1;
private static final int NOTIFICATION_EXIT_INTENT_ID = 2;
private boolean RECONNECT = false;
private boolean hasConnected = false;
private MediaProjectionManager mMediaProjectionManager;
private HyperionThread mHyperionThread;
private static MediaProjection _mediaProjection;
private int mFrameRate;
private int mHorizontalLEDCount;
private int mVerticalLEDCount;
private boolean mSendAverageColor;
private HyperionScreenEncoder mHyperionEncoder;
private NotificationManager mNotificationManager;
private String mStartError = null;
HyperionThreadBroadcaster mReceiver = new HyperionThreadBroadcaster() {
@Override
public void onConnected() {
Log.d(TAG, "CONNECTED TO HYPERION INSTANCE");
hasConnected = true;
notifyActivity();
}
@Override
public void onConnectionError(int errorID, String error) {
Log.e(TAG, "COULD NOT CONNECT TO HYPERION INSTANCE");
if (error != null) Log.e(TAG, error);
if (!hasConnected) {
mStartError = getResources().getString(R.string.error_server_unreachable);
haltStartup();
}
if (RECONNECT && hasConnected) {
Log.e(TAG, "AUTOMATIC RECONNECT ENABLED. CONNECTING ...");
} else if (!RECONNECT && hasConnected) {
mStartError = getResources().getString(R.string.error_connection_lost);
stopSelf();
}
}
@Override
public void onReceiveStatus(boolean isCapturing) {
if (DEBUG) Log.v(TAG, "Received grabber status, notifying activity. Status: " +
String.valueOf(isCapturing));
notifyActivity();
}
};
BroadcastReceiver mEventReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
switch (Objects.requireNonNull(intent.getAction())) {
case Intent.ACTION_SCREEN_ON:
if (DEBUG) Log.v(TAG, "ACTION_SCREEN_ON intent received");
if (mHyperionEncoder != null && !isCapturing()) {
if (DEBUG) Log.v(TAG, "Encoder not grabbing, attempting to restart");
mHyperionEncoder.resumeRecording();
}
notifyActivity();
break;
case Intent.ACTION_SCREEN_OFF:
if (DEBUG) Log.v(TAG, "ACTION_SCREEN_OFF intent received");
if (mHyperionEncoder != null) {
if (DEBUG) Log.v(TAG, "Clearing current light data");
mHyperionEncoder.clearLights();
}
break;
case Intent.ACTION_CONFIGURATION_CHANGED:
if (DEBUG) Log.v(TAG, "ACTION_CONFIGURATION_CHANGED intent received");
if (mHyperionEncoder != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (DEBUG) Log.v(TAG, "Configuration changed, checking orientation");
mHyperionEncoder.setOrientation(getResources().getConfiguration().orientation);
}
break;
case Intent.ACTION_SHUTDOWN:
case Intent.ACTION_REBOOT:
if (DEBUG) Log.v(TAG, "ACTION_SHUTDOWN|ACTION_REBOOT intent received");
stopScreenRecord();
break;
}
}
};
@Override
public void onCreate() {
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
super.onCreate();
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private boolean prepared() {
Preferences prefs = new Preferences(getBaseContext());
String host = prefs.getString(R.string.pref_key_host, null);
int port = prefs.getInt(R.string.pref_key_port, -1);
String priority = prefs.getString(R.string.pref_key_priority, "100");
mFrameRate = prefs.getInt(R.string.pref_key_framerate);
mHorizontalLEDCount = prefs.getInt(R.string.pref_key_x_led);
mVerticalLEDCount = prefs.getInt(R.string.pref_key_y_led);
mSendAverageColor = prefs.getBoolean(R.string.pref_key_use_avg_color);
RECONNECT = prefs.getBoolean(R.string.pref_key_reconnect);
int delay = prefs.getInt(R.string.pref_key_reconnect_delay);
if (host == null || Objects.equals(host, "0.0.0.0") || Objects.equals(host, "")) {
mStartError = getResources().getString(R.string.error_empty_host);
return false;
}
if (port == -1) {
mStartError = getResources().getString(R.string.error_empty_port);
return false;
}
if (mHorizontalLEDCount <= 0 || mVerticalLEDCount <= 0) {
mStartError = getResources().getString(R.string.error_invalid_led_counts);
return false;
}
mMediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
mHyperionThread = new HyperionThread(mReceiver, host, port, Integer.parseInt(priority), RECONNECT, delay);
mHyperionThread.start();
mStartError = null;
return true;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (DEBUG) Log.v(TAG, "Start command received");
super.onStartCommand(intent, flags, startId);
if (intent == null || intent.getAction() == null) {
String nullItem = (intent == null ? "intent" : "action");
if (DEBUG) Log.v(TAG, "Null " + nullItem + " provided to start command");
} else {
final String action = intent.getAction();
if (DEBUG) Log.v(TAG, "Start command action: " + String.valueOf(action));
switch (action) {
case ACTION_START:
if (mHyperionThread == null) {
boolean isPrepared = prepared();
if (isPrepared) {
// For Android 12+, we must start foreground with mediaProjection type BEFORE getting MediaProjection
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ServiceCompat.startForeground(this, NOTIFICATION_ID, getNotification(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION);
} else {
startForeground(NOTIFICATION_ID, getNotification());
}
startScreenRecord(intent);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
intentFilter.addAction(Intent.ACTION_REBOOT);
intentFilter.addAction(Intent.ACTION_SHUTDOWN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(mEventReceiver, intentFilter, Context.RECEIVER_NOT_EXPORTED);
} else {
registerReceiver(mEventReceiver, intentFilter);
}
} else {
haltStartup();
}
}
break;
case ACTION_STOP:
stopScreenRecord();
break;
case GET_STATUS:
notifyActivity();
break;
case ACTION_EXIT:
stopSelf();
break;
}
}
return START_STICKY;
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onDestroy() {
if (DEBUG) Log.v(TAG, "Ending service");
try {
unregisterReceiver(mEventReceiver);
} catch (Exception e) {
if (DEBUG) Log.v(TAG, "Wake receiver not registered");
}
stopScreenRecord();
stopForeground(true);
notifyActivity();
super.onDestroy();
}
private void haltStartup() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ServiceCompat.startForeground(this, NOTIFICATION_ID, getNotification(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION);
} else {
startForeground(NOTIFICATION_ID, getNotification());
}
stopSelf();
}
private Intent buildExitButton() {
Intent notificationIntent = new Intent(this, this.getClass());
notificationIntent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
notificationIntent.setAction(ACTION_EXIT);
return notificationIntent;
}
public Notification getNotification() {
HyperionNotification notification = new HyperionNotification(this, mNotificationManager);
String label = getString(R.string.notification_exit_button);
notification.setAction(NOTIFICATION_EXIT_INTENT_ID, label, buildExitButton());
return notification.buildNotification();
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void startScreenRecord(final Intent intent) {
if (DEBUG) Log.v(TAG, "Start screen recorder");
final int resultCode = intent.getIntExtra(EXTRA_RESULT_CODE, 0);
// get MediaProjection
final MediaProjection projection = mMediaProjectionManager.getMediaProjection(resultCode, intent);
WindowManager window = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
if (projection != null && window != null) {
_mediaProjection = projection;
final DisplayMetrics metrics = new DisplayMetrics();
window.getDefaultDisplay().getRealMetrics(metrics);
final int density = metrics.densityDpi;
HyperionGrabberOptions options = new HyperionGrabberOptions(mHorizontalLEDCount,
mVerticalLEDCount, mFrameRate, mSendAverageColor);
if (DEBUG) Log.v(TAG, "Starting the recorder");
mHyperionEncoder = new HyperionScreenEncoder(mHyperionThread.getReceiver(),
projection, metrics.widthPixels, metrics.heightPixels,
density, options);
mHyperionEncoder.sendStatus();
}
}
private void stopScreenRecord() {
if (DEBUG) Log.v(TAG, "Stop screen recorder");
RECONNECT = false;
mNotificationManager.cancel(NOTIFICATION_ID);
if (mHyperionEncoder != null) {
if (DEBUG) Log.v(TAG, "Stopping the current encoder");
mHyperionEncoder.stopRecording();
}
releaseResource();
if (mHyperionThread != null) {
mHyperionThread.interrupt();
}
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void releaseResource() {
if (_mediaProjection != null) {
_mediaProjection.stop();
_mediaProjection = null;
}
}
boolean isCapturing() {
return mHyperionEncoder != null && mHyperionEncoder.isCapturing();
}
boolean isCommunicating() {
return isCapturing() && hasConnected;
}
private void notifyActivity() {
Intent intent = new Intent(BROADCAST_FILTER);
intent.putExtra(BROADCAST_TAG, isCommunicating());
intent.putExtra(BROADCAST_ERROR, mStartError);
if (DEBUG) {
Log.v(TAG, "Sending status broadcast - communicating: " +
String.valueOf(isCommunicating()));
if (mStartError != null) {
Log.v(TAG, "Startup error: " + mStartError);
}
}
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
}
public interface HyperionThreadBroadcaster {
// void onResponse(String response);
void onConnected();
void onConnectionError(int errorHash, String errorString);
void onReceiveStatus(boolean isCapturing);
}
}
@@ -0,0 +1,97 @@
package com.hyperion.grabber.common;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.media.projection.MediaProjectionManager;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
public class ToggleActivity extends AppCompatActivity {
public static final int REQUEST_MEDIA_PROJECTION = 1;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean serviceRunning = checkForInstance();
if (serviceRunning) {
stopService();
finish();
} else {
requestPermission();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_MEDIA_PROJECTION) {
if (resultCode == Activity.RESULT_OK) {
startScreenRecorder(this, resultCode, data);
}
finish();
}
}
private static void startScreenRecorder(Context context, int resultCode, Intent data) {
Intent intent = new Intent(context, HyperionScreenService.class);
intent.setAction(HyperionScreenService.ACTION_START);
intent.putExtra(HyperionScreenService.EXTRA_RESULT_CODE, resultCode);
intent.putExtras(data);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intent);
} else {
context.startService(intent);
}
}
/** @return whether the service is running */
private boolean checkForInstance() {
if (isServiceRunning()) {
Intent intent = new Intent(this, HyperionScreenService.class);
intent.setAction(HyperionScreenService.GET_STATUS);
startService(intent);
return true;
} else {
return false;
}
}
private boolean isServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
assert manager != null;
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (HyperionScreenService.class.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void requestPermission(){
MediaProjectionManager manager = (MediaProjectionManager)
getSystemService(Context.MEDIA_PROJECTION_SERVICE);
if (manager != null) {
startActivityForResult(manager.createScreenCaptureIntent(), REQUEST_MEDIA_PROJECTION);
}
}
/** stop recording & stop service */
private void stopService() {
Intent stopIntent = new Intent(ToggleActivity.this, HyperionScreenService.class);
stopIntent.setAction(HyperionScreenService.ACTION_EXIT);
startService(stopIntent);
}
}
@@ -0,0 +1,14 @@
package com.hyperion.grabber.common.network;
import java.io.IOException;
public interface HyperionClient {
boolean isConnected();
void disconnect() throws IOException;
void clear(int priority) throws IOException;
void clearAll() throws IOException;
void setColor(int color, int priority) throws IOException;
void setColor(int color, int priority, int duration_ms) throws IOException;
void setImage(byte[] data, int width, int height, int priority) throws IOException;
void setImage(byte[] data, int width, int height, int priority, int duration_ms) throws IOException;
}
@@ -0,0 +1,137 @@
package com.hyperion.grabber.common.network;
import com.google.flatbuffers.FlatBufferBuilder;
import hyperionnet.Clear;
import hyperionnet.Color;
import hyperionnet.Command;
import hyperionnet.Image;
import hyperionnet.ImageType;
import hyperionnet.RawImage;
import hyperionnet.Register;
import hyperionnet.Reply;
import hyperionnet.Request;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
public class HyperionFlatBuffers implements HyperionClient {
private final int TIMEOUT = 1000;
private final Socket mSocket;
private final int mPriority;
private final FlatBufferBuilder mBuilder;
public HyperionFlatBuffers(String address, int port, int priority) throws IOException {
mSocket = new Socket();
mSocket.connect(new InetSocketAddress(address, port), TIMEOUT);
mPriority = priority;
mBuilder = new FlatBufferBuilder(1024);
register();
}
private void register() throws IOException {
mBuilder.clear();
int originOffset = mBuilder.createString("HyperionAndroidGrabber");
int registerOffset = Register.createRegister(mBuilder, originOffset, mPriority);
int requestOffset = Request.createRequest(mBuilder, Command.Register, registerOffset);
Request.finishRequestBuffer(mBuilder, requestOffset);
sendRequest(mBuilder.dataBuffer());
}
@Override
public boolean isConnected() {
return mSocket != null && mSocket.isConnected();
}
@Override
public void disconnect() throws IOException {
if (isConnected()) {
mSocket.close();
}
}
@Override
public void clear(int priority) throws IOException {
mBuilder.clear();
int clearOffset = Clear.createClear(mBuilder, priority);
int requestOffset = Request.createRequest(mBuilder, Command.Clear, clearOffset);
Request.finishRequestBuffer(mBuilder, requestOffset);
sendRequest(mBuilder.dataBuffer());
}
@Override
public void clearAll() throws IOException {
clear(-1);
}
@Override
public void setColor(int color, int priority) throws IOException {
setColor(color, priority, -1);
}
@Override
public void setColor(int color, int priority, int duration_ms) throws IOException {
mBuilder.clear();
int colorOffset = Color.createColor(mBuilder, color, duration_ms);
int requestOffset = Request.createRequest(mBuilder, Command.Color, colorOffset);
Request.finishRequestBuffer(mBuilder, requestOffset);
sendRequest(mBuilder.dataBuffer());
}
@Override
public void setImage(byte[] data, int width, int height, int priority) throws IOException {
setImage(data, width, height, priority, -1);
}
@Override
public void setImage(byte[] data, int width, int height, int priority, int duration_ms) throws IOException {
mBuilder.clear();
int dataOffset = RawImage.createDataVector(mBuilder, data);
int rawImageOffset = RawImage.createRawImage(mBuilder, dataOffset, width, height);
int imageOffset = Image.createImage(mBuilder, ImageType.RawImage, rawImageOffset, duration_ms);
int requestOffset = Request.createRequest(mBuilder, Command.Image, imageOffset);
Request.finishRequestBuffer(mBuilder, requestOffset);
sendRequest(mBuilder.dataBuffer());
}
private void sendRequest(ByteBuffer bb) throws IOException {
if (isConnected()) {
int size = bb.remaining();
byte[] header = new byte[4];
header[0] = (byte)((size >> 24) & 0xFF);
header[1] = (byte)((size >> 16) & 0xFF);
header[2] = (byte)((size >> 8) & 0xFF);
header[3] = (byte)((size ) & 0xFF);
OutputStream output = mSocket.getOutputStream();
output.write(header);
byte[] data = new byte[bb.remaining()];
bb.get(data);
output.write(data);
output.flush();
receiveReply();
}
}
private void receiveReply() throws IOException {
// We don't really need to parse the reply for now, but we should consume it
// to keep the socket clean.
if (mSocket.getInputStream().available() >= 4) {
byte[] header = new byte[4];
int read = mSocket.getInputStream().read(header, 0, 4);
if (read == 4) {
int size = ((header[0] & 0xFF) << 24) | ((header[1] & 0xFF) << 16) | ((header[2] & 0xFF) << 8) | (header[3] & 0xFF);
if (size > 0) {
byte[] data = new byte[size];
mSocket.getInputStream().read(data, 0, size);
// Reply reply = Reply.getRootAsReply(ByteBuffer.wrap(data));
}
}
}
}
}
@@ -0,0 +1,124 @@
package com.hyperion.grabber.common.network;
import com.hyperion.grabber.common.HyperionScreenService;
import java.io.IOException;
public class HyperionThread extends Thread {
private String HOST;
private int PORT;
private int PRIORITY;
private final int FRAME_DURATION = -1;
private boolean RECONNECT = false;
private boolean HAS_CONNECTED = false;
private int RECONNECT_DELAY;
private HyperionClient mHyperion;
HyperionScreenService.HyperionThreadBroadcaster mSender;
HyperionThreadListener mReceiver = new HyperionThreadListener() {
@Override
public void sendFrame(byte[] data, int width, int height) {
if (mHyperion != null && mHyperion.isConnected()) {
try {
mHyperion.setImage(data, width, height, PRIORITY, FRAME_DURATION);
} catch (IOException e) {
mSender.onConnectionError(e.hashCode(), e.getMessage());
e.printStackTrace();
if (RECONNECT && HAS_CONNECTED) {
reconnectDelay(RECONNECT_DELAY);
try {
mHyperion = createClient();
} catch (IOException i) {
i.printStackTrace();
}
}
}
}
}
@Override
public void clear() {
if (mHyperion != null && mHyperion.isConnected()) {
try {
mHyperion.clear(PRIORITY);
} catch (IOException e) {
mSender.onConnectionError(e.hashCode(), e.getMessage());
e.printStackTrace();
}
}
}
@Override
public void disconnect() {
if (mHyperion != null) {
try {
mHyperion.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void sendStatus(boolean isGrabbing) {
if (mSender != null) {
mSender.onReceiveStatus(isGrabbing);
}
}
};
public HyperionThread(HyperionScreenService.HyperionThreadBroadcaster listener, final String host,
final int port, final int priority, final boolean reconnect, final int delay){
HOST = host;
PORT = port;
PRIORITY = priority;
RECONNECT = reconnect;
RECONNECT_DELAY = delay * 1000;
mSender = listener;
}
public HyperionThreadListener getReceiver() {return mReceiver;}
private HyperionClient createClient() throws IOException {
return new HyperionFlatBuffers(HOST, PORT, PRIORITY);
}
@Override
public void run(){
do {
try {
mHyperion = createClient();
} catch (IOException e) {
mSender.onConnectionError(e.hashCode(), e.getMessage());
e.printStackTrace();
if (RECONNECT && HAS_CONNECTED) {
reconnectDelay(RECONNECT_DELAY);
}
} finally {
if (mHyperion != null && mSender != null && mHyperion.isConnected()) {
HAS_CONNECTED = true;
mSender.onConnected();
break;
}
}
} while (RECONNECT && HAS_CONNECTED);
}
public void reconnectDelay(long t) {
try {
Thread.sleep(t);
} catch (InterruptedException e) {
RECONNECT = false;
HAS_CONNECTED = false;
Thread.currentThread().interrupt();
}
}
public interface HyperionThreadListener {
void sendFrame(byte[] data, int width, int height);
void clear();
void disconnect();
void sendStatus(boolean isGrabbing);
}
}
@@ -0,0 +1,171 @@
package com.hyperion.grabber.common.network;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import android.util.Log;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/** Scans the local network for running Hyperion servers
* Created by nino on 27-5-18.
*/
public class NetworkScanner {
public static final int PORT = 19400;
/** The amount of milliseconds we try to connect to a given ip before giving up */
private static final int ATTEMPT_TIMEOUT_MS = 50;
private final String[] ipsToTry;
private int lastTriedIndex = -1;
public NetworkScanner() {
ipsToTry = getIPsToTry();
}
/** Scan the next ip address in the list of addresses to try
*
* @return the hostname (or an ip represented as String) when a Hyperion server was found
*/
@Nullable
@WorkerThread
public String tryNext(){
if (!hasNextAttempt()){
throw new IllegalStateException("No more ip addresses to try");
}
Socket socket = new Socket();
String ip = ipsToTry[++lastTriedIndex];
try {
socket.connect(new InetSocketAddress(ip, PORT), ATTEMPT_TIMEOUT_MS);
if (socket.isConnected()){
socket.close();
return ip;
}
} catch(Exception e) {
return null;
}
return null;
}
/** An indication of how many of the total ip's have been tried
*
* @return progress in in the range [0.0 .. 1.0]
*/
public float getProgress() {
if (ipsToTry.length == 0){
return 1f;
}
return lastTriedIndex / (float)ipsToTry.length;
}
/** True if not all ip's have been tried yet
*
*/
public boolean hasNextAttempt(){
return ipsToTry.length > 0 && lastTriedIndex + 1 < ipsToTry.length;
}
/**
* Get IP addresses for non-localhost interfaces
* @param useIPv4 true=return ipv4, false=return ipv6
* @return a list of found addresses (may be empty)
*
* https://stackoverflow.com/a/13007325
*/
@NonNull
private static List<String> getIPAddresses(boolean useIPv4) {
List<String> foundAddresses = new ArrayList<>();
try {
List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface intf : interfaces) {
List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
for (InetAddress addr : addrs) {
if (!addr.isLoopbackAddress()) {
String sAddr = addr.getHostAddress();
//boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
boolean isIPv4 = sAddr.indexOf(':')<0;
if (useIPv4) {
if (isIPv4)
foundAddresses.add(sAddr);
} else {
if (!isIPv4) {
int delim = sAddr.indexOf('%'); // drop ip6 zone suffix
String v6Addr = delim < 0 ? sAddr.toUpperCase() : sAddr.substring(0, delim).toUpperCase();
foundAddresses.add(v6Addr);
}
}
}
}
}
} catch (Exception e) {
// for now eat exceptions
Log.e("HYPERION SCANNER", "Could not get ip address", e);
}
return foundAddresses;
}
private String[] getIPsToTry(){
try {
List<String> localIpV4Addresses = getIPAddresses(true);
String[] allIpsToTry = new String[localIpV4Addresses.size() * 254];
for (int localIpIdx = 0; localIpIdx < localIpV4Addresses.size(); localIpIdx++) {
String localIpV4Address = localIpV4Addresses.get(localIpIdx);
String[] ipsToTry = new String[254];
String[] ipParts = localIpV4Address.split("\\.");
String ipPrefix = ipParts[0] + "." + ipParts[1] + "." + ipParts[2] + ".";
for (int i = 1; i< 255 ; i++){
ipsToTry[i-1] = ipPrefix + i;
}
int localNumberInSubnet = Integer.parseInt(ipParts[3]);
// sort in such a way that ips close to the local ip will be tried first
Arrays.sort(ipsToTry, (lhs, rhs) -> {
int lhsNumberInSubnet = Integer.parseInt(lhs.split("\\.")[3]);
int rhsNumberInSubnet = Integer.parseInt(rhs.split("\\.")[3]);
int lhsDistance = Math.abs(lhsNumberInSubnet - localNumberInSubnet);
int rhsDistance = Math.abs(rhsNumberInSubnet - localNumberInSubnet);
return lhsDistance - rhsDistance;
});
for (int i = 0; i < ipsToTry.length; i++) {
// interleave with previously found ip addresses
int allIndex = (localIpV4Addresses.size() * i) + localIpIdx;
allIpsToTry[allIndex] = ipsToTry[i];
}
}
return allIpsToTry;
} catch (Exception e){
// for now eat exceptions
Log.e("HYPERION SCANNER", "Error while building list of subnet ip's", e);
return new String[]{};
}
}
}
@@ -0,0 +1,186 @@
package com.hyperion.grabber.common.util;
import java.nio.ByteBuffer;
import java.util.Objects;
public class BorderProcessor {
private final int MAX_INCONSISTENT_FRAME_COUNT = 10;
private final int MAX_UNKNOWN_FRAME_COUNT = 600;
private final int BORDER_CHANGE_FRAME_COUNT = 50;
private final int BLACK_THRESHOLD; // unit to detect how black a pixel is [0..255]
private BorderObject mPreviousBorder;
private BorderObject mCurrentBorder;
private int mConsistentFrames = 0;
private int mInconsistentFrames = 0;
public BorderProcessor(int blackThreshold) {
BLACK_THRESHOLD = blackThreshold;
}
public BorderObject getCurrentBorder() { return mCurrentBorder; }
private void checkNewBorder(BorderObject newBorder) {
if (mPreviousBorder != null && mPreviousBorder.equals(newBorder)) {
++mConsistentFrames;
mInconsistentFrames = 0;
} else {
++mInconsistentFrames;
if (mInconsistentFrames <= MAX_INCONSISTENT_FRAME_COUNT) {
return;
}
mPreviousBorder = newBorder;
mConsistentFrames = 0;
}
if (mCurrentBorder != null && mCurrentBorder.equals(newBorder)) {
mInconsistentFrames = 0;
return;
}
if (!newBorder.isKnown()) {
if (mConsistentFrames == MAX_UNKNOWN_FRAME_COUNT) {
mCurrentBorder = newBorder;
}
} else {
if (mCurrentBorder == null || !mCurrentBorder.isKnown() ||
mConsistentFrames == BORDER_CHANGE_FRAME_COUNT) {
mCurrentBorder = newBorder;
}
}
}
public void parseBorder(ByteBuffer buffer, int width, int height, int rowStride,
int pixelStride) {
checkNewBorder( findBorder(buffer, width, height, rowStride, pixelStride) );
}
private BorderObject findBorder(ByteBuffer buffer, int width, int height, int rowStride,
int pixelStride) {
int width33percent = width / 3;
int width66percent = width33percent * 2;
int height33percent = height / 3;
int height66percent = height33percent * 2;
int yCenter = height / 2;
int xCenter = width / 2;
int firstNonBlackYPixelIndex = -1;
int firstNonBlackXPixelIndex = -1;
// placeholders for the RGB values of each of the 3 pixel positions we check
int p1R, p1G, p1B, p2R, p2G, p2B, p3R, p3G, p3B;
// positions in the byte array that represent 33%, 66%, and center.
// used when parsing both the X and Y axis of the image
int pos33percent, pos66percent, posCentered;
buffer.position(0).mark();
// iterate through the X axis until we either hit 33% of the image width or a non-black pixel
for (int x = 0; x < width33percent; x++) {
// RGB values at 33% height - to left of image
pos33percent = (height33percent * rowStride) + (x * pixelStride);
p1R = buffer.get(pos33percent) & 0xff;
p1G = buffer.get(pos33percent + 1) & 0xff;
p1B = buffer.get(pos33percent + 2) & 0xff;
// RGB values at 66% height - to left of image
pos66percent = (height66percent * rowStride) + (x * pixelStride);
p2R = buffer.get(pos66percent) & 0xff;
p2G = buffer.get(pos66percent + 1) & 0xff;
p2B = buffer.get(pos66percent + 2) & 0xff;
// RGB values at center Y - to right of image
posCentered = (yCenter * rowStride) + ((width - x - 1) * pixelStride);
p3R = buffer.get(posCentered) & 0xff;
p3G = buffer.get(posCentered + 1) & 0xff;
p3B = buffer.get(posCentered + 2) & 0xff;
// check if any of our RGB values DO NOT evaluate as black
if (!isBlack(p1R,p1G,p1B) || !isBlack(p2R,p2G,p2B) || !isBlack(p3R,p3G,p3B)) {
firstNonBlackXPixelIndex = x;
break;
}
}
buffer.reset();
// iterate through the Y axis until we either hit 33% of the image height or a non-black pixel
for (int y = 0; y < height33percent; y++) {
// RGB values at 33% width - top of image
pos33percent = (width33percent * pixelStride) + (y * rowStride);
p1R = buffer.get(pos33percent) & 0xff;
p1G = buffer.get(pos33percent + 1) & 0xff;
p1B = buffer.get(pos33percent + 2) & 0xff;
// RGB values at 66% width - top of image
pos66percent = (width66percent * pixelStride) + (y * rowStride);
p2R = buffer.get(pos66percent) & 0xff;
p2G = buffer.get(pos66percent + 1) & 0xff;
p2B = buffer.get(pos66percent + 2) & 0xff;
// RGB values at center X - bottom of image
posCentered = (xCenter * pixelStride) + ((height - y - 1) * rowStride);
p3R = buffer.get(posCentered) & 0xff;
p3G = buffer.get(posCentered + 1) & 0xff;
p3B = buffer.get(posCentered + 2) & 0xff;
// check if any of our RGB values DO NOT evaluate as black
if (!isBlack(p1R,p1G,p1B) || !isBlack(p2R,p2G,p2B) || !isBlack(p3R,p3G,p3B)) {
firstNonBlackYPixelIndex = y;
break;
}
}
return new BorderObject(firstNonBlackXPixelIndex, firstNonBlackYPixelIndex);
}
private boolean isBlack(int red, int green, int blue) {
return red < BLACK_THRESHOLD && green < BLACK_THRESHOLD && blue < BLACK_THRESHOLD;
}
public static class BorderObject {
private boolean isKnown;
private int horizontalBorderIndex;
private int verticalBorderIndex;
BorderObject(int horizontalBorderIndex, int verticalBorderIndex) {
this.horizontalBorderIndex = horizontalBorderIndex;
this.verticalBorderIndex = verticalBorderIndex;
this.isKnown = this.horizontalBorderIndex != -1 && this.verticalBorderIndex != -1;
}
public boolean isKnown() { return isKnown; }
public int getHorizontalBorderIndex() { return horizontalBorderIndex; }
public int getVerticalBorderIndex() { return verticalBorderIndex; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BorderObject that = (BorderObject) o;
return isKnown == that.isKnown &&
horizontalBorderIndex == that.horizontalBorderIndex &&
verticalBorderIndex == that.verticalBorderIndex;
}
@Override
public int hashCode() {
return Objects.hash(isKnown, horizontalBorderIndex, verticalBorderIndex);
}
@Override
public String toString() {
return "BorderObject{" +
"isKnown=" + isKnown +
", horizontalBorderIndex=" + horizontalBorderIndex +
", verticalBorderIndex=" + verticalBorderIndex +
'}';
}
}
}
@@ -0,0 +1,84 @@
package com.hyperion.grabber.common.util;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
public class HyperionGrabberOptions {
private static final boolean DEBUG = false;
private static final String TAG = "HyperionGrabberOptions";
private final int MINIMUM_IMAGE_PACKET_SIZE; // how many bytes the minimal acceptable image quality is
private final int FRAME_RATE;
private final boolean USE_AVERAGE_COLOR;
private final int BLACK_THRESHOLD = 5; // The limit each RGB value must be under to be considered a black pixel [0-255]
public HyperionGrabberOptions(int horizontalLED, int verticalLED, int frameRate, boolean useAvgColor) {
/*
* To determine the minimal acceptable image packet size we take the count of the width & height
* of the LED pixels (that the user is driving via their hyperion server) and multiply them
* together and then by 3 (1 for each color in RGB). This will give us the count of the bytes
* that the minimal acceptable quality should be equal to or greater than.
**/
MINIMUM_IMAGE_PACKET_SIZE = horizontalLED * verticalLED * 3;
FRAME_RATE = frameRate;
USE_AVERAGE_COLOR = useAvgColor;
if (DEBUG) {
Log.d(TAG, "Horizontal LED Count: " + String.valueOf(horizontalLED));
Log.d(TAG, "Vertical LED Count: " + String.valueOf(verticalLED));
Log.d(TAG, "Minimum Image Packet: " + String.valueOf(MINIMUM_IMAGE_PACKET_SIZE));
}
}
public int getFrameRate() { return FRAME_RATE; }
public boolean useAverageColor() { return USE_AVERAGE_COLOR; }
/**
* returns the divisor best suited to be used to meet the minimum image packet size
* Since we only want to scale using whole numbers, we need to find what common divisors
* are available for the given width & height. We will check those divisors to find the smallest
* number (that we can divide our screen dimensions by) that would meet the minimum image
* packet size required to match the count of the LEDs on the destination hyperion server.
* @param width The original width of the device screen
* @param height The original height of the device screen
* @return int The divisor bes suited to scale the screen dimensions by
**/
public int findDivisor(int width, int height) {
List<Integer> divisors = getCommonDivisors(width, height);
if (DEBUG) Log.d(TAG, "Available Divisors: " + divisors.toString());
ListIterator it = divisors.listIterator(divisors.size());
// iterate backwards since the divisors are listed largest to smallest
while (it.hasPrevious()) {
int i = (int) it.previous();
// check if the image packet size for this divisor is >= the minimum image packet size
// like above we multiply the dimensions together and then by 3 for each byte in RGB
if ((width / i) * (height / i) * 3 >= MINIMUM_IMAGE_PACKET_SIZE)
return i;
}
return 1;
}
/**
* gets a list of all the common divisors [large to small] for the given integers.
* @param num1 The first integer to find a whole number divisor for
* @param num2 The second integer to find a whole number divisor for
* @return List A list of the common divisors [large to small] that match the provided integers
**/
private static List<Integer> getCommonDivisors(int num1, int num2) {
List<Integer> list = new ArrayList<>();
int min = Math.min(num1, num2);
for (int i = 1; i <= min / 2; i++)
if (num1 % i == 0 && num2 % i == 0)
list.add(i);
if (num1 % min == 0 && num2 % min == 0) list.add(min);
return list;
}
public int getBlackThreshold() { return BLACK_THRESHOLD; }
}
@@ -0,0 +1,74 @@
package com.hyperion.grabber.common.util;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.Nullable;
import android.util.Log;
import com.hyperion.grabber.common.network.NetworkScanner;
import java.lang.ref.WeakReference;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Starts a network scan for a running Hyperion server
* and posts progress and results
*/
public class HyperionScannerTask {
private WeakReference<Listener> weakListener;
private ExecutorService executor = Executors.newSingleThreadExecutor();
private Handler mainHandler = new Handler(Looper.getMainLooper());
public HyperionScannerTask(Listener listener){
weakListener = new WeakReference<>(listener);
}
public void execute() {
executor.execute(() -> {
String result = doInBackground();
mainHandler.post(() -> onPostExecute(result));
});
}
private String doInBackground() {
Log.d("Hyperion scanner", "starting scan");
NetworkScanner networkScanner = new NetworkScanner();
String result;
while (networkScanner.hasNextAttempt()){
result = networkScanner.tryNext();
if (result != null){
return result;
}
final float progress = networkScanner.getProgress();
mainHandler.post(() -> onProgressUpdate(progress));
}
return null;
}
private void onProgressUpdate(Float value) {
Log.d("Hyperion scanner", "scan progress: " + value);
if(weakListener.get() != null){
weakListener.get().onScannerProgress(value);
}
}
private void onPostExecute(String result) {
Log.d("Hyperion scanner", "scan result: " + result);
if(weakListener.get() != null){
weakListener.get().onScannerCompleted(result);
}
}
public interface Listener {
void onScannerProgress(float progress);
void onScannerCompleted(@Nullable String foundIpAddress);
}
}
@@ -0,0 +1,85 @@
package com.hyperion.grabber.common.util
import android.content.Context
import android.content.res.Resources
import androidx.preference.PreferenceManager
import androidx.annotation.StringRes
/** Wrapper around SharedPreferences which allows for default values defined in Resources
* Main purpose is that defaults are defined in a centralized location and that preferences are
* accessed through a unified interface */
class Preferences(context: Context) {
private val preferences = PreferenceManager.getDefaultSharedPreferences(context)
private val resources = context.resources
fun contains(@StringRes keyResourceId: Int): Boolean = preferences.contains(key(keyResourceId))
fun getString(@StringRes keyResourceId: Int, default: String? = null): String? {
return preferences.getString(key(keyResourceId), default)
}
fun putString(@StringRes keyResourceId: Int, value: String){
val edit = preferences.edit()
edit.putString(key(keyResourceId), value)
edit.apply()
}
fun getInt(@StringRes keyResourceId: Int): Int {
val default = defaultKey(keyResourceId, "integer").let {
if (it == 0){
0
} else {
try {
resources.getInteger(it)
} catch (e: Resources.NotFoundException) {
0
}
}
}
return getInt(keyResourceId, default)
}
fun getInt(@StringRes keyResourceId: Int, default: Int = 0): Int {
return getString(keyResourceId)?.let { Integer.parseInt(it) } ?: default
}
fun putInt(@StringRes keyResourceId: Int, value: Int){
putString(keyResourceId, value.toString())
}
fun getBoolean(@StringRes keyResourceId: Int): Boolean {
val default = defaultKey(keyResourceId, "bool").let {
if (it == 0){
false
} else {
try {
resources.getBoolean(it)
} catch (e: Resources.NotFoundException) {
false
}
}
}
return preferences.getBoolean(key(keyResourceId), default)
}
fun getBoolean(@StringRes keyResourceId: Int, default: Boolean): Boolean =
preferences.getBoolean(key(keyResourceId), default)
fun putBoolean(@StringRes keyResourceId: Int, value: Boolean){
val edit = preferences.edit()
edit.putBoolean(key(keyResourceId), value)
edit.apply()
}
private fun key(keyResourceId: Int) = resources.getString(keyResourceId)
/** @return 0 if not found, resource id otherwise */
private fun defaultKey(keyResourceId: Int, type: String): Int {
val defaultKeyName = resources.getResourceEntryName(keyResourceId).replace("pref_key_", "pref_default_")
return resources.getIdentifier(defaultKeyName, type, resources.getResourcePackageName(keyResourceId))
}
}
@@ -0,0 +1,69 @@
package com.hyperion.grabber.common.views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.SweepGradient;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by nino on 26-5-18.
*/
public class SweepGradientView extends View{
Paint paint;
final int[] colors = {Color.RED, Color.MAGENTA, Color.BLUE, Color.CYAN, Color.GREEN, Color.YELLOW, Color.RED};
final float[] positions = {0f, 1/6f, 2/6f, 3/6f, 4/6f, 5/6f, 6/6f};
SweepGradient gradient;
Rect viewBounds = new Rect();
Matrix gradientMatrix = new Matrix();
float rotate = 0f;
public SweepGradientView(Context context) {
this(context, null);
}
public SweepGradientView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public SweepGradientView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
paint = new Paint();
paint.setShader(gradient);
}
@Override
protected void onDraw(Canvas canvas) {
gradientMatrix.postRotate(rotate++, viewBounds.width()/2, viewBounds.height()/2);
gradient.setLocalMatrix(gradientMatrix);
paint.setShader(gradient);
canvas.drawRect(viewBounds, paint);
gradientMatrix.reset();
invalidate();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
viewBounds.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
gradient = new SweepGradient(viewBounds.centerX(), viewBounds.centerY(), colors, positions);
}
}
@@ -0,0 +1,28 @@
package hyperionnet;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Clear extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Clear getRootAsClear(ByteBuffer _bb) { return getRootAsClear(_bb, new Clear()); }
public static Clear getRootAsClear(ByteBuffer _bb, Clear obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Clear __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public int priority() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
public static int createClear(FlatBufferBuilder builder, int priority) {
builder.startTable(1);
Clear.addPriority(builder, priority);
return Clear.endClear(builder);
}
public static void startClear(FlatBufferBuilder builder) { builder.startTable(1); }
public static void addPriority(FlatBufferBuilder builder, int priority) { builder.addInt(0, priority, 0); }
public static int endClear(FlatBufferBuilder builder) { return builder.endTable(); }
}
@@ -0,0 +1,31 @@
package hyperionnet;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Color extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Color getRootAsColor(ByteBuffer _bb) { return getRootAsColor(_bb, new Color()); }
public static Color getRootAsColor(ByteBuffer _bb, Color obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Color __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public int data() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
public int duration() { int o = __offset(6); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
public static int createColor(FlatBufferBuilder builder, int data, int duration) {
builder.startTable(2);
Color.addDuration(builder, duration);
Color.addData(builder, data);
return Color.endColor(builder);
}
public static void startColor(FlatBufferBuilder builder) { builder.startTable(2); }
public static void addData(FlatBufferBuilder builder, int data) { builder.addInt(0, data, -1); }
public static void addDuration(FlatBufferBuilder builder, int duration) { builder.addInt(1, duration, -1); }
public static int endColor(FlatBufferBuilder builder) { return builder.endTable(); }
}
@@ -0,0 +1,14 @@
package hyperionnet;
@SuppressWarnings("unused")
public final class Command {
private Command() { }
public static final byte NONE = 0;
public static final byte Color = 1;
public static final byte Image = 2;
public static final byte Clear = 3;
public static final byte Register = 4;
public static final String[] names = { "NONE", "Color", "Image", "Clear", "Register", };
public static String name(int e) { return names[e]; }
}
@@ -0,0 +1,38 @@
package hyperionnet;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Image extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Image getRootAsImage(ByteBuffer _bb) { return getRootAsImage(_bb, new Image()); }
public static Image getRootAsImage(ByteBuffer _bb, Image obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Image __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public byte dataType() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
public Table data(Table obj) { int o = __offset(6); return o != 0 ? __union(obj, o + bb_pos) : null; }
public int duration() { int o = __offset(8); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
public static int createImage(FlatBufferBuilder builder, byte data_type, int dataOffset, int duration) {
builder.startTable(3);
Image.addDuration(builder, duration);
Image.addData(builder, dataOffset);
Image.addDataType(builder, data_type);
return Image.endImage(builder);
}
public static void startImage(FlatBufferBuilder builder) { builder.startTable(3); }
public static void addDataType(FlatBufferBuilder builder, byte dataType) { builder.addByte(0, dataType, 0); }
public static void addData(FlatBufferBuilder builder, int dataOffset) { builder.addOffset(1, dataOffset, 0); }
public static void addDuration(FlatBufferBuilder builder, int duration) { builder.addInt(2, duration, -1); }
public static int endImage(FlatBufferBuilder builder) {
int o = builder.endTable();
builder.required(o, 6); // data
return o;
}
}
@@ -0,0 +1,12 @@
package hyperionnet;
@SuppressWarnings("unused")
public final class ImageType {
private ImageType() { }
public static final byte NONE = 0;
public static final byte RawImage = 1;
public static final byte NV12Image = 2;
public static final String[] names = { "NONE", "RawImage", "NV12Image", };
public static String name(int e) { return names[e]; }
}
@@ -0,0 +1,38 @@
package hyperionnet;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class RawImage extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static RawImage getRootAsRawImage(ByteBuffer _bb) { return getRootAsRawImage(_bb, new RawImage()); }
public static RawImage getRootAsRawImage(ByteBuffer _bb, RawImage obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public RawImage __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public int data(int j) { int o = __offset(4); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
public int dataLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
public ByteBuffer dataAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
public int width() { int o = __offset(6); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
public int height() { int o = __offset(8); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
public static int createRawImage(FlatBufferBuilder builder, int dataOffset, int width, int height) {
builder.startTable(3);
RawImage.addHeight(builder, height);
RawImage.addWidth(builder, width);
RawImage.addData(builder, dataOffset);
return RawImage.endRawImage(builder);
}
public static void startRawImage(FlatBufferBuilder builder) { builder.startTable(3); }
public static void addData(FlatBufferBuilder builder, int dataOffset) { builder.addOffset(0, dataOffset, 0); }
public static int createDataVector(FlatBufferBuilder builder, byte[] data) { return builder.createByteVector(data); }
public static void addWidth(FlatBufferBuilder builder, int width) { builder.addInt(1, width, -1); }
public static void addHeight(FlatBufferBuilder builder, int height) { builder.addInt(2, height, -1); }
public static int endRawImage(FlatBufferBuilder builder) { return builder.endTable(); }
}
@@ -0,0 +1,38 @@
package hyperionnet;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Register extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Register getRootAsRegister(ByteBuffer _bb) { return getRootAsRegister(_bb, new Register()); }
public static Register getRootAsRegister(ByteBuffer _bb, Register obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Register __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public String origin() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer originAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
public ByteBuffer originInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
public int priority() { int o = __offset(6); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
public static int createRegister(FlatBufferBuilder builder, int originOffset, int priority) {
builder.startTable(2);
Register.addPriority(builder, priority);
Register.addOrigin(builder, originOffset);
return Register.endRegister(builder);
}
public static void startRegister(FlatBufferBuilder builder) { builder.startTable(2); }
public static void addOrigin(FlatBufferBuilder builder, int originOffset) { builder.addOffset(0, originOffset, 0); }
public static void addPriority(FlatBufferBuilder builder, int priority) { builder.addInt(1, priority, 0); }
public static int endRegister(FlatBufferBuilder builder) {
int o = builder.endTable();
builder.required(o, 4); // origin
return o;
}
}
@@ -0,0 +1,35 @@
package hyperionnet;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Reply extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Reply getRootAsReply(ByteBuffer _bb) { return getRootAsReply(_bb, new Reply()); }
public static Reply getRootAsReply(ByteBuffer _bb, Reply obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Reply __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public String error() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
public int video() { int o = __offset(6); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
public int registered() { int o = __offset(8); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
public static int createReply(FlatBufferBuilder builder, int errorOffset, int video, int registered) {
builder.startTable(3);
Reply.addRegistered(builder, registered);
Reply.addVideo(builder, video);
Reply.addError(builder, errorOffset);
return Reply.endReply(builder);
}
public static void startReply(FlatBufferBuilder builder) { builder.startTable(3); }
public static void addError(FlatBufferBuilder builder, int errorOffset) { builder.addOffset(0, errorOffset, 0); }
public static void addVideo(FlatBufferBuilder builder, int video) { builder.addInt(1, video, -1); }
public static void addRegistered(FlatBufferBuilder builder, int registered) { builder.addInt(2, registered, -1); }
public static int endReply(FlatBufferBuilder builder) { return builder.endTable(); }
public static void finishReplyBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset); }
}
@@ -0,0 +1,36 @@
package hyperionnet;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Request extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Request getRootAsRequest(ByteBuffer _bb) { return getRootAsRequest(_bb, new Request()); }
public static Request getRootAsRequest(ByteBuffer _bb, Request obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Request __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public byte commandType() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
public Table command(Table obj) { int o = __offset(6); return o != 0 ? __union(obj, o + bb_pos) : null; }
public static int createRequest(FlatBufferBuilder builder, byte command_type, int commandOffset) {
builder.startTable(2);
Request.addCommand(builder, commandOffset);
Request.addCommandType(builder, command_type);
return Request.endRequest(builder);
}
public static void startRequest(FlatBufferBuilder builder) { builder.startTable(2); }
public static void addCommandType(FlatBufferBuilder builder, byte commandType) { builder.addByte(0, commandType, 0); }
public static void addCommand(FlatBufferBuilder builder, int commandOffset) { builder.addOffset(1, commandOffset, 0); }
public static int endRequest(FlatBufferBuilder builder) {
int o = builder.endTable();
builder.required(o, 6); // command
return o;
}
public static void finishRequestBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset); }
}
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="108"
android:viewportHeight="108"
android:width="108dp"
android:height="108dp">
<group
android:translateY="-944.3622">
<group
android:scaleX="0.3899269"
android:scaleY="0.3899269"
android:translateX="16.56894"
android:translateY="625.449">
<path
android:pathData="M121.07324 1014.8876l0 -52.68557 -50.273435 0 0 52.68557 -22.597657 0 0 -117.05081 22.597657 0 0 51.28906 50.273435 0 0 -51.28906 22.72461 0 0 117.05081z"
android:fillColor="#f0ffff" />
</group>
</group>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#CCCCCC"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
</vector>
@@ -0,0 +1,237 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="108"
android:viewportHeight="108"
android:width="108dp"
android:height="108dp">
<group
android:translateY="-944.3622">
<group
android:scaleX="0.01456667"
android:scaleY="0.01456667"
android:translateX="-23.16391"
android:translateY="921.186">
<clip-path
android:pathData="M1590.1995 1590.7765l7414.4502 0 0 7414.4502 -7414.4502 0z" />
<path
android:pathData="M5988 10545c-966 127 -1816 15 -2716 -358C2372 9814 1692 9292 1099 8520 506 7747 178 6955 51 5989 -76 5023 35 4173 408 3273 781 2373 1303 1693 2076 1100 2849 506 3641 178 4607 51 5573 -76 6423 36 7323 409c900 373 1580 895 2173 1667 593 773 921 1565 1048 2531 127 966 15 1816 -357 2716 -373 900 -895 1580 -1668 2173 -773 593 -1565 922 -2531 1049z"
android:fillColor="#ffffff" />
<path
android:pathData="M5297 5298L5067 11c162 -7 299 -7 461 0z"
android:fillColor="#ffff00" />
<path
android:pathData="M5297 5298l231 5287c-162 7 -299 7 -461 0z"
android:fillColor="#0000ff" />
<path
android:pathData="M5297 5298L5528 11c163 7 299 19 460 40z"
android:fillColor="#ffea00" />
<path
android:pathData="M5297 5298l-230 5287c-163 -7 -299 -19 -460 -40z"
android:fillColor="#0015ff" />
<path
android:pathData="M5297 5298L5988 51c161 21 296 45 455 80z"
android:fillColor="#ffd500" />
<path
android:pathData="M5297 5298l-690 5247c-161 -21 -296 -45 -455 -80z"
android:fillColor="#002aff" />
<path
android:pathData="M5297 5298L6443 131c158 36 291 71 446 120z"
android:fillColor="#ffc000" />
<path
android:pathData="M5297 5298l-1145 5167c-158 -36 -291 -71 -446 -120z"
android:fillColor="#003fff" />
<path
android:pathData="M5297 5298L6889 251c155 49 284 96 434 158z"
android:fillColor="#ffaa00" />
<path
android:pathData="M5297 5298l-1591 5047c-155 -49 -284 -96 -434 -158z"
android:fillColor="#0055ff" />
<path
android:pathData="M5297 5298L7323 409c150 62 274 120 418 195z"
android:fillColor="#ff9500" />
<path
android:pathData="M5297 5298l-2025 4889c-150 -62 -274 -120 -418 -195z"
android:fillColor="#006aff" />
<path
android:pathData="M5297 5298L7741 604c144 75 263 144 400 231z"
android:fillColor="#ff8000" />
<path
android:pathData="M5297 5298L2854 9992c-144 -75 -263 -144 -400 -231z"
android:fillColor="#007fff" />
<path
android:pathData="M5297 5298L8141 835c137 87 249 166 378 265z"
android:fillColor="#ff6b00" />
<path
android:pathData="M5297 5298L2454 9761c-137 -87 -249 -166 -378 -265z"
android:fillColor="#0094ff" />
<path
android:pathData="M5297 5298L8519 1100c129 98 234 187 354 296z"
android:fillColor="#ff5500" />
<path
android:pathData="M5297 5298L2076 9496c-129 -98 -234 -187 -354 -296z"
android:fillColor="#00aaff" />
<path
android:pathData="M5297 5298L8873 1396c119 110 216 207 326 327z"
android:fillColor="#ff4000" />
<path
android:pathData="M5297 5298L1722 9200c-119 -110 -217 -207 -326 -327z"
android:fillColor="#00bfff" />
<path
android:pathData="M5297 5298L9199 1723c110 119 198 225 297 353z"
android:fillColor="#ff2b00" />
<path
android:pathData="M5297 5298L1396 8873c-110 -120 -198 -225 -297 -353z"
android:fillColor="#00d4ff" />
<path
android:pathData="M5297 5298L9496 2076c99 129 177 242 265 379z"
android:fillColor="#ff1600" />
<path
android:pathData="M5297 5298L1099 8520C1000 8391 921 8278 834 8141Z"
android:fillColor="#00e9ff" />
<path
android:pathData="M5297 5298L9761 2455c87 137 156 255 231 399z"
android:fillColor="#ff0000" />
<path
android:pathData="M5297 5298L834 8141C747 8004 678 7886 603 7742Z"
android:fillColor="#00ffff" />
<path
android:pathData="M5297 5298L9992 2854c75 144 133 269 195 419z"
android:fillColor="#ff0015" />
<path
android:pathData="M5297 5298L603 7742C528 7598 470 7473 408 7323Z"
android:fillColor="#00ffea" />
<path
android:pathData="M5297 5298l4890 -2025c62 150 109 279 158 434z"
android:fillColor="#ff002a" />
<path
android:pathData="M5297 5298L408 7323C346 7173 299 7044 250 6889Z"
android:fillColor="#00ffd5" />
<path
android:pathData="M5297 5298l5048 -1591c48 155 84 287 119 446z"
android:fillColor="#ff003f" />
<path
android:pathData="M5297 5298L250 6889C202 6734 166 6602 131 6443Z"
android:fillColor="#00ffc0" />
<path
android:pathData="M5297 5298l5167 -1145c35 158 59 293 80 454l0 0z"
android:fillColor="#ff0055" />
<path
android:pathData="M5297 5298L131 6443C96 6285 72 6150 51 5989Z"
android:fillColor="#00ffaa" />
<path
android:pathData="M5297 5298l5247 -691c21 161 33 298 40 460z"
android:fillColor="#ff006a" />
<path
android:pathData="M5297 5298l-5246 691 0 0C30 5828 18 5691 11 5529Z"
android:fillColor="#00ff95" />
<path
android:pathData="M5297 5298l5287 -231c8 162 8 300 0 462z"
android:fillColor="#ff007f" />
<path
android:pathData="M5297 5298L11 5529C3 5367 3 5229 11 5067Z"
android:fillColor="#00ff80" />
<path
android:pathData="M5297 5298l5287 231c-7 162 -19 299 -40 460z"
android:fillColor="#ff0094" />
<path
android:pathData="M5297 5298L11 5067c7 -162 19 -299 40 -460z"
android:fillColor="#00ff6b" />
<path
android:pathData="M5297 5298l5247 691c-21 161 -45 296 -80 454z"
android:fillColor="#ff00aa" />
<path
android:pathData="M5297 5298L51 4607c21 -161 45 -296 80 -454z"
android:fillColor="#00ff55" />
<path
android:pathData="M5297 5298l5167 1145c-35 159 -71 291 -119 446z"
android:fillColor="#ff00bf" />
<path
android:pathData="M5297 5298L131 4153c35 -159 71 -291 119 -446z"
android:fillColor="#00ff40" />
<path
android:pathData="M5297 5298l5048 1591c-49 155 -96 284 -158 434z"
android:fillColor="#ff00d4" />
<path
android:pathData="M5297 5298L250 3707c49 -155 96 -284 158 -434z"
android:fillColor="#00ff2b" />
<path
android:pathData="M5297 5298l4890 2025c-62 150 -120 275 -195 419z"
android:fillColor="#ff00e9" />
<path
android:pathData="M5297 5298L408 3273c62 -150 120 -275 195 -419z"
android:fillColor="#00ff16" />
<path
android:pathData="M5297 5298l4695 2444c-75 144 -144 262 -231 399z"
android:fillColor="#ff00ff" />
<path
android:pathData="M5297 5298L603 2854c75 -144 144 -262 231 -399z"
android:fillColor="#00ff00" />
<path
android:pathData="M5297 5298l4464 2843c-88 137 -166 250 -265 379z"
android:fillColor="#ea00ff" />
<path
android:pathData="M5297 5298L834 2455c87 -137 166 -250 265 -379z"
android:fillColor="#15ff00" />
<path
android:pathData="M5297 5298l4199 3222c-99 128 -187 233 -297 353z"
android:fillColor="#d500ff" />
<path
android:pathData="M5297 5298L1099 2076c99 -128 187 -234 297 -353z"
android:fillColor="#2aff00" />
<path
android:pathData="M5297 5298l3902 3575c-110 120 -207 217 -326 327z"
android:fillColor="#c000ff" />
<path
android:pathData="M5297 5298L1396 1723c109 -120 207 -217 326 -327z"
android:fillColor="#3fff00" />
<path
android:pathData="M5297 5298l3576 3902c-120 109 -225 198 -354 296z"
android:fillColor="#aa00ff" />
<path
android:pathData="M5297 5298L1722 1396c120 -109 225 -198 354 -296z"
android:fillColor="#55ff00" />
<path
android:pathData="M5297 5298l3222 4198c-129 99 -241 178 -378 265z"
android:fillColor="#9500ff" />
<path
android:pathData="M5297 5298L2076 1100c129 -99 241 -178 378 -265z"
android:fillColor="#6aff00" />
<path
android:pathData="M5297 5298l2844 4463c-137 87 -256 156 -400 231z"
android:fillColor="#8000ff" />
<path
android:pathData="M5297 5298L2454 835c137 -87 256 -156 400 -231z"
android:fillColor="#7fff00" />
<path
android:pathData="M5297 5298l2444 4694c-144 75 -268 133 -418 195z"
android:fillColor="#6b00ff" />
<path
android:pathData="M5297 5298L2854 604c144 -75 268 -133 418 -195z"
android:fillColor="#94ff00" />
<path
android:pathData="M5297 5298l2026 4889c-150 62 -279 109 -434 158z"
android:fillColor="#5500ff" />
<path
android:pathData="M5297 5298L3272 409c150 -62 279 -109 434 -158z"
android:fillColor="#aaff00" />
<path
android:pathData="M5297 5298l1592 5047c-155 49 -288 84 -446 120z"
android:fillColor="#4000ff" />
<path
android:pathData="M5297 5298L3706 251c155 -49 288 -84 446 -120z"
android:fillColor="#bfff00" />
<path
android:pathData="M5297 5298l1146 5167c-159 35 -294 59 -455 80z"
android:fillColor="#2b00ff" />
<path
android:pathData="M5297 5298L4152 131c159 -35 294 -59 455 -80z"
android:fillColor="#d4ff00" />
<path
android:pathData="M5297 5298l691 5247 0 0c-161 21 -297 33 -460 40z"
android:fillColor="#1600ff" />
<path
android:pathData="M5297 5298L4607 51c161 -21 297 -33 460 -40z"
android:fillColor="#e9ff00" />
</group>
</group>
</vector>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="48"
android:viewportHeight="48"
android:width="48dp"
android:height="48dp">
<path
android:pathData="M24.066406 0.0859375C23.029883 0.09279219 21.973089 0.169175 20.882812 0.3125 16.52171 0.8859 12.946816 2.365275 9.4570312 5.046875c-3.4897849 2.6772 -5.847305 5.747447 -7.53125 9.810547 -1.68394195 4.0631 -2.18468307 7.900619 -1.61132808 12.261719 0.57335401 4.3612 2.05331178 7.937934 4.73046878 11.427734 2.677157 3.4853 5.7474081 5.841391 9.8105471 7.525391 4.063139 1.6832 7.900615 2.188534 12.261719 1.615234 4.3611 -0.5734 7.937948 -2.057275 11.427734 -4.734375 3.489788 -2.6772 5.845347 -5.747447 7.529297 -9.810547 1.67941 -4.0631 2.184678 -7.900619 1.611328 -12.261719 -0.57335 -4.3612 -2.053309 -7.937834 -4.730469 -11.427734C40.277918 5.967925 37.207669 3.6117344 33.144531 1.9277344 30.097177 0.66533431 27.175977 0.06537344 24.066406 0.0859375Zm-0.07422 0.86328125A0.50005 0.50005 0 0 1 24.5 1.4550781l0 2.5429688a0.50005 0.50005 0 1 1 -1 0l0 -2.5429688A0.50005 0.50005 0 0 1 23.992188 0.94921875ZM15.365234 2.6640625a0.50005 0.50005 0 0 1 0.46875 0.3164063l0.97461 2.3496093a0.50005 0.50005 0 1 1 -0.923828 0.3828125l-0.97461 -2.3496094a0.50005 0.50005 0 0 1 0.455078 -0.6992187zm17.253907 0a0.50005 0.50005 0 0 1 0.470703 0.6992187l-0.97461 2.3496094A0.50005 0.50005 0 1 1 31.191406 5.3300781l0.97461 -2.3496093A0.50005 0.50005 0 0 1 32.619141 2.6640625ZM8.0527344 7.5527344a0.50005 0.50005 0 0 1 0.359375 0.1523437L10.210938 9.5039062A0.50005 0.50005 0 1 1 9.5039062 10.210938L7.7050781 8.4121094a0.50005 0.50005 0 0 1 0.3476563 -0.859375zm31.8789066 0a0.50005 0.50005 0 0 1 0.363281 0.859375L38.496094 10.210938A0.50005 0.50005 0 1 1 37.789062 9.5039062l1.798829 -1.7988281a0.50005 0.50005 0 0 1 0.34375 -0.1523437zm-27.085938 2.7890626l5.273438 0 0 11.96875 11.732421 0 0 -11.96875 5.302735 0 0 27.316406 -5.302735 0 0 -12.294922 -11.732421 0 0 12.294922 -5.273438 0 0 -27.316406zm-9.6777342 4.527344a0.50005 0.50005 0 0 1 0.1953124 0.04101l2.3496094 0.97461a0.50005 0.50005 0 1 1 -0.3828125 0.923828l-2.3496093 -0.97461a0.50005 0.50005 0 0 1 0.1875 -0.964843zm41.6484372 0.002a0.50005 0.50005 0 0 1 0.203125 0.96289l-2.349609 0.97461a0.50005 0.50005 0 1 1 -0.382813 -0.923828l2.34961 -0.97461a0.50005 0.50005 0 0 1 0.179687 -0.03906zM1.4550781 23.5l2.5546875 0a0.50005 0.50005 0 1 1 0 1l-2.5546875 0a0.50005 0.50005 0 1 1 0 -1zm42.5468749 0l2.542969 0a0.50005 0.50005 0 1 1 0 1l-2.542969 0a0.50005 0.50005 0 1 1 0 -1zM5.5195312 31.148438a0.50005 0.50005 0 0 1 0.203125 0.96289l-2.359375 0.978516A0.50005 0.50005 0 1 1 2.9804688 32.166016L5.3398438 31.1875a0.50005 0.50005 0 0 1 0.1796874 -0.03906zm36.9472658 0a0.50005 0.50005 0 0 1 0.193359 0.03906l2.359375 0.978516a0.50005 0.50005 0 1 1 -0.382812 0.923828l-2.359375 -0.978516a0.50005 0.50005 0 0 1 0.189453 -0.96289zM9.8535156 37.630859A0.50005 0.50005 0 0 1 10.21875 38.490234L8.4121094 40.294922A0.50005 0.50005 0 1 1 7.7050781 39.587891L9.5097656 37.78125a0.50005 0.50005 0 0 1 0.34375 -0.150391zm28.2773434 0a0.50005 0.50005 0 0 1 0.359375 0.150391l1.804688 1.806641a0.50005 0.50005 0 1 1 -0.707031 0.707031L37.78125 38.490234a0.50005 0.50005 0 0 1 0.349609 -0.859375zm-21.789062 4.332032a0.50005 0.50005 0 0 1 0.470703 0.697265l-0.978516 2.359375a0.50005 0.50005 0 1 1 -0.923828 -0.382812l0.978516 -2.359375a0.50005 0.50005 0 0 1 0.453125 -0.314453zm15.302734 0a0.50005 0.50005 0 0 1 0.466797 0.314453l0.978516 2.359375a0.50005 0.50005 0 1 1 -0.923828 0.382812L31.1875 42.660156a0.50005 0.50005 0 0 1 0.457031 -0.697265zm-7.652343 1.521484A0.50005 0.50005 0 0 1 24.5 43.990234l0 2.554688a0.50005 0.50005 0 1 1 -1 0l0 -2.554688a0.50005 0.50005 0 0 1 0.492188 -0.505859z"
android:fillColor="#ffffff" />
</vector>
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="72dp"
android:height="72dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M13,3h-2v10h2L13,3zM17.83,5.17l-1.42,1.42C17.99,7.86 19,9.81 19,12c0,3.87 -3.13,7 -7,7s-7,-3.13 -7,-7c0,-2.19 1.01,-4.14 2.58,-5.42L6.17,5.17C4.23,6.82 3,9.26 3,12c0,4.97 4.03,9 9,9s9,-4.03 9,-9c0,-2.74 -1.23,-5.18 -3.17,-6.83z"/>
</vector>
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="72dp"
android:height="72dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
</vector>
@@ -0,0 +1,31 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="700dp"
android:height="375dp"
android:viewportWidth="19755.555"
android:viewportHeight="10597.0">
<path
android:pathData="M3514,1618l12727,0l0,7182l-12727,0z"
android:fillColor="#FFF"
android:strokeWidth="28.222"
android:strokeLineJoin="round"/>
<path
android:fillColor="#FF000000"
android:pathData="M16241,8959l-12727,0c-91,0 -182,-68 -182,-182l0,-7159c0,-91 68,-182 182,-182l12727,0c91,0 182,68 182,182l0,7182c0,91 -91,159 -182,159zM3696,8618l12386,0l0,-6841l-12386,0l0,6841z"
android:strokeWidth="28.222"
android:strokeLineJoin="round"/>
<path
android:fillColor="#FF000000"
android:pathData="M13037,9936l-6318,0c-91,0 -182,-68 -182,-182s68,-182 182,-182l6318,0c91,0 182,68 182,182s-91,182 -182,182z"
android:strokeWidth="28.222"
android:strokeLineJoin="round"/>
<path
android:fillColor="#FF000000"
android:pathData="M9151,8800l341,0l0,955l-341,0z"
android:strokeWidth="28.222"
android:strokeLineJoin="round"/>
<path
android:fillColor="#FF000000"
android:pathData="M10264,8800l341,0l0,955l-341,0z"
android:strokeWidth="28.222"
android:strokeLineJoin="round"/>
</vector>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/round_rectangle_background"
android:state_focused="true" />
<item android:drawable="@android:color/transparent" />
</selector>
@@ -0,0 +1,8 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="1000dp" />
<solid android:color="#8333" />
</shape>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#aaa"/>
<corners android:radius="10dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Loaded 100 of 133 files, more files were not shown because too many files have changed in this diff. Show more