Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
ac5cb93fd9 | |||
97b1f37164 | |||
96a0bf9ed4 | |||
23035084e8 | |||
5872be4fe7 | |||
a776411a2e | |||
86282e6872 | |||
6c8e7bbfa0 | |||
1d1d27257c | |||
9d043c21a3 | |||
ab2c219dca | |||
79c42216fc | |||
a582a5b1bc | |||
e1f6ca4f33 | |||
c6887e5905 | |||
64b2f80848 | |||
58980c494e | |||
239429cb5e |
@@ -21,24 +21,19 @@ buildscript {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
|
||||
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.jakewharton.hugo'
|
||||
apply plugin: 'com.github.ben-manes.versions'
|
||||
|
||||
repositories {
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '23.0.2'
|
||||
compileSdkVersion 28
|
||||
buildToolsVersion '28.0.3'
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
@@ -46,38 +41,31 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.idlegandalf.ledd"
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 23
|
||||
versionCode 3
|
||||
versionName "1.0.3"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 28
|
||||
versionCode System.getenv("BUILD_NUMBER") as Integer ?: 100
|
||||
versionName "2.0.0-SNAPSHOT"
|
||||
archivesBaseName = "LedD-" + versionName + "-" + versionCode
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
zipAlignEnabled true
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
debug {
|
||||
zipAlignEnabled true
|
||||
}
|
||||
compileOptions {
|
||||
targetCompatibility 1.8
|
||||
sourceCompatibility 1.8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:23.2.1'
|
||||
compile 'com.android.support:support-v4:23.2.1'
|
||||
compile 'com.squareup.okhttp:okhttp:2.7.5'
|
||||
compile 'com.google.code.gson:gson:2.6.2'
|
||||
compile 'com.jakewharton:butterknife:7.0.1'
|
||||
compile 'com.koushikdutta.async:androidasync:2.1.7'
|
||||
compile 'com.android.support:design:23.2.1'
|
||||
compile 'com.larswerkman:HoloColorPicker:1.5@aar'
|
||||
compile 'com.google.guava:guava:19.0'
|
||||
compile 'com.thetransactioncompany:jsonrpc2-base:1.38'
|
||||
compile('com.mikepenz:materialdrawer:5.1.4@aar') {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.koushikdutta.async:androidasync:2.2.1'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
|
||||
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
||||
implementation 'com.github.madrapps:pikolo:1.1.6'
|
||||
implementation 'com.google.guava:guava:27.0-android'
|
||||
implementation('com.mikepenz:materialdrawer:6.1.1@aar') {
|
||||
transitive = true
|
||||
}
|
||||
provided 'org.projectlombok:lombok:1.16.8'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.4'
|
||||
compileOnly 'org.projectlombok:lombok:1.18.4'
|
||||
}
|
||||
|
@@ -17,9 +17,8 @@
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<manifest
|
||||
package="com.idlegandalf.ledd"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.idlegandalf.ledd">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
@@ -27,9 +27,8 @@ import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.SparseArray;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -37,54 +36,63 @@ import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.idlegandalf.ledd.callbacks.RecieveColorCallback;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.idlegandalf.ledd.callbacks.ReceiveColorCallback;
|
||||
import com.idlegandalf.ledd.callbacks.StripesCallback;
|
||||
import com.idlegandalf.ledd.components.HSV;
|
||||
import com.idlegandalf.ledd.components.LedDDaemon;
|
||||
import com.idlegandalf.ledd.components.LedStripe;
|
||||
import com.idlegandalf.ledd.components.Profile;
|
||||
import com.idlegandalf.ledd.fragments.AddProfileDialog;
|
||||
import com.idlegandalf.ledd.fragments.AddStripeDialog;
|
||||
import com.idlegandalf.ledd.helper.LedDHelper;
|
||||
import com.idlegandalf.ledd.utils.RateLimiter;
|
||||
import com.larswerkman.holocolorpicker.ColorPicker;
|
||||
import com.larswerkman.holocolorpicker.SaturationBar;
|
||||
import com.larswerkman.holocolorpicker.ValueBar;
|
||||
import com.madrapps.pikolo.HSLColorPicker;
|
||||
import com.madrapps.pikolo.listeners.SimpleColorSelectionListener;
|
||||
import com.mikepenz.materialdrawer.Drawer;
|
||||
import com.mikepenz.materialdrawer.DrawerBuilder;
|
||||
import com.mikepenz.materialdrawer.holder.BadgeStyle;
|
||||
import com.mikepenz.materialdrawer.interfaces.OnCheckedChangeListener;
|
||||
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.SecondarySwitchDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.SwitchDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.Bind;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import hugo.weaving.DebugLog;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerItemClickListener, OnCheckedChangeListener {
|
||||
public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerItemClickListener, Drawer.OnDrawerItemLongClickListener, OnCheckedChangeListener {
|
||||
|
||||
@Bind(R.id.main_layout)
|
||||
@BindView(R.id.main_layout)
|
||||
LinearLayout scrollView;
|
||||
@Bind(R.id.toolbar)
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@Bind(R.id.picker)
|
||||
ColorPicker colorPicker;
|
||||
@Bind(R.id.saturationbar)
|
||||
SaturationBar saturationBar;
|
||||
@Bind(R.id.valuebar)
|
||||
ValueBar valueBar;
|
||||
@BindView(R.id.picker)
|
||||
HSLColorPicker colorPicker;
|
||||
Drawer mDrawer;
|
||||
private List<IDrawerItem> mDaemons;
|
||||
private refreshDaemonsListener daemonsListener;
|
||||
private List<LedStripe> ledStripes;
|
||||
private List<Profile> profiles;
|
||||
private LedStripe mCurrentStripe;
|
||||
private boolean fromOnCreate = true;
|
||||
private boolean autoColorSet = false;
|
||||
private RateLimiter limiter;
|
||||
private boolean isRefreshRunning = false;
|
||||
|
||||
private Type profileList = new TypeToken<List<Profile>>() {
|
||||
}.getType();
|
||||
private PrimaryDrawerItem menuProfiles;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -92,56 +100,78 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
setContentView(R.layout.activity_color);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Timber.plant(new Timber.DebugTree());
|
||||
}
|
||||
|
||||
// check for connectivity
|
||||
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
|
||||
if (networkInfo == null || !networkInfo.isConnected() || networkInfo.getType() != ConnectivityManager.TYPE_WIFI) {
|
||||
Snackbar.make(scrollView, R.string.snackbar_no_wlan, Snackbar.LENGTH_INDEFINITE).setAction("RETRY", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
refreshStripes();
|
||||
}
|
||||
Snackbar.make(scrollView, R.string.snackbar_no_wlan, Snackbar.LENGTH_INDEFINITE).setAction("RETRY", v -> {
|
||||
refreshStripes();
|
||||
}).show();
|
||||
}
|
||||
|
||||
mDaemons = new ArrayList<>();
|
||||
limiter = new RateLimiter(5.0, 100.0);
|
||||
limiter = new RateLimiter(30.0, 1000);
|
||||
|
||||
colorPicker.addSaturationBar(saturationBar);
|
||||
colorPicker.addValueBar(valueBar);
|
||||
colorPicker.setShowOldCenterColor(false);
|
||||
|
||||
colorPicker.setOnColorChangedListener(new ColorPicker.OnColorChangedListener() {
|
||||
colorPicker.setColorSelectionListener(new SimpleColorSelectionListener() {
|
||||
@Override
|
||||
public void onColorChanged(int i) {
|
||||
public void onColorSelected(int color) {
|
||||
if (mCurrentStripe != null && limiter.check() && !autoColorSet) {
|
||||
mCurrentStripe.setColor(i);
|
||||
mCurrentStripe.setColor(color);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
toolbar.setTitle(R.string.app_name);
|
||||
|
||||
mDrawer = new DrawerBuilder()
|
||||
.withActivity(this)
|
||||
.withToolbar(toolbar)
|
||||
.withOnDrawerItemClickListener(this)
|
||||
.withOnDrawerItemLongClickListener(this)
|
||||
.addStickyDrawerItems(
|
||||
new PrimaryDrawerItem().withName(R.string.text_add_stripe).withTag("add_stripe").withSelectable(false),
|
||||
new PrimaryDrawerItem().withName(R.string.text_settings).withTag("settings").withSelectable(false)
|
||||
new PrimaryDrawerItem().withName(R.string.text_add_stripe).withTag("add_stripe").withSelectable(false).withIcon(R.drawable.ic_add_circle_black_48dp),
|
||||
new PrimaryDrawerItem().withName(R.string.text_settings).withTag("settings").withSelectable(false).withIcon(R.drawable.ic_tune_black_48dp)
|
||||
)
|
||||
.addDrawerItems(
|
||||
new DividerDrawerItem(),
|
||||
menuProfiles = new PrimaryDrawerItem()
|
||||
.withName("Profiles")
|
||||
.withIcon(R.drawable.ic_save_black_48dp)
|
||||
.withSelectable(false)
|
||||
.withIsExpanded(true)
|
||||
.withBadgeStyle(new BadgeStyle().withColor(Color.CYAN).withTextColor(Color.WHITE))
|
||||
)
|
||||
.build();
|
||||
|
||||
menuProfiles.withSubItems(new SecondaryDrawerItem().withName("Add Profile").withTag("add_profile").withSelectable(false).withIcon(R.drawable.ic_add_circle_outline_black_48dp));
|
||||
|
||||
// enable Homebutton navigation to drawer
|
||||
// enable HomeButton navigation to drawer
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
mDrawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);
|
||||
}
|
||||
|
||||
List<IDrawerItem> subProfiles = menuProfiles.getSubItems();
|
||||
if (PreferenceManager.getDefaultSharedPreferences(this).contains("profiles")) {
|
||||
profiles = new Gson().fromJson(PreferenceManager.getDefaultSharedPreferences(this).getString("profiles", ""), profileList);
|
||||
|
||||
for (Profile profile : profiles) {
|
||||
subProfiles.add(0, new SecondaryDrawerItem().withName(profile.getName()).withTag(profile.getValues()).withSelectable(false).withIcon(R.drawable.ic_note_black_48dp));
|
||||
}
|
||||
} else {
|
||||
profiles = new ArrayList<>();
|
||||
}
|
||||
|
||||
menuProfiles.withSubItems(subProfiles);
|
||||
mDrawer.updateItem(menuProfiles);
|
||||
|
||||
daemonsListener = new refreshDaemonsListener();
|
||||
registerReceiver(daemonsListener, new IntentFilter(ColorApplication.INTENT_ACTION_REFRESH));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,6 +190,8 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
ColorApplication.getInstance().onResume();
|
||||
registerReceiver(daemonsListener, new IntentFilter(ColorApplication.INTENT_ACTION_REFRESH));
|
||||
refreshStripes();
|
||||
}
|
||||
|
||||
@@ -176,8 +208,8 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
if (stripe != null) {
|
||||
if (isChecked) {
|
||||
if (stripe == mCurrentStripe) {
|
||||
if (colorPicker.getColor() != Color.BLACK)
|
||||
stripe.setColor(colorPicker.getColor());
|
||||
if (colorPicker.getSolidColor() != Color.BLACK)
|
||||
stripe.setColor(colorPicker.getSolidColor());
|
||||
else {
|
||||
colorPicker.setColor(Color.WHITE);
|
||||
}
|
||||
@@ -214,7 +246,10 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
unregisterReceiver(daemonsListener);
|
||||
|
||||
if (mCurrentStripe != null)
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit().putInt("lastStripe", mCurrentStripe.getId()).commit();
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit().putInt("lastStripe", mCurrentStripe.getId()).apply();
|
||||
|
||||
if (profiles != null)
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit().putString("profiles", new Gson().toJson(profiles, profileList)).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -226,6 +261,7 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (!fromOnCreate) {
|
||||
ColorApplication.getInstance().onResume();
|
||||
registerReceiver(daemonsListener, new IntentFilter(ColorApplication.INTENT_ACTION_REFRESH));
|
||||
@@ -236,21 +272,41 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
|
||||
if (drawerItem.isSelectable()) {
|
||||
if (drawerItem.getTag() instanceof String) {
|
||||
String tag = (String) drawerItem.getTag();
|
||||
|
||||
if (drawerItem.getTag() instanceof String) {
|
||||
String tag = (String) drawerItem.getTag();
|
||||
|
||||
if (tag.equals("add_stripe")) {
|
||||
switch (tag) {
|
||||
case "add_stripe":
|
||||
new AddStripeDialog().show(getFragmentManager(), "");
|
||||
return true;
|
||||
} else if (tag.equals("settings")) {
|
||||
case "settings":
|
||||
return true;
|
||||
case "add_profile":
|
||||
new AddProfileDialog().show(getFragmentManager(), "");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (drawerItem.getTag() instanceof SparseArray) {
|
||||
SparseArray<HSV> sparseArray = (SparseArray<HSV>) drawerItem.getTag();
|
||||
|
||||
if (ledStripes != null) {
|
||||
for (LedStripe ledStripe : ledStripes) {
|
||||
String json_workaround = new Gson().toJson(sparseArray.get(ledStripe.getId()));
|
||||
HSV nHSV = new Gson().fromJson(json_workaround, new TypeToken<HSV>() {
|
||||
}.getType());
|
||||
|
||||
if (nHSV != null) {
|
||||
ledStripe.setColor(nHSV);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (drawerItem.isSelectable()) {
|
||||
if (drawerItem.getTag() instanceof Integer) {
|
||||
int tag = (int) drawerItem.getTag();
|
||||
|
||||
@@ -265,6 +321,30 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(View view, int position, IDrawerItem drawerItem) {
|
||||
Timber.d("Longclick of %s", drawerItem.getClass().getName());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<LedStripe> getStripes() {
|
||||
return ledStripes;
|
||||
}
|
||||
|
||||
public void addProfile(Profile profile) {
|
||||
if (profiles != null) {
|
||||
profiles.add(profile);
|
||||
|
||||
List<IDrawerItem> subProfiles = menuProfiles.getSubItems();
|
||||
subProfiles.add(0, new SecondaryDrawerItem().withName(profile.getName()).withSelectable(false).withTag(profile.getValues()).withIcon(R.drawable.ic_note_black_48dp));
|
||||
|
||||
menuProfiles.withSubItems(subProfiles).withIsExpanded(true).withBadge(String.valueOf(profiles.size()));
|
||||
mDrawer.updateItem(menuProfiles);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecated")
|
||||
public void refreshStripes() {
|
||||
if (isRefreshRunning)
|
||||
return;
|
||||
@@ -280,65 +360,65 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
@Override
|
||||
public void onSuccess(List<LedStripe> stripes) {
|
||||
ledStripes = stripes;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PrimaryDrawerItem nDaemonMenu = null;
|
||||
long selectedItemId = -1;
|
||||
for (IDrawerItem drawerItem : mDaemons) {
|
||||
if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(dDaemon.toString())) {
|
||||
nDaemonMenu = (PrimaryDrawerItem) drawerItem;
|
||||
break;
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
PrimaryDrawerItem nDaemonMenu = null;
|
||||
long selectedItemId = -1;
|
||||
for (IDrawerItem drawerItem : mDaemons) {
|
||||
if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(dDaemon.toString())) {
|
||||
nDaemonMenu = (PrimaryDrawerItem) drawerItem;
|
||||
break;
|
||||
}
|
||||
|
||||
if (nDaemonMenu == null) {
|
||||
nDaemonMenu = new PrimaryDrawerItem().withName(dDaemon.toString()).withTag(finalI).withSelectable(false).withIsExpanded(true);
|
||||
mDrawer.addItem(nDaemonMenu);
|
||||
mDaemons.add(nDaemonMenu);
|
||||
}
|
||||
|
||||
int lastStripeId = -1;
|
||||
if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).contains("lastStripe")) {
|
||||
lastStripeId = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("lastStripe", -1);
|
||||
}
|
||||
|
||||
List<IDrawerItem> mStripes = new ArrayList<>();
|
||||
for (LedStripe stripe : ledStripes) {
|
||||
final SecondarySwitchDrawerItem sItem = new SecondarySwitchDrawerItem()
|
||||
.withName(stripe.getName())
|
||||
.withTag(stripe.getId())
|
||||
.withIcon(R.drawable.ic_wb_iridescent_black_48dp)
|
||||
.withOnCheckedChangeListener(ColorActivity.this);
|
||||
|
||||
mStripes.add(sItem);
|
||||
|
||||
if (lastStripeId != -1 && stripe.getId() == lastStripeId) {
|
||||
selectStripe(stripe);
|
||||
selectedItemId = sItem.getIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
nDaemonMenu.withSubItems(mStripes);
|
||||
nDaemonMenu.withBadge(String.valueOf(mStripes.size()));
|
||||
nDaemonMenu.withBadgeStyle(new BadgeStyle().withColor(getResources().getColor(R.color.material_drawer_accent)).withTextColor(Color.WHITE));
|
||||
mDrawer.updateItem(nDaemonMenu);
|
||||
if (selectedItemId != -1)
|
||||
mDrawer.setSelection(selectedItemId);
|
||||
|
||||
Snackbar.make(findViewById(android.R.id.content), R.string.snackbar_stripes_reloaded, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
if (nDaemonMenu == null) {
|
||||
nDaemonMenu = new PrimaryDrawerItem().withName(dDaemon.toString()).withTag(finalI).withSelectable(false).withIsExpanded(true).withIcon(R.drawable.ic_computer_black_48dp);
|
||||
mDrawer.addItemAtPosition(nDaemonMenu, 0);
|
||||
mDaemons.add(nDaemonMenu);
|
||||
}
|
||||
|
||||
int lastStripeId = -1;
|
||||
if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).contains("lastStripe")) {
|
||||
lastStripeId = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("lastStripe", -1);
|
||||
}
|
||||
|
||||
List<IDrawerItem> mStripes = new ArrayList<>();
|
||||
for (LedStripe stripe : ledStripes) {
|
||||
final SwitchDrawerItem sItem = new SwitchDrawerItem()
|
||||
.withName(stripe.getName())
|
||||
.withTag(stripe.getId())
|
||||
.withIcon(R.drawable.ic_wb_iridescent_black_48dp)
|
||||
.withOnCheckedChangeListener(ColorActivity.this);
|
||||
|
||||
mStripes.add(sItem);
|
||||
|
||||
if (lastStripeId != -1 && stripe.getId() == lastStripeId) {
|
||||
selectStripe(stripe);
|
||||
selectedItemId = sItem.getIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
nDaemonMenu.withSubItems(mStripes);
|
||||
nDaemonMenu.withBadge(String.valueOf(mStripes.size()));
|
||||
//noinspection deprecation
|
||||
nDaemonMenu.withBadgeStyle(new BadgeStyle().withColor(getResources().getColor(R.color.material_drawer_accent)).withTextColor(Color.WHITE));
|
||||
mDrawer.updateItem(nDaemonMenu);
|
||||
if (selectedItemId != -1)
|
||||
mDrawer.setSelection(selectedItemId);
|
||||
|
||||
//noinspection ConstantConditions
|
||||
Snackbar.make(findViewById(android.R.id.content), R.string.snackbar_stripes_reloaded, Snackbar.LENGTH_LONG).show();
|
||||
});
|
||||
|
||||
|
||||
for (LedStripe stripe : ledStripes) {
|
||||
stripe.getColor(new RecieveColorCallback() {
|
||||
stripe.getColor(new ReceiveColorCallback() {
|
||||
@Override
|
||||
public void onConnectionFailed(String message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onColorRecieved(LedStripe stripe) {
|
||||
public void onColorReceived(LedStripe stripe) {
|
||||
if (stripe.isOn()) {
|
||||
IDrawerItem sItem = findItemForStripe(stripe);
|
||||
|
||||
@@ -346,18 +426,13 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
final SecondarySwitchDrawerItem cItem = (SecondarySwitchDrawerItem) sItem;
|
||||
cItem.withSwitchEnabled(true);
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mDrawer.updateItem(cItem);
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> mDrawer.updateItem(cItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecievFailed(int code, String msg) {
|
||||
public void onReceiveFailed(int code, String msg) {
|
||||
|
||||
}
|
||||
|
||||
@@ -367,6 +442,7 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
|
||||
@Override
|
||||
public void onGetFailed(int code, String message) {
|
||||
//noinspection ConstantConditions
|
||||
Snackbar.make(findViewById(android.R.id.content), getString(R.string.snackbar_no_connection_stripes) + message, Snackbar
|
||||
.LENGTH_LONG).show();
|
||||
|
||||
@@ -374,6 +450,7 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(String message) {
|
||||
//noinspection ConstantConditions
|
||||
Snackbar.make(findViewById(android.R.id.content), getString(R.string.snackbar_connection_failed) + message, Snackbar
|
||||
.LENGTH_LONG).show();
|
||||
}
|
||||
@@ -387,37 +464,33 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
isRefreshRunning = false;
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
private void selectStripe(LedStripe stripe) {
|
||||
mCurrentStripe = stripe;
|
||||
|
||||
toolbar.setTitle(stripe.getName());
|
||||
autoColorSet = true;
|
||||
mDrawer.closeDrawer();
|
||||
mCurrentStripe.getColor(new RecieveColorCallback() {
|
||||
mCurrentStripe.getColor(new ReceiveColorCallback() {
|
||||
@Override
|
||||
public void onColorRecieved(final LedStripe stripe) {
|
||||
public void onColorReceived(final LedStripe stripe) {
|
||||
final HSV cColor = stripe.getColor();
|
||||
final int color = Color.HSVToColor(new float[]{(float) cColor.getHue(), (float) cColor.getSaturation(), (float) cColor.getValue()});
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
colorPicker.setColor(color);
|
||||
autoColorSet = false;
|
||||
runOnUiThread(() -> {
|
||||
colorPicker.setColor(color);
|
||||
autoColorSet = false;
|
||||
|
||||
if (stripe.isOn()) {
|
||||
IDrawerItem fItem = findItemForStripe(stripe);
|
||||
if (stripe.isOn()) {
|
||||
IDrawerItem fItem = findItemForStripe(stripe);
|
||||
|
||||
if (fItem != null)
|
||||
((SecondarySwitchDrawerItem) fItem).withSwitchEnabled(true);
|
||||
}
|
||||
if (fItem != null)
|
||||
((SecondarySwitchDrawerItem) fItem).withSwitchEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecievFailed(int code, String msg) {
|
||||
public void onReceiveFailed(int code, String msg) {
|
||||
autoColorSet = false;
|
||||
}
|
||||
|
||||
@@ -428,17 +501,7 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
});
|
||||
}
|
||||
|
||||
protected class refreshDaemonsListener extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(ColorApplication.INTENT_ACTION_REFRESH)) {
|
||||
refreshStripes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
@Nullable
|
||||
private IDrawerItem findItemForStripe(LedStripe stripe) {
|
||||
for (IDrawerItem dItem : mDaemons) {
|
||||
if (((PrimaryDrawerItem) dItem).getSubItems() != null) {
|
||||
@@ -452,4 +515,14 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected class refreshDaemonsListener extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(ColorApplication.INTENT_ACTION_REFRESH)) {
|
||||
refreshStripes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ package com.idlegandalf.ledd;
|
||||
import android.app.Application;
|
||||
import android.content.Intent;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@@ -34,6 +33,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class ColorApplication extends Application {
|
||||
public static final String TAG = "LedD";
|
||||
public static final String INTENT_ACTION_REFRESH = "com.idlegandalf.ledd.action.refreshStripes";
|
||||
@@ -74,18 +75,13 @@ public class ColorApplication extends Application {
|
||||
}
|
||||
|
||||
public List<LedDDaemon> getDaemons() {
|
||||
ArrayList<LedDDaemon> ledDDaemons = new ArrayList<>();
|
||||
ledDDaemons.addAll(ledDHelpers.keySet());
|
||||
|
||||
return ledDDaemons;
|
||||
return new ArrayList<>(ledDHelpers.keySet());
|
||||
}
|
||||
|
||||
public void teardown() {
|
||||
for (LedDHelper dHelper : ledDHelpers.values()) {
|
||||
dHelper.teardown();
|
||||
}
|
||||
ledDHelpers.values().forEach(LedDHelper::teardown);
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit().putString("daemons", new Gson().toJson(ledDHelpers.keySet())).commit();
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit().putString("daemons", new Gson().toJson(ledDHelpers.keySet())).apply();
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
@@ -94,7 +90,7 @@ public class ColorApplication extends Application {
|
||||
TypeToken<Set<LedDDaemon>>() {
|
||||
}.getType());
|
||||
|
||||
Log.i(ColorApplication.TAG, "Loaded " + ledDDaemons.size() + " Daemons from preferences");
|
||||
Timber.i("Loaded " + ledDDaemons.size() + " Daemons from preferences");
|
||||
|
||||
for (final LedDDaemon ledDDaemon : ledDDaemons) {
|
||||
final LedDHelper helper = new LedDHelper(ledDDaemon, getApplicationContext());
|
||||
|
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* LEDD Project
|
||||
* Copyright (C) 2015 LEDD Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.idlegandalf.ledd;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.idlegandalf.ledd.fragments.SettingsFragment;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// Display the fragment as the main content.
|
||||
getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
|
||||
}
|
||||
}
|
@@ -20,8 +20,8 @@ package com.idlegandalf.ledd.callbacks;
|
||||
|
||||
import com.idlegandalf.ledd.components.LedStripe;
|
||||
|
||||
public interface RecieveColorCallback extends BaseCallback {
|
||||
void onColorRecieved(LedStripe stripe);
|
||||
public interface ReceiveColorCallback extends BaseCallback {
|
||||
void onColorReceived(LedStripe stripe);
|
||||
|
||||
void onRecievFailed(int code, String msg);
|
||||
void onReceiveFailed(int code, String msg);
|
||||
}
|
@@ -33,8 +33,4 @@ public class HSV {
|
||||
this.saturation = s;
|
||||
this.value = v;
|
||||
}
|
||||
|
||||
public HSV() {
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -50,10 +50,7 @@ public class LedDDaemon {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof LedDDaemon) {
|
||||
if (address.equals(((LedDDaemon) o).address) && port == ((LedDDaemon) o).port) return true;
|
||||
}
|
||||
return false;
|
||||
return o instanceof LedDDaemon && address.equals(((LedDDaemon) o).address) && port == ((LedDDaemon) o).port;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -19,12 +19,12 @@
|
||||
package com.idlegandalf.ledd.components;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.idlegandalf.ledd.ColorApplication;
|
||||
import com.idlegandalf.ledd.callbacks.RecieveColorCallback;
|
||||
import com.idlegandalf.ledd.callbacks.ReceiveColorCallback;
|
||||
import com.idlegandalf.ledd.helper.LedDHelper;
|
||||
|
||||
import hugo.weaving.DebugLog;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -69,7 +69,6 @@ public class LedStripe {
|
||||
return String.format("%s->%s->%s (%d|%d|%d)", ledDDaemon, controller.getAddress(), name, channelRed, channelGreen, channelBlue);
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
public void setColor(int color) {
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
@@ -89,14 +88,29 @@ public class LedStripe {
|
||||
}
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
public void getColor(RecieveColorCallback callback) {
|
||||
public void getColor(@Nullable final ReceiveColorCallback callback) {
|
||||
checkHelper();
|
||||
|
||||
helper.getColor(this, callback);
|
||||
helper.getColor(this, new ReceiveColorCallback() {
|
||||
@Override
|
||||
public void onColorReceived(LedStripe stripe) {
|
||||
color = stripe.getColor();
|
||||
if (callback != null)
|
||||
callback.onColorReceived(LedStripe.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceiveFailed(int code, String msg) {
|
||||
if (callback != null) callback.onReceiveFailed(code, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(String message) {
|
||||
if (callback != null) callback.onConnectionFailed(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
public boolean isOn() {
|
||||
return color != null && color.getValue() != 0.0;
|
||||
}
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.idlegandalf.ledd.components;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Profile {
|
||||
private SparseArray<HSV> values;
|
||||
private String name;
|
||||
|
||||
public Profile(SparseArray<HSV> hsvHashMap) {
|
||||
setValues(hsvHashMap);
|
||||
}
|
||||
|
||||
public Profile(String name) {
|
||||
setValues(new SparseArray<HSV>());
|
||||
setName(name);
|
||||
}
|
||||
}
|
@@ -22,8 +22,6 @@ import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
@@ -31,6 +29,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.google.gson.Gson;
|
||||
import com.idlegandalf.ledd.ColorApplication;
|
||||
import com.idlegandalf.ledd.R;
|
||||
@@ -42,22 +42,22 @@ import com.idlegandalf.ledd.helper.LedDHelper;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParsePosition;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class AddControllerDialog extends DialogFragment implements DialogInterface.OnShowListener {
|
||||
|
||||
@Bind(R.id.input_i2c_layout)
|
||||
@BindView(R.id.input_i2c_layout)
|
||||
TextInputLayout i2cLayout;
|
||||
@Bind(R.id.input_i2c)
|
||||
@BindView(R.id.input_i2c)
|
||||
EditText i2cText;
|
||||
@Bind(R.id.input_address_layout)
|
||||
@BindView(R.id.input_address_layout)
|
||||
TextInputLayout addressLayout;
|
||||
@Bind(R.id.input_address)
|
||||
@BindView(R.id.input_address)
|
||||
EditText addressText;
|
||||
@Bind(R.id.input_channel_layout)
|
||||
@BindView(R.id.input_channel_layout)
|
||||
TextInputLayout channelLayout;
|
||||
@Bind(R.id.input_channel)
|
||||
@BindView(R.id.input_channel)
|
||||
EditText channelText;
|
||||
LedDDaemon dDaemon;
|
||||
|
||||
@@ -140,80 +140,59 @@ public class AddControllerDialog extends DialogFragment implements DialogInterfa
|
||||
}
|
||||
});
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AddStripeDialog.instance.onResume();
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v -> {
|
||||
// TODO: AddStripeDialog.instance.onResume();
|
||||
alertDialog.dismiss();
|
||||
});
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (i2cText.getText().toString().isEmpty() || !isNumeric(i2cText.getText().toString())) {
|
||||
i2cLayout.setError("No valid i2c device number");
|
||||
return;
|
||||
}
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
|
||||
if (i2cText.getText().toString().isEmpty() || !isNumeric(i2cText.getText().toString())) {
|
||||
i2cLayout.setError("No valid i2c device number");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addressText.getText().toString().contains("0x") || !addressText.getText().toString().split("x")[1].matches("-?[0-9a-fA-F]+")) {
|
||||
addressLayout.setError("No valid hexdecimal address");
|
||||
return;
|
||||
}
|
||||
if (!addressText.getText().toString().contains("0x") || !addressText.getText().toString().split("x")[1].matches("-?[0-9a-fA-F]+")) {
|
||||
addressLayout.setError("No valid hexdecimal address");
|
||||
return;
|
||||
}
|
||||
|
||||
if (channelText.getText().toString().isEmpty() || !isNumeric(channelText.getText().toString()) && Integer.parseInt(channelText
|
||||
.getText().toString()) <= 0) {
|
||||
channelLayout.setError("No valid channel amount");
|
||||
return;
|
||||
}
|
||||
if (channelText.getText().toString().isEmpty() || !isNumeric(channelText.getText().toString()) && Integer.parseInt(channelText
|
||||
.getText().toString()) <= 0) {
|
||||
channelLayout.setError("No valid channel amount");
|
||||
return;
|
||||
}
|
||||
|
||||
Controller c = new Controller();
|
||||
c.setAddress(addressText.getText().toString());
|
||||
c.setI2c_device(Integer.parseInt(i2cText.getText().toString()));
|
||||
c.setChannels(Integer.parseInt(channelText.getText().toString()));
|
||||
Controller c = new Controller();
|
||||
c.setAddress(addressText.getText().toString());
|
||||
c.setI2c_device(Integer.parseInt(i2cText.getText().toString()));
|
||||
c.setChannels(Integer.parseInt(channelText.getText().toString()));
|
||||
|
||||
LedDHelper helper = ColorApplication.getInstance().getHelperForDaemon(dDaemon);
|
||||
LedDHelper helper = ColorApplication.getInstance().getHelperForDaemon(dDaemon);
|
||||
|
||||
if (helper != null) {
|
||||
helper.addController(c, new AddControllerCallback() {
|
||||
@Override
|
||||
public void onControllerAdded(final Controller controller) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), String.format(getActivity().getString(R.string.snachbar_added_controller), controller.getId()), Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
if (helper != null) {
|
||||
helper.addController(c, new AddControllerCallback() {
|
||||
@Override
|
||||
public void onControllerAdded(final Controller controller) {
|
||||
getActivity().runOnUiThread(() -> Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), String.format(getActivity().getString(R.string.snachbar_added_controller), controller.getId()), Snackbar.LENGTH_LONG).show());
|
||||
|
||||
dDaemon.getControllers().add(controller);
|
||||
dismiss();
|
||||
}
|
||||
dDaemon.getControllers().add(controller);
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddFailed(final int code, final String msg) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), getActivity().getString(R.string.snackbar_error) + msg, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
AddStripeDialog.instance.onResume();
|
||||
dismiss();
|
||||
}
|
||||
@Override
|
||||
public void onAddFailed(final int code, final String msg) {
|
||||
getActivity().runOnUiThread(() -> Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), getActivity().getString(R.string.snackbar_error) + msg, Snackbar.LENGTH_LONG).show());
|
||||
// TODO: AddStripeDialog.instance.onResume();
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(final String message) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), String.format(getActivity().getString(R.string.snackbar_daemon_connection_failed), dDaemon, message), Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
AddStripeDialog.instance.onResume();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onConnectionFailed(final String message) {
|
||||
getActivity().runOnUiThread(() -> Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), String.format(getActivity().getString(R.string.snackbar_daemon_connection_failed), dDaemon, message), Snackbar.LENGTH_LONG).show());
|
||||
// TODO: AddStripeDialog.instance.onResume();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -25,8 +25,6 @@ import android.content.DialogInterface;
|
||||
import android.net.nsd.NsdManager;
|
||||
import android.net.nsd.NsdServiceInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
@@ -38,6 +36,8 @@ import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import com.idlegandalf.ledd.ColorActivity;
|
||||
import com.idlegandalf.ledd.ColorApplication;
|
||||
@@ -49,18 +49,18 @@ import java.net.Inet4Address;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
|
||||
public class AddDaemonDialog extends DialogFragment implements DialogInterface.OnShowListener, NsdManager.DiscoveryListener {
|
||||
|
||||
private final String SERVICE_TYPE = "_ledd._tcp.";
|
||||
@Bind(R.id.input_ip)
|
||||
@BindView(R.id.input_ip)
|
||||
EditText ip;
|
||||
@Bind(R.id.input_ip_layout)
|
||||
@BindView(R.id.input_ip_layout)
|
||||
TextInputLayout ip_lay;
|
||||
@Bind(R.id.host_container)
|
||||
@BindView(R.id.host_container)
|
||||
LinearLayout hostContainer;
|
||||
List<LedDDaemon> ledDDaemons = new ArrayList<>();
|
||||
NsdManager mNsdManager;
|
||||
@@ -108,46 +108,40 @@ public class AddDaemonDialog extends DialogFragment implements DialogInterface.O
|
||||
}
|
||||
});
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mNsdManager.stopServiceDiscovery(AddDaemonDialog.this);
|
||||
AddStripeDialog.instance.onResume();
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v -> {
|
||||
mNsdManager.stopServiceDiscovery(AddDaemonDialog.this);
|
||||
// TODO: AddStripeDialog.instance.onResume();
|
||||
alertDialog.dismiss();
|
||||
});
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String strIp = ip.getText().toString();
|
||||
int port;
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
|
||||
String strIp = ip.getText().toString();
|
||||
int port;
|
||||
|
||||
if (strIp.contains(":")) {
|
||||
strIp = strIp.split(":")[0];
|
||||
try {
|
||||
port = Integer.parseInt(ip.getText().toString().split(":")[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
ip_lay.setError("Please check your port");
|
||||
return;
|
||||
}
|
||||
|
||||
if (port < 1024 || port > 65535) {
|
||||
ip_lay.setError("Port is out of range");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
port = 1425;
|
||||
if (strIp.contains(":")) {
|
||||
strIp = strIp.split(":")[0];
|
||||
try {
|
||||
port = Integer.parseInt(ip.getText().toString().split(":")[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
ip_lay.setError("Please check your port");
|
||||
return;
|
||||
}
|
||||
|
||||
if (InetAddresses.isInetAddress(strIp)) {
|
||||
LedDDaemon daemon = new LedDDaemon(strIp, port);
|
||||
|
||||
if (!ledDDaemons.contains(daemon)) addDaemon(new LedDDaemon(strIp, port));
|
||||
else ip_lay.setError("Daemon already exist");
|
||||
} else {
|
||||
ip_lay.setError("No valid ip address");
|
||||
if (port < 1024 || port > 65535) {
|
||||
ip_lay.setError("Port is out of range");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
port = 1425;
|
||||
}
|
||||
|
||||
if (InetAddresses.isInetAddress(strIp)) {
|
||||
LedDDaemon daemon = new LedDDaemon(strIp, port);
|
||||
|
||||
if (!ledDDaemons.contains(daemon)) addDaemon(new LedDDaemon(strIp, port));
|
||||
else ip_lay.setError("Daemon already exist");
|
||||
} else {
|
||||
ip_lay.setError("No valid ip address");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -195,49 +189,43 @@ public class AddDaemonDialog extends DialogFragment implements DialogInterface.O
|
||||
final LedDDaemon nLedDDaemon = new LedDDaemon(serviceInfo.getHost().getHostAddress(), serviceInfo.getPort());
|
||||
|
||||
if (!ledDDaemons.contains(nLedDDaemon)) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
View v = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout
|
||||
.host_row, hostContainer, false);
|
||||
getActivity().runOnUiThread(() -> {
|
||||
View v = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout
|
||||
.host_row, hostContainer, false);
|
||||
|
||||
|
||||
TextView host = (TextView) v.findViewById(R.id.text_host);
|
||||
TextView host = (TextView) v.findViewById(R.id.text_host);
|
||||
|
||||
host.setText(nLedDDaemon.toString());
|
||||
host.setText(nLedDDaemon.toString());
|
||||
|
||||
if (ColorApplication.getInstance().getDaemons().contains(nLedDDaemon)) {
|
||||
v.setEnabled(false);
|
||||
host.setEnabled(false);
|
||||
}
|
||||
|
||||
View.OnClickListener listener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.isEnabled()) {
|
||||
LedDDaemon d;
|
||||
|
||||
if (v instanceof TextView) {
|
||||
d = (LedDDaemon) ((LinearLayout) v.getParent()).getTag();
|
||||
} else {
|
||||
d = (LedDDaemon) v.getTag();
|
||||
}
|
||||
|
||||
if (d != null) {
|
||||
addDaemon(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
v.setOnClickListener(listener);
|
||||
host.setOnClickListener(listener);
|
||||
|
||||
v.setTag(nLedDDaemon);
|
||||
|
||||
ledDDaemons.add(nLedDDaemon);
|
||||
hostContainer.addView(v);
|
||||
if (ColorApplication.getInstance().getDaemons().contains(nLedDDaemon)) {
|
||||
v.setEnabled(false);
|
||||
host.setEnabled(false);
|
||||
}
|
||||
|
||||
View.OnClickListener listener = v1 -> {
|
||||
if (v1.isEnabled()) {
|
||||
LedDDaemon d;
|
||||
|
||||
if (v1 instanceof TextView) {
|
||||
d = (LedDDaemon) ((LinearLayout) v1.getParent()).getTag();
|
||||
} else {
|
||||
d = (LedDDaemon) v1.getTag();
|
||||
}
|
||||
|
||||
if (d != null) {
|
||||
addDaemon(d);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
v.setOnClickListener(listener);
|
||||
host.setOnClickListener(listener);
|
||||
|
||||
v.setTag(nLedDDaemon);
|
||||
|
||||
ledDDaemons.add(nLedDDaemon);
|
||||
hostContainer.addView(v);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -286,28 +274,18 @@ public class AddDaemonDialog extends DialogFragment implements DialogInterface.O
|
||||
ColorApplication.getInstance().getHelperForDaemon(ledDDaemon).discover(new DiscoverCallback() {
|
||||
@Override
|
||||
public void onConnectionFailed(final String message) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), String.format(getActivity().getString(R.string.snackbar_daemon_connection_failed), ledDDaemon, message), Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
AddStripeDialog.instance.onResume();
|
||||
getActivity().runOnUiThread(() -> Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), String.format(getActivity().getString(R.string.snackbar_daemon_connection_failed), ledDDaemon, message), Snackbar.LENGTH_LONG).show());
|
||||
// TODO: AddStripeDialog.instance.onResume();
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDiscoverSuccessfully(final String version) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0),
|
||||
getActivity().getString(R.string.snackbar_added_daemon_version, version), Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
getActivity().runOnUiThread(() -> Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0),
|
||||
getActivity().getString(R.string.snackbar_added_daemon_version, version), Snackbar.LENGTH_LONG).show());
|
||||
|
||||
((ColorActivity) getActivity()).refreshStripes();
|
||||
AddStripeDialog.instance.onResume();
|
||||
// TODO: AddStripeDialog.instance.onResume();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
@@ -0,0 +1,142 @@
|
||||
package com.idlegandalf.ledd.fragments;
|
||||
|
||||
/*
|
||||
* LEDD Project
|
||||
* Copyright (C) 2015 LEDD Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.idlegandalf.ledd.ColorActivity;
|
||||
import com.idlegandalf.ledd.R;
|
||||
import com.idlegandalf.ledd.components.LedStripe;
|
||||
import com.idlegandalf.ledd.components.Profile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
|
||||
public class AddProfileDialog extends DialogFragment implements DialogInterface.OnShowListener {
|
||||
|
||||
@BindView(R.id.input_profile_name_layout)
|
||||
TextInputLayout nameLayout;
|
||||
@BindView(R.id.input_profile_name)
|
||||
EditText nameText;
|
||||
@BindView(R.id.container_linlay)
|
||||
LinearLayout checkboxContainer;
|
||||
List<LedStripe> mStripes;
|
||||
List<CheckBox> mCheckboxes;
|
||||
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
View v = View.inflate(getActivity(), R.layout.fragment_addprofile, null);
|
||||
ButterKnife.bind(this, v);
|
||||
|
||||
mStripes = ((ColorActivity) getActivity()).getStripes();
|
||||
mCheckboxes = new ArrayList<>();
|
||||
|
||||
if (mStripes != null) {
|
||||
for (LedStripe ledStripe : mStripes) {
|
||||
CheckBox nC = (CheckBox) View.inflate(getActivity(), R.layout.fragment_addprofile_item, null);
|
||||
|
||||
nC.setText(ledStripe.getName());
|
||||
mCheckboxes.add(nC);
|
||||
checkboxContainer.addView(nC);
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setView(v).setPositiveButton("Save", null).setNegativeButton("Cancel", null);
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
|
||||
dialog.setOnShowListener(this);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
|
||||
final AlertDialog alertDialog = (AlertDialog) dialog;
|
||||
|
||||
nameText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
nameLayout.setError(null);
|
||||
}
|
||||
});
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v -> alertDialog.dismiss());
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
|
||||
if (nameText.getText().toString().isEmpty()) {
|
||||
nameLayout.setError("Please enter a name");
|
||||
return;
|
||||
}
|
||||
|
||||
int checked = 0;
|
||||
for (CheckBox c : mCheckboxes) {
|
||||
if (c.isChecked()) {
|
||||
checked++;
|
||||
mStripes.get(checkboxContainer.indexOfChild(c)).getColor();
|
||||
}
|
||||
}
|
||||
|
||||
if (checked < 2) {
|
||||
Toast.makeText(getActivity(), "Please select at least two stripes for your profile", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Profile profile = new Profile(nameText.getText().toString());
|
||||
|
||||
mCheckboxes.stream().filter(CompoundButton::isChecked).forEach(c -> {
|
||||
LedStripe stripe = mStripes.get(checkboxContainer.indexOfChild(c));
|
||||
profile.getValues().append(stripe.getId(), stripe.getColor());
|
||||
});
|
||||
|
||||
((ColorActivity) getActivity()).addProfile(profile);
|
||||
Toast.makeText(getActivity(), "Added profile " + nameText.getText().toString(), Toast.LENGTH_SHORT).show();
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -23,8 +23,6 @@ import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
@@ -39,6 +37,8 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.google.gson.Gson;
|
||||
import com.idlegandalf.ledd.ColorActivity;
|
||||
import com.idlegandalf.ledd.ColorApplication;
|
||||
@@ -54,42 +54,41 @@ import java.text.NumberFormat;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class AddStripeDialog extends DialogFragment implements DialogInterface.OnShowListener {
|
||||
|
||||
public static AddStripeDialog instance;
|
||||
@Bind(R.id.spinner_daemon)
|
||||
@BindView(R.id.spinner_daemon)
|
||||
Spinner daemonSpinner;
|
||||
@Bind(R.id.spinner_controller)
|
||||
@BindView(R.id.spinner_controller)
|
||||
Spinner controllerSpinner;
|
||||
@Bind(R.id.choose_controller_lay)
|
||||
@BindView(R.id.choose_controller_lay)
|
||||
RelativeLayout controllerLayout;
|
||||
@Bind(R.id.input_stripe_name_lay)
|
||||
@BindView(R.id.input_stripe_name_lay)
|
||||
TextInputLayout stripeNameLay;
|
||||
@Bind(R.id.input_stripe_name)
|
||||
@BindView(R.id.input_stripe_name)
|
||||
EditText stripeNameText;
|
||||
@Bind(R.id.input_channel_r_lay)
|
||||
@BindView(R.id.input_channel_r_lay)
|
||||
TextInputLayout channelRLay;
|
||||
@Bind(R.id.input_channel_r)
|
||||
@BindView(R.id.input_channel_r)
|
||||
EditText channelR;
|
||||
@Bind(R.id.input_channel_g_lay)
|
||||
@BindView(R.id.input_channel_g_lay)
|
||||
TextInputLayout channelGLay;
|
||||
@Bind(R.id.input_channel_g)
|
||||
@BindView(R.id.input_channel_g)
|
||||
EditText channelG;
|
||||
@Bind(R.id.input_channel_b_lay)
|
||||
@BindView(R.id.input_channel_b_lay)
|
||||
TextInputLayout channelBLay;
|
||||
@Bind(R.id.input_channel_b)
|
||||
@BindView(R.id.input_channel_b)
|
||||
EditText channelB;
|
||||
@Bind(R.id.stripe_mapping_lay)
|
||||
@BindView(R.id.stripe_mapping_lay)
|
||||
LinearLayout stripeMapping;
|
||||
@Bind(R.id.imgbuttn_togglechannel_r)
|
||||
@BindView(R.id.imgbuttn_togglechannel_r)
|
||||
ImageButton channelRBttn;
|
||||
@Bind(R.id.imgbuttn_togglechannel_g)
|
||||
@BindView(R.id.imgbuttn_togglechannel_g)
|
||||
ImageButton channelGBttn;
|
||||
@Bind(R.id.imgbuttn_togglechannel_b)
|
||||
@BindView(R.id.imgbuttn_togglechannel_b)
|
||||
ImageButton channelBBttn;
|
||||
ArrayAdapter<LedDDaemon> daemonArrayAdapter;
|
||||
ArrayAdapter<Controller> controllerArrayAdapter;
|
||||
@@ -106,7 +105,6 @@ public class AddStripeDialog extends DialogFragment implements DialogInterface.O
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
View v = View.inflate(getActivity(), R.layout.fragment_addstripe, null);
|
||||
ButterKnife.bind(this, v);
|
||||
instance = this;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setView(v).setPositiveButton("Add", null).setNegativeButton("Cancel", null);
|
||||
@@ -205,20 +203,17 @@ public class AddStripeDialog extends DialogFragment implements DialogInterface.O
|
||||
}
|
||||
});
|
||||
|
||||
ImageButton.OnClickListener imgListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.imgbuttn_togglechannel_r:
|
||||
testChannel(channelR, (ImageButton) v);
|
||||
break;
|
||||
case R.id.imgbuttn_togglechannel_g:
|
||||
testChannel(channelG, (ImageButton) v);
|
||||
break;
|
||||
case R.id.imgbuttn_togglechannel_b:
|
||||
testChannel(channelB, (ImageButton) v);
|
||||
break;
|
||||
}
|
||||
ImageButton.OnClickListener imgListener = v -> {
|
||||
switch (v.getId()) {
|
||||
case R.id.imgbuttn_togglechannel_r:
|
||||
testChannel(channelR, (ImageButton) v);
|
||||
break;
|
||||
case R.id.imgbuttn_togglechannel_g:
|
||||
testChannel(channelG, (ImageButton) v);
|
||||
break;
|
||||
case R.id.imgbuttn_togglechannel_b:
|
||||
testChannel(channelB, (ImageButton) v);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -226,71 +221,53 @@ public class AddStripeDialog extends DialogFragment implements DialogInterface.O
|
||||
channelGBttn.setOnClickListener(imgListener);
|
||||
channelBBttn.setOnClickListener(imgListener);
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
alertDialog.dismiss();
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v -> alertDialog.dismiss());
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
|
||||
if (!mDaemonSelected) {
|
||||
Toast.makeText(getActivity(), "Please select Daemon and Controller", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!mDaemonSelected) {
|
||||
Toast.makeText(getActivity(), "Please select Daemon and Controller", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (stripeNameText.getText().toString().isEmpty()) {
|
||||
stripeNameLay.setError("Please set the Stripe name");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stripeNameText.getText().toString().isEmpty()) {
|
||||
stripeNameLay.setError("Please set the Stripe name");
|
||||
return;
|
||||
}
|
||||
if (channelR.getText().toString().isEmpty() || channelG.getText().toString().isEmpty() || channelB.getText().toString().isEmpty()) {
|
||||
Toast.makeText(getActivity(), "Please add mapping for all channels", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (channelR.getText().toString().isEmpty() || channelG.getText().toString().isEmpty() || channelB.getText().toString().isEmpty()) {
|
||||
Toast.makeText(getActivity(), "Please add mapping for all channels", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
LedStripe stripe = new LedStripe(Integer.parseInt(channelR.getText().toString()), Integer.parseInt(channelG.getText().toString()),
|
||||
Integer.parseInt(channelB.getText().toString()), stripeNameText.getText().toString());
|
||||
stripe.setLedDDaemon((LedDDaemon) daemonSpinner.getSelectedItem());
|
||||
stripe.setController((Controller) controllerSpinner.getSelectedItem());
|
||||
|
||||
LedStripe stripe = new LedStripe(Integer.parseInt(channelR.getText().toString()), Integer.parseInt(channelG.getText().toString()),
|
||||
Integer.parseInt(channelB.getText().toString()), stripeNameText.getText().toString());
|
||||
stripe.setLedDDaemon((LedDDaemon) daemonSpinner.getSelectedItem());
|
||||
stripe.setController((Controller) controllerSpinner.getSelectedItem());
|
||||
LedDHelper helper = ColorApplication.getInstance().getHelperForDaemon((LedDDaemon) daemonSpinner.getSelectedItem());
|
||||
|
||||
LedDHelper helper = ColorApplication.getInstance().getHelperForDaemon((LedDDaemon) daemonSpinner.getSelectedItem());
|
||||
if (helper != null) {
|
||||
helper.addStripe(stripe, new AddStripeCallback() {
|
||||
@Override
|
||||
public void onAddSuccessfully(final LedStripe stripe) {
|
||||
ColorActivity activity = ((ColorActivity) getActivity());
|
||||
activity.refreshStripes();
|
||||
|
||||
if (helper != null) {
|
||||
helper.addStripe(stripe, new AddStripeCallback() {
|
||||
@Override
|
||||
public void onAddSuccessfully(final LedStripe stripe) {
|
||||
ColorActivity activity = ((ColorActivity) getActivity());
|
||||
activity.refreshStripes();
|
||||
getActivity().runOnUiThread(() -> Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), String.format(getActivity().getString(R.string.snackbar_added_stripe_id), stripe.getId()), Snackbar.LENGTH_LONG).show());
|
||||
dismiss();
|
||||
}
|
||||
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), String.format(getActivity().getString(R.string.snackbar_added_stripe_id), stripe.getId()), Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
dismiss();
|
||||
}
|
||||
@Override
|
||||
public void onAddFailed(int code, String msg) {
|
||||
|
||||
@Override
|
||||
public void onAddFailed(int code, String msg) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(final String message) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), getActivity().getString(R.string.snackbar_failed_add_stripe) + message, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onConnectionFailed(final String message) {
|
||||
getActivity().runOnUiThread(() -> Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0), getActivity().getString(R.string.snackbar_failed_add_stripe) + message, Snackbar.LENGTH_LONG).show());
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -359,17 +336,14 @@ public class AddStripeDialog extends DialogFragment implements DialogInterface.O
|
||||
super.onResume();
|
||||
ColorApplication.getInstance().onResume();
|
||||
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (daemonArrayAdapter != null) {
|
||||
daemonArrayAdapter.clear();
|
||||
daemonArrayAdapter.addAll(ColorApplication.getInstance().getDaemons());
|
||||
}
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (daemonArrayAdapter != null) {
|
||||
daemonArrayAdapter.clear();
|
||||
daemonArrayAdapter.addAll(ColorApplication.getInstance().getDaemons());
|
||||
}
|
||||
|
||||
if (controllerArrayAdapter != null && mDaemonSelected) {
|
||||
refreshController((LedDDaemon) daemonSpinner.getSelectedItem());
|
||||
}
|
||||
if (controllerArrayAdapter != null && mDaemonSelected) {
|
||||
refreshController((LedDDaemon) daemonSpinner.getSelectedItem());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -409,12 +383,9 @@ public class AddStripeDialog extends DialogFragment implements DialogInterface.O
|
||||
helper.getStripes(new StripesCallback() {
|
||||
@Override
|
||||
public void onSuccess(List<LedStripe> stripes) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
controllerArrayAdapter.addAll(ledDDaemon.getControllers());
|
||||
toggleAll(stripeMapping, true);
|
||||
}
|
||||
getActivity().runOnUiThread(() -> {
|
||||
controllerArrayAdapter.addAll(ledDDaemon.getControllers());
|
||||
toggleAll(stripeMapping, true);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -23,13 +23,11 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idlegandalf.ledd.ColorApplication;
|
||||
import com.idlegandalf.ledd.callbacks.AddControllerCallback;
|
||||
import com.idlegandalf.ledd.callbacks.AddStripeCallback;
|
||||
import com.idlegandalf.ledd.callbacks.DiscoverCallback;
|
||||
import com.idlegandalf.ledd.callbacks.RecieveColorCallback;
|
||||
import com.idlegandalf.ledd.callbacks.ReceiveColorCallback;
|
||||
import com.idlegandalf.ledd.callbacks.StripesCallback;
|
||||
import com.idlegandalf.ledd.components.AnswerTask;
|
||||
import com.idlegandalf.ledd.components.Controller;
|
||||
@@ -53,6 +51,8 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class LedDHelper {
|
||||
final String ACTION_SETCOLOR = "set_color";
|
||||
final String ACTION_GETCOLOR = "get_color";
|
||||
@@ -70,7 +70,7 @@ public class LedDHelper {
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
Log.d(ColorApplication.TAG, "ColorService bound!");
|
||||
Timber.d("ColorService bound!");
|
||||
requestWorker = new Worker<>(dRequests, (ColorService.ColorBinder) service, ledDDaemon);
|
||||
mBound = true;
|
||||
new Thread(requestWorker).start();
|
||||
@@ -215,7 +215,7 @@ public class LedDHelper {
|
||||
*
|
||||
* @param ledStripe Stripe
|
||||
*/
|
||||
public void getColor(final LedStripe ledStripe, final RecieveColorCallback callback) {
|
||||
public void getColor(final LedStripe ledStripe, final ReceiveColorCallback callback) {
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("sid", ledStripe.getId());
|
||||
|
||||
@@ -232,19 +232,18 @@ public class LedDHelper {
|
||||
JSONObject json = new JSONObject(response.getResult().toString());
|
||||
JSONArray hsv = json.getJSONArray("color");
|
||||
if (hsv.length() == 3) {
|
||||
System.out.println(hsv);
|
||||
ledStripe.setColor(new HSV(hsv.getDouble(0), hsv.getDouble(1), hsv.getDouble(2)));
|
||||
callback.onColorRecieved(ledStripe);
|
||||
callback.onColorReceived(ledStripe);
|
||||
} else {
|
||||
callback.onRecievFailed(-1, "HSV was empty");
|
||||
callback.onReceiveFailed(-1, "HSV was empty");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
callback.onRecievFailed(-1, "Unhandeled JSON Exception");
|
||||
callback.onReceiveFailed(-1, "Unhandeled JSON Exception");
|
||||
}
|
||||
} else {
|
||||
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") JSONRPC2Error error = response.getError();
|
||||
callback.onRecievFailed(error.getCode(), error.getMessage());
|
||||
callback.onReceiveFailed(error.getCode(), error.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -31,7 +31,6 @@ import com.koushikdutta.async.AsyncSocket;
|
||||
import com.koushikdutta.async.ByteBufferList;
|
||||
import com.koushikdutta.async.DataEmitter;
|
||||
import com.koushikdutta.async.Util;
|
||||
import com.koushikdutta.async.callback.ConnectCallback;
|
||||
import com.koushikdutta.async.callback.DataCallback;
|
||||
import com.thetransactioncompany.jsonrpc2.JSONRPC2ParseException;
|
||||
import com.thetransactioncompany.jsonrpc2.JSONRPC2Request;
|
||||
@@ -55,7 +54,7 @@ public class ColorService extends Service {
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
return -1;
|
||||
return Service.START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,32 +135,26 @@ public class ColorService extends Service {
|
||||
null);
|
||||
sendableHashMap.put((String) sendable.getRequest().getID(), sendable);
|
||||
if (!poolExecutor.isTerminating() && !poolExecutor.isTerminated())
|
||||
timeoutHashMap.put((String) sendable.getRequest().getID(), poolExecutor.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendable.onNoResponse();
|
||||
timeoutHashMap.remove(sendable.getRequest().getID());
|
||||
sendableHashMap.remove(sendable.getRequest().getID());
|
||||
}
|
||||
timeoutHashMap.put((String) sendable.getRequest().getID(), poolExecutor.schedule(() -> {
|
||||
sendable.onNoResponse();
|
||||
timeoutHashMap.remove(sendable.getRequest().getID());
|
||||
sendableHashMap.remove(sendable.getRequest().getID());
|
||||
}, 1000, TimeUnit.MILLISECONDS));
|
||||
} else {
|
||||
socketHashMap.put(sendable.getRecipient(), null);
|
||||
AsyncServer.getDefault().connectSocket(new InetSocketAddress(sendable.getRecipient().getAddress(), sendable
|
||||
.getRecipient().getPort()), new ConnectCallback() {
|
||||
@Override
|
||||
public void onConnectCompleted(Exception ex, final AsyncSocket socket) {
|
||||
if (ex == null) {
|
||||
socket.setDataCallback(dataCallback);
|
||||
.getRecipient().getPort()), (ex, socket) -> {
|
||||
if (ex == null) {
|
||||
socket.setDataCallback(dataCallback);
|
||||
|
||||
socketHashMap.put(sendable.getRecipient(), socket);
|
||||
socketHashMap.put(sendable.getRecipient(), socket);
|
||||
|
||||
//if (!workQueue.contains(item)) -> needs equals implementation
|
||||
workQueue.add(item);
|
||||
} else {
|
||||
sendable.onConnectionFailed(ex.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
//if (!workQueue.contains(item)) -> needs equals implementation
|
||||
workQueue.add(item);
|
||||
} else {
|
||||
sendable.onConnectionFailed(ex.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
|
@@ -1,146 +0,0 @@
|
||||
package com.idlegandalf.ledd.utils;
|
||||
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.opengl.GLES30;
|
||||
import android.util.Log;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public class GraphicUtils {
|
||||
int fmt;
|
||||
int w;
|
||||
int h;
|
||||
int nBytes;
|
||||
int[] PBOs;
|
||||
int numDownloads = 0;
|
||||
int numPBOs = 0;
|
||||
int dx = 0;
|
||||
IntBuffer pixelBuf;
|
||||
|
||||
public GraphicUtils(int fmt, int w, int h, int xbuff) {
|
||||
if (PBOs != null) {
|
||||
Log.w("LedD", "Already initialized. Not necessary to initialize again; or shutdown first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (xbuff < 1 || xbuff > 10) {
|
||||
Log.w("LedD", "Invalid number of buffers: more then 10 or less then 1 buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
this.fmt = fmt;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.numPBOs = xbuff;
|
||||
|
||||
if (fmt == GLES30.GL_RED || fmt == GLES30.GL_GREEN || fmt == GLES30.GL_BLUE) {
|
||||
this.nBytes = w * h;
|
||||
} else if (fmt == GLES30.GL_RGB) {
|
||||
this.nBytes = w * h * 3;
|
||||
} else if (fmt == GLES30.GL_RGBA) {
|
||||
this.nBytes = w * h * 4;
|
||||
} else {
|
||||
Log.w("LedD", "Unhandled pixel format, use GL_R, GL_RG, GL_RGB or GL_RGBA.");
|
||||
}
|
||||
|
||||
if (this.nBytes == 0) {
|
||||
Log.w("LedD", String.format("Invalid width or height given: %d x %d", w, h));
|
||||
return;
|
||||
}
|
||||
|
||||
PBOs = new int[xbuff];
|
||||
|
||||
pixelBuf = IntBuffer.allocate(nBytes);
|
||||
|
||||
GLES30.glGenBuffers(xbuff, PBOs, 0);
|
||||
|
||||
for (int i = 0; i < xbuff; i++) {
|
||||
GLES30.glBindBuffer(GLES30.GL_PIXEL_PACK_BUFFER, PBOs[i]);
|
||||
GLES30.glBufferData(GLES30.GL_PIXEL_PACK_BUFFER, nBytes, null, GLES30.GL_STREAM_READ);
|
||||
}
|
||||
|
||||
GLES30.glBindBuffer(GLES30.GL_PIXEL_PACK_BUFFER, 0);
|
||||
}
|
||||
|
||||
public void download() {
|
||||
long curNanos = System.nanoTime();
|
||||
|
||||
if (numDownloads < numPBOs) {
|
||||
GLES30.glBindBuffer(GLES30.GL_PIXEL_PACK_BUFFER, PBOs[dx]);
|
||||
GLES30.glReadPixels(0, 0, w, h, fmt, GLES30.GL_UNSIGNED_BYTE, null);
|
||||
Log.d("LedD", String.format("glReadPixels() with pbo: %d", PBOs[dx]));
|
||||
} else {
|
||||
Log.d("LedD", String.format("glMapBuffer() with pbo: %d", PBOs[dx]));
|
||||
|
||||
GLES30.glBindBuffer(GLES30.GL_PIXEL_PACK_BUFFER, PBOs[dx]);
|
||||
GLES30.glBufferData(GLES30.GL_PIXEL_PACK_BUFFER, nBytes, pixelBuf, GLES30.GL_STATIC_READ);
|
||||
|
||||
GLES30.glReadPixels(0, 0, w, h, fmt, GLES30.GL_UNSIGNED_BYTE, null);
|
||||
}
|
||||
|
||||
dx++;
|
||||
dx = dx % numPBOs;
|
||||
|
||||
numDownloads++;
|
||||
if (numDownloads == Integer.MAX_VALUE) {
|
||||
numDownloads = 0;
|
||||
}
|
||||
|
||||
GLES30.glBindBuffer(GLES30.GL_PIXEL_PACK_BUFFER, 0);
|
||||
|
||||
Log.d("LedD", String.format("Download took: %f ms.", ((double) System.nanoTime() - curNanos) / 1000000.0));
|
||||
}
|
||||
|
||||
public Bitmap getCurBufferBitmap() {
|
||||
int[] b = pixelBuf.array();
|
||||
int[] bt = new int[w * h];
|
||||
|
||||
for (int i = 0; i < h; i++) {
|
||||
//remember, that OpenGL bitmap is incompatible with Android bitmap
|
||||
//and so, some correction need.
|
||||
|
||||
for (int j = 0; j < w; j++) {
|
||||
int pix = b[i * w + j];
|
||||
int pb = (pix >> 16) & 0xff;
|
||||
int pr = (pix << 16) & 0x00ff0000;
|
||||
int pix1 = (pix & 0xff00ff00) | pr | pb;
|
||||
bt[(h - i - 1) * w + j] = pix1;
|
||||
}
|
||||
}
|
||||
Bitmap.Config bconfig = Bitmap.Config.RGB_565;
|
||||
|
||||
return Bitmap.createBitmap(bt, w, h, bconfig);
|
||||
}
|
||||
|
||||
public int getAvgBitmapBufferColor() {
|
||||
download();
|
||||
Bitmap bitmap = getCurBufferBitmap();
|
||||
int redBucket = 0;
|
||||
int greenBucket = 0;
|
||||
int blueBucket = 0;
|
||||
int alphaBucket = 0;
|
||||
|
||||
boolean hasAlpha = bitmap.hasAlpha();
|
||||
int pixelCount = bitmap.getWidth() * bitmap.getHeight();
|
||||
int[] pixels = new int[pixelCount];
|
||||
bitmap.getPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
|
||||
for (int y = 0, h = bitmap.getHeight(); y < h; y++) {
|
||||
for (int x = 0, w = bitmap.getWidth(); x < w; x++) {
|
||||
int color = pixels[x + y * w]; // x + y * width
|
||||
redBucket += (color >> 16) & 0xFF; // Color.red
|
||||
greenBucket += (color >> 8) & 0xFF; // Color.greed
|
||||
blueBucket += (color & 0xFF); // Color.blue
|
||||
if (hasAlpha) alphaBucket += (color >>> 24); // Color.alpha
|
||||
}
|
||||
}
|
||||
|
||||
return Color.argb(
|
||||
(hasAlpha) ? (alphaBucket / pixelCount) : 255,
|
||||
redBucket / pixelCount,
|
||||
greenBucket / pixelCount,
|
||||
blueBucket / pixelCount);
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 933 B |
Before Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 347 B |
Before Width: | Height: | Size: 219 B |
Before Width: | Height: | Size: 302 B |
BIN
app/src/main/res/drawable-hdpi/ic_note_black_48dp.png
Normal file
After Width: | Height: | Size: 277 B |
BIN
app/src/main/res/drawable-hdpi/ic_save_black_48dp.png
Normal file
After Width: | Height: | Size: 368 B |
Before Width: | Height: | Size: 411 B |
After Width: | Height: | Size: 638 B |
Before Width: | Height: | Size: 175 B |
Before Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 239 B |
BIN
app/src/main/res/drawable-mdpi/ic_note_black_48dp.png
Normal file
After Width: | Height: | Size: 192 B |
BIN
app/src/main/res/drawable-mdpi/ic_save_black_48dp.png
Normal file
After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 273 B |
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 436 B |
Before Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 355 B |
BIN
app/src/main/res/drawable-xhdpi/ic_note_black_48dp.png
Normal file
After Width: | Height: | Size: 358 B |
BIN
app/src/main/res/drawable-xhdpi/ic_save_black_48dp.png
Normal file
After Width: | Height: | Size: 477 B |
Before Width: | Height: | Size: 465 B |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 347 B |
Before Width: | Height: | Size: 524 B |
Before Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 522 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_note_black_48dp.png
Normal file
After Width: | Height: | Size: 501 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_save_black_48dp.png
Normal file
After Width: | Height: | Size: 696 B |
Before Width: | Height: | Size: 573 B |
After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 436 B |
Before Width: | Height: | Size: 702 B |
Before Width: | Height: | Size: 355 B |
Before Width: | Height: | Size: 653 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_note_black_48dp.png
Normal file
After Width: | Height: | Size: 678 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_save_black_48dp.png
Normal file
After Width: | Height: | Size: 967 B |
Before Width: | Height: | Size: 814 B |
@@ -16,58 +16,26 @@
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
|
||||
<!-- The main content view -->
|
||||
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="?android:attr/actionBarSize"
|
||||
app:titleTextColor="@android:color/black">
|
||||
android:titleTextColor="@android:color/black" />
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<com.larswerkman.holocolorpicker.ColorPicker
|
||||
<com.github.madrapps.HSLColorPicker
|
||||
android:id="@+id/picker"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="25dp"
|
||||
app:color_center_radius="100dp"
|
||||
app:color_pointer_halo_radius="13dp"
|
||||
app:color_pointer_radius="12dp"
|
||||
app:color_wheel_radius="180dp"
|
||||
app:color_wheel_thickness="20dp" />
|
||||
|
||||
<com.larswerkman.holocolorpicker.SaturationBar
|
||||
android:id="@+id/saturationbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="15dp"
|
||||
app:bar_pointer_halo_radius="11dp"
|
||||
app:bar_pointer_radius="10dp"
|
||||
app:bar_thickness="15dp" />
|
||||
|
||||
<com.larswerkman.holocolorpicker.ValueBar
|
||||
android:id="@+id/valuebar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
app:bar_pointer_halo_radius="11dp"
|
||||
app:bar_pointer_radius="10dp"
|
||||
app:bar_thickness="15dp" />
|
||||
android:layout_marginTop="25dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ LEDD Project
|
||||
~ Copyright (C) 2015 LEDD Team
|
||||
~
|
||||
@@ -18,15 +17,16 @@
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minWidth="350dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="15dp">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minWidth="350dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingRight="15dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
@@ -36,68 +36,68 @@
|
||||
android:id="@+id/img_host"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:src="@drawable/ic_developer_board_black_48dp"/>
|
||||
android:src="@drawable/ic_developer_board_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/img_host"
|
||||
android:layout_alignTop="@id/img_host"
|
||||
android:layout_marginLeft="7dp"
|
||||
android:layout_toRightOf="@id/img_host"
|
||||
android:layout_alignBottom="@id/img_host"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_toEndOf="@id/img_host"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_add_controller"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
/>
|
||||
android:textAppearance="?android:textAppearanceMedium" />
|
||||
</RelativeLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/input_i2c_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
app:errorEnabled="true">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/input_i2c"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/hint_i2c_device"
|
||||
android:inputType="number"
|
||||
android:minWidth="350dp"/>
|
||||
android:minWidth="350dp" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/input_address_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
app:errorEnabled="true">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/input_address"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/hint_controller_address"
|
||||
android:minWidth="350dp"/>
|
||||
android:minWidth="350dp" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/input_channel_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
app:errorEnabled="true">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/input_channel"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/hint_channels"
|
||||
android:inputType="number"
|
||||
android:minWidth="350dp"/>
|
||||
android:minWidth="350dp" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ LEDD Project
|
||||
~ Copyright (C) 2015 LEDD Team
|
||||
~
|
||||
@@ -18,15 +17,16 @@
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minWidth="250dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="15dp">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minWidth="250dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="15dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
@@ -36,27 +36,29 @@
|
||||
android:id="@+id/img_host"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:src="@drawable/ic_computer_black_48dp"/>
|
||||
android:src="@drawable/ic_computer_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/img_host"
|
||||
android:layout_alignTop="@id/img_host"
|
||||
android:layout_marginLeft="7dp"
|
||||
android:layout_toRightOf="@id/img_host"
|
||||
android:gravity="center"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_toEndOf="@id/img_host"
|
||||
android:layout_toStartOf="@id/progress_daemon"
|
||||
android:gravity="start|center_vertical"
|
||||
android:text="@string/text_choose_daemon"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
/>
|
||||
android:textAppearance="?android:textAppearanceMedium" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_daemon"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:indeterminate="true"/>
|
||||
android:layout_marginStart="5dp"
|
||||
android:indeterminate="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -70,7 +72,7 @@
|
||||
android:id="@+id/host_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"/>
|
||||
android:orientation="vertical" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
@@ -81,20 +83,20 @@
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/text_or"
|
||||
android:textAppearance="?android:textAppearanceMedium"/>
|
||||
android:textAppearance="?android:textAppearanceMedium" />
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/input_ip_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:errorEnabled="true">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/input_ip"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/hint_daemon_ip_port"
|
||||
android:minWidth="250dp"/>
|
||||
android:minWidth="250dp" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
90
app/src/main/res/layout/fragment_addprofile.xml
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ LEDD Project
|
||||
~ Copyright (C) 2015 LEDD Team
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<LinearLayout 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="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minWidth="350dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="15dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_host"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:src="@drawable/ic_save_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/img_host"
|
||||
android:layout_alignTop="@id/img_host"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_toEndOf="@id/img_host"
|
||||
android:gravity="center"
|
||||
android:text="@string/add_profile"
|
||||
android:textAppearance="?android:textAppearanceMedium" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/choose_stripes_to_include" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_linlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/input_profile_name_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
app:errorEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/input_profile_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/profile_name"
|
||||
android:inputType="text"
|
||||
android:minWidth="350dp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
6
app/src/main/res/layout/fragment_addprofile_item.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp" />
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ LEDD Project
|
||||
~ Copyright (C) 2015 LEDD Team
|
||||
~
|
||||
@@ -18,15 +17,16 @@
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minWidth="250dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="15dp">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minWidth="250dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="15dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
@@ -36,19 +36,19 @@
|
||||
android:id="@+id/img_host"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/ic_computer_black_48dp"/>
|
||||
android:src="@drawable/ic_computer_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/img_host"
|
||||
android:layout_alignTop="@id/img_host"
|
||||
android:layout_marginLeft="7dp"
|
||||
android:layout_toRightOf="@id/img_host"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_toEndOf="@id/img_host"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_choose_daemon"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
/>
|
||||
android:textAppearance="?android:textAppearanceSmall" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -62,20 +62,21 @@
|
||||
android:id="@+id/imgbuttn_adddaemon"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_add_circle_black_48dp"/>
|
||||
android:src="@drawable/ic_add_circle_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner_daemon"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_toLeftOf="@id/imgbuttn_adddaemon"/>
|
||||
android:layout_toStartOf="@id/imgbuttn_adddaemon" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -89,19 +90,19 @@
|
||||
android:id="@+id/img_controller"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/ic_developer_board_black_48dp"/>
|
||||
android:src="@drawable/ic_developer_board_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/img_controller"
|
||||
android:layout_alignTop="@id/img_controller"
|
||||
android:layout_marginLeft="7dp"
|
||||
android:layout_toRightOf="@id/img_controller"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_toEndOf="@id/img_controller"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_choose_controller"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
/>
|
||||
android:textAppearance="?android:textAppearanceSmall" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -115,20 +116,21 @@
|
||||
android:id="@+id/imgbuttn_addcontroller"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_add_circle_black_48dp"/>
|
||||
android:src="@drawable/ic_add_circle_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner_controller"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_toLeftOf="@id/imgbuttn_addcontroller"/>
|
||||
android:layout_toStartOf="@id/imgbuttn_addcontroller" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -141,53 +143,52 @@
|
||||
android:id="@+id/img_stripe"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/ic_wb_iridescent_black_48dp"/>
|
||||
android:src="@drawable/ic_wb_iridescent_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/img_stripe"
|
||||
android:layout_alignTop="@id/img_stripe"
|
||||
android:layout_marginLeft="7dp"
|
||||
android:layout_toRightOf="@id/img_stripe"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_toEndOf="@id/img_stripe"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_stripe_properties"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
/>
|
||||
android:textAppearance="?android:textAppearanceSmall" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/input_stripe_name_lay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="15dp"
|
||||
app:errorEnabled="true">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/input_stripe_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/hint_stripe_name"
|
||||
android:inputType="text"
|
||||
android:minEms="12"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
android:minEms="12" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="9dp"
|
||||
android:layout_marginStart="9dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_channel_mapping"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
/>
|
||||
android:textAppearance="?android:textAppearanceSmall" />
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<LinearLayout
|
||||
@@ -196,79 +197,82 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/input_channel_r_lay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/input_channel_r"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="2"
|
||||
android:hint="@string/hint_channel_r"
|
||||
android:inputType="number"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
android:inputType="number" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imgbuttn_togglechannel_r"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_visibility_off_black_48dp"/>
|
||||
android:src="@drawable/ic_visibility_off_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/input_channel_g_lay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp">
|
||||
android:layout_marginStart="10dp">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/input_channel_g"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="2"
|
||||
android:hint="@string/hint_channel_g"
|
||||
android:inputType="number"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
android:inputType="number" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imgbuttn_togglechannel_g"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_visibility_off_black_48dp"/>
|
||||
android:src="@drawable/ic_visibility_off_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/input_channel_b_lay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp">
|
||||
android:layout_marginStart="10dp">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/input_channel_b"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="2"
|
||||
android:hint="@string/hint_channel_b"
|
||||
android:inputType="number"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
android:inputType="number" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imgbuttn_togglechannel_b"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_visibility_off_black_48dp"/>
|
||||
android:src="@drawable/ic_visibility_off_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ LEDD Project
|
||||
~ Copyright (C) 2015 LEDD Team
|
||||
~
|
||||
@@ -18,31 +17,36 @@
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="7dp">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="7dp"
|
||||
android:focusable="true"
|
||||
tools:ignore="RtlSymmetry">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/ic_developer_board_black_48dp"/>
|
||||
android:src="@drawable/ic_developer_board_black_48dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_host"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:text=""
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:textColor="@color/primaryColorDark"/>
|
||||
android:textColor="@color/primaryColorDark"
|
||||
android:focusable="true" />
|
||||
|
||||
</LinearLayout>
|
@@ -1,86 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ LEDD Project
|
||||
~ Copyright (C) 2015 LEDD Team
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="192dp"
|
||||
android:background="?attr/colorPrimaryDark"
|
||||
android:gravity="bottom"
|
||||
android:padding="16dp"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nvh_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:text="Name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="19sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nvh_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/nvh_name"
|
||||
android:layout_marginTop="15dp"
|
||||
android:text="type"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nvh_mapping"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/nvh_type"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="mapping"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nvh_hex_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/nvh_mapping"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="#hex"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/nhv_delete"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_clear_white_48dp"/>
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_toLeftOf="@id/nhv_delete"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_mode_edit_white_24dp"/>
|
||||
|
||||
</RelativeLayout>
|
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ LEDD Project
|
||||
~ Copyright (C) 2015 LEDD Team
|
||||
~
|
||||
@@ -17,12 +16,11 @@
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<CheckedTextView
|
||||
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
style="?android:attr/spinnerDropDownItemStyle"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:ellipsize="marquee"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/black"/>
|
||||
android:textColor="@android:color/black" />
|
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ LEDD Project
|
||||
~ Copyright (C) 2015 LEDD Team
|
||||
~
|
||||
@@ -17,13 +16,12 @@
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<TextView
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
style="?android:attr/spinnerItemStyle"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:singleLine="true"
|
||||
android:textAlignment="inherit"
|
||||
android:textColor="@android:color/black"/>
|
||||
android:textColor="@android:color/black" />
|
@@ -46,5 +46,8 @@
|
||||
<string name="snackbar_added_daemon_version">Added LedD Daemon version: %1$s</string>
|
||||
<string name="snackbar_added_stripe_id">Added Stripe (Id=%1$d)</string>
|
||||
<string name="snackbar_failed_add_stripe">Failed to add Stripe: </string>
|
||||
<string name="add_profile">Add Profile</string>
|
||||
<string name="choose_stripes_to_include">Choose stripes to include</string>
|
||||
<string name="profile_name">Profile name</string>
|
||||
|
||||
</resources>
|
||||
|
@@ -22,7 +22,7 @@
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="MaterialDrawerTheme.Light.DarkToolbar.TranslucentStatus">
|
||||
<style name="AppBaseTheme" parent="MaterialDrawerTheme.Light.DarkToolbar">
|
||||
<!--
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
|
@@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ LEDD Project
|
||||
~ Copyright (C) 2015 LEDD Team
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="0.0.0.0"
|
||||
android:inputType="phone"
|
||||
android:key="pref_key_host"
|
||||
android:summary="hostip the dameon is running on (restart required)"
|
||||
android:title="IP"/>
|
||||
<EditTextPreference
|
||||
android:defaultValue="8825"
|
||||
android:inputType="phone"
|
||||
android:key="pref_key_port"
|
||||
android:summary="port the dameon is running on (restart required)"
|
||||
android:title="Port"/>
|
||||
<EditTextPreference
|
||||
android:defaultValue="0"
|
||||
android:inputType="phone"
|
||||
android:key="pref_key_chan"
|
||||
android:summary="start channel of the stripe"
|
||||
android:title="Channel"/>
|
||||
|
||||
</PreferenceScreen>
|
11
build.gradle
@@ -16,22 +16,19 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.0.0-beta7'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
}
|
||||
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Sun Nov 30 16:28:30 CET 2014
|
||||
#Sat Dec 01 13:51:30 CET 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||
|
10
gradlew
vendored
Normal file → Executable file
@@ -42,11 +42,6 @@ case "`uname`" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
@@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
@@ -114,6 +109,7 @@ fi
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
|