Skip to content

Commit

Permalink
updated sample
Browse files Browse the repository at this point in the history
  • Loading branch information
damson committed May 28, 2014
1 parent ab014b7 commit 8f5b1cd
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 205 deletions.
11 changes: 8 additions & 3 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.devddagnet.bright.lib"
android:versionCode="2" android:versionName="0.2">
<manifest
package="com.devddagnet.bright.lib"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="3"
android:versionName="0.3">

<application android:hardwareAccelerated="true" android:allowBackup="true" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true" />

</manifest>
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion '19.0.3'

defaultConfig {
minSdkVersion 8
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class BrightActivity extends FragmentActivity implements ActionBar.TabLis

SectionsPagerAdapter mSectionsPagerAdapter;
ViewPager mViewPager;
ActionBar mActionbar;
ActionBar mActionbar;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.view.ViewGroup;
import android.widget.TextView;

import static com.devddagnet.bright.lib.Bright.Config;

public class MultiColorFragment extends Fragment {

public MultiColorFragment() {
Expand All @@ -31,10 +33,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
TextView textView = (TextView) rootView.getChildAt(i);

final int color = ((ColorDrawable) textView.getBackground()).getColor();
final int luminance = Bright.getBrightness(color);
int luminance = Bright.setup(Config.RELATIVE).brightness(color);
boolean isBright = Bright.getInstance().isBright(luminance);

textView.setText("Bright (" + luminance + ")");
textView.setTextColor(Bright.isBright(luminance) ? Color.BLACK : Color.WHITE);
textView.setTextColor(isBright ? Color.BLACK : Color.WHITE);
}
return rootView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
import android.widget.ImageView;
import android.widget.TextView;

import static com.devddagnet.bright.lib.Bright.Config;

public class PictureFragment extends Fragment implements Transformation, Callback {

private static final String TAG = "BRIGHT";

TextView[] labels = new TextView[5];
int[] luminances = new int[5];
int[] luminances = new int[5];
ImageView mPicture;
Bright.Luminance bright = Bright.setup(Config.PERCEIVED | Config.PERFORMANCE);

public PictureFragment() {
}
Expand Down Expand Up @@ -62,11 +65,11 @@ public void onSuccess() {
for (int i = 0; i < labels.length; ++i) {
int luminance = luminances[i];
TextView label = labels[i];
final int textColor = Bright.isBright(luminance) ? Color.BLACK
final int textColor = bright.isBright(luminance) ? Color.BLACK
: Color.WHITE;

label.setTextColor(textColor);
label.setText("Bright (" + luminance + ")");
label.setText("Bright (" + (int) luminance + ")");
}
}

Expand All @@ -86,8 +89,7 @@ public Bitmap transform(Bitmap source) {
int height = label.getHeight();

Bitmap dest = Bitmap.createBitmap(source, x, y, width, height);
int[] rgb = Bright.averageRGB(dest);
luminances[i] = Bright.getBrightness(rgb);
luminances[i] = bright.brightness(dest);
dest.recycle();
}
return source;
Expand Down
Loading

0 comments on commit 8f5b1cd

Please sign in to comment.