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

+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);
}
}