Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
9ff32af9f1 | |||
![]() |
9a3b955d32 | ||
![]() |
9739116db6 | ||
![]() |
2211186d9f | ||
![]() |
ce198af0ef | ||
![]() |
2991094f2d | ||
![]() |
aaea03a5c2 | ||
![]() |
7bac6a394a |
@@ -28,7 +28,7 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
|
||||
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
|
||||
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,34 +38,46 @@ apply plugin: 'com.github.ben-manes.versions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '23.0.1'
|
||||
buildToolsVersion '23.0.2'
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.idlegandalf.ledd"
|
||||
minSdkVersion 17
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 23
|
||||
versionCode 2
|
||||
versionName "1.0.1"
|
||||
versionCode 3
|
||||
versionName "1.0.3"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
zipAlignEnabled true
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
debug {
|
||||
zipAlignEnabled true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:23.0.1'
|
||||
compile 'com.android.support:support-v4:23.0.1'
|
||||
compile 'com.squareup.okhttp:okhttp:2.5.0'
|
||||
compile 'com.google.code.gson:gson:2.4'
|
||||
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.6'
|
||||
compile 'com.android.support:design:23.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-rc2'
|
||||
compile 'com.google.guava:guava:19.0'
|
||||
compile 'com.thetransactioncompany:jsonrpc2-base:1.38'
|
||||
provided 'org.projectlombok:lombok:1.16.6'
|
||||
compile('com.mikepenz:materialdrawer:5.1.4@aar') {
|
||||
transitive = true
|
||||
}
|
||||
provided 'org.projectlombok:lombok:1.16.8'
|
||||
}
|
||||
|
BIN
app/libs/holo-color-picker.aar
Normal file
@@ -25,6 +25,7 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||
<uses-feature android:glEsVersion="0x00030000" android:required="true" />
|
||||
|
||||
<application
|
||||
android:name=".ColorApplication"
|
||||
|
@@ -22,25 +22,20 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.widget.Switch;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.idlegandalf.ledd.callbacks.RecieveColorCallback;
|
||||
import com.idlegandalf.ledd.callbacks.StripesCallback;
|
||||
@@ -49,42 +44,47 @@ import com.idlegandalf.ledd.components.LedDDaemon;
|
||||
import com.idlegandalf.ledd.components.LedStripe;
|
||||
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.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.PrimaryDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.SecondarySwitchDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnCheckedChanged;
|
||||
import hugo.weaving.DebugLog;
|
||||
|
||||
public class ColorActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
|
||||
public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerItemClickListener, OnCheckedChangeListener {
|
||||
|
||||
@Bind(R.id.drawer_layout)
|
||||
DrawerLayout mDrawerLayout;
|
||||
@Bind(R.id.main_layout)
|
||||
LinearLayout scrollView;
|
||||
@Bind(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@Bind(R.id.drawer)
|
||||
NavigationView navigationView;
|
||||
@Bind(R.id.picker)
|
||||
ColorPicker colorPicker;
|
||||
@Bind(R.id.saturationbar)
|
||||
SaturationBar saturationBar;
|
||||
@Bind(R.id.valuebar)
|
||||
ValueBar valueBar;
|
||||
@Bind(R.id.switch_onoff)
|
||||
Switch aSwitch;
|
||||
private ActionBarDrawerToggle mDrawerToggle;
|
||||
Drawer mDrawer;
|
||||
private List<IDrawerItem> mDaemons;
|
||||
private refreshDaemonsListener daemonsListener;
|
||||
private List<LedStripe> ledStripes;
|
||||
private LedStripe mCurrentStripe;
|
||||
private LedDHelper mCurrentHelper;
|
||||
private boolean fromOnCreate = true;
|
||||
private double rate = 5.0;
|
||||
private double per = 100.0;
|
||||
private double allowance = rate;
|
||||
private long last_check = System.currentTimeMillis();
|
||||
private boolean autoColorSet = false;
|
||||
private RateLimiter limiter;
|
||||
private boolean isRefreshRunning = false;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -96,7 +96,7 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
|
||||
if (networkInfo == null || !networkInfo.isConnected() || networkInfo.getType() != ConnectivityManager.TYPE_WIFI) {
|
||||
Snackbar.make(mDrawerLayout, R.string.snackbar_no_wlan, Snackbar.LENGTH_INDEFINITE).setAction("RETRY", new View.OnClickListener() {
|
||||
Snackbar.make(scrollView, R.string.snackbar_no_wlan, Snackbar.LENGTH_INDEFINITE).setAction("RETRY", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
refreshStripes();
|
||||
@@ -104,6 +104,9 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
}).show();
|
||||
}
|
||||
|
||||
mDaemons = new ArrayList<>();
|
||||
limiter = new RateLimiter(5.0, 100.0);
|
||||
|
||||
colorPicker.addSaturationBar(saturationBar);
|
||||
colorPicker.addValueBar(valueBar);
|
||||
colorPicker.setShowOldCenterColor(false);
|
||||
@@ -111,36 +114,30 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
colorPicker.setOnColorChangedListener(new ColorPicker.OnColorChangedListener() {
|
||||
@Override
|
||||
public void onColorChanged(int i) {
|
||||
if (mCurrentStripe != null && mCurrentHelper != null && isRateAcceptable() && aSwitch.isChecked()) {
|
||||
setStripeFromColor(i);
|
||||
if (mCurrentStripe != null && limiter.check() && !autoColorSet) {
|
||||
mCurrentStripe.setColor(i);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
setSupportActionBar(toolbar);
|
||||
toolbar.setTitle(R.string.app_name);
|
||||
|
||||
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.app_name, R.string.app_name) {
|
||||
mDrawer = new DrawerBuilder()
|
||||
.withActivity(this)
|
||||
.withToolbar(toolbar)
|
||||
.withOnDrawerItemClickListener(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)
|
||||
)
|
||||
.build();
|
||||
|
||||
/** Called when a drawer has settled in a completely closed state. */
|
||||
public void onDrawerClosed(View view) {
|
||||
// TODO: do things that have to be done here
|
||||
}
|
||||
|
||||
/** Called when a drawer has settled in a completely open state. */
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
// TODO: do things that have to be done here
|
||||
}
|
||||
};
|
||||
|
||||
// set the drawer toggle as the DrawerListener
|
||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||
|
||||
// enable Homebutton navigation to drawer
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
mDrawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);
|
||||
}
|
||||
|
||||
daemonsListener = new refreshDaemonsListener();
|
||||
@@ -155,43 +152,43 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
// Sync the toggle state after onRestoreInstanceState has occurred.
|
||||
mDrawerToggle.syncState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
mDrawerToggle.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Pass the event to ActionBarDrawerToggle, if it returns
|
||||
// true, then it has handled the app icon touch event
|
||||
if (mDrawerToggle.onOptionsItemSelected(item)) {
|
||||
return true;
|
||||
}
|
||||
// Handle your other action bar items...
|
||||
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@OnCheckedChanged(R.id.switch_onoff)
|
||||
public void onOffToggle(boolean checked) {
|
||||
if (mCurrentStripe != null && mCurrentHelper != null) {
|
||||
if (!checked) {
|
||||
HSV nHSV = mCurrentStripe.getColor();
|
||||
nHSV.setValue(0.0);
|
||||
mCurrentStripe.setColor(nHSV);
|
||||
mCurrentHelper.setColor(mCurrentStripe);
|
||||
//colorPicker.setColor(Color.HSVToColor(new float[]{(float) nHSV.getHue(), (float) nHSV.getSaturation(), (float) nHSV.getValue()}));
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
refreshStripes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton buttonView, boolean isChecked) {
|
||||
LedStripe stripe = null;
|
||||
for (LedStripe ledStripe : ledStripes) {
|
||||
if (((int) drawerItem.getTag()) == ledStripe.getId()) {
|
||||
stripe = ledStripe;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (stripe != null) {
|
||||
if (isChecked) {
|
||||
if (stripe == mCurrentStripe) {
|
||||
if (colorPicker.getColor() != Color.BLACK)
|
||||
stripe.setColor(colorPicker.getColor());
|
||||
else {
|
||||
colorPicker.setColor(Color.WHITE);
|
||||
}
|
||||
} else {
|
||||
stripe.setColor(Color.WHITE);
|
||||
}
|
||||
} else {
|
||||
setStripeFromColor(colorPicker.getColor());
|
||||
if (stripe == mCurrentStripe)
|
||||
colorPicker.setColor(Color.BLACK);
|
||||
else
|
||||
stripe.setColor(Color.BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,10 +196,10 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_MENU) {
|
||||
if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
|
||||
mDrawerLayout.closeDrawer(Gravity.LEFT);
|
||||
if (mDrawer.isDrawerOpen()) {
|
||||
mDrawer.closeDrawer();
|
||||
} else {
|
||||
mDrawerLayout.openDrawer(Gravity.LEFT);
|
||||
mDrawer.openDrawer();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -216,7 +213,8 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
ColorApplication.getInstance().teardown();
|
||||
unregisterReceiver(daemonsListener);
|
||||
|
||||
if (mCurrentStripe != null) PreferenceManager.getDefaultSharedPreferences(this).edit().putInt("lastStripe", mCurrentStripe.getId()).commit();
|
||||
if (mCurrentStripe != null)
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit().putInt("lastStripe", mCurrentStripe.getId()).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,68 +235,134 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem menuItem) {
|
||||
int id = menuItem.getItemId();
|
||||
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
|
||||
if (drawerItem.isSelectable()) {
|
||||
|
||||
switch (id) {
|
||||
case R.id.nv_add_stripe:
|
||||
new AddStripeDialog().show(getFragmentManager(), "");
|
||||
return true;
|
||||
case R.id.nv_settings:
|
||||
return true;
|
||||
}
|
||||
if (drawerItem.getTag() instanceof String) {
|
||||
String tag = (String) drawerItem.getTag();
|
||||
|
||||
for (LedStripe stripe : ledStripes) {
|
||||
if (stripe.getName().equals(menuItem.getTitle())) {
|
||||
selectStripe(stripe);
|
||||
return true;
|
||||
if (tag.equals("add_stripe")) {
|
||||
new AddStripeDialog().show(getFragmentManager(), "");
|
||||
return true;
|
||||
} else if (tag.equals("settings")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (drawerItem.getTag() instanceof Integer) {
|
||||
int tag = (int) drawerItem.getTag();
|
||||
|
||||
for (LedStripe stripe : ledStripes) {
|
||||
if (tag == stripe.getId()) {
|
||||
selectStripe(stripe);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void refreshStripes() {
|
||||
reCreateNavigationView(); // need to recreate the navigationview since we can't remove a once added submenu
|
||||
|
||||
final Menu nvMenu = navigationView.getMenu();
|
||||
final int stripeGroup = 42;
|
||||
if (isRefreshRunning)
|
||||
return;
|
||||
isRefreshRunning = true;
|
||||
|
||||
int i = 1;
|
||||
for (final LedDDaemon dDaemon : ColorApplication.getInstance().getDaemons()) {
|
||||
|
||||
LedDHelper helper = ColorApplication.getInstance().getHelperForDaemon(dDaemon);
|
||||
|
||||
if (helper != null) {
|
||||
final int finalI = i;
|
||||
helper.getStripes(new StripesCallback() {
|
||||
@Override
|
||||
public void onSuccess(final List<LedStripe> stripes) {
|
||||
public void onSuccess(List<LedStripe> stripes) {
|
||||
ledStripes = stripes;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SubMenu nDaemonMenu = nvMenu.addSubMenu(Menu.NONE, Menu.NONE, finalI, dDaemon.toString());
|
||||
nDaemonMenu.setGroupCheckable(stripeGroup, true, true);
|
||||
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);
|
||||
}
|
||||
|
||||
ledStripes = stripes;
|
||||
List<IDrawerItem> mStripes = new ArrayList<>();
|
||||
for (LedStripe stripe : ledStripes) {
|
||||
MenuItem sItem = nDaemonMenu.add(stripeGroup, View.generateViewId(), stripe.getId(), stripe.getName());
|
||||
sItem.setIcon(R.drawable.ic_wb_iridescent_black_48dp);
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
for (LedStripe stripe : ledStripes) {
|
||||
stripe.getColor(new RecieveColorCallback() {
|
||||
@Override
|
||||
public void onConnectionFailed(String message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onColorRecieved(LedStripe stripe) {
|
||||
if (stripe.isOn()) {
|
||||
IDrawerItem sItem = findItemForStripe(stripe);
|
||||
|
||||
if (sItem != null) {
|
||||
final SecondarySwitchDrawerItem cItem = (SecondarySwitchDrawerItem) sItem;
|
||||
cItem.withSwitchEnabled(true);
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mDrawer.updateItem(cItem);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecievFailed(int code, String msg) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -319,36 +383,20 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
isRefreshRunning = false;
|
||||
}
|
||||
|
||||
private void reCreateNavigationView() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mDrawerLayout.removeView(navigationView);
|
||||
navigationView = new NavigationView(ColorActivity.this);
|
||||
DrawerLayout.LayoutParams params = new DrawerLayout.LayoutParams(DrawerLayout.LayoutParams.WRAP_CONTENT, DrawerLayout.LayoutParams
|
||||
.MATCH_PARENT);
|
||||
params.gravity = Gravity.START;
|
||||
navigationView.setLayoutParams(params);
|
||||
navigationView.inflateMenu(R.menu.navigation_drawer);
|
||||
navigationView.inflateHeaderView(R.layout.navigation_header);
|
||||
mDrawerLayout.addView(navigationView, params);
|
||||
navigationView.setNavigationItemSelectedListener(ColorActivity.this);
|
||||
mDrawerToggle.syncState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
private void selectStripe(LedStripe stripe) {
|
||||
mCurrentStripe = stripe;
|
||||
mCurrentHelper = ColorApplication.getInstance().getHelperForDaemon(stripe.getLedDDaemon());
|
||||
|
||||
mDrawerLayout.closeDrawer(Gravity.LEFT);
|
||||
toolbar.setTitle(stripe.getName());
|
||||
mCurrentHelper.getColor(mCurrentStripe, new RecieveColorCallback() {
|
||||
autoColorSet = true;
|
||||
mDrawer.closeDrawer();
|
||||
mCurrentStripe.getColor(new RecieveColorCallback() {
|
||||
@Override
|
||||
public void onColorRecieved(LedStripe stripe) {
|
||||
public void onColorRecieved(final LedStripe stripe) {
|
||||
final HSV cColor = stripe.getColor();
|
||||
final int color = Color.HSVToColor(new float[]{(float) cColor.getHue(), (float) cColor.getSaturation(), (float) cColor.getValue()});
|
||||
|
||||
@@ -356,10 +404,13 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
@Override
|
||||
public void run() {
|
||||
colorPicker.setColor(color);
|
||||
if (cColor.getValue() == 0.0) {
|
||||
aSwitch.setChecked(false);
|
||||
} else {
|
||||
aSwitch.setChecked(true);
|
||||
autoColorSet = false;
|
||||
|
||||
if (stripe.isOn()) {
|
||||
IDrawerItem fItem = findItemForStripe(stripe);
|
||||
|
||||
if (fItem != null)
|
||||
((SecondarySwitchDrawerItem) fItem).withSwitchEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -367,40 +418,16 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
|
||||
@Override
|
||||
public void onRecievFailed(int code, String msg) {
|
||||
|
||||
autoColorSet = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(String message) {
|
||||
|
||||
autoColorSet = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isRateAcceptable() {
|
||||
long current = System.currentTimeMillis();
|
||||
long time_passed = current - last_check;
|
||||
last_check = current;
|
||||
allowance += time_passed * (rate / per);
|
||||
if (allowance > rate) {
|
||||
allowance = rate; // throttle
|
||||
}
|
||||
|
||||
if (allowance < 1.0) {
|
||||
return false;
|
||||
} else {
|
||||
allowance -= 1.0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void setStripeFromColor(int color) {
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
mCurrentStripe.setColor(new HSV(hsv[0], hsv[1], hsv[2]));
|
||||
mCurrentHelper.setColor(mCurrentStripe);
|
||||
}
|
||||
|
||||
protected class refreshDaemonsListener extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
@@ -410,4 +437,19 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
private IDrawerItem findItemForStripe(LedStripe stripe) {
|
||||
for (IDrawerItem dItem : mDaemons) {
|
||||
if (((PrimaryDrawerItem) dItem).getSubItems() != null) {
|
||||
for (IDrawerItem sItem : ((PrimaryDrawerItem) dItem).getSubItems()) {
|
||||
if (((int) sItem.getTag()) == stripe.getId()) {
|
||||
return sItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -47,8 +47,8 @@ public class ColorApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
singleton = this;
|
||||
|
||||
singleton = this;
|
||||
ledDHelpers = new HashMap<>();
|
||||
this.onResume();
|
||||
}
|
||||
|
@@ -18,6 +18,13 @@
|
||||
|
||||
package com.idlegandalf.ledd.components;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import com.idlegandalf.ledd.ColorApplication;
|
||||
import com.idlegandalf.ledd.callbacks.RecieveColorCallback;
|
||||
import com.idlegandalf.ledd.helper.LedDHelper;
|
||||
|
||||
import hugo.weaving.DebugLog;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -34,6 +41,7 @@ public class LedStripe {
|
||||
boolean RGB;
|
||||
Controller controller;
|
||||
LedDDaemon ledDDaemon;
|
||||
LedDHelper helper;
|
||||
|
||||
public LedStripe() {
|
||||
this(-1, -1, -1, -1, "");
|
||||
@@ -58,6 +66,38 @@ public class LedStripe {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s<-%s@%s (r=%d;g=%d;b=%d)", name, controller.getAddress(), ledDDaemon, channelRed, channelGreen, channelBlue);
|
||||
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);
|
||||
setColor(new HSV(hsv[0], hsv[1], hsv[2]));
|
||||
}
|
||||
|
||||
public void setColor(HSV color) {
|
||||
checkHelper();
|
||||
this.color = color;
|
||||
|
||||
helper.setColor(this);
|
||||
}
|
||||
|
||||
private void checkHelper() {
|
||||
if (helper == null) {
|
||||
helper = ColorApplication.getInstance().getHelperForDaemon(ledDDaemon);
|
||||
}
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
public void getColor(RecieveColorCallback callback) {
|
||||
checkHelper();
|
||||
|
||||
helper.getColor(this, callback);
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
public boolean isOn() {
|
||||
return color != null && color.getValue() != 0.0;
|
||||
}
|
||||
}
|
@@ -48,6 +48,8 @@ public class Sendable {
|
||||
}
|
||||
|
||||
public void onConnectionFailed(String message) {
|
||||
onAnswer.onConnectionFailed(message);
|
||||
if (onAnswer != null) {
|
||||
onAnswer.onConnectionFailed(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -301,7 +301,8 @@ public class AddDaemonDialog extends DialogFragment implements DialogInterface.O
|
||||
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();
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -231,10 +231,16 @@ public class LedDHelper {
|
||||
try {
|
||||
JSONObject json = new JSONObject(response.getResult().toString());
|
||||
JSONArray hsv = json.getJSONArray("color");
|
||||
ledStripe.setColor(new HSV(hsv.getDouble(0), hsv.getDouble(1), hsv.getDouble(2)));
|
||||
callback.onColorRecieved(ledStripe);
|
||||
if (hsv.length() == 3) {
|
||||
System.out.println(hsv);
|
||||
ledStripe.setColor(new HSV(hsv.getDouble(0), hsv.getDouble(1), hsv.getDouble(2)));
|
||||
callback.onColorRecieved(ledStripe);
|
||||
} else {
|
||||
callback.onRecievFailed(-1, "HSV was empty");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
callback.onRecievFailed(-1, "Unhandeled JSON Exception");
|
||||
}
|
||||
} else {
|
||||
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") JSONRPC2Error error = response.getError();
|
||||
|
@@ -83,12 +83,14 @@ public class ColorService extends Service {
|
||||
@Override
|
||||
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
|
||||
JSONRPC2Response reqIn = null;
|
||||
String dataStr = new String(bb.getAllByteArray());
|
||||
|
||||
try {
|
||||
reqIn = JSONRPC2Response.parse(new String(bb.getAllByteArray()));
|
||||
|
||||
} catch (JSONRPC2ParseException e) {
|
||||
e.printStackTrace();
|
||||
if (!dataStr.isEmpty()) {
|
||||
try {
|
||||
reqIn = JSONRPC2Response.parse(dataStr);
|
||||
} catch (JSONRPC2ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (reqIn != null) {
|
||||
|
146
app/src/main/java/com/idlegandalf/ledd/utils/GraphicUtils.java
Normal file
@@ -0,0 +1,146 @@
|
||||
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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.utils;
|
||||
|
||||
|
||||
public class RateLimiter {
|
||||
private double rate;
|
||||
private double per;
|
||||
private double allowance;
|
||||
private long last_check;
|
||||
|
||||
public RateLimiter(double rate, double per) {
|
||||
this.rate = rate;
|
||||
this.per = per;
|
||||
this.allowance = rate;
|
||||
this.last_check = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean check() {
|
||||
long current = System.currentTimeMillis();
|
||||
long time_passed = current - last_check;
|
||||
last_check = current;
|
||||
allowance += time_passed * (rate / per);
|
||||
if (allowance > rate) {
|
||||
allowance = rate; // throttle
|
||||
}
|
||||
|
||||
if (allowance < 1.0) {
|
||||
return false;
|
||||
} else {
|
||||
allowance -= 1.0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
BIN
app/src/main/res/drawable-hdpi/ic_clear_white_24dp.png
Normal file
After Width: | Height: | Size: 221 B |
BIN
app/src/main/res/drawable-hdpi/ic_mode_edit_white_24dp.png
Normal file
After Width: | Height: | Size: 219 B |
BIN
app/src/main/res/drawable-hdpi/ic_mode_edit_white_48dp.png
Normal file
After Width: | Height: | Size: 302 B |
BIN
app/src/main/res/drawable-hdpi/ic_wb_iridescent_white_48dp.png
Normal file
After Width: | Height: | Size: 411 B |
BIN
app/src/main/res/drawable-mdpi/ic_clear_white_24dp.png
Normal file
After Width: | Height: | Size: 175 B |
BIN
app/src/main/res/drawable-mdpi/ic_mode_edit_white_24dp.png
Normal file
After Width: | Height: | Size: 165 B |
BIN
app/src/main/res/drawable-mdpi/ic_mode_edit_white_48dp.png
Normal file
After Width: | Height: | Size: 239 B |
BIN
app/src/main/res/drawable-mdpi/ic_wb_iridescent_white_48dp.png
Normal file
After Width: | Height: | Size: 273 B |
BIN
app/src/main/res/drawable-xhdpi/ic_clear_white_24dp.png
Normal file
After Width: | Height: | Size: 257 B |
BIN
app/src/main/res/drawable-xhdpi/ic_mode_edit_white_24dp.png
Normal file
After Width: | Height: | Size: 239 B |
BIN
app/src/main/res/drawable-xhdpi/ic_mode_edit_white_48dp.png
Normal file
After Width: | Height: | Size: 355 B |
BIN
app/src/main/res/drawable-xhdpi/ic_wb_iridescent_white_48dp.png
Normal file
After Width: | Height: | Size: 465 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_clear_white_24dp.png
Normal file
After Width: | Height: | Size: 347 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_mode_edit_white_24dp.png
Normal file
After Width: | Height: | Size: 302 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_mode_edit_white_48dp.png
Normal file
After Width: | Height: | Size: 522 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_wb_iridescent_white_48dp.png
Normal file
After Width: | Height: | Size: 573 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_clear_white_24dp.png
Normal file
After Width: | Height: | Size: 436 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_mode_edit_white_24dp.png
Normal file
After Width: | Height: | Size: 355 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_mode_edit_white_48dp.png
Normal file
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 814 B |
@@ -16,73 +16,58 @@
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
android:id="@+id/drawer_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
<!-- The main content view -->
|
||||
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:id="@+id/main_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- The main content view -->
|
||||
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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">
|
||||
|
||||
<LinearLayout
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<com.larswerkman.holocolorpicker.ColorPicker
|
||||
android:id="@+id/picker"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
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" />
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="?android:attr/actionBarSize">
|
||||
<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" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switch_onoff"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"/>
|
||||
<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.support.v7.widget.Toolbar>
|
||||
|
||||
<com.larswerkman.holocolorpicker.ColorPicker
|
||||
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="140dp"
|
||||
app:color_wheel_radius="180dp"
|
||||
app:color_wheel_thickness="30dp"/>
|
||||
|
||||
<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_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_thickness="15dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- The navigation drawer -->
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/drawer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
app:headerLayout="@layout/navigation_header"
|
||||
app:menu="@menu/navigation_drawer"/>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
</LinearLayout>
|
||||
|
@@ -46,7 +46,7 @@
|
||||
android:layout_marginLeft="7dp"
|
||||
android:layout_toRightOf="@id/img_host"
|
||||
android:gravity="center"
|
||||
android:text="Choose Daemon"
|
||||
android:text="@string/text_choose_daemon"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
/>
|
||||
|
||||
|
@@ -26,18 +26,61 @@
|
||||
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="-- stripes infos go here --"
|
||||
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:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
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,35 +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/>.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/nv_add_stripe"
|
||||
android:icon="@drawable/ic_add_circle_black_48dp"
|
||||
android:orderInCategory="51"
|
||||
android:title="@string/text_add_stripe"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nv_settings"
|
||||
android:icon="@drawable/ic_tune_black_48dp"
|
||||
android:orderInCategory="52"
|
||||
android:title="@string/test_settings"/>
|
||||
|
||||
|
||||
</menu>
|
@@ -1,29 +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/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 11+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- API 11 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
@@ -1,30 +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/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 14+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 14+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- API 14 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
@@ -22,7 +22,7 @@
|
||||
Base application theme for API 19+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 19+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<style name="AppBaseTheme" parent="MaterialDrawerTheme.Light.DarkToolbar.TranslucentStatus">
|
||||
<!-- API 19 theme customizations can go here. -->
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
</style>
|
||||
|
@@ -1,30 +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/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 21+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 21+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- API 14 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
@@ -18,6 +18,7 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<color name="primaryColor">#3ae765</color>
|
||||
<color name="primaryColorDark">#69cc59</color>
|
||||
<color name="primaryColor">#3ae88d</color>
|
||||
<color name="primaryColorDark">#327D26</color>
|
||||
<!--- <color name="material_drawer_accent">#</color> -->
|
||||
</resources>
|
@@ -35,7 +35,7 @@
|
||||
<string name="hint_channel_g">G</string>
|
||||
<string name="hint_channel_b">B</string>
|
||||
<string name="text_add_stripe">Add Stripe</string>
|
||||
<string name="test_settings">Settings</string>
|
||||
<string name="text_settings">Settings</string>
|
||||
<string name="snackbar_no_wlan">We currently only support WLAN, please connect to one</string>
|
||||
<string name="snackbar_stripes_reloaded">LED stripes reloaded</string>
|
||||
<string name="snackbar_no_connection_stripes">Couldn\'t get stripes from daemon: </string>
|
||||
@@ -43,7 +43,7 @@
|
||||
<string name="snachbar_added_controller">Added Controller (Id=%1$d)</string>
|
||||
<string name="snackbar_error">Error: </string>
|
||||
<string name="snackbar_daemon_connection_failed">Couldn\'t connect to daemon at %1$s: %2$s</string>
|
||||
<string name="snackbar_added_daemon_version">Added LedD Daemon version: </string>
|
||||
<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>
|
||||
|
||||
|
@@ -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="Theme.AppCompat.Light.NoActionBar">
|
||||
<style name="AppBaseTheme" parent="MaterialDrawerTheme.Light.DarkToolbar.TranslucentStatus">
|
||||
<!--
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
@@ -37,7 +37,14 @@
|
||||
<!-- ...and here we setting appcompat’s color theming attrs -->
|
||||
<item name="colorPrimary">@color/primaryColor</item>
|
||||
<item name="colorPrimaryDark">@color/primaryColorDark</item>
|
||||
<item name="colorAccent">@color/material_drawer_accent</item>
|
||||
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="DrawerArrowStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">
|
||||
<item name="spinBars">true</item>
|
||||
<item name="color">@android:color/black</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
@@ -23,7 +23,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.3.1'
|
||||
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
|
||||
|