List of usage examples for android.graphics Color BLACK
int BLACK
To view the source code for android.graphics Color BLACK.
Click Source Link
From source file:com.kunze.androidlocaltodo.TaskListActivity.java
private void SetFriendlyDueDateText(TextView dueDateView, Calendar dueDate) { SimpleDateFormat dateFormatDisplay = new SimpleDateFormat("MM-dd-yyyy", Locale.US); Calendar now = Calendar.getInstance(); int nowDay = TaskDatabase.ConvertDateToInt(now); int dueDay = TaskDatabase.ConvertDateToInt(dueDate); int dayDiff = nowDay - dueDay; if (dayDiff == 0) { dueDateView.setText("Today"); dueDateView.setTextColor(Color.RED); } else if (dueDate.before(now)) { dueDateView.setText("+ " + dayDiff + " days!"); dueDateView.setTextColor(Color.RED); } else if (dayDiff > -7) { dueDateView.setText(dueDate.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US)); dueDateView.setTextColor(Color.BLACK); } else if (dayDiff > -14) { dueDateView.setText("Next " + dueDate.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US)); dueDateView.setTextColor(Color.BLACK); } else {//from ww w . j av a 2 s . c om dueDateView.setText(dateFormatDisplay.format(dueDate.getTime())); dueDateView.setTextColor(Color.BLACK); } }
From source file:terse.a1.TerseActivity.java
private void viewPath9display(String path, LayoutParams widgetParams) { String explain;//from w w w. ja v a2s.c om if (terp_error != null) { explain = "terp_error = " + terp_error; } else { try { terp.say("Sending to terp: %s", path); final Dict d = terp.handleUrl(path, taQuery); explain = "DEFAULT EXPLANATION:\n\n" + d.toString(); Str TYPE = d.cls.terp.newStr("type"); Str VALUE = d.cls.terp.newStr("value"); Str TITLE = d.cls.terp.newStr("title"); Str type = (Str) d.dict.get(TYPE); Ur value = d.dict.get(VALUE); Ur title = d.dict.get(TITLE); // { // double ticks = Static.floatAt(d, "ticks", -1); // double nanos = Static.floatAt(d, "nanos", -1); // Toast.makeText( // getApplicationContext(), // Static.fmt("%d ticks, %.3f secs", (long) ticks, // (double) nanos / 1e9), Toast.LENGTH_SHORT) // .show(); // } if (type.str.equals("list") && value instanceof Vec) { final ArrayList<Ur> v = ((Vec) value).vec; final ArrayList<String> labels = new ArrayList<String>(); final ArrayList<String> links = new ArrayList<String>(); for (int i = 0; i < v.size(); i++) { Ur item = v.get(i); String label = item instanceof Str ? ((Str) item).str : item.toString(); if (item instanceof Vec && ((Vec) item).vec.size() == 2) { // OLD STYLE label = ((Vec) item).vec.get(0).toString(); Matcher m = LINK_P.matcher(label); if (m.lookingAt()) { label = m.group(2) + " " + m.group(3); } label += " [" + ((Vec) item).vec.get(1).toString().length() + "]"; links.add(null); // Use old style, not links. } else { // NEW STYLE label = item.toString(); if (label.charAt(0) == '/') { String link = Terp.WHITE_PLUS.split(label, 2)[0]; links.add(link); } else { links.add(""); } } labels.add(label); } if (labels.size() != links.size()) terp.toss("lables#%d links#%d", labels.size(), links.size()); ListView listv = new ListView(this); listv.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, labels)); listv.setLayoutParams(widgetParams); listv.setTextFilterEnabled(true); listv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // When clicked, show a toast with the TextView text // Toast.makeText(getApplicationContext(), // ((TextView) view).getText(), // Toast.LENGTH_SHORT).show(); String toast_text = ((TextView) view).getText().toString(); // if (v.get(position) instanceof Vec) { if (links.get(position) == null) { // OLD STYLE Vec pair = (Vec) v.get(position); if (pair.vec.size() == 2) { if (pair.vec.get(0) instanceof Str) { String[] words = ((Str) pair.vec.get(0)).str.split("\\|"); Log.i("TT-WORDS", terp.arrayToString(words)); toast_text += "\n\n" + Static.arrayToString(words); if (words[1].equals("link")) { Uri uri = new Uri.Builder().scheme("terse").path(words[2]).build(); Intent intent = new Intent("android.intent.action.MAIN", uri); intent.setClass(getApplicationContext(), TerseActivity.class); startActivity(intent); } } } } else { // NEW STYLE terp.say("NEW STYLE LIST SELECT #%d link=<%s> label=<%s>", position, links.get(position), labels.get(position)); if (links.get(position).length() > 0) { Uri uri = new Uri.Builder().scheme("terse").path(links.get(position)).build(); Intent intent = new Intent("android.intent.action.MAIN", uri); intent.setClass(getApplicationContext(), TerseActivity.class); startActivity(intent); } } // } // Toast.makeText(getApplicationContext(), // ((TextView) view).getText(), // Toast.LENGTH_SHORT).show(); } }); setContentView(listv); return; } else if (type.str.equals("edit") && value instanceof Str) { final EditText ed = new EditText(this); ed.setText(taSaveMe == null ? value.toString() : taSaveMe); ed.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); ed.setLayoutParams(widgetParams); // ed.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); ed.setTextAppearance(this, R.style.teletype); ed.setBackgroundColor(Color.BLACK); ed.setGravity(Gravity.TOP); ed.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET); ed.setVerticalFadingEdgeEnabled(true); ed.setVerticalScrollBarEnabled(true); ed.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" // button // if ((event.getAction() == KeyEvent.ACTION_DOWN) // && // (keyCode == KeyEvent.KEYCODE_ENTER)) { // // Perform action on key press // Toast.makeText(TerseActivity.this, ed.getText(), // Toast.LENGTH_SHORT).show(); // return true; // } return false; } }); Button btn = new Button(this); btn.setText("Save"); btn.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks String text = ed.getText().toString(); text = Parser.charSubsts(text); Toast.makeText(TerseActivity.this, text, Toast.LENGTH_SHORT).show(); String action = stringAt(d, "action"); String query = ""; String f1 = stringAt(d, "field1"); String v1 = stringAt(d, "value1"); String f2 = stringAt(d, "field2"); String v2 = stringAt(d, "value2"); f1 = (f1 == null) ? "f1null" : f1; v1 = (v1 == null) ? "v1null" : v1; f2 = (f2 == null) ? "f2null" : f2; v2 = (v2 == null) ? "v2null" : v2; startTerseActivity(action, query, stringAt(d, "field1"), stringAt(d, "value1"), stringAt(d, "field2"), stringAt(d, "value2"), "text", text); } }); LinearLayout linear = new LinearLayout(this); linear.setOrientation(LinearLayout.VERTICAL); linear.addView(btn); linear.addView(ed); setContentView(linear); return; } else if (type.str.equals("draw") && value instanceof Vec) { Vec v = ((Vec) value); DrawView dv = new DrawView(this, v.vec, d); dv.setLayoutParams(widgetParams); setContentView(dv); return; } else if (type.str.equals("live")) { Blk blk = value.mustBlk(); Blk event = Static.urAt(d, "event").asBlk(); TerseSurfView tsv = new TerseSurfView(this, blk, event); setContentView(tsv); return; } else if (type.str.equals("fnord")) { Blk blk = value.mustBlk(); Blk event = Static.urAt(d, "event").asBlk(); FnordView fnord = new FnordView(this, blk, event); setContentView(fnord); return; } else if (type.str.equals("world") && value instanceof Str) { String newWorld = value.toString(); if (Terp.WORLD_P.matcher(newWorld).matches()) { world = newWorld; resetTerp(); explain = Static.fmt("Switching to world <%s>\nUse menu to go Home.", world); Toast.makeText(getApplicationContext(), explain, Toast.LENGTH_LONG).show(); } else { terp.toss("Bad world syntax (must be 3 letters then 0 to 3 digits: <%s>", newWorld); } // Fall thru for explainv.setText(explain). } else if (type.str.equals("text")) { explain = "<<< " + title + " >>>\n\n" + value.toString(); // Fall thru for explainv.setText(explain). } else if (type.str.equals("html")) { final WebView webview = new WebView(this); // webview.loadData(value.toString(), "text/html", null); webview.loadDataWithBaseURL("terse://terse", value.toString(), "text/html", "UTF-8", null); webview.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // terp.say("WebView UrlLoading: url=%s", url); URI uri = URI.create("" + url); // terp.say("WebView UrlLoading: URI=%s", uri); terp.say("WebView UrlLoading: getPath=%s", uri.getPath()); terp.say("WebView UrlLoading: getQuery=%s", uri.getQuery()); // Toast.makeText(getApplicationContext(), // uri.toASCIIString(), Toast.LENGTH_SHORT) // .show(); // webview.invalidate(); // // TextView quick = new // TextView(TerseActivity.this); // quick.setText(uri.toASCIIString()); // quick.setBackgroundColor(Color.BLACK); // quick.setTextColor(Color.WHITE); // setContentView(quick); startTerseActivity(uri.getPath(), uri.getQuery()); return true; } }); // webview.setWebChromeClient(new WebChromeClient()); webview.getSettings().setBuiltInZoomControls(true); // webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setDefaultFontSize(18); webview.getSettings().setNeedInitialFocus(true); webview.getSettings().setSupportZoom(true); webview.getSettings().setSaveFormData(true); setContentView(webview); // ScrollView scrollv = new ScrollView(this); // scrollv.addView(webview); // setContentView(scrollv); return; } else { explain = "Unknown page type: " + type.str + " with vaule type: " + value.cls + "\n\n##############\n\n"; explain += value.toString(); // Fall thru for explainv.setText(explain). } } catch (Exception ex) { ex.printStackTrace(); explain = Static.describe(ex); } } TextView explainv = new TextView(this); explainv.setText(explain); explainv.setBackgroundColor(Color.BLACK); explainv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24); explainv.setTextColor(Color.YELLOW); SetContentViewWithHomeButtonAndScroll(explainv); }
From source file:com.fvd.nimbus.PaintActivity.java
private int colorToId(int c) { int res = 0;//w w w .j av a 2 s . com switch (c) { case Color.CYAN: res = 2; break; case Color.RED: res = 5; break; case Color.GREEN: res = 3; break; case Color.WHITE: res = 0; break; case Color.BLACK: res = 7; break; } return res; }
From source file:com.nps.micro.view.TestsSectionFragment.java
private void createDeviceChooser(View rootView, final Button runButton) { availableDevicesListView = (ListView) rootView.findViewById(R.id.availableDevicesListView); availableDevicesAdapter = new ArrayAdapter<String>(getActivity(), R.layout.text_view, devicesList); availableDevicesListView.setAdapter(availableDevicesAdapter); availableDevicesListView.setTextFilterEnabled(true); availableDevicesListView.setOnItemClickListener(new OnItemClickListener() { @Override/*from w w w . ja v a 2s. c o m*/ public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { String item = (String) parent.getItemAtPosition(position); selectedDevices.add(ensureUniqueItem(item)); selectedDevicesAdapter = new StableArrayAdapter(getActivity(), R.layout.text_view, selectedDevices); selectedDevicesListView.setAdapter(selectedDevicesAdapter); setListViewHeightBasedOnChildren(selectedDevicesListView); updateModelSelectedDevices(); } private String ensureUniqueItem(String item) { if (selectedDevices.contains(item)) { return ensureUniqueItem(item + "'"); } else { return item; } } }); availableDevicesListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, final View view, int position, long id) { view.setBackgroundColor(Color.CYAN); final String item = (String) parent.getItemAtPosition(position); final String msg = getResources().getString(R.string.ping_device_info); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.ping_device_title).setMessage(String.format(msg, item)) .setPositiveButton(R.string.ping, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { view.setBackgroundColor(Color.BLACK); if (listener != null) { listener.pingDevice(item); } dialog.dismiss(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { view.setBackgroundColor(Color.BLACK); dialog.dismiss(); } }); builder.create().show(); return true; } }); setListViewHeightBasedOnChildren(availableDevicesListView); selectedDevicesListView = (DynamicListView) rootView.findViewById(R.id.selectedDevicesListView); selectedDevicesListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); selectedDevicesAdapter = new StableArrayAdapter(getActivity(), R.layout.text_view, selectedDevices); selectedDevicesListView.setListItems(selectedDevices); selectedDevicesListView.setAdapter(selectedDevicesAdapter); selectedDevicesListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { final String item = (String) parent.getItemAtPosition(position); selectedDevices.remove(item); selectedDevicesAdapter = new StableArrayAdapter(getActivity(), R.layout.text_view, selectedDevices); selectedDevicesListView.setAdapter(selectedDevicesAdapter); setListViewHeightBasedOnChildren(selectedDevicesListView); updateModelSelectedDevices(); } }); selectedDevicesListView.setOnTouchListener(new ListView.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: v.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: v.getParent().requestDisallowInterceptTouchEvent(false); break; } v.onTouchEvent(event); return true; } }); setListViewHeightBasedOnChildren(selectedDevicesListView); }
From source file:com.example.cityrally.app.engine.view.GeoActivity.java
/** * Check all the input values and flag those that are incorrect * @return true if all the widget values are correct; otherwise false *//*w w w . j a v a 2 s . c o m*/ private boolean checkInputFields() { // Start with the input validity flag set to true boolean inputOK = true; /* * Latitude, longitude, and radius values can't be empty. If they are, highlight the input * field in red and put a Toast message in the UI. Otherwise set the input field highlight * to black, ensuring that a field that was formerly wrong is reset. */ if (TextUtils.isEmpty(mLatitude1.getText())) { mLatitude1.setBackgroundColor(Color.RED); Toast.makeText(getView().getContext(), R.string.geofence_input_error_missing, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { //mLatitude1.setBackgroundColor(Color.BLACK); } if (TextUtils.isEmpty(mLongitude1.getText())) { mLongitude1.setBackgroundColor(Color.RED); Toast.makeText(getView().getContext(), R.string.geofence_input_error_missing, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { // mLongitude1.setBackgroundColor(Color.BLACK); } if (TextUtils.isEmpty(mRadius1.getText())) { mRadius1.setBackgroundColor(Color.RED); Toast.makeText(getView().getContext(), R.string.geofence_input_error_missing, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { //mRadius1.setBackgroundColor(Color.BLACK); } if (TextUtils.isEmpty(mLatitude2.getText())) { mLatitude2.setBackgroundColor(Color.RED); Toast.makeText(getView().getContext(), R.string.geofence_input_error_missing, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { //mLatitude2.setBackgroundColor(Color.BLACK); } if (TextUtils.isEmpty(mLongitude2.getText())) { mLongitude2.setBackgroundColor(Color.RED); Toast.makeText(getView().getContext(), R.string.geofence_input_error_missing, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { //mLongitude2.setBackgroundColor(Color.BLACK); } if (TextUtils.isEmpty(mRadius2.getText())) { mRadius2.setBackgroundColor(Color.RED); Toast.makeText(getView().getContext(), R.string.geofence_input_error_missing, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { mRadius2.setBackgroundColor(Color.BLACK); } /* * If all the input fields have been entered, test to ensure that their values are within * the acceptable range. The tests can't be performed until it's confirmed that there are * actual values in the fields. */ /* if (inputOK) { /* * Get values from the latitude, longitude, and radius fields. */ /* double lat1 = Double.valueOf(mLatitude1.getText().toString()); double lng1 = Double.valueOf(mLongitude1.getText().toString()); double lat2 = Double.valueOf(mLatitude1.getText().toString()); double lng2 = Double.valueOf(mLongitude1.getText().toString()); float rd1 = Float.valueOf(mRadius1.getText().toString()); float rd2 = Float.valueOf(mRadius2.getText().toString()); /* * Test latitude and longitude for minimum and maximum values. Highlight incorrect * values and set a Toast in the UI. */ /* if (lat1 > GeofenceUtils.MAX_LATITUDE || lat1 < GeofenceUtils.MIN_LATITUDE) { mLatitude1.setBackgroundColor(Color.RED); Toast.makeText( getView().getContext(), R.string.geofence_input_error_latitude_invalid, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { mLatitude1.setBackgroundColor(Color.BLACK); } if ((lng1 > GeofenceUtils.MAX_LONGITUDE) || (lng1 < GeofenceUtils.MIN_LONGITUDE)) { mLongitude1.setBackgroundColor(Color.RED); Toast.makeText( getView().getContext(), R.string.geofence_input_error_longitude_invalid, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { mLongitude1.setBackgroundColor(Color.BLACK); } if (lat2 > GeofenceUtils.MAX_LATITUDE || lat2 < GeofenceUtils.MIN_LATITUDE) { mLatitude2.setBackgroundColor(Color.RED); Toast.makeText( getView().getContext(), R.string.geofence_input_error_latitude_invalid, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { mLatitude2.setBackgroundColor(Color.BLACK); } if ((lng2 > GeofenceUtils.MAX_LONGITUDE) || (lng2 < GeofenceUtils.MIN_LONGITUDE)) { mLongitude2.setBackgroundColor(Color.RED); Toast.makeText( getView().getContext(), R.string.geofence_input_error_longitude_invalid, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { mLongitude2.setBackgroundColor(Color.BLACK); } if (rd1 < GeofenceUtils.MIN_RADIUS) { mRadius1.setBackgroundColor(Color.RED); Toast.makeText( getView().getContext(), R.string.geofence_input_error_radius_invalid, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { mRadius1.setBackgroundColor(Color.BLACK); } if (rd2 < GeofenceUtils.MIN_RADIUS) { mRadius2.setBackgroundColor(Color.RED); Toast.makeText( getView().getContext(), R.string.geofence_input_error_radius_invalid, Toast.LENGTH_LONG).show(); // Set the validity to "invalid" (false) inputOK = false; } else { mRadius2.setBackgroundColor(Color.BLACK); } } */ // If everything passes, the validity flag will still be true, otherwise it will be false. return inputOK; }
From source file:com.makotojava.android.debate.PolicySpeechFragment.java
private void createSpeechTimerOnLongClickListener(TextView speechTimer) { speechTimer.setOnLongClickListener(new OnLongClickListener() { @Override//from w w w . j av a 2 s . co m public boolean onLongClick(View v) { getActivity().startActionMode(new ActionMode.Callback() { @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public void onDestroyActionMode(ActionMode mode) { // Nothing to do } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // Inflate the menu MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.speech_timer_context_menu, menu); return true; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { boolean ret = false; switch (item.getItemId()) { case R.id.speech_context_menu_item_reset: Log.i(TAG, "CONTEXT MENU: Speech Timer **RESET**"); long originalDurationInMillis = _speechTimer.reset(); updateTimerTextView(_speechTimerTextView, originalDurationInMillis); _speechTimerTextView.setTextColor(Color.BLACK); ret = true; break; case R.id.speech_context_menu_item_set: Log.i(TAG, "CONTEXT MENU: Speech Timer **SET**"); // Display dialog to set Timer FragmentManager fragMan = getActivity().getFragmentManager(); TimePickerFragment dialog = TimePickerFragment.newInstance( _speechTimer.getMillisUntilFinished(), _speech.getDurationInMinutes(), RQID_SPEECHTIMER); dialog.setTargetFragment(PolicySpeechFragment.this, 0); dialog.show(fragMan, MINUTES_SECONDS_PICKER_TITLE); _speechTimerTextView.setTextColor(Color.BLACK); ret = true; break; } return ret; } }); return true; } }); }
From source file:net.droidsolutions.droidcharts.core.plot.CategoryPlot.java
/** * Creates a new plot./*w w w .j a v a2s. c o m*/ * * @param dataset * the dataset (<code>null</code> permitted). * @param domainAxis * the domain axis (<code>null</code> permitted). * @param rangeAxis * the range axis (<code>null</code> permitted). * @param renderer * the item renderer (<code>null</code> permitted). * */ public CategoryPlot(CategoryDataset dataset, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryItemRenderer renderer) { super(); this.orientation = PlotOrientation.VERTICAL; // allocate storage for dataset, axes and renderers this.domainAxes = new ObjectList(); this.domainAxisLocations = new ObjectList(); this.rangeAxes = new ObjectList(); this.rangeAxisLocations = new ObjectList(); this.datasetToDomainAxesMap = new TreeMap(); this.datasetToRangeAxesMap = new TreeMap(); this.renderers = new ObjectList(); this.datasets = new ObjectList(); this.datasets.set(0, dataset); this.axisOffset = RectangleInsets.ZERO_INSETS; setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT, false); setRangeAxisLocation(AxisLocation.TOP_OR_LEFT, false); this.renderers.set(0, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } this.domainAxes.set(0, domainAxis); this.mapDatasetToDomainAxis(0, 0); if (domainAxis != null) { domainAxis.setPlot(this); } this.drawSharedDomainAxis = false; this.rangeAxes.set(0, rangeAxis); this.mapDatasetToRangeAxis(0, 0); if (rangeAxis != null) { rangeAxis.setPlot(this); } configureDomainAxes(); configureRangeAxes(); this.domainGridlinesVisible = DEFAULT_DOMAIN_GRIDLINES_VISIBLE; this.domainGridlinePosition = CategoryAnchor.MIDDLE; this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeZeroBaselineVisible = false; Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.BLACK); this.rangeZeroBaselinePaint = paint; this.rangeZeroBaselineStroke = .5f; this.rangeGridlinesVisible = DEFAULT_RANGE_GRIDLINES_VISIBLE; this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeMinorGridlinesVisible = false; this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); this.rangeMinorGridlinePaint = paint; this.foregroundDomainMarkers = new HashMap(); this.backgroundDomainMarkers = new HashMap(); this.foregroundRangeMarkers = new HashMap(); this.backgroundRangeMarkers = new HashMap(); this.anchorValue = 0.0; this.domainCrosshairVisible = false; this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.rangeCrosshairVisible = DEFAULT_CROSSHAIR_VISIBLE; this.rangeCrosshairValue = 0.0; this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.annotations = new java.util.ArrayList(); this.rangePannable = false; }
From source file:com.heinrichreimersoftware.materialintro.app.IntroActivity.java
private void updateBackground() { @ColorInt//from ww w . jav a 2 s. com int background; @ColorInt int backgroundNext; @ColorInt int backgroundDark; @ColorInt int backgroundDarkNext; if (position == getCount()) { background = Color.TRANSPARENT; backgroundNext = Color.TRANSPARENT; backgroundDark = Color.TRANSPARENT; backgroundDarkNext = Color.TRANSPARENT; } else { background = ContextCompat.getColor(IntroActivity.this, getBackground(position)); backgroundNext = ContextCompat.getColor(IntroActivity.this, getBackground(Math.min(position + 1, getCount() - 1))); background = ColorUtils.setAlphaComponent(background, 0xFF); backgroundNext = ColorUtils.setAlphaComponent(backgroundNext, 0xFF); try { backgroundDark = ContextCompat.getColor(IntroActivity.this, getBackgroundDark(position)); } catch (Resources.NotFoundException e) { backgroundDark = ContextCompat.getColor(IntroActivity.this, R.color.mi_status_bar_background); } try { backgroundDarkNext = ContextCompat.getColor(IntroActivity.this, getBackgroundDark(Math.min(position + 1, getCount() - 1))); } catch (Resources.NotFoundException e) { backgroundDarkNext = ContextCompat.getColor(IntroActivity.this, R.color.mi_status_bar_background); } } if (position + positionOffset >= adapter.getCount() - 1) { backgroundNext = ColorUtils.setAlphaComponent(background, 0x00); backgroundDarkNext = ColorUtils.setAlphaComponent(backgroundDark, 0x00); } background = (Integer) evaluator.evaluate(positionOffset, background, backgroundNext); backgroundDark = (Integer) evaluator.evaluate(positionOffset, backgroundDark, backgroundDarkNext); miFrame.setBackgroundColor(background); float[] backgroundDarkHsv = new float[3]; Color.colorToHSV(backgroundDark, backgroundDarkHsv); //Slightly darken the background color a bit for more contrast backgroundDarkHsv[2] *= 0.95; int backgroundDarker = Color.HSVToColor(backgroundDarkHsv); miPagerIndicator.setPageIndicatorColor(backgroundDarker); ViewCompat.setBackgroundTintList(miButtonNext, ColorStateList.valueOf(backgroundDarker)); ViewCompat.setBackgroundTintList(miButtonBack, ColorStateList.valueOf(backgroundDarker)); @ColorInt int backgroundButtonCta = buttonCtaTintMode == BUTTON_CTA_TINT_MODE_TEXT ? ContextCompat.getColor(this, android.R.color.white) : backgroundDarker; ViewCompat.setBackgroundTintList(miButtonCta.getChildAt(0), ColorStateList.valueOf(backgroundButtonCta)); ViewCompat.setBackgroundTintList(miButtonCta.getChildAt(1), ColorStateList.valueOf(backgroundButtonCta)); int iconColor; if (ColorUtils.calculateLuminance(backgroundDark) > 0.4) { //Light background iconColor = ContextCompat.getColor(this, R.color.mi_icon_color_light); } else { //Dark background iconColor = ContextCompat.getColor(this, R.color.mi_icon_color_dark); } miPagerIndicator.setCurrentPageIndicatorColor(iconColor); DrawableCompat.setTint(miButtonNext.getDrawable(), iconColor); DrawableCompat.setTint(miButtonBack.getDrawable(), iconColor); @ColorInt int textColorButtonCta = buttonCtaTintMode == BUTTON_CTA_TINT_MODE_TEXT ? backgroundDarker : iconColor; ((Button) miButtonCta.getChildAt(0)).setTextColor(textColorButtonCta); ((Button) miButtonCta.getChildAt(1)).setTextColor(textColorButtonCta); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(backgroundDark); if (position == adapter.getCount()) { getWindow().setNavigationBarColor(Color.TRANSPARENT); } else if (position + positionOffset >= adapter.getCount() - 1) { TypedValue typedValue = new TypedValue(); TypedArray a = obtainStyledAttributes(typedValue.data, new int[] { android.R.attr.navigationBarColor }); int defaultNavigationBarColor = a.getColor(0, Color.BLACK); a.recycle(); int navigationBarColor = (Integer) evaluator.evaluate(positionOffset, defaultNavigationBarColor, Color.TRANSPARENT); getWindow().setNavigationBarColor(navigationBarColor); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { int systemUiVisibility = getWindow().getDecorView().getSystemUiVisibility(); int flagLightStatusBar = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; if (ColorUtils.calculateLuminance(backgroundDark) > 0.4) { //Light background systemUiVisibility |= flagLightStatusBar; } else { //Dark background systemUiVisibility &= ~flagLightStatusBar; } getWindow().getDecorView().setSystemUiVisibility(systemUiVisibility); } } }
From source file:com.matthewtamlin.sliding_intro_screen_library.core.IntroActivity.java
/** * Shows the status bar background and prevents Views from being drawn behind the status bar. * The primary dark color of the current theme will be used for the status bar color (on SDK * version 21 and higher). If the current theme does not specify a primary dark color, the * status bar will be colored black./* w w w . j a v a 2 s. co m*/ * * @deprecated use the AndroidUtilities library directly (com.matthewtamlin:android-utilities) */ @Deprecated public final void showStatusBar() { final int statusBarColor = ThemeColorHelper.getPrimaryDarkColor(this, Color.BLACK); StatusBarHelper.showStatusBar(getWindow(), statusBarColor); }
From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java
private void setListeners() { final ImageButton penButton = (ImageButton) findViewById(R.id.supersede_feedbacklibrary_pen_btn); final ImageButton rectangleButton = (ImageButton) findViewById( R.id.supersede_feedbacklibrary_rectangle_btn); final ImageButton circleButton = (ImageButton) findViewById(R.id.supersede_feedbacklibrary_circle_btn); final ImageButton lineButton = (ImageButton) findViewById(R.id.supersede_feedbacklibrary_line_btn); final ImageButton arrowButton = (ImageButton) findViewById(R.id.supersede_feedbacklibrary_arrow_btn); final ImageButton stickerButton = (ImageButton) findViewById(R.id.supersede_feedbacklibrary_sticker_btn); final ImageButton colorPickerButton = (ImageButton) findViewById( R.id.supersede_feedbacklibrary_color_picker_btn); final ImageButton cropButton = (ImageButton) findViewById(R.id.supersede_feedbacklibrary_crop_btn); final ImageButton textAnnotationButton = (ImageButton) findViewById( R.id.supersede_feedbacklibrary_text_comment_btn); final ImageButton undoButton = (ImageButton) findViewById(R.id.supersede_feedbacklibrary_undo_btn); final ImageButton redoButton = (ImageButton) findViewById(R.id.supersede_feedbacklibrary_redo_btn); final Button blurButton = (Button) findViewById(R.id.supersede_feedbacklibrary_blur_btn); final Button fillButton = (Button) findViewById(R.id.supersede_feedbacklibrary_fill_btn); final Button blackButton = (Button) findViewById(R.id.supersede_feedbacklibrary_black_btn); if (colorPickerButton != null) { colorPickerButton.setOnClickListener(new View.OnClickListener() { @Override/* w w w .ja va 2 s . co m*/ public void onClick(View v) { showColorPickerDialog(); } }); } if (blurButton != null) { blurButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!(annotateImageView.getBlur() > 0F)) { annotateImageView.setOpacity(180); annotateImageView.setBlur(10F); blurButton.setText(R.string.supersede_feedbacklibrary_unblurbutton_text); } else { annotateImageView.setOpacity(255); annotateImageView.setBlur(0F); blurButton.setText(R.string.supersede_feedbacklibrary_blurbutton_text); } } }); } if (fillButton != null) { fillButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (annotateImageView.getPaintStyle() == Paint.Style.FILL) { annotateImageView.setPaintStyle(Paint.Style.STROKE); fillButton.setText(R.string.supersede_feedbacklibrary_fillbutton_text); } else { annotateImageView.setPaintStyle(Paint.Style.FILL); fillButton.setText(R.string.supersede_feedbacklibrary_strokebutton_text); } } }); } if (blackButton != null && colorPickerButton != null) { blackButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!blackModeOn) { oldPaintStrokeColor = annotateImageView.getPaintStrokeColor(); oldPaintFillColor = annotateImageView.getPaintFillColor(); annotateImageView.setPaintStrokeColor(Color.BLACK); annotateImageView.setPaintFillColor(Color.BLACK); colorPickerButton.setEnabled(false); blackButton.setText(R.string.supersede_feedbacklibrary_colorbutton_text); } else { annotateImageView.setPaintStrokeColor(oldPaintStrokeColor); annotateImageView.setPaintFillColor(oldPaintFillColor); colorPickerButton.setEnabled(true); blackButton.setText(R.string.supersede_feedbacklibrary_blackbutton_text); } blackModeOn = !blackModeOn; } }); } if (penButton != null) { penButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { annotateImageView.setDrawer(AnnotateImageView.Drawer.PEN); } }); } if (lineButton != null) { lineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { annotateImageView.setDrawer(AnnotateImageView.Drawer.LINE); } }); } if (arrowButton != null) { arrowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { annotateImageView.setDrawer(AnnotateImageView.Drawer.ARROW); } }); } if (undoButton != null && redoButton != null) { annotateImageView.setUndoButton(undoButton); undoButton.setEnabled(false); undoButton.setAlpha(0.4F); undoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (annotateImageView.isUndoable()) { redoButton.setEnabled(annotateImageView.undo()); redoButton.setAlpha(1.0F); if (!annotateImageView.isUndoable()) { undoButton.setEnabled(false); undoButton.setAlpha(0.4F); annotateImageView.setNoActionExecuted(true); } } } }); annotateImageView.setRedoButton(redoButton); redoButton.setEnabled(false); redoButton.setAlpha(0.4F); redoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (annotateImageView.isRedoable()) { undoButton.setEnabled(annotateImageView.redo()); undoButton.setAlpha(1.0F); if (!annotateImageView.isRedoable()) { redoButton.setEnabled(false); redoButton.setAlpha(0.4F); } } } }); } if (rectangleButton != null) { rectangleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { annotateImageView.setDrawer(AnnotateImageView.Drawer.RECTANGLE); } }); } if (circleButton != null) { circleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { annotateImageView.setDrawer(AnnotateImageView.Drawer.CIRCLE); } }); } if (cropButton != null) { cropButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Bitmap tempBitmap = annotateImageView.getBitmap(); Bitmap croppedBitmap = Bitmap.createBitmap(tempBitmap, 0, 0, tempBitmap.getWidth(), tempBitmap.getHeight()); File tempFile = Utils.createTempChacheFile(getApplicationContext(), "crop", ".jpg"); if (Utils.saveBitmapToFile(tempFile, croppedBitmap, Bitmap.CompressFormat.JPEG, 100)) { Uri cropInput = Uri.fromFile(tempFile); CropImage.activity(cropInput).setGuidelines(CropImageView.Guidelines.ON) .start(AnnotateImageActivity.this); } } }); } if (stickerButton != null) { stickerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showStickerDialog(); } }); } if (textAnnotationButton != null) { textAnnotationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { addTextAnnotation(R.drawable.ic_comment_black_48dp); } }); } }