Example usage for android.graphics Color parseColor

List of usage examples for android.graphics Color parseColor

Introduction

In this page you can find the example usage for android.graphics Color parseColor.

Prototype

@ColorInt
public static int parseColor(@Size(min = 1) String colorString) 

Source Link

Document

Parse the color string, and return the corresponding color-int.

Usage

From source file:foam.zizim.android.BoskoiService.java

public static int getColorForIncident(IncidentsData incident) {
    try {/*  www  .j  a v  a2 s. co  m*/
        int end = incident.getIncidentCategories().indexOf(',') > -1
                ? incident.getIncidentCategories().indexOf(',')
                : incident.getIncidentCategories().length();
        String category = incident.getIncidentCategories().substring(0, end);
        String color = "#" + getCategoriesDetails(category)[0].getCategoryColor();

        return Color.parseColor(color);
    } catch (IndexOutOfBoundsException e) {
        e.printStackTrace();
        return R.drawable.marker_color;
    } catch (NumberFormatException e) {
        e.printStackTrace();
        return R.drawable.marker_color;
    }
}

From source file:com.huofu.RestaurantOS.ui.splash.activate.java

/**
 * ?/*www  .ja v a  2  s  .  co  m*/
 */
public void widgetConfigure() {

    buttonActivate.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            if (authDialog == null) {
                authDialog = new Dialog(activate.this, R.style.PauseDialog);
            }
            if (ttv.getParent() != null) {
                ttv = new TitanicTextView(ctxt);
            }

            String key = etActivteCode.getText().toString();
            if (key.length() >= 16) {
                CommonUtils.LogWuwei(tag, "key is " + key);
                CommonUtils.sendMsg("?", activate.SHOW_LOADING_TEXT, mUiHandler);
                activate(ctxt, key);
            } else {
                CommonUtils.sendMsg("????", activate.SHOW_ERROR_MESSAGE, mUiHandler);
            }

        }
    });

    InputFilter filter = new InputFilter() {

        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                int dend) {
            // TODO Auto-generated method stub
            for (int i = start; i < end; i++) {
                //???'-'
                if (!Character.isLetter(source.charAt(i)) && source.charAt(i) != '-') {
                    return "";
                }
            }
            return null;
        }
    };

    InputFilter filterLength = new InputFilter.LengthFilter(19);

    etActivteCode.setCursorVisible(false);
    etActivteCode.setFilters(new InputFilter[] { filter, filterLength });
    etActivteCode.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

            etActivteCode.setCursorVisible(true);
            etActivteCode.removeTextChangedListener(this);// ?
            etActivteCode.setText(s.toString().toUpperCase());// ?
            etActivteCode.setSelection(s.toString().length());// ??
            etActivteCode.addTextChangedListener(this);// ?
            String licensePlateNumber = etActivteCode.getText().toString().trim();

            if (s.length() == 19) {
                InputMethodUtils.HideKeyboard(etActivteCode);
            }

        }
    });
    etActivteCode.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // TODO Auto-generated method stub
            if (keyCode == KeyEvent.KEYCODE_DEL) {
                CommonUtils.LogWuwei(tag, "delete");
                etActivteCode.setCursorVisible(false);
            }
            return false;
        }
    });

    rl_activate_qrscan_ready.setVisibility(View.INVISIBLE);

    OnClickListener oclGetQrCode = new OnClickListener() {
        @Override
        public void onClick(View v) {
            flagInQrcodeDialog = true;
            CommonUtils.sendMsg("??", SHOW_LOADING_TEXT, mUiHandler);

            if (LocalDataDeal.readFromLocalPublicKey(ctxt) == null
                    || LocalDataDeal.readFromLocalPublicKey(ctxt).equals("")) {
                ApisManager.GetPublicKey(new ApiCallback() {
                    @Override
                    public void success(Object object) {
                        sendUIMessage(HIDE_LOADING, "");
                        try {
                            org.json.JSONObject obj = new org.json.JSONObject((String) object);
                            String public_key = obj.getString("public_key");
                            LocalDataDeal.writeToLocalPublicKey(public_key, ctxt);//key?base64?
                        } catch (Exception e) {
                        }
                        CommonUtils.sendMsg("", GET_QRCODE, mUiHandler);
                    }

                    @Override
                    public void error(BaseApi.ApiResponse response) {
                        sendUIMessage(HIDE_LOADING, "");
                        sendUIMessage(SHOW_ERROR_MESSAGE, response.error_message);
                    }
                });
            } else {
                CommonUtils.sendMsg("", GET_QRCODE, mUiHandler);
            }

            rl_activate_input.setVisibility(View.INVISIBLE);
            rl_activate_qrscan_ready.setVisibility(View.VISIBLE);
            imageViewQrcode.setVisibility(View.INVISIBLE);
            rl_activate_qrscan_ready
                    .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big));

            textviewScanStauts.setTextColor(Color.parseColor("#898989"));
            textviewScanStauts.setText(R.string.activateByQrCodeTips);

            rl_activate_qrscan_ready
                    .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_in));
            rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_out));
        }
    };

    buttonSwitchQrScan.setOnClickListener(oclGetQrCode);
    findViewById(R.id.rl_switch_activate_qrcode_way).setOnClickListener(oclGetQrCode);

    buttonSwitchInputCode.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            flagInQrcodeDialog = false;
            flagWaitingCmd = false;
            rl_activate_qrscan_ready.setVisibility(View.INVISIBLE);
            rl_activate_input.setVisibility(View.VISIBLE);
            rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big));

            stopQrScanTimer();

            rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_in));
            rl_activate_qrscan_ready
                    .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_out));

        }
    });

    findViewById(R.id.rl_switch_activate_keyboard_way).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            flagInQrcodeDialog = false;
            flagWaitingCmd = false;
            rl_activate_qrscan_ready.setVisibility(View.INVISIBLE);
            rl_activate_input.setVisibility(View.VISIBLE);
            rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big));

            stopQrScanTimer();
        }
    });

    PackageManager manager;
    PackageInfo info = null;
    manager = this.getPackageManager();
    String versionName = null;
    try {
        info = manager.getPackageInfo(this.getPackageName(), 0);
        versionName = info.versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    ((TextView) findViewById(R.id.tv_app_version))
            .setText(getResources().getString(R.string.app_name) + " V" + versionName);

    LocalDataDeal.writeToLocalVersion(versionName, ctxt);
    LocalDataDeal.writeToLocalVersionCode(info.versionCode, ctxt);

    ftpServiceStart();
}

