diff --git a/app/build.gradle b/app/build.gradle
index 5e7368b..28a45e1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -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'
}
}
@@ -46,10 +46,10 @@ android {
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 {
@@ -57,7 +57,7 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
-
+
debug {
zipAlignEnabled true
}
@@ -66,15 +66,18 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
- compile 'com.android.support:appcompat-v7:23.1.1'
- compile 'com.android.support:support-v4:23.1.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.1.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'
}
diff --git a/app/libs/holo-color-picker.aar b/app/libs/holo-color-picker.aar
new file mode 100644
index 0000000..692c3ee
Binary files /dev/null and b/app/libs/holo-color-picker.aar differ
diff --git a/app/libs/holo-color-picker_ledd_version.aar b/app/libs/holo-color-picker_ledd_version.aar
deleted file mode 100644
index ee686e1..0000000
Binary files a/app/libs/holo-color-picker_ledd_version.aar and /dev/null differ
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e505294..b563199 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -25,6 +25,7 @@
+
mDaemons;
private refreshDaemonsListener daemonsListener;
private List ledStripes;
private LedStripe mCurrentStripe;
private boolean fromOnCreate = true;
private boolean autoColorSet = false;
private RateLimiter limiter;
- private View headerLayout;
+ private boolean isRefreshRunning = false;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -97,21 +92,11 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
setContentView(R.layout.activity_color);
ButterKnife.bind(this);
- headerLayout = navigationView.getHeaderView(0);
- mStripeName = ButterKnife.findById(headerLayout, R.id.nvh_name);
- System.out.println("name: " + mStripeName.getText().toString());
- mStripeType = ButterKnife.findById(headerLayout, R.id.nvh_type);
- System.out.println("type: " + mStripeType.getText().toString());
- mStripeHex = ButterKnife.findById(headerLayout, R.id.nvh_hex_color);
- System.out.println("hex: " + mStripeHex.getText().toString());
- mStripeMapping = ButterKnife.findById(headerLayout, R.id.nvh_mapping);
- System.out.println("mapping: " + mStripeMapping.getText().toString());
-
// 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(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();
@@ -119,6 +104,7 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
}).show();
}
+ mDaemons = new ArrayList<>();
limiter = new RateLimiter(5.0, 100.0);
colorPicker.addSaturationBar(saturationBar);
@@ -128,37 +114,30 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
colorPicker.setOnColorChangedListener(new ColorPicker.OnColorChangedListener() {
@Override
public void onColorChanged(int i) {
- if (mCurrentStripe != null && limiter.check() && aSwitch.isChecked() && !autoColorSet) {
+ if (mCurrentStripe != null && limiter.check() && !autoColorSet) {
mCurrentStripe.setColor(i);
- mStripeHex.setText(String.format("#%06X", (0xFFFFFF & 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();
@@ -173,46 +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) {
- if (!checked) {
- HSV nHSV = mCurrentStripe.getColor();
- if (nHSV != null) {
- nHSV.setValue(0.0);
- mCurrentStripe.setColor(nHSV);
+ @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 {
- mCurrentStripe.setColor(Color.BLACK);
+ stripe.setColor(Color.WHITE);
}
- //colorPicker.setColor(Color.HSVToColor(new float[]{(float) nHSV.getHue(), (float) nHSV.getSaturation(), (float) nHSV.getValue()}));
} else {
- mCurrentStripe.setColor(colorPicker.getColor());
+ if (stripe == mCurrentStripe)
+ colorPicker.setColor(Color.BLACK);
+ else
+ stripe.setColor(Color.BLACK);
}
}
}
@@ -220,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;
@@ -237,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
@@ -258,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 stripes) {
+ public void onSuccess(List 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 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
@@ -340,41 +383,20 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
i++;
}
- }
- 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();
- }
- });
+ isRefreshRunning = false;
}
@DebugLog
private void selectStripe(LedStripe stripe) {
mCurrentStripe = stripe;
- mStripeName.setText(stripe.getName());
- System.out.println("name: " + mStripeName.getText().toString());
- mStripeMapping.setText(String.format("R: %d - G: %d - B: %d", stripe.getChannelRed(), stripe.getChannelGreen(), stripe.getChannelBlue()));
- headerLayout.invalidate();
- mDrawerLayout.closeDrawer(Gravity.LEFT);
toolbar.setTitle(stripe.getName());
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()});
@@ -384,10 +406,11 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
colorPicker.setColor(color);
autoColorSet = false;
- if (cColor.getValue() == 0.0) {
- aSwitch.setChecked(false);
- } else {
- aSwitch.setChecked(true);
+ if (stripe.isOn()) {
+ IDrawerItem fItem = findItemForStripe(stripe);
+
+ if (fItem != null)
+ ((SecondarySwitchDrawerItem) fItem).withSwitchEnabled(true);
}
}
});
@@ -414,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;
+ }
}
diff --git a/app/src/main/java/com/idlegandalf/ledd/ColorApplication.java b/app/src/main/java/com/idlegandalf/ledd/ColorApplication.java
index f9cf234..a9a40e9 100644
--- a/app/src/main/java/com/idlegandalf/ledd/ColorApplication.java
+++ b/app/src/main/java/com/idlegandalf/ledd/ColorApplication.java
@@ -47,8 +47,8 @@ public class ColorApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
- singleton = this;
+ singleton = this;
ledDHelpers = new HashMap<>();
this.onResume();
}
diff --git a/app/src/main/java/com/idlegandalf/ledd/components/LedStripe.java b/app/src/main/java/com/idlegandalf/ledd/components/LedStripe.java
index 48590c0..409f1ce 100644
--- a/app/src/main/java/com/idlegandalf/ledd/components/LedStripe.java
+++ b/app/src/main/java/com/idlegandalf/ledd/components/LedStripe.java
@@ -95,4 +95,9 @@ public class LedStripe {
helper.getColor(this, callback);
}
+
+ @DebugLog
+ public boolean isOn() {
+ return color != null && color.getValue() != 0.0;
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/idlegandalf/ledd/utils/GraphicUtils.java b/app/src/main/java/com/idlegandalf/ledd/utils/GraphicUtils.java
new file mode 100644
index 0000000..56d1cee
--- /dev/null
+++ b/app/src/main/java/com/idlegandalf/ledd/utils/GraphicUtils.java
@@ -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);
+ }
+}
diff --git a/app/src/main/res/drawable-hdpi/ic_wb_iridescent_white_48dp.png b/app/src/main/res/drawable-hdpi/ic_wb_iridescent_white_48dp.png
new file mode 100644
index 0000000..1d2a4bf
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_wb_iridescent_white_48dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_wb_iridescent_white_48dp.png b/app/src/main/res/drawable-mdpi/ic_wb_iridescent_white_48dp.png
new file mode 100644
index 0000000..0e7543d
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_wb_iridescent_white_48dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_wb_iridescent_white_48dp.png b/app/src/main/res/drawable-xhdpi/ic_wb_iridescent_white_48dp.png
new file mode 100644
index 0000000..e7058c5
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_wb_iridescent_white_48dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_wb_iridescent_white_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_wb_iridescent_white_48dp.png
new file mode 100644
index 0000000..3389ccc
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_wb_iridescent_white_48dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_wb_iridescent_white_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_wb_iridescent_white_48dp.png
new file mode 100644
index 0000000..638499a
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_wb_iridescent_white_48dp.png differ
diff --git a/app/src/main/res/layout/activity_color.xml b/app/src/main/res/layout/activity_color.xml
index 4e21b0a..611118f 100644
--- a/app/src/main/res/layout/activity_color.xml
+++ b/app/src/main/res/layout/activity_color.xml
@@ -16,85 +16,58 @@
~ along with this program. If not, see .
-->
-
+
+
+
+ android:id="@+id/main_layout"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:fitsSystemWindows="true"
+ 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" />
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
diff --git a/app/src/main/res/menu/navigation_drawer.xml b/app/src/main/res/menu/navigation_drawer.xml
deleted file mode 100644
index 3103fae..0000000
--- a/app/src/main/res/menu/navigation_drawer.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/values-v11/styles.xml b/app/src/main/res/values-v11/styles.xml
deleted file mode 100644
index f61a03d..0000000
--- a/app/src/main/res/values-v11/styles.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/values-v14/styles.xml b/app/src/main/res/values-v14/styles.xml
deleted file mode 100644
index 5cec8a8..0000000
--- a/app/src/main/res/values-v14/styles.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/values-v19/styles.xml b/app/src/main/res/values-v19/styles.xml
index b444b87..f92e4eb 100644
--- a/app/src/main/res/values-v19/styles.xml
+++ b/app/src/main/res/values-v19/styles.xml
@@ -22,7 +22,7 @@
Base application theme for API 19+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 19+ devices.
-->
-
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
deleted file mode 100644
index fcf4827..0000000
--- a/app/src/main/res/values-v21/styles.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/values/color.xml b/app/src/main/res/values/color.xml
index d1837a3..15c1235 100644
--- a/app/src/main/res/values/color.xml
+++ b/app/src/main/res/values/color.xml
@@ -20,4 +20,5 @@
#3ae88d
#327D26
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6a58f9d..b395c0d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -35,7 +35,7 @@
G
B
Add Stripe
- Settings
+ Settings
We currently only support WLAN, please connect to one
LED stripes reloaded
Couldn\'t get stripes from daemon:
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index db20e05..eb5437d 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -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.
-->
-
+
+
diff --git a/build.gradle b/build.gradle
index aac6a05..372e9c5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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