List of usage examples for android.graphics Color rgb
@ColorInt public static int rgb(float red, float green, float blue)
From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java
private void adjBottomColor(Drawable d) { Bitmap b = ((BitmapDrawable) d).getBitmap(); int b_sum = 0; int g_sum = 0; int r_sum = 0; for (int i = 0; i < 10; i++) { int x = (int) ((double) b.getWidth() * Math.random()); int y = (int) ((double) b.getHeight() * Math.random()); int pixel = b.getPixel(x, y); int redValue = Color.red(pixel); int blueValue = Color.blue(pixel); int greenValue = Color.green(pixel); b_sum += blueValue;/*from w w w. j a v a 2s . c o m*/ g_sum += greenValue; r_sum += redValue; } int av_r = r_sum / 10; int av_g = g_sum / 10; int av_b = b_sum / 10; iBottomPanel.setBackgroundColor(Color.rgb(av_r, av_g, av_b)); ArtistImage.setBackgroundColor(Color.rgb(av_r, av_g, av_b)); int ave_sum = (av_b + av_g + av_r); Log.d("musicInfo", "ave_sum = " + ave_sum); if (ave_sum > 400) { tEchoNest.setTextColor(Color.parseColor("#8f363c6b")); for (int i = 0; i < lLinkList.getChildCount(); i++) { ((TextView) lLinkList.getChildAt(i)).setTextColor(Color.DKGRAY); } } else { tEchoNest.setTextColor(Color.parseColor("#8fc9cfff")); for (int i = 0; i < lLinkList.getChildCount(); i++) { ((TextView) lLinkList.getChildAt(i)).setTextColor(Color.LTGRAY); } } }
From source file:de.blinkt.openvpn.ActivityDashboard.java
public void setStatus(Status status) { Button btnConnect = (Button) findViewById(R.id.button_dashboard_connect); // Spinner spinPackage = (Spinner)findViewById(R.id.spinner_dashboard_package); // Spinner spinServer = (Spinner)findViewById(R.id.spinner_dashboard_location); TextView locationServer = (TextView) findViewById(R.id.view_location); ImageView ibVpnLogo = (ImageView) findViewById(R.id.ib_vpn_Con_ic); if (btnConnect == null || myToolbar.getTitle() == null || locationServer == null) { Log.e("ibVPN", "at least one item do not exist."); return;/*from www. j a v a 2s . c om*/ } m_status = status; switch (m_status) { case Connecting: { // spinPackage.setEnabled(false); // spinServer.setEnabled(false); btnConnect.setEnabled(true); btnConnect.setText(R.string.text_cancel); myToolbar.setTitle("Connecting"); if (VpnStatus.isVPNActive()) { Toast.makeText(this, "Connection established", Toast.LENGTH_LONG); } Log.d("mservice", mService.toString()); // textStatus.setText(Html.fromHtml("<font color=#FFFFFF>Status: </font><font color=#fdbb2f>CONNECTING...</font><b> >>></b>")); break; } case Connected: { // spinPackage.setEnabled(false); // spinServer.setEnabled(false); btnConnect.setEnabled(true); btnConnect.setText("Disconnect"); myToolbar.setTitle("Connected"); myToolbar.setBackgroundColor(Color.rgb(28, 146, 29)); ibVpnLogo.setImageDrawable(getDrawable(R.drawable.icon_connected)); // textStatus.setText(Html.fromHtml("<font color=#FFFFFF>Status: </font><font color=#00FF20>CONNECTED</font><b> >>></b>")); break; } case Disconnecting: { // spinPackage.setEnabled(false); // spinServer.setEnabled(false); btnConnect.setEnabled(false); btnConnect.setText("Disconnect"); myToolbar.setTitle("Disconnecting"); ibVpnLogo.setImageDrawable(getDrawable(R.drawable.icon_notconnected)); // textStatus.setText(Html.fromHtml("<font color=#FFFFFF>Status: </font><font color=#FF0000>DISCONNECTING...</font><b> >>></b>")); break; } case Disconnected: { // spinPackage.setEnabled(true); // spinServer.setEnabled(true); btnConnect.setEnabled(true); btnConnect.setText("Connect"); myToolbar.setTitle("NOT CONNECTED"); myToolbar.setBackgroundColor(Color.rgb(255, 0, 64)); ibVpnLogo.setImageDrawable(getDrawable(R.drawable.icon_notconnected)); // textStatus.setText(Html.fromHtml("<font color=#FFFFFF>Status: </font><font color=#FF0000>NOT CONNECTED</font><b> >>></b>")); break; } default: Log.e("ibVPN", "no such status."); return; } }
From source file:com.nttec.everychan.ui.presentation.HtmlParser.java
private static int parseColor(String css) { if (TextUtils.isEmpty(css)) return 0; try {//ww w. ja v a 2 s. c o m Matcher m = CSS_STYLE_COLOR_RGB_PATTERN.matcher(css); if (m.find() && m.groupCount() == 3) { int n1 = Integer.parseInt(m.group(1)); int n2 = Integer.parseInt(m.group(2)); int n3 = Integer.parseInt(m.group(3)); return Color.rgb(n1, n2, n3); } m = CSS_STYLE_COLOR_COMMON_PATTERN.matcher(css); if (m.find() && m.groupCount() == 1) { return Color.parseColor(m.group(1)); } } catch (Exception e) { /*? ? ? ( ? )*/ } return 0; }
From source file:com.gizwits.smartlight.activity.MainListActivity.java
/** * Inits the views.//from w ww .j a va 2 s.c o m */ private void initViews() { mView = (SlidingMenu) findViewById(R.id.main_layout); llFooter = (LinearLayout) findViewById(R.id.llFooter); alpha_bg = (Button) findViewById(R.id.black_alpha_bg); tvLName = (TextView) findViewById(R.id.show_led_name); tvSceneName = (TextView) findViewById(R.id.show_scene_name); tvEditSceneName = (EditText) findViewById(R.id.scene_name); //etGroup = (ImageView) findViewById(R.id.edit_group); llBottom = (LinearLayout) findViewById(R.id.llBottom); ivMenu = (ImageView) findViewById(R.id.ivMenu); tvTitle = (TextView) findViewById(R.id.tvTitle); ivEdit = (ImageView) findViewById(R.id.ivEdit); ivEdit.setTag("1"); sclContent = (RefreshableListView) findViewById(R.id.sclContent); btnSwitch = (TextView) findViewById(R.id.btnSwitch); sbLightness = (SeekBar) findViewById(R.id.sbLightness); sbSaturation = (SeekBar) findViewById(R.id.sbSaturation); sbColor = (ColorSelectSeekBar) findViewById(R.id.sbcolor); addSceneButton = (Button) findViewById(R.id.btn_addscene); sceneLayout = (RelativeLayout) findViewById(R.id.relativeLayout2); //sceneRemove = (ImageView) findViewById(R.id.scene_remove); iftttButton = (Button) findViewById(R.id.ifttt); screenWidth = getWindowManager().getDefaultDisplay().getWidth(); //For lightness text_light = new TextView(this); text_light.setBackgroundColor(Color.rgb(254, 254, 254)); text_light.setTextColor(Color.rgb(0, 161, 229)); text_light.setTextSize(12); layoutParams_light = new ViewGroup.LayoutParams(screenWidth, 50); textMoveLayout = (TextMoveLayout) findViewById(R.id.textLayout1); textMoveLayout.addView(text_light, layoutParams_light); text_light.layout(0, 20, screenWidth, 40); //For hue text_hue = new TextView(this); text_hue.setBackgroundColor(Color.rgb(254, 254, 254)); text_hue.setTextColor(Color.rgb(0, 161, 229)); text_hue.setTextSize(12); layoutParams_hue = new ViewGroup.LayoutParams(screenWidth, 50); textMoveLayout = (TextMoveLayout) findViewById(R.id.textLayout2); textMoveLayout.addView(text_hue, layoutParams_hue); text_hue.layout(0, 20, screenWidth, 40); //For saturation text_saturation = new TextView(this); text_saturation.setBackgroundColor(Color.rgb(254, 254, 254)); text_saturation.setTextColor(Color.rgb(0, 161, 229)); text_saturation.setTextSize(12); layoutParams_saturation = new ViewGroup.LayoutParams(screenWidth, 50); textMoveLayout = (TextMoveLayout) findViewById(R.id.textLayout3); textMoveLayout.addView(text_saturation, layoutParams_saturation); text_saturation.layout(0, 20, screenWidth, 40); mAdapter = new MenuDeviceAdapter(this, bindlist); lvDevice = (ListView) findViewById(R.id.lvDevice); lvDevice.setAdapter(mAdapter); progressDialog = new ProgressDialog(MainListActivity.this); progressDialog.setCancelable(false); progressDialog.setMessage("Device connecting,waiting....."); mSceneAdapter = new ItemListBaseAdapter(this, R.layout.list_scene, scene_details); sceneListView = (ListView) findViewById(R.id.listView_Scene); sceneListView.setAdapter(mSceneAdapter); }
From source file:com.example.angel.parkpanda.MainActivity.java
public Bitmap drawTextToBitmap(int gResId, String gText) { Resources resources = getResources(); float scale = resources.getDisplayMetrics().density; Bitmap bitmap = BitmapFactory.decodeResource(resources, gResId); android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig(); if (bitmapConfig == null) { bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888; }/*from w ww .j ava 2 s. co m*/ bitmap = bitmap.copy(bitmapConfig, true); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.rgb(0, 0, 0)); paint.setTextSize((int) (15 * scale)); paint.setShadowLayer(1f, 0f, 1f, Color.BLACK); Rect bounds = new Rect(); paint.getTextBounds(gText, 0, gText.length(), bounds); int x = (bitmap.getWidth() - bounds.width()) / 2; int y = (bitmap.getHeight() + bounds.height()) / 2 - 10; canvas.drawText(gText, x, y, paint); return bitmap; }
From source file:com.devwang.logcabin.LogCabinMainActivity.java
/** * /*from www .java2s . c o m*/ * * @param strCmd */ private void sendBtMessageWithState(char strCmd) { sendMessage(strCmd + "");// char to string switch (strCmd) { case 'a': break; case 'b':// b blue setTempWindowRGBLedStateTextView("", "", getString(R.string.str_blue)); mRgbLedColorStateTextView.setTextColor(Color.BLUE); break; case 'c': break; case 'd':// d dieout setTempWindowRGBLedStateTextView("", "", getString(R.string.str_close)); mRgbLedColorStateTextView.setTextColor(Color.BLACK); buttonMusicPlay(R.raw.tick); break; case 'e': break; case 'f': break; case 'g':// g green setTempWindowRGBLedStateTextView("", "", getString(R.string.str_green)); mRgbLedColorStateTextView.setTextColor(Color.GREEN); break; case 'h': break; case 'i': break; case 'j': break; case 'k': break; case 'l': break; case 'm':// m motor if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "...", ""); new Thread(new Runnable() { public void run() { spandTimeMethod(); // handler.sendEmptyMessage(FLAG_HANDLER_MESSAGE_OPEN_WINDOW); // handler } }).start(); buttonMusicPlay(R.raw.tock); break; case 'n':// n if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "...", ""); new Thread(new Runnable() { public void run() { spandTimeMethod(); // handler.sendEmptyMessage(FLAG_HANDLER_MESSAGE_CLOSE_WINDOW); // handler } }).start(); buttonMusicPlay(R.raw.tick); break; case 'o':// o orange if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "", getString(R.string.str_orange)); mRgbLedColorStateTextView.setTextColor(Color.rgb(255, 125, 0)); break; case 'p':// p purple if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "", getString(R.string.str_purple)); mRgbLedColorStateTextView.setTextColor(Color.rgb(255, 0, 255)); break; case 'q': break; case 'r':// r red if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "", getString(R.string.str_red)); mRgbLedColorStateTextView.setTextColor(Color.RED); break; case 's': break; case 't':// t ring-time break; case 'u':// u up if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "", ""); break; case 'v':// v if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "", ""); break; case 'w':// w white if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "", getString(R.string.str_open)); mRgbLedColorStateTextView.setTextColor(Color.BLACK); buttonMusicPlay(R.raw.tock); break; case 'x':// x if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "", ""); break; case 'y':// yellow if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "", getString(R.string.str_yellow)); mRgbLedColorStateTextView.setTextColor(Color.YELLOW); break; case 'z':// z if (D) Log.i("TEST_BT_CMD", "===>>"); setTempWindowRGBLedStateTextView("", "", ""); break; default: break; } Log.i("TEST_BT_CMD", strCmd + ""); }
From source file:com.bookkos.bircle.CaptureActivity.java
private void setMode(TextView textview) { arrayList.clear();// w ww .ja v a 2s. c om if (textview.getText().toString().equals("??")) { textview.setText("?"); textview.setTextColor(Color.rgb(62, 162, 229)); strokeColor = Color.rgb(62, 162, 229); registFlag = 1; } else { textview.setText("??"); textview.setTextColor(Color.rgb(56, 234, 123)); strokeColor = Color.rgb(56, 234, 123); registFlag = 0; } }
From source file:no.barentswatch.fiskinfo.BaseActivity.java
/** * This functions creates a dialog which allows the user to export different * map layers./*from ww w . j av a 2 s . c o m*/ * * @param ActivityContext * The context of the current activity. * @return True if the export succeeded, false otherwise. */ public boolean exportMapLayerToUser(Context activityContext) { LayoutInflater layoutInflater = getLayoutInflater(); View view = layoutInflater.inflate(R.layout.dialog_export_metadata, (null)); Button downloadButton = (Button) view.findViewById(R.id.metadataDownloadButton); Button cancelButton = (Button) view.findViewById(R.id.cancel_button); final AlertDialog builder = new AlertDialog.Builder(activityContext).create(); builder.setTitle(R.string.map_export_metadata_title); builder.setView(view); final AtomicReference<String> selectedHeader = new AtomicReference<String>(); final AtomicReference<String> selectedFormat = new AtomicReference<String>(); final ExpandableListView expListView = (ExpandableListView) view .findViewById(R.id.exportMetadataMapServices); final List<String> listDataHeader = new ArrayList<String>(); final HashMap<String, List<String>> listDataChild = new HashMap<String, List<String>>(); final Map<String, String> nameToApiNameResolver = new HashMap<String, String>(); JSONArray availableSubscriptions = getSharedCacheOfAvailableSubscriptions(); if (availableSubscriptions == null) { availableSubscriptions = authenticatedGetRequestToBarentswatchAPIService( getString(R.string.my_page_geo_data_service)); setSharedCacheOfAvailableSubscriptions(availableSubscriptions); } for (int i = 0; i < availableSubscriptions.length(); i++) { try { JSONObject currentSub = availableSubscriptions.getJSONObject(i); nameToApiNameResolver.put(currentSub.getString("Name"), currentSub.getString("ApiName")); listDataHeader.add(currentSub.getString("Name")); List<String> availableDownloadFormatsOfCurrentLayer = new ArrayList<String>(); JSONArray availableFormats = currentSub.getJSONArray("Formats"); for (int j = 0; j < availableFormats.length(); j++) { availableDownloadFormatsOfCurrentLayer.add(availableFormats.getString(j)); } listDataChild.put(listDataHeader.get(i), availableDownloadFormatsOfCurrentLayer); System.out .println("item: " + currentSub.getString("Name") + ", " + currentSub.getString("ApiName")); } catch (JSONException e) { e.printStackTrace(); Log.d("ExportMapLAyerToUser", "Invalid JSON returned from API CALL"); return false; } } final ExpandableListAdapter listAdapter = new ExpandableListAdapter(activityContext, listDataHeader, listDataChild); expListView.setAdapter(listAdapter); // Listview on child click listener expListView.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { selectedHeader.set(nameToApiNameResolver.get(listDataHeader.get(groupPosition))); selectedHeader.set(listDataHeader.get(groupPosition)); selectedFormat.set(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition)); LinearLayout currentlySelected = (LinearLayout) parent.findViewWithTag("currentlySelectedRow"); if (currentlySelected != null) { currentlySelected.getChildAt(0).setBackgroundColor(Color.WHITE); currentlySelected.setTag(null); } ((LinearLayout) v).getChildAt(0).setBackgroundColor(Color.rgb(214, 214, 214)); v.setTag("currentlySelectedRow"); return true; } }); downloadButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new DownloadMapLayerFromBarentswatchApiInBackground() .execute(nameToApiNameResolver.get(selectedHeader.get()), selectedFormat.get()); builder.dismiss(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { builder.dismiss(); } }); builder.setCanceledOnTouchOutside(false); builder.show(); return true; }
From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationActivity.java
private void animateInstructions(MotionEvent event) { if (animationInstructions != null && animationInstructions.isInitialized()) { animationInstructions.cancel();//from w ww . j ava 2 s . co m } if (event.getAction() == MotionEvent.ACTION_DOWN) { if (System.currentTimeMillis() - lastDownTimestamp <= DOUBLE_TAP_PERIOD) { isDoubleTap = true; lastDownTimestamp = System.currentTimeMillis(); } else { lastDownTimestamp = 0; } lastDownTimestamp = System.currentTimeMillis(); mapFragment.locationOverlay.disableMyLocation(); lastY = event.getY(); instructionsView.setVisibility(View.GONE); instructionsViewMin.setVisibility(View.INVISIBLE); instructionsViewMax.setVisibility(View.VISIBLE); darkenedView.setVisibility(View.VISIBLE); darkenedView.getBackground().setAlpha(Util.yToAlpha((int) event.getRawY())); } else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { if (isDoubleTap && System.currentTimeMillis() - lastDownTimestamp <= DOUBLE_TAP_PERIOD) { if (instructionsViewState == InstrcutionViewState.Normal) { setInstructionViewState(InstrcutionViewState.Maximized); } else if (instructionsViewState == InstrcutionViewState.Maximized) { setInstructionViewState(InstrcutionViewState.Normal); } else if (instructionsViewState == InstrcutionViewState.Minimized) { setInstructionViewState(InstrcutionViewState.Normal); } } else if (event.getRawY() < Util.getScreenHeight() / 2) { setInstructionViewState(InstrcutionViewState.Maximized); } else if (event.getRawY() < 9 * Util.getScreenHeight() / 10) { instructionList.smoothScrollToPosition(0); mapFragment.locationOverlay.enableMyLocation(mapFragment.locationProvider == null ? mapFragment.locationProvider = new GpsMyLocationProvider(this) : mapFragment.locationProvider); setInstructionViewState(InstrcutionViewState.Normal); } else { instructionList.smoothScrollToPosition(0); mapFragment.locationOverlay.enableMyLocation(mapFragment.locationProvider == null ? mapFragment.locationProvider = new GpsMyLocationProvider(this) : mapFragment.locationProvider); setInstructionViewState(InstrcutionViewState.Minimized); } instructionsViewMax.clearAnimation(); isDoubleTap = false; return; } if (event.getRawY() > Util.getScreenHeight() - Util.dp2px(40)) { pullHandleMax.setBackgroundColor(Color.TRANSPARENT); } else { pullHandleMax.setBackgroundColor(Color.rgb(26, 26, 26)); } darkenedView.getBackground().setAlpha(Util.yToAlpha((int) event.getRawY())); animationInstructions = new TranslateAnimation(0, 0, lastY, event.getY()); animationInstructions.setFillAfter(true); animationInstructions.setFillBefore(true); lastY = event.getY(); animationInstructions.setDuration(0); instructionsViewMax.startAnimation(animationInstructions); }
From source file:org.totschnig.myexpenses.fragment.CategoryList.java
private ArrayList<Integer> getShades(int color) { ArrayList<Integer> result = new ArrayList<>(); int red = Color.red(color); int redDecrement = (int) Math.round(red * 0.1); int green = Color.green(color); int greenDecrement = (int) Math.round(green * 0.1); int blue = Color.blue(color); int blueDecrement = (int) Math.round(blue * 0.1); for (int i = 0; i < 10; i++) { red = red - redDecrement;/* ww w.j a v a2s.com*/ if (red <= 0) { red = 0; } green = green - greenDecrement; if (green <= 0) { green = 0; } blue = blue - blueDecrement; if (blue <= 0) { blue = 0; } result.add(Color.rgb(red, green, blue)); } result.add(Color.BLACK); return result; }