From source file:com.example.ray.firstapp.bottombar.BottomBar.java

/**
 * Set a custom color for an active tab when there's three
 * or less items./*from  w ww  .j  a v a  2  s  .c o  m*/
 * <p/>
 * NOTE: This value is ignored on mobile devices if you have more than
 * three items.
 *
 * @param activeTabColor a hex color used for active tabs, such as "#00FF000".
 */
public void setActiveTabColor(String activeTabColor) {
    setActiveTabColor(Color.parseColor(activeTabColor));
}

From source file:com.filemanager.free.utils.Futils.java

public void deleteFiles(ArrayList<Layoutelements> a, final Main b, List<Integer> pos,
        final CoordinatorLayout v) {
    final MaterialDialog.Builder c = new MaterialDialog.Builder(b.getActivity());
    c.title(getString(b.getActivity(), R.string.confirm));
    String names = "";
    final ArrayList<BaseFile> todelete = new ArrayList<>();
    for (int i = 0; i < pos.size(); i++) {
        todelete.add(a.get(pos.get(i)).generateBaseFile());
        names = names + "\n" + (i + 1) + ". " + a.get(pos.get(i)).getTitle();
    }//from   www .j av a2s  . co m
    c.content(getString(b.getActivity(), R.string.questiondelete) + names);

    if (b.theme1 == 1)
        c.theme(Theme.DARK);
    c.negativeText(getString(b.getActivity(), R.string.no));
    c.positiveText(getString(b.getActivity(), R.string.yes));
    c.positiveColor(Color.parseColor(b.fabSkin));
    c.negativeColor(Color.parseColor(b.fabSkin));
    c.callback(new MaterialDialog.ButtonCallback() {
        @Override
        public void onPositive(MaterialDialog materialDialog) {
            Snackbar.make(v, getString(b.getActivity(), R.string.deleting), Snackbar.LENGTH_LONG).show();
            b.MAIN_ACTIVITY.mainActivityHelper.deleteFiles(todelete);
        }

        @Override
        public void onNegative(MaterialDialog materialDialog) {

            //materialDialog.cancel();
        }
    });
    c.build().show();
}

