Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'

}
42 changes: 33 additions & 9 deletions app/src/main/java/com/teamtreehouse/colorizer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,41 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.SeekBar;

import com.bumptech.glide.Glide;

public class MainActivity extends AppCompatActivity {
ImageView imageView;
int[] imageResIds = {R.drawable.cuba1, R.drawable.cuba2, R.drawable.cuba3};
int imageIndex = 0;
boolean color = true;
boolean red = true;
boolean green = true;
boolean blue = true;
private ImageView imageView;
private SeekBar saturationSeekBar;
private int[] imageResIds = {R.drawable.cuba1, R.drawable.cuba2, R.drawable.cuba3};
private int imageIndex = 0;
private boolean color = true;
private boolean red = true;
private boolean green = true;
private boolean blue = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = (ImageView)findViewById(R.id.imageView);
saturationSeekBar = (SeekBar)findViewById(R.id.saturationSeekBar);

saturationSeekBar.setOnSeekBarChangeListener(saturationSeekBarListener);

loadImage();
}

private void loadImage() {
Glide.with(this).load(imageResIds[imageIndex]).into(imageView);
}

private void updateSaturation() {
private void updateSaturation(int saturation) {
ColorMatrix colorMatrix = new ColorMatrix();
if (color) {
red = green = blue = true;
colorMatrix.setSaturation(1);
colorMatrix.setSaturation(saturation);
} else {
colorMatrix.setSaturation(0);
}
Expand All @@ -56,4 +62,22 @@ private void updateColors() {
ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
imageView.setColorFilter(colorFilter);
}

/*Add a SeekBar for saturation*/
private final SeekBar.OnSeekBarChangeListener saturationSeekBarListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
updateSaturation(progress);
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
};
}
14 changes: 14 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,18 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<SeekBar
android:id="@+id/saturationSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/imageView" />

</android.support.constraint.ConstraintLayout>