use of android.graphics.Color in project mapbox-plugins-android by mapbox.
the class CircleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_annotation);
TextView draggableInfoTv = findViewById(R.id.draggable_position_tv);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
findViewById(R.id.fabStyles).setOnClickListener(v -> mapboxMap.setStyle(Utils.INSTANCE.getNextStyle()));
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(2));
// create circle manager
circleManager = new CircleManager(mapView, mapboxMap, style);
circleManager.addClickListener(circle -> {
Toast.makeText(CircleActivity.this, String.format("Circle clicked %s", circle.getId()), Toast.LENGTH_SHORT).show();
return false;
});
circleManager.addLongClickListener(circle -> {
Toast.makeText(CircleActivity.this, String.format("Circle long clicked %s", circle.getId()), Toast.LENGTH_SHORT).show();
return false;
});
// create a fixed circle
CircleOptions circleOptions = new CircleOptions().withLatLng(new LatLng(6.687337, 0.381457)).withCircleColor(ColorUtils.colorToRgbaString(Color.YELLOW)).withCircleRadius(12f).withDraggable(true);
circleManager.create(circleOptions);
// random add circles across the globe
List<CircleOptions> circleOptionsList = new ArrayList<>();
for (int i = 0; i < 20; i++) {
int color = Color.argb(255, random.nextInt(256), random.nextInt(256), random.nextInt(256));
circleOptionsList.add(new CircleOptions().withLatLng(createRandomLatLng()).withCircleColor(ColorUtils.colorToRgbaString(color)).withCircleRadius(8f).withDraggable(true));
}
circleManager.create(circleOptionsList);
try {
circleManager.create(Utils.INSTANCE.loadStringFromAssets(this, "annotations.json"));
} catch (IOException e) {
throw new RuntimeException("Unable to parse annotations.json");
}
circleManager.addDragListener(new OnCircleDragListener() {
@Override
public void onAnnotationDragStarted(Circle annotation) {
draggableInfoTv.setVisibility(View.VISIBLE);
}
@Override
public void onAnnotationDrag(Circle annotation) {
draggableInfoTv.setText(String.format(Locale.US, "ID: %s\nLatLng:%f, %f", annotation.getId(), annotation.getLatLng().getLatitude(), annotation.getLatLng().getLongitude()));
}
@Override
public void onAnnotationDragFinished(Circle annotation) {
draggableInfoTv.setVisibility(View.GONE);
}
});
}));
}
use of android.graphics.Color in project Slide by ccrama.
the class CommentAdapter method setCommentStateHighlighted.
public void setCommentStateHighlighted(final CommentViewHolder holder, final Comment n, final CommentNode baseNode, boolean isReplying, boolean animate) {
if (currentlySelected != null && currentlySelected != holder) {
setCommentStateUnhighlighted(currentlySelected, currentBaseNode, true);
}
if (mContext instanceof BaseActivity) {
((BaseActivity) mContext).setShareUrl("https://reddit.com" + submission.getPermalink() + n.getFullName() + "?context=3");
}
// and expand to show all children comments
if (SettingValues.swap && holder.firstTextView.getVisibility() == View.GONE && !isReplying) {
hiddenPersons.remove(n.getFullName());
unhideAll(baseNode, holder.getBindingAdapterPosition() + 1);
if (toCollapse.contains(n.getFullName()) && SettingValues.collapseComments) {
setViews(n.getDataNode().get("body_html").asText(), submission.getSubredditName(), holder);
}
CommentAdapterHelper.hideChildrenObject(holder.childrenNumber);
holder.commentOverflow.setVisibility(View.VISIBLE);
toCollapse.remove(n.getFullName());
} else {
currentlySelected = holder;
currentBaseNode = baseNode;
int color = Palette.getColor(n.getSubredditName());
currentSelectedItem = n.getFullName();
currentNode = baseNode;
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
resetMenu(holder.menuArea, false);
final View baseView = inflater.inflate(SettingValues.rightHandedCommentMenu ? R.layout.comment_menu_right_handed : R.layout.comment_menu, holder.menuArea);
if (!isReplying) {
baseView.setVisibility(View.GONE);
if (animate) {
expand(baseView);
} else {
baseView.setVisibility(View.VISIBLE);
final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
baseView.measure(widthSpec, heightSpec);
View l2 = baseView.findViewById(R.id.replyArea) == null ? baseView.findViewById(R.id.innerSend) : baseView.findViewById(R.id.replyArea);
final int widthSpec2 = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
final int heightSpec2 = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
l2.measure(widthSpec2, heightSpec2);
ViewGroup.LayoutParams layoutParams = baseView.getLayoutParams();
layoutParams.height = baseView.getMeasuredHeight() - l2.getMeasuredHeight();
baseView.setLayoutParams(layoutParams);
}
}
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams();
params.setMargins(0, 0, 0, 0);
holder.itemView.setLayoutParams(params);
View reply = baseView.findViewById(R.id.reply);
View send = baseView.findViewById(R.id.send);
final View menu = baseView.findViewById(R.id.menu);
final View replyArea = baseView.findViewById(R.id.replyArea);
final View more = baseView.findViewById(R.id.more);
final ImageView upvote = baseView.findViewById(R.id.upvote);
final ImageView downvote = baseView.findViewById(R.id.downvote);
View discard = baseView.findViewById(R.id.discard);
final EditText replyLine = baseView.findViewById(R.id.replyLine);
final ImageView mod = baseView.findViewById(R.id.mod);
final Comment comment = baseNode.getComment();
if (ActionStates.getVoteDirection(comment) == VoteDirection.UPVOTE) {
BlendModeUtil.tintImageViewAsModulate(upvote, holder.textColorUp);
upvote.setContentDescription(mContext.getResources().getString(R.string.btn_upvoted));
} else if (ActionStates.getVoteDirection(comment) == VoteDirection.DOWNVOTE) {
BlendModeUtil.tintImageViewAsModulate(downvote, holder.textColorDown);
downvote.setContentDescription(mContext.getResources().getString(R.string.btn_downvoted));
} else {
downvote.clearColorFilter();
downvote.setContentDescription(mContext.getResources().getString(R.string.btn_downvote));
upvote.clearColorFilter();
upvote.setContentDescription(mContext.getResources().getString(R.string.btn_upvote));
}
try {
if (UserSubscriptions.modOf.contains(submission.getSubredditName())) {
// todo
mod.setVisibility(View.GONE);
} else {
mod.setVisibility(View.GONE);
}
} catch (Exception e) {
Log.d(LogUtil.getTag(), "Error loading mod " + e.toString());
}
if (UserSubscriptions.modOf != null && UserSubscriptions.modOf.contains(submission.getSubredditName().toLowerCase(Locale.ENGLISH))) {
mod.setVisibility(View.VISIBLE);
final Map<String, Integer> reports = comment.getUserReports();
final Map<String, String> reports2 = comment.getModeratorReports();
if (reports.size() + reports2.size() > 0) {
BlendModeUtil.tintImageViewAsSrcAtop(mod, ContextCompat.getColor(mContext, R.color.md_red_300));
} else {
BlendModeUtil.tintImageViewAsSrcAtop(mod, Color.WHITE);
}
mod.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
CommentAdapterHelper.showModBottomSheet(CommentAdapter.this, mContext, baseNode, comment, holder, reports, reports2);
}
});
} else {
mod.setVisibility(View.GONE);
}
final ImageView edit = baseView.findViewById(R.id.edit);
if (Authentication.name != null && Authentication.name.toLowerCase(Locale.ENGLISH).equals(comment.getAuthor().toLowerCase(Locale.ENGLISH)) && Authentication.didOnline) {
edit.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
CommentAdapterHelper.doCommentEdit(CommentAdapter.this, mContext, fm, baseNode, baseNode.isTopLevel() ? submission.getSelftext() : baseNode.getParent().getComment().getBody(), holder);
}
});
} else {
edit.setVisibility(View.GONE);
}
final ImageView delete = baseView.findViewById(R.id.delete);
if (Authentication.name != null && Authentication.name.toLowerCase(Locale.ENGLISH).equals(comment.getAuthor().toLowerCase(Locale.ENGLISH)) && Authentication.didOnline) {
delete.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
CommentAdapterHelper.deleteComment(CommentAdapter.this, mContext, baseNode, holder);
}
});
} else {
delete.setVisibility(View.GONE);
}
if (Authentication.isLoggedIn && !submission.isArchived() && !submission.isLocked() && !(comment.getDataNode().has("locked") && comment.getDataNode().get("locked").asBoolean()) && !deleted.contains(n.getFullName()) && !comment.getAuthor().equals("[deleted]") && Authentication.didOnline) {
if (isReplying) {
baseView.setVisibility(View.VISIBLE);
final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
baseView.measure(widthSpec, heightSpec);
View l2 = baseView.findViewById(R.id.replyArea) == null ? baseView.findViewById(R.id.innerSend) : baseView.findViewById(R.id.replyArea);
final int widthSpec2 = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
final int heightSpec2 = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
l2.measure(widthSpec2, heightSpec2);
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) baseView.getLayoutParams();
params2.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
params2.addRule(RelativeLayout.BELOW, R.id.commentOverflow);
baseView.setLayoutParams(params2);
replyArea.setVisibility(View.VISIBLE);
menu.setVisibility(View.GONE);
currentlyEditing = replyLine;
currentlyEditing.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
mPage.fastScroll.setVisibility(View.GONE);
if (mPage.fab != null) {
mPage.fab.setVisibility(View.GONE);
}
mPage.overrideFab = true;
} else if (SettingValues.fastscroll) {
mPage.fastScroll.setVisibility(View.VISIBLE);
if (mPage.fab != null) {
mPage.fab.setVisibility(View.VISIBLE);
}
mPage.overrideFab = false;
}
}
});
final TextView profile = baseView.findViewById(R.id.profile);
changedProfile = Authentication.name;
profile.setText("/u/" + changedProfile);
profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final HashMap<String, String> accounts = new HashMap<>();
for (String s : Authentication.authentication.getStringSet("accounts", new HashSet<String>())) {
if (s.contains(":")) {
accounts.put(s.split(":")[0], s.split(":")[1]);
} else {
accounts.put(s, "");
}
}
final ArrayList<String> keys = new ArrayList<>(accounts.keySet());
final int i = keys.indexOf(changedProfile);
new AlertDialog.Builder(mContext).setTitle(R.string.sorting_choose).setSingleChoiceItems(keys.toArray(new String[0]), i, (dialog, which) -> {
changedProfile = keys.get(which);
profile.setText("/u/" + changedProfile);
}).setNegativeButton(R.string.btn_cancel, null).show();
}
});
replyLine.requestFocus();
KeyboardUtil.toggleKeyboard(mContext, InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
currentlyEditingId = n.getFullName();
replyLine.setText(backedText);
replyLine.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
backedText = s.toString();
}
});
editingPosition = holder.getBindingAdapterPosition();
}
reply.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
expandAndSetParams(baseView);
// If the base theme is Light or Sepia, tint the Editor actions to be white
if (SettingValues.currentTheme == 1 || SettingValues.currentTheme == 5) {
final ImageView saveDraft = (ImageView) replyArea.findViewById(R.id.savedraft);
final ImageView draft = (ImageView) replyArea.findViewById(R.id.draft);
final ImageView imagerep = (ImageView) replyArea.findViewById(R.id.imagerep);
final ImageView link = (ImageView) replyArea.findViewById(R.id.link);
final ImageView bold = (ImageView) replyArea.findViewById(R.id.bold);
final ImageView italics = (ImageView) replyArea.findViewById(R.id.italics);
final ImageView bulletlist = (ImageView) replyArea.findViewById(R.id.bulletlist);
final ImageView numlist = (ImageView) replyArea.findViewById(R.id.numlist);
final ImageView draw = (ImageView) replyArea.findViewById(R.id.draw);
final ImageView quote = (ImageView) replyArea.findViewById(R.id.quote);
final ImageView size = (ImageView) replyArea.findViewById(R.id.size);
final ImageView strike = (ImageView) replyArea.findViewById(R.id.strike);
final ImageView author = (ImageView) replyArea.findViewById(R.id.author);
final ImageView spoiler = (ImageView) replyArea.findViewById(R.id.spoiler);
final List<ImageView> imageViewSet = Arrays.asList(saveDraft, draft, imagerep, link, bold, italics, bulletlist, numlist, draw, quote, size, strike, author, spoiler);
BlendModeUtil.tintImageViewsAsSrcAtop(imageViewSet, Color.WHITE);
BlendModeUtil.tintDrawableAsSrcIn(replyLine.getBackground(), Color.WHITE);
}
replyArea.setVisibility(View.VISIBLE);
menu.setVisibility(View.GONE);
currentlyEditing = replyLine;
DoEditorActions.doActions(currentlyEditing, replyArea, fm, (Activity) mContext, comment.getBody(), getParents(baseNode));
currentlyEditing.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
mPage.fastScroll.setVisibility(View.GONE);
if (mPage.fab != null)
mPage.fab.setVisibility(View.GONE);
mPage.overrideFab = true;
} else if (SettingValues.fastscroll) {
mPage.fastScroll.setVisibility(View.VISIBLE);
if (mPage.fab != null)
mPage.fab.setVisibility(View.VISIBLE);
mPage.overrideFab = false;
}
}
});
final TextView profile = baseView.findViewById(R.id.profile);
changedProfile = Authentication.name;
profile.setText("/u/" + changedProfile);
profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final HashMap<String, String> accounts = new HashMap<>();
for (String s : Authentication.authentication.getStringSet("accounts", new HashSet<String>())) {
if (s.contains(":")) {
accounts.put(s.split(":")[0], s.split(":")[1]);
} else {
accounts.put(s, "");
}
}
final ArrayList<String> keys = new ArrayList<>(accounts.keySet());
final int i = keys.indexOf(changedProfile);
new AlertDialog.Builder(mContext).setTitle(R.string.sorting_choose).setSingleChoiceItems(keys.toArray(new String[0]), i, (dialog, which) -> {
changedProfile = keys.get(which);
profile.setText("/u/" + changedProfile);
}).setNegativeButton(R.string.btn_cancel, null).show();
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
replyLine.setOnFocusChangeListener((view, b) -> {
if (b) {
view.postDelayed(() -> {
if (!view.hasFocus())
view.requestFocus();
}, 100);
}
});
}
// TODO: Not working when called a second time
replyLine.requestFocus();
KeyboardUtil.toggleKeyboard(mContext, InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
currentlyEditingId = n.getFullName();
replyLine.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
backedText = s.toString();
}
});
editingPosition = holder.getBindingAdapterPosition();
}
});
send.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
currentlyEditingId = "";
backedText = "";
doShowMenu(baseView);
if (SettingValues.fastscroll) {
mPage.fastScroll.setVisibility(View.VISIBLE);
if (mPage.fab != null)
mPage.fab.setVisibility(View.VISIBLE);
mPage.overrideFab = false;
}
dataSet.refreshLayout.setRefreshing(true);
if (currentlyEditing != null) {
String text = currentlyEditing.getText().toString();
new ReplyTaskComment(n, baseNode, holder, changedProfile).execute(text);
currentlyEditing = null;
editingPosition = -1;
}
// Hide soft keyboard
View view = ((Activity) mContext).findViewById(android.R.id.content);
if (view != null) {
KeyboardUtil.hideKeyboard(mContext, view.getWindowToken(), 0);
}
}
});
discard.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
currentlyEditing = null;
editingPosition = -1;
currentlyEditingId = "";
backedText = "";
mPage.overrideFab = false;
View view = ((Activity) mContext).findViewById(android.R.id.content);
if (view != null) {
KeyboardUtil.hideKeyboard(mContext, view.getWindowToken(), 0);
}
doShowMenu(baseView);
}
});
} else {
if (reply.getVisibility() == View.VISIBLE) {
reply.setVisibility(View.GONE);
}
if ((submission.isArchived() || deleted.contains(n.getFullName()) || comment.getAuthor().equals("[deleted]")) && Authentication.isLoggedIn && Authentication.didOnline && upvote.getVisibility() == View.VISIBLE) {
upvote.setVisibility(View.GONE);
}
if ((submission.isArchived() || deleted.contains(n.getFullName()) || comment.getAuthor().equals("[deleted]")) && Authentication.isLoggedIn && Authentication.didOnline && downvote.getVisibility() == View.VISIBLE) {
downvote.setVisibility(View.GONE);
}
}
more.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
CommentAdapterHelper.showOverflowBottomSheet(CommentAdapter.this, mContext, holder, baseNode);
}
});
upvote.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
setCommentStateUnhighlighted(holder, comment, baseNode, true);
if (ActionStates.getVoteDirection(comment) == VoteDirection.UPVOTE) {
new Vote(v, mContext).execute(n);
ActionStates.setVoteDirection(comment, VoteDirection.NO_VOTE);
doScoreText(holder, n, CommentAdapter.this);
upvote.clearColorFilter();
} else {
new Vote(true, v, mContext).execute(n);
ActionStates.setVoteDirection(comment, VoteDirection.UPVOTE);
// reset colour
downvote.clearColorFilter();
doScoreText(holder, n, CommentAdapter.this);
BlendModeUtil.tintImageViewAsModulate(upvote, holder.textColorUp);
}
}
});
downvote.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
setCommentStateUnhighlighted(holder, comment, baseNode, true);
if (ActionStates.getVoteDirection(comment) == VoteDirection.DOWNVOTE) {
new Vote(v, mContext).execute(n);
ActionStates.setVoteDirection(comment, VoteDirection.NO_VOTE);
doScoreText(holder, n, CommentAdapter.this);
downvote.clearColorFilter();
} else {
new Vote(false, v, mContext).execute(n);
ActionStates.setVoteDirection(comment, VoteDirection.DOWNVOTE);
// reset colour
upvote.clearColorFilter();
doScoreText(holder, n, CommentAdapter.this);
BlendModeUtil.tintImageViewAsModulate(downvote, holder.textColorDown);
}
}
});
menu.setBackgroundColor(color);
replyArea.setBackgroundColor(color);
if (!isReplying) {
menu.setVisibility(View.VISIBLE);
replyArea.setVisibility(View.GONE);
}
holder.itemView.findViewById(R.id.background).setBackgroundColor(Color.argb(50, Color.red(color), Color.green(color), Color.blue(color)));
}
}
use of android.graphics.Color in project Taskbar by farmerbb.
the class AppearanceFragment method showColorPicker.
@SuppressLint("SetTextI18n")
private void showColorPicker(ColorPickerType type) {
int color = -1;
int dialogTitle = -1;
switch(type) {
case BACKGROUND_TINT:
color = U.getBackgroundTint(getActivity());
dialogTitle = R.string.tb_pref_title_background_tint;
break;
case ACCENT_COLOR:
color = U.getAccentColor(getActivity());
dialogTitle = R.string.tb_pref_title_accent_color;
break;
}
alpha = Color.alpha(color);
red = Color.red(color);
green = Color.green(color);
blue = Color.blue(color);
ScrollView dialogLayout = (ScrollView) View.inflate(getActivity(), R.layout.tb_color_picker_pref, null);
View colorPreview = dialogLayout.findViewById(R.id.color_preview);
colorPreview.setBackgroundColor(Color.argb(alpha, red, green, blue));
TextView hexPreview = dialogLayout.findViewById(R.id.hex_preview);
hexPreview.setText("#" + String.format("%08x", Color.argb(alpha, red, green, blue)).toUpperCase());
final TextView alphaValue = dialogLayout.findViewById(R.id.alpha_value);
alphaValue.setText("0");
final SeekBar alphaSeekBar = dialogLayout.findViewById(R.id.alpha_seekbar);
alphaSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
alpha = progress;
alphaValue.setText(Integer.toString(alpha));
colorPreview.setBackgroundColor(Color.argb(alpha, red, green, blue));
hexPreview.setText("#" + String.format("%08x", Color.argb(alpha, red, green, blue)).toUpperCase());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
alphaSeekBar.setProgress(Color.alpha(color));
final TextView redValue = dialogLayout.findViewById(R.id.red_value);
redValue.setText("0");
final SeekBar redSeekBar = dialogLayout.findViewById(R.id.red_seekbar);
redSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
red = progress;
redValue.setText(Integer.toString(red));
colorPreview.setBackgroundColor(Color.argb(alpha, red, green, blue));
hexPreview.setText("#" + String.format("%08x", Color.argb(alpha, red, green, blue)).toUpperCase());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
redSeekBar.setProgress(Color.red(color));
final TextView greenValue = dialogLayout.findViewById(R.id.green_value);
greenValue.setText("0");
final SeekBar greenSeekBar = dialogLayout.findViewById(R.id.green_seekbar);
greenSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
green = progress;
greenValue.setText(Integer.toString(green));
colorPreview.setBackgroundColor(Color.argb(alpha, red, green, blue));
hexPreview.setText("#" + String.format("%08x", Color.argb(alpha, red, green, blue)).toUpperCase());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
greenSeekBar.setProgress(Color.green(color));
final TextView blueValue = dialogLayout.findViewById(R.id.blue_value);
blueValue.setText("0");
final SeekBar blueSeekBar = dialogLayout.findViewById(R.id.blue_seekbar);
blueSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
blue = progress;
blueValue.setText(Integer.toString(blue));
colorPreview.setBackgroundColor(Color.argb(alpha, red, green, blue));
hexPreview.setText("#" + String.format("%08x", Color.argb(alpha, red, green, blue)).toUpperCase());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
blueSeekBar.setProgress(Color.blue(color));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(dialogLayout).setTitle(dialogTitle).setPositiveButton(R.string.tb_action_ok, (dialog, which) -> {
String preferenceId = null;
switch(type) {
case BACKGROUND_TINT:
preferenceId = PREF_BACKGROUND_TINT;
break;
case ACCENT_COLOR:
preferenceId = PREF_ACCENT_COLOR;
break;
}
SharedPreferences pref = U.getSharedPreferences(getActivity());
pref.edit().putInt(preferenceId, Color.argb(alpha, red, green, blue)).apply();
findPreference(preferenceId + "_pref").setSummary("#" + String.format("%08x", Color.argb(alpha, red, green, blue)).toUpperCase());
U.restartTaskbar(getActivity());
}).setNegativeButton(R.string.tb_action_cancel, null);
AlertDialog dialog = builder.create();
dialog.show();
}
use of android.graphics.Color in project MTweaks-KernelAdiutorMOD by morogoku.
the class BuildpropFragment method load.
@Override
protected void load(List<RecyclerViewItem> items) {
super.load(items);
if (mProps == null)
return;
String[] titles = mProps.keySet().toArray(new String[mProps.size()]);
for (int i = 0; i < mProps.size(); i++) {
final String title = titles[i];
final String value = mProps.values().toArray(new String[mProps.size()])[i];
if ((mKeyText != null && !title.contains(mKeyText) || (mValueText != null && !value.contains(mValueText)))) {
continue;
}
int color = ViewUtils.getThemeAccentColor(getActivity());
String colorCode = "#" + Integer.toHexString(Color.red(color)) + Integer.toHexString(Color.green(color)) + Integer.toHexString(Color.blue(color));
DescriptionView descriptionView = new DescriptionView();
if (mKeyText != null && !mKeyText.isEmpty()) {
descriptionView.setTitle(Utils.htmlFrom(title.replace(mKeyText, "<b><font color=\"" + colorCode + "\">" + mKeyText + "</font></b>")));
} else {
descriptionView.setTitle(title);
}
if (mValueText != null && !mValueText.isEmpty()) {
descriptionView.setSummary(Utils.htmlFrom(value.replace(mValueText, "<b><font color=\"" + colorCode + "\">" + mValueText + "</font></b>")));
} else {
descriptionView.setSummary(value);
}
descriptionView.setOnItemClickListener(item -> {
mItemOptionsDialog = new Dialog(getActivity()).setItems(getResources().getStringArray(R.array.build_prop_item_options), (dialogInterface, i1) -> {
switch(i1) {
case 0:
modify(title, value);
break;
case 1:
delete(title, value);
break;
}
}).setOnDismissListener(dialogInterface -> mItemOptionsDialog = null);
mItemOptionsDialog.show();
});
items.add(descriptionView);
}
Activity activity;
if (mSearchFragment != null && (activity = getActivity()) != null) {
activity.runOnUiThread(() -> {
if (isAdded()) {
for (int i = 0; i < childFragmentCount(); i++) {
Fragment fragment = getChildFragment(i);
if (fragment instanceof SearchFragment) {
((SearchFragment) fragment).setCount(items.size());
}
}
}
});
}
}
use of android.graphics.Color in project qksms by moezbhatti.
the class ThemeManager method setIcon.
public static void setIcon(final QKActivity context) {
String[] colors = { "Default", "Dark", "Red", "Pink", "Purple", "DeepPurple", "Indigo", "Blue", "LightBlue", "Cyan", "Teal", "Green", "LightGreen", "Lime", "Yellow", "Amber", "Orange", "DeepOrange", "Brown", "Grey", "BlueGrey" };
RecyclerView recyclerView = new RecyclerView(context);
recyclerView.setLayoutParams(new LinearLayout.LayoutParams(-1, Units.dpToPx(context, 200)));
recyclerView.setLayoutManager(new GridLayoutManager(context, 4));
recyclerView.setAdapter(new IconAdapter(context, (parent, view, position, id) -> {
PackageManager packageManager = context.getPackageManager();
// Disable all of the color aliases, except for the alias with the current
// color.
String enabledComponent = null;
for (int i = 0; i < colors.length; i++) {
String componentClassName = String.format("com.moez.QKSMS.ui.MainActivity-%s", colors[i]);
// it's all done.
if (i == position) {
enabledComponent = componentClassName;
} else {
packageManager.setComponentEnabledSetting(new ComponentName(context, componentClassName), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, // won't show up to the user.
PackageManager.DONT_KILL_APP);
}
}
// Broadcast an intent to a receiver that will:
// 1) enable the last component; and
// 2) relaunch QKSMS with the new component name.
Intent intent = new Intent(IconColorReceiver.ACTION_ICON_COLOR_CHANGED);
intent.putExtra(IconColorReceiver.EXTRA_COMPONENT_NAME, enabledComponent);
context.sendBroadcast(intent);
}));
new QKDialog().setContext(context).setTitle(R.string.update_icon_title).setMessage(R.string.update_icon_message).setCustomView(recyclerView).setNegativeButton(R.string.cancel, null).show();
}
Aggregations