From source file:com.bitants.wally.fragments.SearchFragment.java

private void showColorPickerDialog() {
    FragmentManager fragmentManager = getFragmentManager();
    if (fragmentManager != null) {
        int color = Color.BLACK;
        try {/*from w ww . j a  v  a 2  s  .  c  om*/
            color = Color.parseColor(currentColor != null ? "#" + currentColor : "#000000");
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }
        ColorPickerDialogFragment colorPickerDialogFragment = new ColorPickerDialogFragment(color, null,
                getColorPickerOnDialogButtonClickedListener());
        colorPickerDialogFragment.show(fragmentManager, ColorPickerDialogFragment.TAG);
    }
}

From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentJournalMainHome.java

/**
 * Equation for all of the Nutrition and Meal information
 *//*from  w  w  w . j  av a  2  s  . com*/
private void equations() {
    double mCalorieGoal = Double.valueOf(sharedPreferences.getString(Globals.USER_CALORIES_TO_REACH_GOAL, ""));
    double mFatGoal = Double.valueOf(sharedPreferences.getString(Globals.USER_DAILY_FAT, ""));
    double mCarbGoal = Double.valueOf(sharedPreferences.getString(Globals.USER_DAILY_CARBOHYDRATES, ""));
    double mProteinGoal = Double.valueOf(sharedPreferences.getString(Globals.USER_DAILY_PROTEIN, ""));
    mCalorieGoalMeal = Double.valueOf(sharedPreferences.getString(Globals.USER_CALORIES_TO_REACH_GOAL, "")) / 4;

    icSnack = (ImageView) v.findViewById(R.id.icSnack);
    icBreakfast = (ImageView) v.findViewById(R.id.icBreakfast);
    icLunch = (ImageView) v.findViewById(R.id.icLunch);
    icDinner = (ImageView) v.findViewById(R.id.icDinner);

    // _________________________Calories Snack_____________________________
    double mCalConsumedSnack = 0;
    for (LogMeal logMeal : mLogSnackAdapter.getLogs()) {
        mCalConsumedSnack += logMeal.getCalorieCount();
    }
    mCalSnack.setText(df.format(mCalConsumedSnack));

    // Set icon visible and color based on calories consumed for meal.
    if (mCalConsumedSnack >= mCalorieGoalMeal + 100) {
        icSnack.setImageResource(R.mipmap.ic_check_circle);
        icSnack.setColorFilter(Color.parseColor("#F44336"), android.graphics.PorterDuff.Mode.MULTIPLY);
    } else if (mCalConsumedSnack > mCalorieGoalMeal - 100 && mCalConsumedSnack < mCalorieGoalMeal + 99) {
        icSnack.setImageResource(R.mipmap.ic_check_circle);
        icSnack.setColorFilter(Color.parseColor("#4CAF50"), android.graphics.PorterDuff.Mode.MULTIPLY);
    } else {
        icSnack.setImageResource(R.mipmap.ic_check);
        icSnack.setColorFilter(Color.parseColor("#6D6D6D"), android.graphics.PorterDuff.Mode.MULTIPLY);
    }

    // _________________________Calories Breakfast_____________________________
    double mCalConsumedBreakfast = 0;
    for (LogMeal logMeal : mLogBreakfastAdapter.getLogs()) {
        mCalConsumedBreakfast += logMeal.getCalorieCount();
    }
    mCalBreakfast.setText(df.format(mCalConsumedBreakfast));

    // Set icon visible and color based on calories consumed for meal.
    if (mCalConsumedBreakfast >= mCalorieGoalMeal + 100) {
        icBreakfast.setColorFilter(Color.parseColor("#F44336"), android.graphics.PorterDuff.Mode.MULTIPLY);
        icBreakfast.setImageResource(R.mipmap.ic_check_circle);
    } else if (mCalConsumedBreakfast > mCalorieGoalMeal - 100
            && mCalConsumedBreakfast < mCalorieGoalMeal + 99) {
        icBreakfast.setColorFilter(Color.parseColor("#4CAF50"), android.graphics.PorterDuff.Mode.MULTIPLY);
        icBreakfast.setImageResource(R.mipmap.ic_check_circle);
    } else {
        icBreakfast.setImageResource(R.mipmap.ic_check);
        icBreakfast.setColorFilter(Color.parseColor("#6D6D6D"), android.graphics.PorterDuff.Mode.MULTIPLY);
    }

    // _________________________Calories Lunch_____________________________
    double mCalConsumedLunch = 0;
    for (LogMeal logMeal : mLogLunchAdapter.getLogs()) {
        mCalConsumedLunch += logMeal.getCalorieCount();
    }
    mCalLunch.setText(df.format(mCalConsumedLunch));

    // Set icon visible and color based on calories consumed for meal.
    if (mCalConsumedLunch >= mCalorieGoalMeal + 100) {
        icLunch.setImageResource(R.mipmap.ic_check_circle);
        icLunch.setColorFilter(Color.parseColor("#F44336"), android.graphics.PorterDuff.Mode.MULTIPLY);
    } else if (mCalConsumedLunch > mCalorieGoalMeal - 100 && mCalConsumedLunch < mCalorieGoalMeal + 99) {
        icLunch.setImageResource(R.mipmap.ic_check_circle);
        icLunch.setColorFilter(Color.parseColor("#4CAF50"), android.graphics.PorterDuff.Mode.MULTIPLY);
    } else {
        icLunch.setImageResource(R.mipmap.ic_check);
        icLunch.setColorFilter(Color.parseColor("#6D6D6D"), android.graphics.PorterDuff.Mode.MULTIPLY);
    }

    // _________________________Calories Lunch_____________________________
    double mCalConsumedDinner = 0;
    for (LogMeal logMeal : mLogDinnerAdapter.getLogs()) {
        mCalConsumedDinner += logMeal.getCalorieCount();
    }
    mCalDinner.setText(df.format(mCalConsumedDinner));

    // Set icon visible and color based on calories consumed for meal.
    if (mCalConsumedDinner >= mCalorieGoalMeal + 100) {
        icDinner.setImageResource(R.mipmap.ic_check_circle);
        icDinner.setColorFilter(Color.parseColor("#F44336"), android.graphics.PorterDuff.Mode.MULTIPLY);
    } else if (mCalConsumedDinner > mCalorieGoalMeal - 100 && mCalConsumedDinner < mCalorieGoalMeal + 99) {
        icDinner.setImageResource(R.mipmap.ic_check_circle);
        icDinner.setColorFilter(Color.parseColor("#4CAF50"), android.graphics.PorterDuff.Mode.MULTIPLY);
    } else {
        icDinner.setImageResource(R.mipmap.ic_check);
        icDinner.setColorFilter(Color.parseColor("#6D6D6D"), android.graphics.PorterDuff.Mode.MULTIPLY);
    }

    // _________________________Calories, Fat, Carbs, Protein All_____________________________
    // Nutrition Consumed
    double mAllCaloriesConsumed = 0;
    double mAllFatConsumed = 0;
    double mAllCarbsConsumed = 0;
    double mAllProteinConsumed = 0;

    for (LogMeal logMeal : mLogAdapterAll.getLogs()) {
        mAllCaloriesConsumed += logMeal.getCalorieCount();
        mAllFatConsumed += logMeal.getFatCount();
        mAllCarbsConsumed += logMeal.getCarbCount();
        mAllProteinConsumed += logMeal.getProteinCount();
    }
    // Nutrition Goals
    // Remainder Nutrition
    mCaloriesRemainder.setText(df.format(mCalorieGoal - mAllCaloriesConsumed) + " Left");
    mFatRemainder.setText(df.format(mFatGoal - mAllFatConsumed) + " Left");
    mCarbRemainder.setText(df.format(mCarbGoal - mAllCarbsConsumed) + " Left");
    mProteinRemainder.setText(df.format(mProteinGoal - mAllProteinConsumed) + " Left");
    // Progress bars

    mPbCalories.setMax(Integer.valueOf(df.format(mCalorieGoal)));
    mPbCalories.setProgress(Integer.valueOf(df.format(mAllCaloriesConsumed)));
    mPbFat.setMax(Integer.valueOf(df.format(mFatGoal)));
    mPbFat.setProgress(Integer.valueOf(df.format(mAllFatConsumed)));
    mPbCarbs.setMax(Integer.valueOf(df.format(mCarbGoal)));
    mPbCarbs.setProgress(Integer.valueOf(df.format(mAllCarbsConsumed)));
    mPbProtein.setMax(Integer.valueOf(df.format(mProteinGoal)));
    mPbProtein.setProgress(Integer.valueOf(df.format(mAllProteinConsumed)));

    /**
     * Update Widget
     */
    Context context = getActivity();
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    if (appWidgetManager != null) {
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);
        ComponentName thisWidget = new ComponentName(context, FitHealthWidget.class);

        views.setProgressBar(R.id.pbCal, Integer.valueOf(df.format(mCalorieGoal)),
                Integer.valueOf(df.format(mAllCaloriesConsumed)), false);
        views.setProgressBar(R.id.pbFat, Integer.valueOf(df.format(mFatGoal)),
                Integer.valueOf(df.format(mAllFatConsumed)), false);
        views.setProgressBar(R.id.pbCarb, Integer.valueOf(df.format(mCarbGoal)),
                Integer.valueOf(df.format(mAllCarbsConsumed)), false);
        views.setProgressBar(R.id.pbPro, Integer.valueOf(df.format(mProteinGoal)),
                Integer.valueOf(df.format(mAllProteinConsumed)), false);

        views.setTextViewText(R.id.txtRemainderCal, df.format(mCalorieGoal - mAllCaloriesConsumed));
        views.setTextViewText(R.id.txtRemainderFat, df.format(mFatGoal - mAllFatConsumed));
        views.setTextViewText(R.id.txtRemainderCarb, df.format(mCarbGoal - mAllCarbsConsumed));
        views.setTextViewText(R.id.txtRemainderPro, df.format(mProteinGoal - mAllProteinConsumed));

        appWidgetManager.updateAppWidget(thisWidget, views);
    }
}

From source file:com.phonegap.bossbolo.plugin.inappbrowser.InAppBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url           The url to load.
 * @param jsonObject/*  w ww. j  a v  a  2  s .  com*/
 * @param header
 */
public String showWebPage(final String url, HashMap<String, Boolean> features, final String header) {
    // Determine if we should hide the location bar.
    showLocationBar = true;
    showZoomControls = true;
    openWindowHidden = false;
    if (features != null) {
        Boolean show = features.get(LOCATION);
        if (show != null) {
            showLocationBar = show.booleanValue();
        }
        Boolean zoom = features.get(ZOOM);
        if (zoom != null) {
            showZoomControls = zoom.booleanValue();
        }
        Boolean hidden = features.get(HIDDEN);
        if (hidden != null) {
            openWindowHidden = hidden.booleanValue();
        }
        Boolean hardwareBack = features.get(HARDWARE_BACK_BUTTON);
        if (hardwareBack != null) {
            hadwareBackButton = hardwareBack.booleanValue();
        }
        Boolean cache = features.get(CLEAR_ALL_CACHE);
        if (cache != null) {
            clearAllCache = cache.booleanValue();
        } else {
            cache = features.get(CLEAR_SESSION_CACHE);
            if (cache != null) {
                clearSessionCache = cache.booleanValue();
            }
        }
    }

    final CordovaWebView thatWebView = this.webView;

    // Create dialog in new thread
    Runnable runnable = new Runnable() {
        /**
         * Convert our DIP units to Pixels
         *
         * @return int
         */
        private int dpToPixels(int dipValue) {
            int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue,
                    cordova.getActivity().getResources().getDisplayMetrics());

            return value;
        }

        @SuppressLint("NewApi")
        public void run() {
            int backgroundColor = Color.parseColor("#46bff7");
            // Let's create the main dialog
            dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
            dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);
            dialog.setInAppBroswer(getInAppBrowser());

            // Main container layout
            LinearLayout main = new LinearLayout(cordova.getActivity());
            main.setOrientation(LinearLayout.VERTICAL);

            // Toolbar layout  header
            RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
            //Please, no more black! 
            toolbar.setBackgroundColor(android.graphics.Color.LTGRAY);
            toolbar.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(50)));
            toolbar.setPadding(this.dpToPixels(8), this.dpToPixels(10), this.dpToPixels(8),
                    this.dpToPixels(10));
            toolbar.setHorizontalGravity(Gravity.LEFT);
            toolbar.setVerticalGravity(Gravity.TOP);
            toolbar.setBackgroundColor(backgroundColor);

            // Action Button Container layout
            RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity());
            actionButtonContainer.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            actionButtonContainer.setHorizontalGravity(Gravity.LEFT);
            actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);
            actionButtonContainer.setId(1);

            // Back button
            Button back = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
            back.setLayoutParams(backLayoutParams);
            back.setContentDescription("Back Button");
            back.setId(2);
            back.setWidth(this.dpToPixels(34));
            back.setHeight(this.dpToPixels(31));
            Resources activityRes = cordova.getActivity().getResources();
            int backResId = activityRes.getIdentifier("back", "drawable",
                    cordova.getActivity().getPackageName());
            Drawable backIcon = activityRes.getDrawable(backResId);
            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                back.setBackgroundDrawable(backIcon);
            } else {
                back.setBackground(backIcon);
            }
            back.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    closeDialog();
                    //                        goBack();
                }
            });

            // Edit Text Box
            titletext = new TextView(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            textLayoutParams.addRule(RelativeLayout.RIGHT_OF, this.dpToPixels(65));
            textLayoutParams.addRule(RelativeLayout.LEFT_OF, this.dpToPixels(10));
            titletext.setLayoutParams(textLayoutParams);
            titletext.setId(3);
            titletext.setSingleLine(true);
            titletext.setText(header);
            titletext.setTextColor(Color.WHITE);
            titletext.setGravity(Gravity.CENTER);
            titletext.setTextSize(TypedValue.COMPLEX_UNIT_PX, this.dpToPixels(20));
            titletext.setSingleLine();
            titletext.setEllipsize(TruncateAt.END);

            edittext = new EditText(cordova.getActivity());
            RelativeLayout.LayoutParams editLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            editLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
            editLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
            edittext.setLayoutParams(textLayoutParams);
            edittext.setId(4);
            edittext.setSingleLine(true);
            edittext.setText(url);
            edittext.setVisibility(View.GONE);

            // Forward button
            /*Button forward = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
            forward.setLayoutParams(forwardLayoutParams);
            forward.setContentDescription("Forward Button");
            forward.setId(3);
            int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
            Drawable fwdIcon = activityRes.getDrawable(fwdResId);
            if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
            {
            forward.setBackgroundDrawable(fwdIcon);
            }
            else
            {
            forward.setBackground(fwdIcon);
            }
            forward.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                goForward();
            }
            });
                    
            // Edit Text Box
            edittext = new TextView(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
            textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
            edittext.setLayoutParams(textLayoutParams);
            edittext.setId(4);
            edittext.setSingleLine(true);
            edittext.setText(url);
            edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            edittext.setImeOptions(EditorInfo.IME_ACTION_GO);
            edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE
            edittext.setOnKeyListener(new View.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)) {
                  navigate(edittext.getText().toString());
                  return true;
                }
                return false;
            }
            });
                    
                    
            // Close/Done button
            Button close = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            close.setLayoutParams(closeLayoutParams);
            forward.setContentDescription("Close Button");
            close.setId(5);
            int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName());
            Drawable closeIcon = activityRes.getDrawable(closeResId);
            if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
            {
            close.setBackgroundDrawable(closeIcon);
            }
            else
            {
            close.setBackground(closeIcon);
            }
            close.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                closeDialog();
            }
            });*/

            // WebView
            inAppWebView = new WebView(cordova.getActivity());
            inAppWebView.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView));
            WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
            inAppWebView.setWebViewClient(client);
            WebSettings settings = inAppWebView.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setBuiltInZoomControls(getShowZoomControls());
            settings.setPluginState(android.webkit.WebSettings.PluginState.ON);

            //Toggle whether this is enabled or not!
            Bundle appSettings = cordova.getActivity().getIntent().getExtras();
            boolean enableDatabase = appSettings == null ? true
                    : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
            if (enableDatabase) {
                String databasePath = cordova.getActivity().getApplicationContext()
                        .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath();
                settings.setDatabasePath(databasePath);
                settings.setDatabaseEnabled(true);
            }
            settings.setDomStorageEnabled(true);

            if (clearAllCache) {
                CookieManager.getInstance().removeAllCookie();
            } else if (clearSessionCache) {
                CookieManager.getInstance().removeSessionCookie();
            }

            inAppWebView.loadUrl(url);
            inAppWebView.setId(6);
            inAppWebView.getSettings().setLoadWithOverviewMode(true);
            inAppWebView.getSettings().setUseWideViewPort(true);
            inAppWebView.requestFocus();
            inAppWebView.requestFocusFromTouch();

            // Add the back and forward buttons to our action button container layout
            actionButtonContainer.addView(back);
            //                actionButtonContainer.addView(forward);

            // Add the views to our toolbar
            toolbar.addView(actionButtonContainer);
            toolbar.addView(titletext);
            //                toolbar.addView(edittext);
            //                toolbar.addView(close);

            // Don't add the toolbar if its been disabled
            if (getShowLocationBar()) {
                // Add our toolbar to our main view/layout
                main.addView(toolbar);
            }

            // Add our webview to our main view/layout
            main.addView(inAppWebView);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.MATCH_PARENT;

            dialog.setContentView(main);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
            // the goal of openhidden is to load the url and not display it
            // Show() needs to be called to cause the URL to be loaded
            if (openWindowHidden) {
                dialog.hide();
            }
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
    return "";
}

