Skip to content

Commit

Permalink
Fixed import issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sowmen committed Jan 20, 2020
1 parent 47f5316 commit 635c81c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 37 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ dependencies {

implementation project(":draw")
implementation 'com.github.markushi:circlebutton:1.1'
implementation 'com.github.QuadFlask:colorpicker:0.0.15'
implementation 'com.jaredrummler:colorpicker:1.1.0'
}
repositories {
Expand Down
41 changes: 6 additions & 35 deletions app/src/main/java/com/example/painter/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
Expand All @@ -17,21 +16,15 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;

import com.divyanshu.draw.widget.CircleView;
import com.divyanshu.draw.widget.DrawView;
import com.flask.colorpicker.ColorPickerView;
import com.flask.colorpicker.OnColorSelectedListener;
import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
import com.jaredrummler.android.colorpicker.ColorPickerDialog;
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener;

Expand Down Expand Up @@ -63,7 +56,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

draw = (DrawView) findViewById(R.id.drawing);
draw = findViewById(R.id.drawing);

colorSelect = findViewById(R.id.image_draw_color);
colorSelect.setOnClickListener(this);
Expand Down Expand Up @@ -146,32 +139,6 @@ else if (view.getId() == R.id.image_draw_eraser) {
preview.setColor(Color.WHITE);
}
else if(view.getId() == R.id.image_draw_color){
// ColorPickerDialogBuilder
// .with(getApplicationContext())
// .setTitle("Choose color")
// .initialColor(currentColor.toArgb())
// .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
// .density(12)
// .setOnColorSelectedListener(new OnColorSelectedListener() {
// @Override
// public void onColorSelected(int selectedColor) {
// Toast.makeText(getApplicationContext(), "onColorSelected: 0x" + Integer.toHexString(selectedColor), Toast.LENGTH_SHORT).show();
// }
// })
// .setPositiveButton("ok", new ColorPickerClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
// currentColor = Color.valueOf(selectedColor);
// draw.setColor(currentColor.toArgb());
// }
// })
// .setNegativeButton("cancel", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// }
// })
// .build()
// .show();
ColorPickerDialog.newBuilder()
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)
.setAllowPresets(false)
Expand All @@ -184,7 +151,7 @@ else if (view.getId() == R.id.newBtn)
{
AlertDialog.Builder newDialog = new AlertDialog.Builder(this);
newDialog.setTitle("New Drawing");
newDialog.setMessage("Start a new_img drawing? (This will erase your current drawing.)");
newDialog.setMessage("Start a new drawing? (This will erase your current drawing.)");
newDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Expand Down Expand Up @@ -231,8 +198,12 @@ private void toggleToolbar() {
switch (dialogId) {
case DIALOG_ID:
// We got result from the dialog that is shown when clicking on the icon in the action bar.

currentColor = Color.valueOf(color);
draw.setColor(color);
int alpha = (color >> 24) & 0x000000FF;
Log.d("Alpha",color+" "+alpha);
draw.setAlpha(alpha);

break;
}
Expand Down
6 changes: 5 additions & 1 deletion draw/src/main/java/com/divyanshu/draw/widget/DrawView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.divyanshu.draw.widget
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
import android.view.ScaleGestureDetector
import android.view.View
Expand Down Expand Up @@ -101,6 +102,8 @@ class DrawView(context: Context, attrs: AttributeSet) : View(context, attrs) {
}

fun setColor(newColor: Int) {

Log.d("alpha", mPaintOptions.alpha.toString());
@ColorInt
val alphaColor = ColorUtils.setAlphaComponent(newColor, mPaintOptions.alpha)
mPaintOptions.color = alphaColor
Expand All @@ -109,8 +112,9 @@ class DrawView(context: Context, attrs: AttributeSet) : View(context, attrs) {
}
}


fun setAlpha(newAlpha: Int) {
val alpha = (newAlpha*255)/100
val alpha = newAlpha
mPaintOptions.alpha = alpha
setColor(mPaintOptions.color)
}
Expand Down

0 comments on commit 635c81c

Please sign in to comment.