List of usage examples for android.graphics Color parseColor
@ColorInt public static int parseColor(@Size(min = 1) String colorString)
From source file:com.dm.material.dashboard.candybar.activities.CandyBarMainActivity.java
private void initNavigationViewHeader() { String imageUrl = getResources().getString(R.string.navigation_view_header); String titleText = getResources().getString(R.string.navigation_view_header_title); View header = mNavigationView.getHeaderView(0); ImageView image = (ImageView) header.findViewById(R.id.header_image); LinearLayout container = (LinearLayout) header.findViewById(R.id.header_title_container); TextView title = (TextView) header.findViewById(R.id.header_title); TextView version = (TextView) header.findViewById(R.id.header_version); if (titleText.length() == 0) { container.setVisibility(View.GONE); } else {/*from w w w. j ava 2 s .c o m*/ title.setText(titleText); try { String versionText = "v" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName; version.setText(versionText); } catch (Exception ignored) { } } if (ColorHelper.isValidColor(imageUrl)) { image.setBackgroundColor(Color.parseColor(imageUrl)); return; } if (!URLUtil.isValidUrl(imageUrl)) { imageUrl = "drawable://" + DrawableHelper.getResourceId(this, imageUrl); } ImageLoader.getInstance().displayImage(imageUrl, new ImageViewAware(image), ImageConfig.getDefaultImageOptions(true), new ImageSize(720, 720), null, null); }
From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java
private boolean displayNotification(final Bundle pushBundle, final Class<?> targetClass, String imageUrl, String iconImageUrl, String iconSmallImageUrl, Map<String, String> campaignAttributes, String intentAction) {/* ww w. j a v a 2 s .c om*/ log.info("Display Notification: " + pushBundle.toString()); final String title = pushBundle.getString(NOTIFICATION_TITLE_PUSH_KEY); final String message = pushBundle.getString(NOTIFICATION_BODY_PUSH_KEY); final String campaignId = campaignAttributes.get(CAMPAIGN_ID_ATTRIBUTE_KEY); final String activityId = campaignAttributes.get(CAMPAIGN_ACTIVITY_ID_ATTRIBUTE_KEY); final int requestID = (campaignId + ":" + activityId + ":" + System.currentTimeMillis()).hashCode(); final int iconResId = getNotificationIconResourceId(pushBundle.getString(NOTIFICATION_ICON_PUSH_KEY)); if (iconResId == 0) { return false; } final Notification notification = createNotification(iconResId, title, message, imageUrl, iconImageUrl, iconSmallImageUrl, this.createOpenAppPendingIntent(pushBundle, targetClass, campaignId, requestID, intentAction)); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE; if (android.os.Build.VERSION.SDK_INT >= ANDROID_LOLLIPOP) { log.info("SDK greater than 21 detected: " + android.os.Build.VERSION.SDK_INT); final String colorString = pushBundle.getString(NOTIFICATION_COLOR_PUSH_KEY); if (colorString != null) { int color; try { color = Color.parseColor(colorString); } catch (final IllegalArgumentException ex) { log.warn("Couldn't parse campaign notification color.", ex); color = 0; } Exception exception = null; try { final Field colorField = notification.getClass().getDeclaredField("color"); colorField.setAccessible(true); colorField.set(notification, color); } catch (final IllegalAccessException ex) { exception = ex; } catch (final NoSuchFieldException ex) { exception = ex; } if (exception != null) { log.error("Couldn't set campaign notification color : " + exception.getMessage(), exception); } } } final NotificationManager notificationManager = (NotificationManager) pinpointContext .getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(requestID, notification); return true; }
From source file:com.amaze.filemanager.utils.Futils.java
public void showProps(final BaseFile hFile, final String perm, final Main c, boolean root) { long last = hFile.getDate(); String date = getdate(last);// w ww . j a v a2 s. c o m String items = getString(c.getActivity(), R.string.calculating), size = getString(c.getActivity(), R.string.calculating), name, parent; name = hFile.getName(); parent = hFile.getReadablePath(hFile.getParent()); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(c.getActivity()); String fabskin = PreferenceUtils.getAccentString(sp); MaterialDialog.Builder a = new MaterialDialog.Builder(c.getActivity()); a.title(getString(c.getActivity(), R.string.properties)); if (c.theme1 == 1) a.theme(Theme.DARK); View v = c.getActivity().getLayoutInflater().inflate(R.layout.properties_dialog, null); AppCompatButton appCompatButton = (AppCompatButton) v.findViewById(R.id.appX); appCompatButton.setAllCaps(true); final View permtabl = v.findViewById(R.id.permtable); final View but = v.findViewById(R.id.set); if (root && perm.length() > 6) { appCompatButton.setVisibility(View.VISIBLE); appCompatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (permtabl.getVisibility() == View.GONE) { permtabl.setVisibility(View.VISIBLE); but.setVisibility(View.VISIBLE); setPermissionsDialog(permtabl, but, hFile, perm, c); } else { but.setVisibility(View.GONE); permtabl.setVisibility(View.GONE); } } }); } a.customView(v, true); a.positiveText(R.string.copy_path); a.negativeText(getString(c.getActivity(), R.string.md5_2)); a.positiveColor(Color.parseColor(fabskin)); a.negativeColor(Color.parseColor(fabskin)); a.neutralText(R.string.cancel); a.neutralColor(Color.parseColor(fabskin)); a.callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog materialDialog) { c.MAIN_ACTIVITY.copyToClipboard(c.getActivity(), hFile.getPath()); Toast.makeText(c.getActivity(), c.getResources().getString(R.string.pathcopied), Toast.LENGTH_SHORT) .show(); } @Override public void onNegative(MaterialDialog materialDialog) { } }); MaterialDialog materialDialog = a.build(); materialDialog.show(); new GenerateMD5Task(materialDialog, hFile, name, parent, size, items, date, c.getActivity(), v) .execute(hFile.getPath()); }
From source file:com.coinblesk.client.utils.UIUtils.java
public static int getStatusColorFilter(TransactionWrapper tx) { if (ClientUtils.isConfidenceReached(tx)) { return Color.parseColor(COLOR_WHITE); } else {//from w ww . j a va2 s.c o m return Color.parseColor(COLOR_MATERIAL_LIGHT_YELLOW_900); } }
From source file:com.filemanager.free.adapters.Recycleradapter.java
@Override public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup viewGroup) { View view = mInflater.inflate(R.layout.listheader, viewGroup, false); if (main.theme1 == 1) view.setBackgroundResource(R.color.holo_dark_background); HeaderViewHolder holder = new HeaderViewHolder(view); if (main.theme1 == 0) holder.ext.setTextColor(Color.parseColor("#8A000000")); else/*w ww. j a va2 s . c o m*/ holder.ext.setTextColor(Color.parseColor("#B3ffffff")); return holder; }
From source file:com.elitise.appv2.Peripheral.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Window wd = this.getWindow(); wd.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); wd.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); wd.setStatusBarColor(Color.parseColor("#000000")); return true;// w ww .j a v a 2s.c o m }
From source file:com.fa.mastodon.activity.MainActivity.java
private void setupSearchView() { searchView.attachNavigationDrawerToMenuButton(drawer.getDrawerLayout()); // Setup content descriptions for the different elements in the search view. final View leftAction = searchView.findViewById(R.id.left_action); leftAction.setContentDescription(getString(R.string.action_open_drawer)); searchView.setOnFocusChangeListener(new FloatingSearchView.OnFocusChangeListener() { @Override/*from w w w . j av a 2 s.com*/ public void onFocus() { leftAction.setContentDescription(getString(R.string.action_close)); } @Override public void onFocusCleared() { leftAction.setContentDescription(getString(R.string.action_open_drawer)); } }); View clearButton = searchView.findViewById(R.id.clear_btn); clearButton.setContentDescription(getString(R.string.action_clear)); searchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { @Override public void onSearchTextChanged(String oldQuery, String newQuery) { if (!oldQuery.equals("") && newQuery.equals("")) { searchView.clearSuggestions(); return; } if (newQuery.length() < 3) { return; } searchView.showProgress(); mastodonAPI.searchAccounts(newQuery, false, 5).enqueue(new Callback<List<Account>>() { @Override public void onResponse(Call<List<Account>> call, Response<List<Account>> response) { if (response.isSuccessful()) { searchView.swapSuggestions(response.body()); searchView.hideProgress(); } else { searchView.hideProgress(); } } @Override public void onFailure(Call<List<Account>> call, Throwable t) { searchView.hideProgress(); } }); } }); searchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() { @Override public void onSuggestionClicked(SearchSuggestion searchSuggestion) { Account accountSuggestion = (Account) searchSuggestion; Intent intent = new Intent(MainActivity.this, AccountActivity.class); intent.putExtra("id", accountSuggestion.id); startActivity(intent); } @Override public void onSearchAction(String currentQuery) { } }); searchView.setOnBindSuggestionCallback(new SearchSuggestionsAdapter.OnBindSuggestionCallback() { @Override public void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView, SearchSuggestion item, int itemPosition) { Account accountSuggestion = ((Account) item); Picasso.with(MainActivity.this).load(accountSuggestion.avatar) .placeholder(R.drawable.avatar_default).into(leftIcon); String searchStr = accountSuggestion.getDisplayName() + " " + accountSuggestion.username; final SpannableStringBuilder str = new SpannableStringBuilder(searchStr); str.setSpan(new StyleSpan(Typeface.BOLD), 0, accountSuggestion.getDisplayName().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(str); textView.setMaxLines(1); textView.setEllipsize(TextUtils.TruncateAt.END); } }); if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light") .equals("black")) { searchView.setBackgroundColor(Color.parseColor("#444444")); } }
From source file:at.alladin.rmbt.android.views.ResultGraphView.java
/** * //from w ww.j a v a 2 s . c om * @param graphArray * @param graphView * @throws JSONException */ public void drawCurve(JSONArray graphArray, CustomizableGraphView graphView, String color, String labelHMax) throws JSONException { final double maxTime = graphArray.optJSONObject(graphArray.length() - 1).optDouble("time_elapsed"); //final double pointDistance = (0.25d / (maxTime / 1000)); graphView.getLabelHMaxList().clear(); graphView.addLabelHMax(labelHMax); //StaticGraph signal = StaticGraph.addGraph(graphView, Color.parseColor(color)); GraphService signal = SmoothGraph.addGraph(graphView, Color.parseColor(color), RMBTTestFragment.SMOOTHING_DATA_AMOUNT, RMBTTestFragment.SMOOTHING_FUNCTION, false); if (graphArray != null && graphArray.length() > 0) { long bytes = 0; for (int i = 0; i < graphArray.length(); i++) { JSONObject uploadObject = graphArray.getJSONObject(i); double time_elapsed = uploadObject.getInt("time_elapsed"); bytes = uploadObject.getInt("bytes_total"); double bitPerSec = (bytes * 8000 / time_elapsed); double time = (time_elapsed / maxTime); if (i + 1 == graphArray.length()) { signal.addValue(IntermediateResult.toLog((long) bitPerSec), time, SmoothGraph.FLAG_ALIGN_RIGHT); } else { signal.addValue(IntermediateResult.toLog((long) bitPerSec), time, i == 0 ? SmoothGraph.FLAG_ALIGN_LEFT : SmoothGraph.FLAG_NONE); } } } }
From source file:com.customdatepicker.date.DatePickerDialog.java
/** * Set the accent color of this dialog//from w w w . j av a 2 s . c o m * * @param color the accent color you want */ @SuppressWarnings("unused") public void setAccentColor(String color) { mAccentColor = Color.parseColor(color); }
From source file:com.filemanager.free.adapters.Recycleradapter.java
void showPopup(View v, final Layoutelements rowItem) { v.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a 2 s.c om*/ public void onClick(View view) { PopupMenu popupMenu = new PopupMenu(main.getActivity(), view); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.about: main.utils.showProps((rowItem).generateBaseFile(), rowItem.getPermissions(), main, main.ROOT_MODE); return true; case R.id.share: ArrayList<File> arrayList = new ArrayList<File>(); arrayList.add(new File(rowItem.getDesc())); main.utils.shareFiles(arrayList, main.MAIN_ACTIVITY, main.theme1, Color.parseColor(main.fabSkin)); return true; case R.id.rename: main.rename(rowItem.generateBaseFile()); return true; case R.id.cpy: MainActivity MAIN_ACTIVITY = main.MAIN_ACTIVITY; main.MAIN_ACTIVITY.MOVE_PATH = null; ArrayList<BaseFile> copies = new ArrayList<>(); copies.add(rowItem.generateBaseFile()); MAIN_ACTIVITY.COPY_PATH = copies; MAIN_ACTIVITY.supportInvalidateOptionsMenu(); return true; case R.id.cut: MainActivity MAIN_ACTIVITY1 = main.MAIN_ACTIVITY; MAIN_ACTIVITY1.COPY_PATH = null; ArrayList<BaseFile> copie = new ArrayList<>(); copie.add(rowItem.generateBaseFile()); MAIN_ACTIVITY1.MOVE_PATH = copie; MAIN_ACTIVITY1.supportInvalidateOptionsMenu(); return true; case R.id.ex: main.MAIN_ACTIVITY.mainActivityHelper.extractFile(new File(rowItem.getDesc())); return true; case R.id.book: DataUtils.addBook(new String[] { rowItem.getTitle(), rowItem.getDesc() }, true); main.MAIN_ACTIVITY.updateDrawer(); Toast.makeText(main.getActivity(), main.utils.getString(main.getActivity(), R.string.bookmarksadded), Toast.LENGTH_LONG).show(); return true; } return false; } }); popupMenu.inflate(R.menu.item_extras); String x = rowItem.getDesc().toLowerCase(); if (rowItem.isDirectory()) popupMenu.getMenu().findItem(R.id.share).setVisible(false); if (x.endsWith(".zip") || x.endsWith(".jar") || x.endsWith(".apk") || x.endsWith(".rar") || x.endsWith(".tar") || x.endsWith(".tar.gz")) popupMenu.getMenu().findItem(R.id.ex).setVisible(true); popupMenu.show(); } }); }