From source file:com.snt.bt.recon.activities.MainActivity.java

@Override
public void onResume() {
    super.onResume();

    //initial sync
    syncServerDatabase();//w  w  w.ja v a  2s . c  o m

    final boolean mIsBluetoothOn = mBluetoothUtils.isBluetoothOn();
    final boolean mIsBluetoothLePresent = mBluetoothUtils.isBluetoothLeSupported();

    if (mIsBluetoothOn) {
        mTvBluetoothStatus.setText(com.snt.bt.recon.R.string.on);
    } else {
        mTvBluetoothStatus.setText(com.snt.bt.recon.R.string.off);
    }

    if (mIsBluetoothLePresent) {
        mTvBluetoothLeStatus.setText(com.snt.bt.recon.R.string.supported);
    } else {
        mTvBluetoothLeStatus.setText(com.snt.bt.recon.R.string.not_supported);
    }

    if (!mLeScanner.isScanning()) {
        mTvScanning.setText("Off");
        mTvScanning.setTextColor(Color.RED);

    } else {
        mTvScanning.setText("On");
        mTvScanning.setTextColor(Color.parseColor("#00B100"));
    }

    invalidateOptionsMenu();
}

From source file:com.fa.imaged.activity.DetailActivityV2.java

private void applyPalette(Palette palette) {
    if (palette.getVibrantSwatch() != null) {
        int paletteColor = palette.getVibrantColor(Color.parseColor(themePrimaryDarkColors[selectedThemeInt]));
        detailUserInfo.setBackgroundColor(paletteColor);
    } else {/* ww  w.j a v a 2 s . c o m*/
        detailUserInfo.setBackgroundColor(Color.parseColor(themePrimaryDarkColors[selectedThemeInt]));
    }

}

From source file:com.example.ray.firstapp.bottombar.BottomBar.java

/**
 * Creates a new Badge (for example, an indicator for unread messages) for a Tab at
 * the specified position./*from   w w  w . ja v a2  s  .  c o  m*/
 *
 * @param tabPosition     zero-based index for the tab.
 * @param backgroundColor a color for this badge, such as "#FF0000".
 * @param initialCount    text displayed initially for this Badge.
 * @return a {@link BottomBarBadge} object.
 */
public BottomBarBadge makeBadgeForTabAt(int tabPosition, String backgroundColor, int initialCount) {
    return makeBadgeForTabAt(tabPosition, Color.parseColor(backgroundColor), initialCount);
}