List of usage examples for android.graphics Color WHITE
int WHITE
To view the source code for android.graphics Color WHITE.
Click Source Link
From source file:com.cellbots.logger.LoggerActivity.java
private void updateSensorUi(int sensorType, int accuracy, float[] values) { // IMPORTANT: DO NOT UPDATE THE CONTENTS INSIDE A DRAWER IF IT IS BEING // ANIMATED VIA A CALL TO animateOpen/animateClose!!! // Updating anything inside will stop the animation from running. // Note that this does not seem to affect the animation if it had been // triggered by dragging the drawer instead of being called // programatically. if (mDataDrawer.isMoving()) { return;//from www . j ava2s .c o m } TextView xTextView; TextView yTextView; TextView zTextView; if (sensorType == Sensor.TYPE_ACCELEROMETER) { xTextView = mAccelXTextView; yTextView = mAccelYTextView; zTextView = mAccelZTextView; } else if (sensorType == Sensor.TYPE_GYROSCOPE) { xTextView = mGyroXTextView; yTextView = mGyroYTextView; zTextView = mGyroZTextView; } else if (sensorType == Sensor.TYPE_MAGNETIC_FIELD) { xTextView = mMagXTextView; yTextView = mMagYTextView; zTextView = mMagZTextView; } else { return; } int textColor = Color.WHITE; String prefix = ""; switch (accuracy) { case SensorManager.SENSOR_STATUS_ACCURACY_HIGH: prefix = " "; break; case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM: prefix = " *"; break; case SensorManager.SENSOR_STATUS_ACCURACY_LOW: prefix = " **"; break; case SensorManager.SENSOR_STATUS_UNRELIABLE: prefix = " ***"; break; } xTextView.setTextColor(textColor); yTextView.setTextColor(textColor); zTextView.setTextColor(textColor); xTextView.setText(prefix + numberDisplayFormatter(values[0])); yTextView.setText(prefix + numberDisplayFormatter(values[1])); zTextView.setText(prefix + numberDisplayFormatter(values[2])); }
From source file:net.droidsolutions.droidcharts.core.plot.XYPlot.java
/** * Creates a new plot with the specified dataset, axes and renderer. Any of * the arguments can be <code>null</code>, but in that case you should take * care to specify the value before using the plot (otherwise a * <code>NullPointerException</code> may be thrown). * //from w ww. ja v a 2 s . co 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 renderer (<code>null</code> permitted). */ public XYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer) { super(); this.orientation = PlotOrientation.VERTICAL; this.weight = 1; // only relevant when this is a subplot this.axisOffset = RectangleInsets.ZERO_INSETS; // allocate storage for datasets, axes and renderers (all optional) this.domainAxes = new ObjectList(); this.domainAxisLocations = new ObjectList(); this.foregroundDomainMarkers = new HashMap(); this.backgroundDomainMarkers = new HashMap(); this.rangeAxes = new ObjectList(); this.rangeAxisLocations = new ObjectList(); this.foregroundRangeMarkers = new HashMap(); this.backgroundRangeMarkers = new HashMap(); this.datasets = new ObjectList(); this.renderers = new ObjectList(); this.datasetToDomainAxesMap = new TreeMap(); this.datasetToRangeAxesMap = new TreeMap(); this.annotations = new java.util.ArrayList(); this.datasets.set(0, dataset); if (dataset != null) { // dataset.addChangeListener(this); } 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); // domainAxis.addChangeListener(this); } this.domainAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); this.rangeAxes.set(0, rangeAxis); this.mapDatasetToRangeAxis(0, 0); if (rangeAxis != null) { rangeAxis.setPlot(this); // rangeAxis.addChangeListener(this); } this.rangeAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); configureDomainAxes(); configureRangeAxes(); Paint white = new Paint(Paint.ANTI_ALIAS_FLAG); white.setColor(Color.WHITE); Paint black = new Paint(Paint.ANTI_ALIAS_FLAG); white.setColor(Color.BLACK); this.domainGridlinesVisible = true; this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.domainMinorGridlinesVisible = false; this.domainMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainMinorGridlinePaint = white; this.domainZeroBaselineVisible = false; this.domainZeroBaselinePaint = black; this.domainZeroBaselineStroke = 1f; this.rangeGridlinesVisible = true; this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeMinorGridlinesVisible = false; this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeMinorGridlinePaint = white; this.rangeZeroBaselineVisible = false; this.rangeZeroBaselinePaint = black; this.rangeZeroBaselineStroke = 1f; this.domainCrosshairVisible = false; this.domainCrosshairValue = 0.0; this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.rangeCrosshairVisible = false; this.rangeCrosshairValue = 0.0; this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; }
From source file:com.cybrosys.scientific.EventListener.java
@SuppressWarnings("deprecation") public void showHistory() { shPref = ScientificActivity.ctx.getSharedPreferences("myHistpref", 0); int inSize = shPref.getInt("HistIndex", 0); System.out.println("" + inSize); String[] str = new String[inSize]; for (int inI = 0; inI < inSize; inI++) { str[inI] = shPref.getString("hist" + inI, ""); System.out.println(str[inI]); }//from ww w .ja v a 2 s . c o m LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); vwLayout = inflater.inflate(R.layout.pop_history, (ViewGroup) ((Activity) ctx).findViewById(R.id.popup_element)); popmW1 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW1.setBackgroundDrawable(new BitmapDrawable()); popmW1.setOutsideTouchable(true); popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 0); tblltTable = (TableLayout) vwLayout.findViewById(R.id.tablelay); ImageButton btnCancel = (ImageButton) vwLayout.findViewById(R.id.butcancelmain); btnCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW1.dismiss(); } }); txtvHistory = new TextView[inSize]; btnHistory = new Button[inSize]; tblrRowL = new TableRow[inSize]; TableRow.LayoutParams buttonParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f); TableRow.LayoutParams textParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT, .1f); int inJ = 0, inL = inSize - 1; for (int inI = 0; inI < inSize; inI++) { if (!str[inI].equalsIgnoreCase("")) { btnHistory[inJ] = new Button(ctx); txtvHistory[inJ] = new TextView(ctx); txtvHistory[inJ].setText("" + (inJ + 1)); txtvHistory[inJ].setGravity(Gravity.CENTER); txtvHistory[inJ].setTextColor(ScientificActivity.ctx.getResources().getColor(R.color.HistColor)); txtvHistory[inJ].setLayoutParams(textParams); btnHistory[inJ].setText(str[inL]); btnHistory[inJ].setTextColor(Color.WHITE); btnHistory[inJ].setGravity(Gravity.LEFT); btnHistory[inJ].setLayoutParams(buttonParams); btnHistory[inJ].setBackgroundDrawable(ctx.getResources().getDrawable(R.drawable.button_effect)); tblrRowL[inJ] = new TableRow(ctx); tblrRowL[inJ].addView(txtvHistory[inJ]); tblrRowL[inJ].addView(btnHistory[inJ]); tblltTable.addView(tblrRowL[inJ]); final int inK = inJ; btnHistory[inK].setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // etxt.setText(btns[inK].getText().toString()); mHandler.insert(btnHistory[inK].getText().toString()); popmW1.dismiss(); } }); inJ++; inL--; } } if (inSize == 0) { TextView txtvHistory = new TextView(ctx); txtvHistory.setLayoutParams(textParams); txtvHistory.setGravity(Gravity.CENTER); txtvHistory.setTextColor(Color.WHITE); txtvHistory.setText("History Empty"); TableRow tblrRowL = new TableRow(ctx); tblrRowL.addView(txtvHistory); tblltTable.addView(tblrRowL); } }
From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedPost.java
private void rebuildSubtitle(Context context) { // TODO customise display // TODO preference for the X days, X hours thing final TypedArray appearance = context .obtainStyledAttributes(new int[] { R.attr.srPostSubtitleBoldCol, R.attr.srPostSubtitleUpvoteCol, R.attr.srPostSubtitleDownvoteCol, R.attr.srFlairBackCol, R.attr.srFlairTextCol }); final int boldCol = appearance.getColor(0, 255), rrPostSubtitleUpvoteCol = appearance.getColor(1, 255), rrPostSubtitleDownvoteCol = appearance.getColor(2, 255), rrFlairBackCol = appearance.getColor(3, 255), rrFlairTextCol = appearance.getColor(4, 255); appearance.recycle();/*from w w w.j a v a 2 s. c o m*/ final BetterSSB postListDescSb = new BetterSSB(); // SpannableStringBuilder for the Karma that goes between our up/downvote arrows final BetterSSB karmaSb = new BetterSSB(); final int pointsCol; final int score = computeScore(); if (isUpvoted()) { pointsCol = rrPostSubtitleUpvoteCol; } else if (isDownvoted()) { pointsCol = rrPostSubtitleDownvoteCol; } else { pointsCol = boldCol; } if (src.isSpoiler()) { postListDescSb.append(" SPOILER ", BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR, Color.WHITE, Color.rgb(50, 50, 50), 1f); postListDescSb.append(" ", 0); } if (src.isStickied()) { postListDescSb.append(" STICKY ", BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR, Color.WHITE, Color.rgb(0, 170, 0), 1f); // TODO color? postListDescSb.append(" ", 0); } if (src.isNsfw()) { postListDescSb.append(" NSFW ", BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR, Color.WHITE, Color.RED, 1f); // TODO color? postListDescSb.append(" ", 0); } if (src.getFlairText() != null) { postListDescSb.append(" " + src.getFlairText() + " ", BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR, rrFlairTextCol, rrFlairBackCol, 1f); postListDescSb.append(" ", 0); } postListDescSb.append(String.valueOf(score), BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, pointsCol, 0, 1f); postListDescSb.append(" " + context.getString(R.string.subtitle_points) + " ", 0); postListDescSb.append(SRTime.formatDurationFrom(context, src.getCreatedTimeSecsUTC() * 1000), BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, boldCol, 0, 1f); postListDescSb.append(" " + context.getString(R.string.subtitle_by) + " ", 0); postListDescSb.append(src.getAuthor(), BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, boldCol, 0, 1f); if (showSubreddit) { postListDescSb.append(" " + context.getString(R.string.subtitle_to) + " ", 0); postListDescSb.append(src.getSubreddit(), BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, boldCol, 0, 1f); } postListDescSb.append(" (" + src.getDomain() + ")", 0); karmaSb.append(String.valueOf(score), BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, pointsCol, 0, 1f); postListDescription = postListDescSb.get(); postKarma = karmaSb.get(); }
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
public void setUpTheme() { actionBar = getActionBar();/*from www .j a v a2s. c om*/ if (!getResources().getBoolean(R.bool.isTablet)) { actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); } else { actionBar.setIcon(R.mipmap.ic_launcher); } if (Build.VERSION.SDK_INT > 18 && settings.uiExtras && (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE || getResources().getBoolean(R.bool.isTablet)) && !MainActivity.isPopup) { translucent = true; getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); try { int immersive = android.provider.Settings.System.getInt(getContentResolver(), "immersive_mode"); if (immersive == 1) { translucent = false; } } catch (Exception e) { } } else { translucent = false; } Utils.setUpTheme(context, settings); /*if (settings.addonTheme) { getWindow().getDecorView().setBackgroundColor(settings.backgroundColor); } else { TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{R.attr.windowBackground}); int resource = a.getResourceId(0, 0); a.recycle(); getWindow().getDecorView().setBackgroundResource(resource); }*/ // this is a super hacky workaround for the theme problems that some people were having... but it works ok int actionBarTitleId = 0; TextView title = null; try { actionBarTitleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); } catch (Exception e) { // just in case } if (actionBarTitleId > 0) { title = (TextView) findViewById(actionBarTitleId); } switch (settings.theme) { case AppSettings.THEME_LIGHT: getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_solid_light_holo)); if (title != null) { title.setTextColor(Color.BLACK); } break; case AppSettings.THEME_DARK: getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_solid_dark)); if (title != null) { title.setTextColor(Color.WHITE); } break; case AppSettings.THEME_BLACK: getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_solid_black)); if (title != null) { title.setTextColor(Color.WHITE); } break; } Utils.setActionBar(context, true); }
From source file:com.ryan.ryanreader.reddit.prepared.RedditPreparedPost.java
public VerticalToolbar generateToolbar(final Context context, final Fragment fragmentParent, final SideToolbarOverlay overlay) { final VerticalToolbar toolbar = new VerticalToolbar(context); final EnumSet<Action> itemsPref = PrefsUtility.pref_menus_post_toolbar_items(context, PreferenceManager.getDefaultSharedPreferences(context)); final Action[] possibleItems = { Action.ACTION_MENU, fragmentParent instanceof CommentListingFragment ? Action.LINK_SWITCH : Action.COMMENTS_SWITCH, Action.UPVOTE, Action.DOWNVOTE, Action.SAVE, Action.HIDE, Action.REPLY, Action.EXTERNAL, Action.SAVE_IMAGE, Action.SHARE, Action.COPY, Action.USER_PROFILE, Action.PROPERTIES }; // TODO make static final EnumMap<Action, Integer> iconsDark = new EnumMap<Action, Integer>(Action.class); iconsDark.put(Action.ACTION_MENU, R.drawable.ic_action_overflow); iconsDark.put(Action.COMMENTS_SWITCH, R.drawable.ic_action_comments_dark); iconsDark.put(Action.LINK_SWITCH, imageUrl != null ? R.drawable.ic_action_image_dark : R.drawable.ic_action_page_dark); iconsDark.put(Action.UPVOTE, R.drawable.action_upvote_dark); iconsDark.put(Action.DOWNVOTE, R.drawable.action_downvote_dark); iconsDark.put(Action.SAVE, R.drawable.ic_action_star_filled_dark); iconsDark.put(Action.HIDE, R.drawable.ic_action_cross_dark); iconsDark.put(Action.REPLY, R.drawable.ic_action_reply_dark); iconsDark.put(Action.EXTERNAL, R.drawable.ic_action_globe_dark); iconsDark.put(Action.SAVE_IMAGE, R.drawable.ic_action_save_dark); iconsDark.put(Action.SHARE, R.drawable.ic_action_share_dark); iconsDark.put(Action.COPY, R.drawable.ic_action_copy_dark); iconsDark.put(Action.USER_PROFILE, R.drawable.ic_action_person_dark); iconsDark.put(Action.PROPERTIES, R.drawable.ic_action_info_dark); final EnumMap<Action, Integer> iconsLight = new EnumMap<Action, Integer>(Action.class); iconsLight.put(Action.ACTION_MENU, R.drawable.ic_action_overflow); iconsLight.put(Action.COMMENTS_SWITCH, R.drawable.ic_action_comments_light); iconsLight.put(Action.LINK_SWITCH, imageUrl != null ? R.drawable.ic_action_image_light : R.drawable.ic_action_page_light); iconsLight.put(Action.UPVOTE, R.drawable.action_upvote_light); iconsLight.put(Action.DOWNVOTE, R.drawable.action_downvote_light); iconsLight.put(Action.SAVE, R.drawable.ic_action_star_filled_light); iconsLight.put(Action.HIDE, R.drawable.ic_action_cross_light); iconsLight.put(Action.REPLY, R.drawable.ic_action_reply_light); iconsLight.put(Action.EXTERNAL, R.drawable.ic_action_globe_light); iconsLight.put(Action.SAVE_IMAGE, R.drawable.ic_action_save_light); iconsLight.put(Action.SHARE, R.drawable.ic_action_share_light); iconsLight.put(Action.COPY, R.drawable.ic_action_copy_light); iconsLight.put(Action.USER_PROFILE, R.drawable.ic_action_person_light); iconsLight.put(Action.PROPERTIES, R.drawable.ic_action_info_light); for (final Action action : possibleItems) { if (action == Action.SAVE_IMAGE && imageUrl == null) continue; if (itemsPref.contains(action)) { final FlatImageButton ib = new FlatImageButton(context); final int buttonPadding = General.dpToPixels(context, 10); ib.setPadding(buttonPadding, buttonPadding, buttonPadding, buttonPadding); if (action == Action.UPVOTE && isUpvoted() || action == Action.DOWNVOTE && isDownvoted() || action == Action.SAVE && isSaved() || action == Action.HIDE && isHidden()) { ib.setBackgroundColor(Color.WHITE); ib.setImageResource(iconsLight.get(action)); } else { ib.setImageResource(iconsDark.get(action)); // TODO highlight on click }//from w ww . ja v a 2 s .c o m ib.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final Action actionToTake; switch (action) { case UPVOTE: actionToTake = isUpvoted() ? Action.UNVOTE : Action.UPVOTE; break; case DOWNVOTE: actionToTake = isDownvoted() ? Action.UNVOTE : Action.DOWNVOTE; break; case SAVE: actionToTake = isSaved() ? Action.UNSAVE : Action.SAVE; break; case HIDE: actionToTake = isHidden() ? Action.UNHIDE : Action.HIDE; break; default: actionToTake = action; break; } onActionMenuItemSelected(RedditPreparedPost.this, fragmentParent, actionToTake); overlay.hide(); } }); toolbar.addItem(ib); } } return toolbar; }
From source file:ab.util.AbDialogUtil.java
/** * popupwindow/* w w w . ja v a2s . c o m*/ */ public static PopupWindow showPopWindow(Context context, View targetView, View contentView, Integer width) { PopupWindow popupWindow = null; popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); if (width != null) { popupWindow.setWidth(width); } popupWindow.setOutsideTouchable(true); popupWindow.showAsDropDown(targetView); return popupWindow; }
From source file:com.ichi2.anki2.Reviewer.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); Log.i(AnkiDroidApp.TAG, "Reviewer - onCreate"); // Remove the status bar and title bar if (mPrefFullscreenReview) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Do not hide the title bar in Honeycomb, since it contains the action bar. if (AnkiDroidApp.SDK_VERSION <= 11) { requestWindowFeature(Window.FEATURE_NO_TITLE); }//w w w .java2 s. co m } mChangeBorderStyle = Themes.getTheme() == Themes.THEME_ANDROID_LIGHT || Themes.getTheme() == Themes.THEME_ANDROID_DARK; // The hardware buttons should control the music volume while reviewing. setVolumeControlStream(AudioManager.STREAM_MUSIC); Collection col = AnkiDroidApp.getCol(); if (col == null) { reloadCollection(savedInstanceState); return; } else { mSched = col.getSched(); mCollectionFilename = col.getPath(); mBaseUrl = Utils.getBaseUrl(col.getMedia().getDir()); restorePreferences(); setFullScreen(mPrefFullscreenReview); registerExternalStorageListener(); if (mNightMode) { mCurrentBackgroundColor = Themes.getNightModeCardBackground(this); } else { mCurrentBackgroundColor = Color.WHITE; } mRefreshWebview = getRefreshWebviewAndInitializeWebviewVariables(); initLayout(R.layout.flashcard); try { String[] title = mSched.getCol().getDecks().current().getString("name").split("::"); AnkiDroidApp.getCompat().setTitle(this, title[title.length - 1], mInvertedColors); } catch (JSONException e) { throw new RuntimeException(e); } AnkiDroidApp.getCompat().setSubtitle(this, "", mInvertedColors); if (mPrefTextSelection) { clipboardSetText(""); } // Load the template for the card try { mCardTemplate = Utils.convertStreamToString(getAssets().open("card_template.html")); } catch (IOException e) { e.printStackTrace(); } // Initialize text-to-speech. This is an asynchronous operation. if (mSpeakText) { ReadText.initializeTts(this); } // Initialize answer recorder if (mPrefRecord) { Recorder.initialize(this); } // Get last whiteboard state if (mPrefWhiteboard && mCurrentCard != null && MetaDB.getWhiteboardState(this, mCurrentCard.getDid()) == 1) { mShowWhiteboard = true; mWhiteboard.setVisibility(View.VISIBLE); } // Load the first card and start reviewing. Uses the answer card // task to load a card, but since we send null // as the card to answer, no card will be answered. DeckTask.launchDeckTask(DeckTask.TASK_TYPE_ANSWER_CARD, mAnswerCardHandler, new DeckTask.TaskData(mSched, null, 0)); // Since we aren't actually answering a card, decrement the rep count mSched.setReps(mSched.getReps() - 1); } }
From source file:ab.util.AbDialogUtil.java
/** * popupwindow/*from w w w .j a v a 2 s .c o m*/ */ public static PopupWindow showPopWindow2(Context context, View targetView, View contentView, Integer width) { PopupWindow popupWindow = null; popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); if (width != null) { popupWindow.setWidth(width); } popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0); return popupWindow; }
From source file:com.cybrosys.scientific.EventListener.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override//from ww w. ja va 2 s .com public void onClick(View vwView) { vibrate(); ctx = PalmCalcActivity.ctx; int id = vwView.getId(); ScientificActivity.txtvShift.setText(""); switch (id) { case R.id.buttonDel: mHandler.onDelete(); break; case R.id.button3: if (inShift == 0) mHandler.insert("3"); else { mHandler.insert(","); inShift = 0; } break; case R.id.buttonDot: if (inShift == 0) mHandler.insert("."); else { showD(); inShift = 0; } break; case R.id.buttonAC: mHandler.onClear(); break; case R.id.ButtonEqual: String strDisplayEq = mHandler.getDisplayText(); if (!strDisplayEq.equalsIgnoreCase("")) mHandler.onEnter(); break; case R.id.ButtonAns: if (inShift == 0) mHandler.onShow(); else { showHistory(); inShift = 0; } break; case R.id.buttonDeg: mHandler.onDegChange(); break; case R.id.buttonAlt: if (inShift == 0) { String[] strMode = new String[] { "Floatpt", "FIX", "SCI" }; int inSizeM = 3; LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); vwLayout = inflater.inflate(R.layout.pop_history, (ViewGroup) ((Activity) ctx).findViewById(R.id.popup_element)); TextView txtvHeaderPop = (TextView) vwLayout.findViewById(R.id.txtvHeaderPop); txtvHeaderPop.setText("MODE"); popmW1 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW1.setBackgroundDrawable(new BitmapDrawable()); popmW1.setOutsideTouchable(true); popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 0); tblltTable = (TableLayout) vwLayout.findViewById(R.id.tablelay); ImageButton btnCancel = (ImageButton) vwLayout.findViewById(R.id.butcancelmain); btnCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW1.dismiss(); } }); txtvHistory = new TextView[inSizeM]; btnHistory = new Button[inSizeM]; tblrRowL = new TableRow[inSizeM]; TableRow.LayoutParams buttonParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f); TableRow.LayoutParams textParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT, .1f); int inJ = 0; for (int inI = 0; inI < inSizeM; inI++) { btnHistory[inJ] = new Button(ctx); txtvHistory[inJ] = new TextView(ctx); txtvHistory[inJ].setText("" + (inJ + 1)); txtvHistory[inJ].setLayoutParams(textParams); btnHistory[inJ].setText(strMode[inI]); txtvHistory[inJ].setGravity(Gravity.CENTER); txtvHistory[inJ] .setTextColor(ScientificActivity.ctx.getResources().getColor(R.color.HistColor)); btnHistory[inJ].setTextColor(Color.WHITE); btnHistory[inJ].setGravity(Gravity.LEFT); btnHistory[inJ].setLayoutParams(buttonParams); btnHistory[inJ].setBackgroundDrawable(ctx.getResources().getDrawable(R.drawable.button_effect)); tblrRowL[inJ] = new TableRow(ctx); tblrRowL[inJ].addView(txtvHistory[inJ]); tblrRowL[inJ].addView(btnHistory[inJ]); tblltTable.addView(tblrRowL[inJ]); final int inK = inJ; btnHistory[inK].setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // etxt.setText(btns[inK].getText().toString()); ScientificActivity.txtvFSE.setText(btnHistory[inK].getText().toString()); popmW1.dismiss(); } }); inJ++; } } else { setFSE(); inShift = 0; } mHandler.onFSEChange(); break; case R.id.buttonShift: if (inShift == 0) { inShift = 1; mHandler.onShiftPress(); } else inShift = 0; break; case R.id.buttonHyp: if (inHyp == 0) { inHyp = 1; mHandler.onHypPress(); } else { inHyp = 0; ScientificActivity.txtvHyp.setText(""); } break; case R.id.buttonMS: mHandler.onEnter(); String strDisplay = mHandler.getDisplayText(); if (inShift == 0) { if (isValidNumber(strDisplay)) { PreferenceClass.setMyStringPref(ctx, strDisplay); Toast.makeText(ctx, "Memory Saved!", Toast.LENGTH_SHORT).show(); mHandler.onClear(); } else Toast.makeText(ctx, "Save Failed!", Toast.LENGTH_SHORT).show(); } else { Memstore(); } break; case R.id.buttonMR: if (inShift == 0) { String strPref = PreferenceClass.getMyStringPref(ctx); if (!strPref.equalsIgnoreCase("")) { mHandler.insert(strPref); } else Toast.makeText(ctx, "Empty", Toast.LENGTH_SHORT).show(); } else { Memread(); inShift = 0; } break; case R.id.buttonMp: mHandler.onEnter(); String strDisplay2 = mHandler.getDisplayText(); if (isValidNumber(strDisplay2)) { String strPref2 = PreferenceClass.getMyStringPref(ctx); if (!strPref2.equalsIgnoreCase("")) { if (inShift == 0) { try { PreferenceClass.setMyStringPref(ctx, "" + mSymbols.eval(strPref2 + "+" + strDisplay2)); mHandler.onClear(); } catch (SyntaxException e) { e.printStackTrace(); } Toast.makeText(ctx, "Value added", Toast.LENGTH_SHORT).show(); } else { Memplus(); inShift = 0; } } } break; default: if (vwView instanceof Button) { String strText = ((Button) vwView).getTag().toString(); if (strText.contains(",")) { int inInComa = strText.lastIndexOf(","); if (inShift == 1) { strText = strText.substring(inInComa + 1, strText.length()); inShift = 0; } else { strText = strText.substring(0, inInComa); } } if (inHyp == 1) { if (strText.contains("sin(")) { strText = strText.replace("sin(", "sinh("); } if (strText.contains("cos(")) { strText = strText.replace("cos(", "cosh("); } if (strText.contains("tan(")) { strText = strText.replace("tan(", "tanh("); } ScientificActivity.txtvHyp.setText(""); inHyp = 0; } mHandler.insert(strText); } } }