comparison app/src/main/java/com/five_ten_sg/connectbot/util/UberColorPickerDialog.java @ 457:105815cce146 stable-1.9.3-3

minimum version android 5, target and compile version api 28
author Carl Byington <carl@five-ten-sg.com>
date Tue, 29 Jan 2019 11:21:57 -0800
parents d29cce60f393
children
comparison
equal deleted inserted replaced
456:b00031b2d6ac 457:105815cce146
50 import android.graphics.SweepGradient; 50 import android.graphics.SweepGradient;
51 import android.graphics.drawable.GradientDrawable; 51 import android.graphics.drawable.GradientDrawable;
52 import android.graphics.drawable.GradientDrawable.Orientation; 52 import android.graphics.drawable.GradientDrawable.Orientation;
53 import android.os.Bundle; 53 import android.os.Bundle;
54 import android.util.DisplayMetrics; 54 import android.util.DisplayMetrics;
55 import android.util.FloatMath;
56 import android.view.MotionEvent; 55 import android.view.MotionEvent;
57 import android.view.View; 56 import android.view.View;
58 57
59 /** 58 /**
60 * UberColorPickerDialog is a seriously enhanced version of the UberColorPickerDialog 59 * UberColorPickerDialog is a seriously enhanced version of the UberColorPickerDialog
490 private void initHSV1Palette() { 489 private void initHSV1Palette() {
491 setOvalValDimmer(); 490 setOvalValDimmer();
492 setVerValSlider(); 491 setVerValSlider();
493 float angle = 2 * PI - mHSV[0] / (180 / 3.1415927f); 492 float angle = 2 * PI - mHSV[0] / (180 / 3.1415927f);
494 float radius = mHSV[1] * PALETTE_RADIUS; 493 float radius = mHSV[1] * PALETTE_RADIUS;
495 mCoord[0] = (int)(FloatMath.cos(angle) * radius); 494 mCoord[0] = (int)(Math.cos(angle) * radius);
496 mCoord[1] = (int)(FloatMath.sin(angle) * radius); 495 mCoord[1] = (int)(Math.sin(angle) * radius);
497 mCoord[2] = PALETTE_DIM - (int)(mHSV[2] * PALETTE_DIM); 496 mCoord[2] = PALETTE_DIM - (int)(mHSV[2] * PALETTE_DIM);
498 } 497 }
499 498
500 //NEW_METHOD_WORK_NEEDED_HERE 499 //NEW_METHOD_WORK_NEEDED_HERE
501 //To add a new method, replicate and extend the set functions below, one per UI controller in the new method 500 //To add a new method, replicate and extend the set functions below, one per UI controller in the new method
729 if (mCoord[1] < -PALETTE_RADIUS) 728 if (mCoord[1] < -PALETTE_RADIUS)
730 mCoord[1] = -PALETTE_RADIUS; 729 mCoord[1] = -PALETTE_RADIUS;
731 else if (mCoord[1] > PALETTE_RADIUS) 730 else if (mCoord[1] > PALETTE_RADIUS)
732 mCoord[1] = PALETTE_RADIUS; 731 mCoord[1] = PALETTE_RADIUS;
733 732
734 float radius = FloatMath.sqrt(mCoord[0] * mCoord[0] + mCoord[1] * mCoord[1]); 733 float radius = (float)Math.sqrt(mCoord[0] * mCoord[0] + mCoord[1] * mCoord[1]);
735 734
736 if (radius > PALETTE_RADIUS) 735 if (radius > PALETTE_RADIUS)
737 radius = PALETTE_RADIUS; 736 radius = PALETTE_RADIUS;
738 737
739 float angle = (float)Math.atan2(mCoord[1], mCoord[0]); 738 float angle = (float)Math.atan2(mCoord[1], mCoord[0]);
742 741
743 if (unit < 0) { 742 if (unit < 0) {
744 unit += 1; 743 unit += 1;
745 } 744 }
746 745
747 mCoord[0] = round(FloatMath.cos(angle) * radius); 746 mCoord[0] = round(Math.cos(angle) * radius);
748 mCoord[1] = round(FloatMath.sin(angle) * radius); 747 mCoord[1] = round(Math.sin(angle) * radius);
749 int c = interpColor(mSpectrumColorsRev, unit); 748 int c = interpColor(mSpectrumColorsRev, unit);
750 float[] hsv = new float[3]; 749 float[] hsv = new float[3];
751 Color.colorToHSV(c, hsv); 750 Color.colorToHSV(c, hsv);
752 mHSV[0] = hsv[0]; 751 mHSV[0] = hsv[0];
753 mHSV[1] = radius / PALETTE_RADIUS; 752 mHSV[1] = radius / PALETTE_RADIUS;
848 float circlePinnedY = y - PALETTE_POS_Y - PALETTE_CENTER_Y; 847 float circlePinnedY = y - PALETTE_POS_Y - PALETTE_CENTER_Y;
849 //Is the event in a swatch? 848 //Is the event in a swatch?
850 boolean inSwatchOld = ptInRect(round(x), round(y), mOldSwatchRect); 849 boolean inSwatchOld = ptInRect(round(x), round(y), mOldSwatchRect);
851 boolean inSwatchNew = ptInRect(round(x), round(y), mNewSwatchRect); 850 boolean inSwatchNew = ptInRect(round(x), round(y), mNewSwatchRect);
852 //Get the event's distance from the center of the main 2D palette 851 //Get the event's distance from the center of the main 2D palette
853 float radius = FloatMath.sqrt(circlePinnedX * circlePinnedX + circlePinnedY * circlePinnedY); 852 float radius = (float)Math.sqrt(circlePinnedX * circlePinnedX + circlePinnedY * circlePinnedY);
854 //Is the event in a circle-pinned 2D palette? 853 //Is the event in a circle-pinned 2D palette?
855 boolean inOvalPalette = radius <= PALETTE_RADIUS; 854 boolean inOvalPalette = radius <= PALETTE_RADIUS;
856 855
857 //Pin the radius 856 //Pin the radius
858 if (radius > PALETTE_RADIUS) 857 if (radius > PALETTE_RADIUS)
894 893
895 if (unit < 0) { 894 if (unit < 0) {
896 unit += 1; 895 unit += 1;
897 } 896 }
898 897
899 mCoord[0] = round(FloatMath.cos(angle) * radius); 898 mCoord[0] = round(Math.cos(angle) * radius);
900 mCoord[1] = round(FloatMath.sin(angle) * radius); 899 mCoord[1] = round(Math.sin(angle) * radius);
901 int c = interpColor(mSpectrumColorsRev, unit); 900 int c = interpColor(mSpectrumColorsRev, unit);
902 float[] hsv = new float[3]; 901 float[] hsv = new float[3];
903 Color.colorToHSV(c, hsv); 902 Color.colorToHSV(c, hsv);
904 mHSV[0] = hsv[0]; 903 mHSV[0] = hsv[0];
905 mHSV[1] = radius / PALETTE_RADIUS; 904 mHSV[1] = radius / PALETTE_RADIUS;