Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 441a2f0

Browse files
committed
Changed colorpicker
1 parent 64fa6eb commit 441a2f0

File tree

4 files changed

+41
-24
lines changed

4 files changed

+41
-24
lines changed

‎app/build.gradle‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ dependencies {
4545
exclude group: "com.android.support"
4646
}
4747
implementation 'com.android.support:support-fragment:28.0.0'
48-
implementation project(':colorpicker')
4948
implementation project(':barcode-reader')
5049

5150
implementation 'com.google.android.gms:play-services-vision:18.0.0'
@@ -55,4 +54,6 @@ dependencies {
5554
implementation 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
5655
implementation 'com.google.zxing:core:3.2.0'
5756
implementation 'com.github.kenglxn.QRGen:android:2.6.0'
57+
58+
implementation 'com.github.QuadFlask:colorpicker:0.0.13'
5859
}

‎app/src/main/java/com/example/chatfull/ChatActivity.java‎

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import android.app.DownloadManager;
44
import android.content.Context;
5+
import android.content.DialogInterface;
56
import android.content.Intent;
67
import android.content.res.TypedArray;
78
import android.database.Cursor;
9+
import android.graphics.Color;
810
import android.net.Uri;
911
import android.os.Bundle;
1012
import android.os.Environment;
@@ -26,9 +28,11 @@
2628
import androidx.appcompat.app.AppCompatActivity;
2729
import androidx.appcompat.widget.Toolbar;
2830

29-
import com.android.colorpicker.ColorPickerDialog;
30-
import com.android.colorpicker.ColorPickerSwatch;
3131
import com.bumptech.glide.Glide;
32+
import com.flask.colorpicker.ColorPickerView;
33+
import com.flask.colorpicker.OnColorSelectedListener;
34+
import com.flask.colorpicker.builder.ColorPickerClickListener;
35+
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
3236
import com.stfalcon.chatkit.commons.ImageLoader;
3337
import com.stfalcon.chatkit.messages.MessageHolders;
3438
import com.stfalcon.chatkit.messages.MessagesList;
@@ -42,8 +46,7 @@
4246
import java.util.Calendar;
4347

4448
public class ChatActivity extends AppCompatActivity
45-
implements ColorPickerSwatch.OnColorSelectedListener,
46-
MessageHolders.ContentChecker<Message>,
49+
implements MessageHolders.ContentChecker<Message>,
4750
MessagesListAdapter.OnMessageLongClickListener<Message> {
4851

4952
private static final int PICK_FILE_REQUEST = 1;
@@ -64,7 +67,6 @@ public class ChatActivity extends AppCompatActivity
6467
ImageButton btnAttachement, btnImage;
6568
EditText input;
6669

67-
ColorPickerDialog colorPickerDialog;
6870
RelativeLayout back_view;
6971
int[] colors;
7072

@@ -125,9 +127,6 @@ public void loadImage(ImageView imageView, @Nullable String url, @Nullable Objec
125127
colors[i] = ta.getColor(i, 0);
126128
}
127129
ta.recycle();
128-
colorPickerDialog = new ColorPickerDialog();
129-
colorPickerDialog.initialize(R.string.color_title, colors, colors[0], 5, colors.length);
130-
colorPickerDialog.setOnColorSelectedListener(this);
131130

132131
adapter.setOnMessageLongClickListener(this);
133132
}
@@ -157,24 +156,42 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
157156
Toast.makeText(getApplicationContext(), "Select All Clicked", Toast.LENGTH_SHORT).show();
158157
break;
159158
case R.id.background_button:
160-
colorPickerDialog.show(getFragmentManager(), "COLOR");
159+
ColorPickerDialogBuilder
160+
.with(this)
161+
.setTitle("Choose color")
162+
.initialColor(Color.WHITE)
163+
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
164+
.density(12)
165+
.setOnColorSelectedListener(new OnColorSelectedListener() {
166+
@Override
167+
public void onColorSelected(int selectedColor) {
168+
Toast.makeText(getApplicationContext(),"onColorSelected: 0x" + Integer.toHexString(selectedColor),Toast.LENGTH_SHORT).show();
169+
}
170+
})
171+
.setPositiveButton("ok", new ColorPickerClickListener() {
172+
@Override
173+
public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
174+
Message message = new Message(Integer.toString(++cnt), me, null, Calendar.getInstance().getTime());
175+
message.setColor(selectedColor);
176+
message.setIsColor(true);
177+
178+
sender = new SendMessage(user.getIpAddress(), user.getPort(), message, ChatActivity.this);
179+
sender.execute();
180+
back_view.setBackgroundColor(selectedColor);
181+
}
182+
})
183+
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
184+
@Override
185+
public void onClick(DialogInterface dialog, int which) {
186+
}
187+
})
188+
.build()
189+
.show();
161190
break;
162191
}
163192
return super.onOptionsItemSelected(item);
164193
}
165194

166-
@Override
167-
public void onColorSelected(int color) {
168-
Message message = new Message(Integer.toString(++cnt), me, null, Calendar.getInstance().getTime());
169-
message.setColor(color);
170-
message.setIsColor(true);
171-
172-
sender = new SendMessage(user.getIpAddress(), user.getPort(), message, this);
173-
sender.execute();
174-
175-
back_view.setBackgroundColor(color);
176-
}
177-
178195
public void onBtnSendClick(View view) {
179196
if (input.getText().toString() == null) return;
180197

‎colorpicker‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎settings.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':app', ':colorpicker', ':barcode-reader'
1+
include ':app', ':barcode-reader'

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /