feat: Add direct WLED DDP support and multi-language features
- Refactor core network layer to Kotlin - Implement high-performance WLED UDP packets chunking - Auto-translate settings strings across locales - Update App Quick Settings tile - Bump app version to 2.5.0 for auto-update
This commit is contained in:
1 parent
2a4ee357ce
commit
2563dee326
55 files changed
+2431
-1009
No files matched your search
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-23/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>app</name>
|
||||
<comment>Project app created by Buildship.</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1775340865147</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,2 @@
|
||||
connection.project.dir=..
|
||||
eclipse.preferences.version=1
|
||||
+2
-2
@@ -13,8 +13,8 @@ android {
|
||||
applicationId "com.hyperion.grabber"
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode 2013
|
||||
versionName "2.0"
|
||||
versionCode 2500
|
||||
versionName "2.5.0"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
@@ -93,6 +95,16 @@
|
||||
android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,147 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
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.os.Looper
|
||||
import android.service.quicksettings.Tile
|
||||
import android.service.quicksettings.TileService
|
||||
import android.text.TextUtils
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.app.TaskStackBuilder
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
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)
|
||||
class HyperionGrabberTileService : TileService() {
|
||||
private val REMOVE_LISTENER_DELAY = 10000L // 10 second delay to remove listener
|
||||
private val mHandle = Handler(Looper.getMainLooper())
|
||||
|
||||
private val mMessageReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val tile = qsTile ?: return
|
||||
val running = intent.getBooleanExtra(HyperionScreenService.BROADCAST_TAG, false)
|
||||
val error = intent.getStringExtra(HyperionScreenService.BROADCAST_ERROR)
|
||||
tile.state = if (running) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
|
||||
|
||||
// Helpful feature: Show WLED / Hyperion text on tile subtitle if available (API 29+)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
val prefs = Preferences(applicationContext)
|
||||
val wledEnabled = prefs.getBoolean(com.hyperion.grabber.common.R.string.pref_key_wled_enabled)
|
||||
tile.subtitle = if (wledEnabled) "WLED" else "Hyperion"
|
||||
}
|
||||
|
||||
tile.updateTile()
|
||||
if (error != null) {
|
||||
Toast.makeText(baseContext, error, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val unregisterReceiverRunner = Runnable {
|
||||
LocalBroadcastManager.getInstance(this@HyperionGrabberTileService).unregisterReceiver(mMessageReceiver)
|
||||
mIsListening = false
|
||||
}
|
||||
|
||||
override fun onStartListening() {
|
||||
super.onStartListening()
|
||||
mHandle.removeCallbacksAndMessages(null)
|
||||
if (!mIsListening) {
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(
|
||||
mMessageReceiver, IntentFilter(HyperionScreenService.BROADCAST_FILTER)
|
||||
)
|
||||
mIsListening = true
|
||||
}
|
||||
if (isServiceRunning()) {
|
||||
val intent = Intent(this, HyperionScreenService::class.java)
|
||||
intent.action = HyperionScreenService.GET_STATUS
|
||||
startService(intent)
|
||||
} else {
|
||||
val tile = qsTile ?: return
|
||||
tile.state = Tile.STATE_INACTIVE
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
val prefs = Preferences(applicationContext)
|
||||
val wledEnabled = prefs.getBoolean(com.hyperion.grabber.common.R.string.pref_key_wled_enabled)
|
||||
tile.subtitle = if (wledEnabled) "WLED" else "Hyperion"
|
||||
}
|
||||
|
||||
tile.updateTile()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStopListening() {
|
||||
super.onStopListening()
|
||||
mHandle.postDelayed(unregisterReceiverRunner, REMOVE_LISTENER_DELAY)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mIsListening = false
|
||||
}
|
||||
|
||||
override fun onClick() {
|
||||
val tile = qsTile ?: return
|
||||
tile.updateTile()
|
||||
val tileState = tile.state
|
||||
if (tileState == Tile.STATE_ACTIVE) {
|
||||
val intent = Intent(this, HyperionScreenService::class.java)
|
||||
intent.action = HyperionScreenService.ACTION_EXIT
|
||||
startService(intent)
|
||||
} else {
|
||||
val runner = Runnable {
|
||||
val setupStarted = startSetupIfNeeded()
|
||||
if (!setupStarted) {
|
||||
val i = Intent(this, BootActivity::class.java).apply {
|
||||
addFlags(
|
||||
Intent.FLAG_ACTIVITY_NO_ANIMATION
|
||||
or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||
or Intent.FLAG_ACTIVITY_NO_HISTORY
|
||||
)
|
||||
}
|
||||
startActivityAndCollapse(i)
|
||||
}
|
||||
}
|
||||
if (isLocked) {
|
||||
unlockAndRun(runner)
|
||||
} else {
|
||||
runner.run()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun isServiceRunning(): Boolean {
|
||||
val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
for (service in manager.getRunningServices(Int.MAX_VALUE)) {
|
||||
if (HyperionScreenService::class.java.name == service.service.className) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/** Starts the Settings Activity if connection settings are missing
|
||||
* @return true if setup was started
|
||||
*/
|
||||
private fun startSetupIfNeeded(): Boolean {
|
||||
val preferences = Preferences(applicationContext)
|
||||
val wledEnabled = preferences.getBoolean(com.hyperion.grabber.common.R.string.pref_key_wled_enabled)
|
||||
val hostMissing = TextUtils.isEmpty(preferences.getString(com.hyperion.grabber.common.R.string.pref_key_host, null))
|
||||
val portMissing = preferences.getInt(com.hyperion.grabber.common.R.string.pref_key_port, -1) == -1
|
||||
val wledIpMissing = TextUtils.isEmpty(preferences.getString(com.hyperion.grabber.common.R.string.pref_key_wled_ip, null))
|
||||
|
||||
if ((!wledEnabled && (hostMissing || portMissing)) || (wledEnabled && wledIpMissing)) {
|
||||
val settingsIntent = Intent(this, SettingsActivity::class.java).apply {
|
||||
putExtra(SettingsActivity.EXTRA_SHOW_TOAST_KEY, SettingsActivity.EXTRA_SHOW_TOAST_SETUP_REQUIRED_FOR_QUICK_TILE)
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
|
||||
TaskStackBuilder.create(this)
|
||||
.addNextIntentWithParentStack(settingsIntent)
|
||||
.startActivities()
|
||||
|
||||
val closeIntent = Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
|
||||
sendBroadcast(closeIntent)
|
||||
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var mIsListening = false
|
||||
|
||||
@JvmStatic
|
||||
fun isListening(): Boolean = mIsListening
|
||||
}
|
||||
}
|
||||
@@ -30,16 +30,21 @@ import android.widget.Toast;
|
||||
|
||||
import com.hyperion.grabber.common.BootActivity;
|
||||
import com.hyperion.grabber.common.HyperionScreenService;
|
||||
import com.hyperion.grabber.common.util.PermissionHelper;
|
||||
import com.hyperion.grabber.common.util.TclBypass;
|
||||
|
||||
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 int REQUEST_OVERLAY_PERMISSION = 3;
|
||||
private static final String TAG = "DEBUG";
|
||||
private boolean mRecorderRunning = false;
|
||||
private static MediaProjectionManager mMediaProjectionManager;
|
||||
private Intent mPendingProjectionData = null;
|
||||
private int mPendingResultCode = 0;
|
||||
private int mPermissionDeniedCount = 0;
|
||||
private boolean mTclWarningShown = false;
|
||||
|
||||
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -47,7 +52,12 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
||||
boolean checked = intent.getBooleanExtra(HyperionScreenService.BROADCAST_TAG, false);
|
||||
mRecorderRunning = checked;
|
||||
String error = intent.getStringExtra(HyperionScreenService.BROADCAST_ERROR);
|
||||
if (error != null &&
|
||||
boolean tclBlocked = intent.getBooleanExtra(HyperionScreenService.BROADCAST_TCL_BLOCKED, false);
|
||||
|
||||
if (tclBlocked && !mTclWarningShown) {
|
||||
mTclWarningShown = true;
|
||||
TclBypass.showTclHelpDialog(MainActivity.this, () -> requestScreenCapture());
|
||||
} else if (error != null &&
|
||||
(Build.VERSION.SDK_INT < Build.VERSION_CODES.N ||
|
||||
!HyperionGrabberTileService.isListening())) {
|
||||
Toast.makeText(getBaseContext(), error, Toast.LENGTH_LONG).show();
|
||||
@@ -61,6 +71,9 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// Check for updates
|
||||
checkForUpdates();
|
||||
mMediaProjectionManager = (MediaProjectionManager)
|
||||
getSystemService(Context.MEDIA_PROJECTION_SERVICE);
|
||||
|
||||
@@ -90,6 +103,13 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// Check for updates when app returns to foreground
|
||||
checkForUpdates();
|
||||
}
|
||||
|
||||
private void requestNotificationPermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS)
|
||||
@@ -104,13 +124,51 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// Check for updates when user clicks play
|
||||
checkForUpdates();
|
||||
|
||||
if (!mRecorderRunning) {
|
||||
startActivityForResult(mMediaProjectionManager.createScreenCaptureIntent(),
|
||||
REQUEST_MEDIA_PROJECTION);
|
||||
requestScreenCapture();
|
||||
} else {
|
||||
stopScreenRecorder();
|
||||
mRecorderRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void requestScreenCapture() {
|
||||
// On TCL and other restricted devices, try shell bypass first
|
||||
if (TclBypass.isTclDevice() || TclBypass.isRestrictedManufacturer()) {
|
||||
Log.d(TAG, "Detected TCL/restricted device, trying shell bypass");
|
||||
TclBypass.tryShellBypass(this);
|
||||
}
|
||||
|
||||
// Also try general shell permissions
|
||||
PermissionHelper.tryGrantProjectMediaViaShell(this);
|
||||
|
||||
// Check overlay permission on first attempt
|
||||
if (mPermissionDeniedCount == 0 && !PermissionHelper.canDrawOverlays(this)) {
|
||||
Log.d(TAG, "Requesting overlay permission first");
|
||||
PermissionHelper.requestOverlayPermission(this, REQUEST_OVERLAY_PERMISSION);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Intent captureIntent = mMediaProjectionManager.createScreenCaptureIntent();
|
||||
startActivityForResult(captureIntent, REQUEST_MEDIA_PROJECTION);
|
||||
} catch (SecurityException e) {
|
||||
Log.e(TAG, "Screen capture permission denied: " + e.getMessage());
|
||||
mPermissionDeniedCount++;
|
||||
if (TclBypass.isTclDevice()) {
|
||||
TclBypass.showTclHelpDialog(this, this::requestScreenCapture);
|
||||
} else {
|
||||
PermissionHelper.showFullPermissionDialog(this, this::requestScreenCapture);
|
||||
}
|
||||
setImageViews(false, true);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to request screen capture: " + e.getMessage());
|
||||
Toast.makeText(this, "Failed to request screen recording: " + e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
setImageViews(false, true);
|
||||
}
|
||||
mRecorderRunning = !mRecorderRunning;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,17 +186,30 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
||||
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();
|
||||
mPermissionDeniedCount++;
|
||||
mRecorderRunning = false;
|
||||
if (mPermissionDeniedCount >= 2) {
|
||||
if (TclBypass.isTclDevice()) {
|
||||
TclBypass.showTclHelpDialog(this, this::requestScreenCapture);
|
||||
} else {
|
||||
PermissionHelper.showFullPermissionDialog(this, this::requestScreenCapture);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, "Screen recording permission was denied. Tap again to retry.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
setImageViews(false, true);
|
||||
return;
|
||||
}
|
||||
mPermissionDeniedCount = 0;
|
||||
mTclWarningShown = false;
|
||||
Log.i(TAG, "Starting screen capture");
|
||||
startScreenRecorder(resultCode, (Intent) data.clone());
|
||||
mRecorderRunning = true;
|
||||
}
|
||||
if (requestCode == REQUEST_OVERLAY_PERMISSION) {
|
||||
// Small delay before requesting capture - helps on some devices
|
||||
getWindow().getDecorView().postDelayed(this::requestScreenCapture, 500);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,6 +284,42 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForUpdates() {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Log.d(TAG, "Checking for updates...");
|
||||
|
||||
com.hyperion.grabber.common.util.UpdateChecker checker =
|
||||
new com.hyperion.grabber.common.util.UpdateChecker(this);
|
||||
com.hyperion.grabber.common.util.GithubRelease release = checker.checkForUpdates();
|
||||
|
||||
if (release != null) {
|
||||
Log.d(TAG, "Update found: " + release.getTagName());
|
||||
runOnUiThread(() -> showUpdateDialog(release));
|
||||
} else {
|
||||
Log.d(TAG, "No updates available");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error checking for updates", e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void showUpdateDialog(com.hyperion.grabber.common.util.GithubRelease release) {
|
||||
UpdateDialog dialog = new UpdateDialog(this);
|
||||
dialog.show(release,
|
||||
() -> {
|
||||
com.hyperion.grabber.common.util.UpdateManager manager =
|
||||
new com.hyperion.grabber.common.util.UpdateManager(getApplicationContext());
|
||||
manager.downloadAndInstall(release.getDownloadUrl(), release.getTagName(), success -> {
|
||||
return kotlin.Unit.INSTANCE;
|
||||
});
|
||||
return kotlin.Unit.INSTANCE;
|
||||
},
|
||||
() -> kotlin.Unit.INSTANCE
|
||||
);
|
||||
}
|
||||
|
||||
private boolean isServiceRunning() {
|
||||
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||
assert manager != null;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.hyperion.grabber
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.TextView
|
||||
import com.hyperion.grabber.common.util.GithubRelease
|
||||
|
||||
class UpdateDialog(private val context: Context) {
|
||||
|
||||
fun show(release: GithubRelease, onUpdate: () -> Unit, onDismiss: () -> Unit) {
|
||||
try {
|
||||
val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_update, null)
|
||||
|
||||
dialogView.findViewById<TextView>(R.id.update_version)?.text =
|
||||
"Version ${release.tagName} available"
|
||||
|
||||
val description = release.body.ifEmpty { "Bug fixes and improvements" }
|
||||
dialogView.findViewById<TextView>(R.id.update_description)?.text =
|
||||
if (description.length > 300) description.take(300) + "..." else description
|
||||
|
||||
AlertDialog.Builder(context)
|
||||
.setTitle("Update Available")
|
||||
.setView(dialogView)
|
||||
.setPositiveButton("Update Now") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
onUpdate()
|
||||
}
|
||||
.setNegativeButton("Later") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setCancelable(true)
|
||||
.show()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
onDismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.hyperion.grabber.common.BootActivity;
|
||||
import com.hyperion.grabber.common.HyperionScreenService;
|
||||
import com.hyperion.grabber.common.util.TclBypass;
|
||||
import com.hyperion.grabber.common.util.Preferences;
|
||||
import com.hyperion.grabber.R;
|
||||
|
||||
@@ -40,9 +41,11 @@ public class MainActivity extends LeanbackActivity implements ImageView.OnClickL
|
||||
public static final String BROADCAST_ERROR = "SERVICE_ERROR";
|
||||
public static final String BROADCAST_TAG = "SERVICE_STATUS";
|
||||
public static final String BROADCAST_FILTER = "SERVICE_FILTER";
|
||||
public static final String BROADCAST_TCL_BLOCKED = "TCL_BLOCKED";
|
||||
private static final String TAG = "DEBUG";
|
||||
private boolean mRecorderRunning = false;
|
||||
private static MediaProjectionManager mMediaProjectionManager;
|
||||
private int mPermissionDeniedCount = 0;
|
||||
|
||||
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -50,7 +53,11 @@ public class MainActivity extends LeanbackActivity implements ImageView.OnClickL
|
||||
boolean checked = intent.getBooleanExtra(BROADCAST_TAG, false);
|
||||
mRecorderRunning = checked;
|
||||
String error = intent.getStringExtra(BROADCAST_ERROR);
|
||||
if (error != null) {
|
||||
boolean tclBlocked = intent.getBooleanExtra(BROADCAST_TCL_BLOCKED, false);
|
||||
|
||||
if (tclBlocked) {
|
||||
TclBypass.showTclHelpDialog(MainActivity.this, () -> requestScreenCapture());
|
||||
} else if (error != null) {
|
||||
Toast.makeText(getBaseContext(), error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
setImageViews(checked, true);
|
||||
@@ -148,16 +155,28 @@ public class MainActivity extends LeanbackActivity implements ImageView.OnClickL
|
||||
int id = view.getId();
|
||||
if (id == R.id.power_toggle) {
|
||||
if (!mRecorderRunning) {
|
||||
startActivityForResult(mMediaProjectionManager.createScreenCaptureIntent(),
|
||||
REQUEST_MEDIA_PROJECTION);
|
||||
requestScreenCapture();
|
||||
} else {
|
||||
stopScreenRecorder();
|
||||
mRecorderRunning = false;
|
||||
}
|
||||
mRecorderRunning = !mRecorderRunning;
|
||||
} else if (id == R.id.settingsButton) {
|
||||
startSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void requestScreenCapture() {
|
||||
TclBypass.tryShellBypass(this);
|
||||
|
||||
try {
|
||||
Intent captureIntent = mMediaProjectionManager.createScreenCaptureIntent();
|
||||
startActivityForResult(captureIntent, REQUEST_MEDIA_PROJECTION);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to request screen capture: " + e.getMessage());
|
||||
mPermissionDeniedCount++;
|
||||
TclBypass.showTclHelpDialog(this, this::requestScreenCapture);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean focused) {
|
||||
@@ -185,18 +204,23 @@ public class MainActivity extends LeanbackActivity implements ImageView.OnClickL
|
||||
} 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();
|
||||
mPermissionDeniedCount++;
|
||||
Toast.makeText(this, "Permission denied. Tap again to retry.", Toast.LENGTH_SHORT).show();
|
||||
if (mPermissionDeniedCount >= 2) {
|
||||
TclBypass.showTclHelpDialog(this, this::requestScreenCapture);
|
||||
}
|
||||
if (mRecorderRunning) {
|
||||
stopScreenRecorder();
|
||||
}
|
||||
mRecorderRunning = false;
|
||||
setImageViews(false, true);
|
||||
return;
|
||||
}
|
||||
mPermissionDeniedCount = 0;
|
||||
Log.i(TAG, "Starting screen capture");
|
||||
startScreenRecorder(resultCode, (Intent) data.clone());
|
||||
mRecorderRunning = true;
|
||||
|
||||
+1
-2
@@ -270,7 +270,6 @@ internal class BasicSettingsStepFragment : SettingsStepBaseFragment() {
|
||||
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)
|
||||
@@ -294,7 +293,7 @@ internal class BasicSettingsStepFragment : SettingsStepBaseFragment() {
|
||||
try {
|
||||
val (host, port, priority, color) = spec
|
||||
val hyperion = HyperionFlatBuffers(host, port, priority)
|
||||
if (hyperion.isConnected) {
|
||||
if (hyperion.isConnected()) {
|
||||
hyperion.setColor(color, priority, 3000)
|
||||
} else {
|
||||
return RESULT_UNREACHABLE
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/update_version"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:paddingBottom="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/update_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:maxLines="10"
|
||||
android:scrollbars="vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -19,4 +19,8 @@
|
||||
<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>
|
||||
<string name="pref_title_wled_enabled">Habilitar WLED DDP</string>
|
||||
<string name="pref_summary_wled_enabled">Enviar datos de píxeles directamente a una instancia WLED usando DDP</string>
|
||||
<string name="pref_title_wled_ip">Dirección IP de WLED</string>
|
||||
<string name="pref_summary_wled_ip">La dirección IP de tu instancia WLED</string>
|
||||
</resources>
|
||||
@@ -17,4 +17,8 @@
|
||||
<string name="guidedstep_nevermind">Nevadí</string>
|
||||
<string name="guidedstep_cancel">Zrušit</string>
|
||||
<string name="guidedstep_required">Vyžadováno</string>
|
||||
<string name="pref_title_wled_enabled">Habilitar WLED DDP</string>
|
||||
<string name="pref_summary_wled_enabled">Enviar datos de píxeles directamente a una instancia WLED usando DDP</string>
|
||||
<string name="pref_title_wled_ip">Dirección IP de WLED</string>
|
||||
<string name="pref_summary_wled_ip">La dirección IP de tu instancia WLED</string>
|
||||
</resources>
|
||||
@@ -19,4 +19,8 @@
|
||||
<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>
|
||||
<string name="pref_title_wled_enabled">Habilitar WLED DDP</string>
|
||||
<string name="pref_summary_wled_enabled">Enviar datos de píxeles directamente a una instancia WLED usando DDP</string>
|
||||
<string name="pref_title_wled_ip">Dirección IP de WLED</string>
|
||||
<string name="pref_summary_wled_ip">La dirección IP de tu instancia WLED</string>
|
||||
</resources>
|
||||
@@ -11,4 +11,8 @@
|
||||
<string name="guidedstep_continue">Continuar</string>
|
||||
<string name="guidedstep_nevermind">No importa</string>
|
||||
<string name="guidedstep_cancel">Cancelar</string>
|
||||
<string name="pref_title_wled_enabled">Habilitar WLED DDP</string>
|
||||
<string name="pref_summary_wled_enabled">Enviar datos de píxeles directamente a una instancia WLED usando DDP</string>
|
||||
<string name="pref_title_wled_ip">Dirección IP de WLED</string>
|
||||
<string name="pref_summary_wled_ip">La dirección IP de tu instancia WLED</string>
|
||||
</resources>
|
||||
@@ -17,4 +17,8 @@
|
||||
<string name="guidedstep_nevermind">Cela ne fait rien</string>
|
||||
<string name="guidedstep_cancel">Annuler</string>
|
||||
<string name="guidedstep_required">Obligatoire</string>
|
||||
<string name="pref_title_wled_enabled">Habilitar WLED DDP</string>
|
||||
<string name="pref_summary_wled_enabled">Enviar datos de píxeles directamente a una instancia WLED usando DDP</string>
|
||||
<string name="pref_title_wled_ip">Dirección IP de WLED</string>
|
||||
<string name="pref_summary_wled_ip">La dirección IP de tu instancia WLED</string>
|
||||
</resources>
|
||||
@@ -17,4 +17,8 @@
|
||||
<string name="guidedstep_nevermind">Non importa</string>
|
||||
<string name="guidedstep_cancel">Annulla</string>
|
||||
<string name="guidedstep_required">Obbligatorio</string>
|
||||
<string name="pref_title_wled_enabled">Habilitar WLED DDP</string>
|
||||
<string name="pref_summary_wled_enabled">Enviar datos de píxeles directamente a una instancia WLED usando DDP</string>
|
||||
<string name="pref_title_wled_ip">Dirección IP de WLED</string>
|
||||
<string name="pref_summary_wled_ip">La dirección IP de tu instancia WLED</string>
|
||||
</resources>
|
||||
@@ -17,4 +17,8 @@
|
||||
<string name="guidedstep_nevermind">Laat maar</string>
|
||||
<string name="guidedstep_cancel">Annuleren</string>
|
||||
<string name="guidedstep_required">Vereist</string>
|
||||
<string name="pref_title_wled_enabled">Habilitar WLED DDP</string>
|
||||
<string name="pref_summary_wled_enabled">Enviar datos de píxeles directamente a una instancia WLED usando DDP</string>
|
||||
<string name="pref_title_wled_ip">Dirección IP de WLED</string>
|
||||
<string name="pref_summary_wled_ip">La dirección IP de tu instancia WLED</string>
|
||||
</resources>
|
||||
@@ -17,4 +17,8 @@
|
||||
<string name="guidedstep_nevermind">Glem det</string>
|
||||
<string name="guidedstep_cancel">Avbryt</string>
|
||||
<string name="guidedstep_required">Påkrevd</string>
|
||||
<string name="pref_title_wled_enabled">Habilitar WLED DDP</string>
|
||||
<string name="pref_summary_wled_enabled">Enviar datos de píxeles directamente a una instancia WLED usando DDP</string>
|
||||
<string name="pref_title_wled_ip">Dirección IP de WLED</string>
|
||||
<string name="pref_summary_wled_ip">La dirección IP de tu instancia WLED</string>
|
||||
</resources>
|
||||
@@ -9,4 +9,8 @@
|
||||
<string name="guidedstep_continue">Продолжать</string>
|
||||
<string name="guidedstep_cancel">Отмена</string>
|
||||
<string name="guidedstep_required">Требуется</string>
|
||||
<string name="pref_title_wled_enabled">Habilitar WLED DDP</string>
|
||||
<string name="pref_summary_wled_enabled">Enviar datos de píxeles directamente a una instancia WLED usando DDP</string>
|
||||
<string name="pref_title_wled_ip">Dirección IP de WLED</string>
|
||||
<string name="pref_summary_wled_ip">La dirección IP de tu instancia WLED</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths>
|
||||
<external-path name="downloads" path="Download/" />
|
||||
<external-files-path name="external_files" path="." />
|
||||
<cache-path name="cache" path="." />
|
||||
</paths>
|
||||
Reference in new issue
Block a user