Example usage for android.widget RelativeLayout LEFT_OF

List of usage examples for android.widget RelativeLayout LEFT_OF

Introduction

In this page you can find the example usage for android.widget RelativeLayout LEFT_OF.

Prototype

int LEFT_OF

To view the source code for android.widget RelativeLayout LEFT_OF.

Click Source Link

Document

Rule that aligns a child's right edge with another child's left edge.

Usage

From source file:com.mobiroller.tools.inappbrowser.MobirollerInAppBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url           The url to load.
 * @param jsonObject//from ww w  .j  a va2s  .c om
 */
public String showWebPage(final String url, final HashMap<String, Boolean> features) {
    // Determine if we should hide the location bar.
    showLocationBar = true;
    showZoomControls = false;
    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() {
            // Let's create the main dialog
            dialog = new MobirollerInAppBrowserDialog(cordova.getActivity(),
                    android.R.style.Theme_Translucent_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.setBackgroundColor(Color.TRANSPARENT);
            main.setOrientation(LinearLayout.VERTICAL);

            // Toolbar layout
            RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
            //Please, no more black!
            toolbar.setBackgroundColor(Color.TRANSPARENT);
            toolbar.setLayoutParams(new RelativeLayout.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
                    this.dpToPixels(44)));
            toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
            toolbar.setHorizontalGravity(Gravity.LEFT);
            toolbar.setVerticalGravity(Gravity.TOP);

            // Action Button Container layout
            RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity());
            actionButtonContainer.setLayoutParams(new RelativeLayout.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.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(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.MATCH_PARENT);
            backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
            back.setLayoutParams(backLayoutParams);
            back.setContentDescription("Back Button");
            back.setId(2);
            Resources activityRes = cordova.getActivity().getResources();
            int backResId = activityRes.getIdentifier("ic_action_previous_item", "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) {
                    goBack();
                }
            });

            // Forward button
            Button forward = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.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 EditText(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
                    WindowManager.LayoutParams.MATCH_PARENT, WindowManager.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(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.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(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.MATCH_PARENT));
            inAppWebView.setWebChromeClient(new MobirollerInAppChromeClient(thatWebView));
            WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
            inAppWebView.setWebViewClient(client);
            WebSettings settings = inAppWebView.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setBuiltInZoomControls(showZoomControls);
            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(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;

            //Mobiroller Needs
            DisplayMetrics metrics = cordova.getActivity().getResources().getDisplayMetrics();
            Rect windowRect = new Rect();
            webView.getView().getWindowVisibleDisplayFrame(windowRect);

            int bottomGap = 0;
            if (features.containsKey("hasTabs")) {
                if (features.get("hasTabs")) {
                    bottomGap += Math.ceil(44 * metrics.density);
                }
            }
            lp.height = (windowRect.bottom - windowRect.top) - (bottomGap);
            lp.gravity = Gravity.TOP;
            lp.format = PixelFormat.TRANSPARENT;
            close.setAlpha(0);
            //Mobiroller Needs

            dialog.setContentView(main);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.show();
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            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.kenmeidearu.materialdatetimepicker.time.TimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.mdtp_time_picker_dialog, container, false);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }/*from  ww w. jav a  2  s  .  c o  m*/

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark);
    }

    Resources res = getResources();
    Context context = getActivity();
    mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description);
    mSelectHours = res.getString(R.string.mdtp_select_hours);
    mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description);
    mSelectMinutes = res.getString(R.string.mdtp_select_minutes);
    mSecondPickerDescription = res.getString(R.string.mdtp_second_picker_description);
    mSelectSeconds = res.getString(R.string.mdtp_select_seconds);
    mSelectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_accent_color_focused);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mSecondSpaceView = (TextView) view.findViewById(R.id.seconds_space);
    mSecondView = (TextView) view.findViewById(R.id.seconds);
    mSecondView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    if (mTimePicker != null) {
        mInitialTime = new Timepoint(mTimePicker.getHours(), mTimePicker.getMinutes(),
                mTimePicker.getSeconds());
    }

    mInitialTime = roundToNearest(mInitialTime);

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), this, mInitialTime, mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mSecondView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setCurrentItemShowing(SECOND_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mOkButton = (Button) view.findViewById(R.id.ok);
    mOkButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            notifyOnDateListener();
            dismiss();
        }
    });
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(mOkResid);

    mCancelButton = (Button) view.findViewById(R.id.cancel);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    mCancelButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mCancelString != null)
        mCancelButton.setText(mCancelString);
    else
        mCancelButton.setText(mCancelResid);
    mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialTime.isAM() ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // Don't do anything if either AM or PM are disabled
                if (isAmDisabled() || isPmDisabled())
                    return;

                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    // Disable seconds picker
    if (!mEnableSeconds) {
        mSecondView.setVisibility(View.GONE);
        view.findViewById(R.id.separator_seconds).setVisibility(View.GONE);
    }

    // Disable minutes picker
    if (!mEnableMinutes) {
        mMinuteSpaceView.setVisibility(View.GONE);
        view.findViewById(R.id.separator).setVisibility(View.GONE);
    }

    // Center stuff depending on what's visible
    if (mIs24HourMode && !mEnableSeconds && mEnableMinutes) {
        // center first separator
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else if (!mEnableMinutes && !mEnableSeconds) {
        // center the hour
        RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsHour.addRule(RelativeLayout.CENTER_IN_PARENT);
        mHourSpaceView.setLayoutParams(paramsHour);

        if (!mIs24HourMode) {
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.hour_space);
            paramsAmPm.addRule(RelativeLayout.ALIGN_BASELINE, R.id.hour_space);
            mAmPmTextView.setLayoutParams(paramsAmPm);
        }
    } else if (mEnableSeconds) {
        // link separator to minutes
        final View separator = view.findViewById(R.id.separator);
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.minutes_space);
        paramsSeparator.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        separator.setLayoutParams(paramsSeparator);

        if (!mIs24HourMode) {
            // center minutes
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.CENTER_IN_PARENT);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        } else {
            // move minutes to right of center
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.RIGHT_OF, R.id.center_view);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        }
    }

    mAllowAutoAdvance = true;
    setHour(mInitialTime.getHour(), true);
    setMinute(mInitialTime.getMinute());
    setSecond(mInitialTime.getSecond());

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.mdtp_deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<>();
    }

    // Set the title (if any)
    TextView timePickerHeader = (TextView) view.findViewById(R.id.time_picker_header);
    if (!mTitle.isEmpty()) {
        timePickerHeader.setVisibility(TextView.VISIBLE);
        timePickerHeader.setText(mTitle.toUpperCase(Locale.getDefault()));
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mOkButton.setTextColor(mAccentColor);
    mCancelButton.setTextColor(mAccentColor);
    timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.time_display_background).setBackgroundColor(mAccentColor);
    view.findViewById(R.id.time_display).setBackgroundColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    int circleBackground = ContextCompat.getColor(context, R.color.mdtp_circle_background);
    int backgroundColor = ContextCompat.getColor(context, R.color.mdtp_background_color);
    int darkBackgroundColor = ContextCompat.getColor(context, R.color.mdtp_light_gray);
    int lightGray = ContextCompat.getColor(context, R.color.mdtp_light_gray);

    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    view.findViewById(R.id.time_picker_dialog)
            .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    return view;
}

From source file:com.jamiealtizer.cordova.inappbrowser.InAppBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url           The url to load.
 * @param jsonObject//  ww  w  .j  a v a2s  .  com
 */
public String showWebPage(final String url, HashMap<String, Boolean> features) {
    // 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() {
            // Let's create the main dialog
            final Context ctx = cordova.getActivity();
            dialog = new InAppBrowserDialog(ctx, 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(ctx);
            main.setOrientation(LinearLayout.VERTICAL);

            // Toolbar layout
            RelativeLayout toolbar = new RelativeLayout(ctx);
            //Please, no more black!
            toolbar.setBackgroundColor(android.graphics.Color.LTGRAY); // JAMIE REVIEW
            toolbar.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
            toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
            toolbar.setHorizontalGravity(Gravity.LEFT);
            toolbar.setVerticalGravity(Gravity.CENTER_VERTICAL);

            // Action Button Container layout
            RelativeLayout actionButtonContainer = new RelativeLayout(ctx);
            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
            final ButtonAwesome back = new ButtonAwesome(ctx);
            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.setBackgroundResource(ExternalResourceHelper.getDrawable(ctx, "buttonbackground"));
            back.setTextColor(ExternalResourceHelper.getColor(ctx, "gray"));
            back.setText(ExternalResourceHelper.getStrings(ctx, "fa_chevron_left"));
            back.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
            //            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) {
                    goBack();
                }
            });

            // Forward button
            final ButtonAwesome forward = new ButtonAwesome(ctx);
            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);
            forward.setBackgroundResource(ExternalResourceHelper.getDrawable(ctx, "buttonbackground"));
            forward.setTextColor(ExternalResourceHelper.getColor(ctx, "gray"));
            forward.setText(ExternalResourceHelper.getStrings(ctx, "fa_chevron_right"));
            forward.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
            //            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();
                }
            });

            // external button
            ButtonAwesome external = new ButtonAwesome(ctx);
            RelativeLayout.LayoutParams externalLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            externalLayoutParams.addRule(RelativeLayout.RIGHT_OF, 3);
            external.setLayoutParams(externalLayoutParams);
            external.setContentDescription("Back Button");
            external.setId(7);
            external.setBackgroundResource(ExternalResourceHelper.getDrawable(ctx, "buttonbackground"));
            external.setTextColor(ExternalResourceHelper.getColor(ctx, "white"));
            external.setText(ExternalResourceHelper.getStrings(ctx, "fa_external_link"));
            external.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
            external.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    openExternal(edittext.getText().toString());
                    closeDialog();
                }
            });

            // Edit Text Box
            edittext = new EditText(ctx);
            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.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    if (s.length() > 0) {
                        if (inAppWebView.canGoBack()) {
                            back.setTextColor(ExternalResourceHelper.getColor(ctx, "white"));
                        } else {
                            back.setTextColor(ExternalResourceHelper.getColor(ctx, "gray"));
                        }
                        if (inAppWebView.canGoForward()) {
                            forward.setTextColor(ExternalResourceHelper.getColor(ctx, "white"));
                        } else {
                            forward.setTextColor(ExternalResourceHelper.getColor(ctx, "gray"));
                        }
                    }
                }

                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                }

                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }
            });
            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
            ButtonAwesome close = new ButtonAwesome(ctx);
            RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            close.setLayoutParams(closeLayoutParams);
            close.setContentDescription("Close Button");
            close.setId(5);
            close.setBackgroundResource(ExternalResourceHelper.getDrawable(ctx, "buttonbackground"));
            close.setText(ExternalResourceHelper.getStrings(ctx, "fa_times"));
            close.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
            close.setTextColor(ExternalResourceHelper.getColor(ctx, "white"));
            //            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(ctx);
            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(showZoomControls);
            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 = ctx.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);
            actionButtonContainer.addView(external);

            // Add the views to our toolbar
            toolbar.addView(actionButtonContainer);
            if (getShowLocationBar()) {
                toolbar.addView(edittext);
            }
            toolbar.setBackgroundColor(ExternalResourceHelper.getColor(ctx, "green"));
            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.jarklee.materialdatetimepicker.time.TimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.mdtp_time_picker_dialog, container, false);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }/*  www  .j av  a 2 s  . c  o  m*/

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark);
    }

    Resources res = getResources();
    Context context = getActivity();
    mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description);
    mSelectHours = res.getString(R.string.mdtp_select_hours);
    mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description);
    mSelectMinutes = res.getString(R.string.mdtp_select_minutes);
    mSecondPickerDescription = res.getString(R.string.mdtp_second_picker_description);
    mSelectSeconds = res.getString(R.string.mdtp_select_seconds);
    mSelectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_accent_color_focused);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mSecondSpaceView = (TextView) view.findViewById(R.id.seconds_space);
    mSecondView = (TextView) view.findViewById(R.id.seconds);
    mSecondView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols(getLocale()).getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    if (mTimePicker != null) {
        mInitialTime = new Timepoint(mTimePicker.getHours(), mTimePicker.getMinutes(),
                mTimePicker.getSeconds());
    }

    mInitialTime = roundToNearest(mInitialTime);

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), this, mInitialTime, mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mSecondView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setCurrentItemShowing(SECOND_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mOkButton = (Button) view.findViewById(R.id.ok);
    mOkButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            notifyOnDateListener();
            dismiss();
        }
    });
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(Utils.getStringFromLocale(getContext(), mOkResid, getLocale()));

    mCancelButton = (Button) view.findViewById(R.id.cancel);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    mCancelButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mCancelString != null)
        mCancelButton.setText(mCancelString);
    else
        mCancelButton.setText(Utils.getStringFromLocale(getContext(), mCancelResid, getLocale()));
    mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialTime.isAM() ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // Don't do anything if either AM or PM are disabled
                if (isAmDisabled() || isPmDisabled())
                    return;

                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    // Disable seconds picker
    if (!mEnableSeconds) {
        mSecondView.setVisibility(View.GONE);
        view.findViewById(R.id.separator_seconds).setVisibility(View.GONE);
    }

    // Disable minutes picker
    if (!mEnableMinutes) {
        mMinuteSpaceView.setVisibility(View.GONE);
        view.findViewById(R.id.separator).setVisibility(View.GONE);
    }

    // Center stuff depending on what's visible
    if (mIs24HourMode && !mEnableSeconds && mEnableMinutes) {
        // center first separator
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else if (!mEnableMinutes && !mEnableSeconds) {
        // center the hour
        RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsHour.addRule(RelativeLayout.CENTER_IN_PARENT);
        mHourSpaceView.setLayoutParams(paramsHour);

        if (!mIs24HourMode) {
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.hour_space);
            paramsAmPm.addRule(RelativeLayout.ALIGN_BASELINE, R.id.hour_space);
            mAmPmTextView.setLayoutParams(paramsAmPm);
        }
    } else if (mEnableSeconds) {
        // link separator to minutes
        final View separator = view.findViewById(R.id.separator);
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.minutes_space);
        paramsSeparator.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        separator.setLayoutParams(paramsSeparator);

        if (!mIs24HourMode) {
            // center minutes
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.CENTER_IN_PARENT);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        } else {
            // move minutes to right of center
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.RIGHT_OF, R.id.center_view);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        }
    }

    mAllowAutoAdvance = true;
    setHour(mInitialTime.getHour(), true);
    setMinute(mInitialTime.getMinute());
    setSecond(mInitialTime.getSecond());

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.mdtp_deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<>();
    }

    // Set the title (if any)
    TextView timePickerHeader = (TextView) view.findViewById(R.id.time_picker_header);
    if (!mTitle.isEmpty()) {
        timePickerHeader.setVisibility(TextView.VISIBLE);
        timePickerHeader.setText(mTitle.toUpperCase(getLocale()));
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mOkButton.setTextColor(mAccentColor);
    mCancelButton.setTextColor(mAccentColor);
    timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.time_display_background).setBackgroundColor(mAccentColor);
    view.findViewById(R.id.time_display).setBackgroundColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    int circleBackground = ContextCompat.getColor(context, R.color.mdtp_circle_background);
    int backgroundColor = ContextCompat.getColor(context, R.color.mdtp_background_color);
    int darkBackgroundColor = ContextCompat.getColor(context, R.color.mdtp_light_gray);
    int lightGray = ContextCompat.getColor(context, R.color.mdtp_light_gray);

    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    view.findViewById(R.id.time_picker_dialog)
            .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    return view;
}

From source file:com.esri.squadleader.view.SquadLeaderActivity.java

private void adjustLayoutForOrientation(int orientation) {
    View displayView = findViewById(R.id.tableLayout_display);
    if (displayView.getLayoutParams() instanceof RelativeLayout.LayoutParams) {
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) displayView.getLayoutParams();
        switch (orientation) {
        case Configuration.ORIENTATION_LANDSCAPE: {
            params.addRule(RelativeLayout.RIGHT_OF, R.id.toggleButton_grid);
            params.addRule(RelativeLayout.LEFT_OF, R.id.toggleButton_followMe);
            params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.imageButton_zoomOut);
            params.addRule(RelativeLayout.ABOVE, -1);
            break;
        }/* w w  w.jav  a 2  s.  c om*/
        case Configuration.ORIENTATION_PORTRAIT:
        default: {
            params.addRule(RelativeLayout.RIGHT_OF, -1);
            params.addRule(RelativeLayout.LEFT_OF, R.id.imageButton_zoomIn);
            params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.imageButton_zoomIn);
            params.addRule(RelativeLayout.ABOVE, R.id.toggleButton_grid);
        }
        }
        displayView.setLayoutParams(params);
    }
}

From source file:com.customdatepicker.time.TimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    int viewRes = mVersion == Version.VERSION_1 ? R.layout.mdtp_time_picker_dialog
            : R.layout.mdtp_time_picker_dialog_v2;
    View view = inflater.inflate(viewRes, container, false);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.mdtp_time_picker_dialog).setOnKeyListener(keyboardListener);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }/*from  ww  w  . j  a v  a 2  s.  co  m*/

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark);
    }

    Resources res = getResources();
    Context context = getActivity();
    mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description);
    mSelectHours = res.getString(R.string.mdtp_select_hours);
    mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description);
    mSelectMinutes = res.getString(R.string.mdtp_select_minutes);
    mSecondPickerDescription = res.getString(R.string.mdtp_second_picker_description);
    mSelectSeconds = res.getString(R.string.mdtp_select_seconds);
    mSelectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_accent_color_focused);

    mHourView = (TextView) view.findViewById(R.id.mdtp_hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.mdtp_hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.mdtp_minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.mdtp_minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mSecondSpaceView = (TextView) view.findViewById(R.id.mdtp_seconds_space);
    mSecondView = (TextView) view.findViewById(R.id.mdtp_seconds);
    mSecondView.setOnKeyListener(keyboardListener);
    mAmTextView = (TextView) view.findViewById(R.id.mdtp_am_label);
    mAmTextView.setOnKeyListener(keyboardListener);
    mPmTextView = (TextView) view.findViewById(R.id.mdtp_pm_label);
    mPmTextView.setOnKeyListener(keyboardListener);
    mAmPmLayout = view.findViewById(R.id.mdtp_ampm_layout);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    if (mTimePicker != null) {
        mInitialTime = new Timepoint(mTimePicker.getHours(), mTimePicker.getMinutes(),
                mTimePicker.getSeconds());
    }

    mInitialTime = roundToNearest(mInitialTime);

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.mdtp_time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), this, mInitialTime, mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mSecondView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setCurrentItemShowing(SECOND_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mOkButton = (Button) view.findViewById(R.id.mdtp_ok);
    mOkButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            notifyOnDateListener();
            dismiss();
        }
    });
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(mOkResid);

    mCancelButton = (Button) view.findViewById(R.id.mdtp_cancel);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    mCancelButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mCancelString != null)
        mCancelButton.setText(mCancelString);
    else
        mCancelButton.setText(mCancelResid);
    mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // Enable or disable the AM/PM view.
    if (mIs24HourMode) {
        mAmPmLayout.setVisibility(View.GONE);
    } else {
        OnClickListener listener = new OnClickListener() {
            @Override
            public void onClick(View v) {
                // Don't do anything if either AM or PM are disabled
                if (isAmDisabled() || isPmDisabled())
                    return;

                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                mTimePicker.setAmOrPm(amOrPm);
            }
        };
        mAmTextView.setVisibility(View.GONE);
        mPmTextView.setVisibility(View.VISIBLE);
        mAmPmLayout.setOnClickListener(listener);
        if (mVersion == Version.VERSION_2) {
            mAmTextView.setText(mAmText);
            mPmTextView.setText(mPmText);
            mAmTextView.setVisibility(View.VISIBLE);
        }
        updateAmPmDisplay(mInitialTime.isAM() ? AM : PM);

    }

    // Disable seconds picker
    if (!mEnableSeconds) {
        mSecondView.setVisibility(View.GONE);
        view.findViewById(R.id.mdtp_separator_seconds).setVisibility(View.GONE);
    }

    // Disable minutes picker
    if (!mEnableMinutes) {
        mMinuteSpaceView.setVisibility(View.GONE);
        view.findViewById(R.id.mdtp_separator).setVisibility(View.GONE);
    }

    // Center stuff depending on what's visible
    boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    // Landscape layout is radically different
    if (isLandscape) {
        if (!mEnableMinutes && !mEnableSeconds) {
            // Just the hour
            // Put the hour above the center
            RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsHour.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view);
            paramsHour.addRule(RelativeLayout.CENTER_HORIZONTAL);
            mHourSpaceView.setLayoutParams(paramsHour);
            if (mIs24HourMode) {
                // Hour + Am/Pm indicator
                // Put the am / pm indicator next to the hour
                RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(
                        ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_hour_space);
                mAmPmLayout.setLayoutParams(paramsAmPm);
            }
        } else if (!mEnableSeconds && mIs24HourMode) {
            // Hour + Minutes
            // Put the separator above the center
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
        } else if (!mEnableSeconds) {
            // Hour + Minutes + Am/Pm indicator
            // Put separator above the center
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
            // Put the am/pm indicator below the separator
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.CENTER_IN_PARENT);
            paramsAmPm.addRule(RelativeLayout.BELOW, R.id.mdtp_center_view);
            mAmPmLayout.setLayoutParams(paramsAmPm);
        } else if (mIs24HourMode) {
            // Hour + Minutes + Seconds
            // Put the separator above the center
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_seconds_space);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
            // Center the seconds
            RelativeLayout.LayoutParams paramsSeconds = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeconds.addRule(RelativeLayout.CENTER_IN_PARENT);
            mSecondSpaceView.setLayoutParams(paramsSeconds);
        } else {
            // Hour + Minutes + Seconds + Am/Pm Indicator
            // Put the seconds on the center
            RelativeLayout.LayoutParams paramsSeconds = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeconds.addRule(RelativeLayout.CENTER_IN_PARENT);
            mSecondSpaceView.setLayoutParams(paramsSeconds);
            // Put the separator above the seconds
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_seconds_space);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
            // Put the Am/Pm indicator below the seconds
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsAmPm.addRule(RelativeLayout.BELOW, R.id.mdtp_seconds_space);
            mAmPmLayout.setLayoutParams(paramsAmPm);
        }
    } else if (mIs24HourMode && !mEnableSeconds && mEnableMinutes) {
        // center first separator
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else if (!mEnableMinutes && !mEnableSeconds) {
        // center the hour
        RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsHour.addRule(RelativeLayout.CENTER_IN_PARENT);
        mHourSpaceView.setLayoutParams(paramsHour);

        if (!mIs24HourMode) {
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_hour_space);
            paramsAmPm.addRule(RelativeLayout.ALIGN_BASELINE, R.id.mdtp_hour_space);
            mAmPmLayout.setLayoutParams(paramsAmPm);
        }
    } else if (mEnableSeconds) {
        // link separator to minutes
        final View separator = view.findViewById(R.id.mdtp_separator);
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.mdtp_minutes_space);
        paramsSeparator.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        separator.setLayoutParams(paramsSeparator);

        if (!mIs24HourMode) {
            // center minutes
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.CENTER_IN_PARENT);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        } else {
            // move minutes to right of center
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_center_view);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        }
    }

    mAllowAutoAdvance = true;
    setHour(mInitialTime.getHour(), true);
    setMinute(mInitialTime.getMinute());
    setSecond(mInitialTime.getSecond());

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.mdtp_deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<>();
    }

    // Set the title (if any)
    TextView timePickerHeader = (TextView) view.findViewById(R.id.mdtp_time_picker_header);
    if (!mTitle.isEmpty()) {
        timePickerHeader.setVisibility(TextView.VISIBLE);
        timePickerHeader.setText(mTitle.toUpperCase(Locale.getDefault()));
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.mdtp_time_display_background).setBackgroundColor(mAccentColor);
    view.findViewById(R.id.mdtp_time_display).setBackgroundColor(mAccentColor);

    // Button text can have a different color
    if (mOkColor != -1)
        mOkButton.setTextColor(mOkColor);
    else
        mOkButton.setTextColor(mAccentColor);
    if (mCancelColor != -1)
        mCancelButton.setTextColor(mCancelColor);
    else
        mCancelButton.setTextColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.mdtp_done_background).setVisibility(View.GONE);
    }

    int circleBackground = ContextCompat.getColor(context, R.color.mdtp_circle_background);
    int backgroundColor = ContextCompat.getColor(context, R.color.mdtp_background_color);
    int darkBackgroundColor = ContextCompat.getColor(context, R.color.mdtp_light_gray);
    int lightGray = ContextCompat.getColor(context, R.color.mdtp_light_gray);

    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    view.findViewById(R.id.mdtp_time_picker_dialog)
            .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    return view;
}

From source file:nu.yona.timepicker.time.TimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.mdtp_dual_time_picker_dialog, container, false);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }/*from www  .java  2s.  co  m*/

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark);
    }

    Resources res = getResources();
    Context context = getActivity();
    mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description);
    mSelectHours = res.getString(R.string.mdtp_select_hours);
    mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description);
    mSelectMinutes = res.getString(R.string.mdtp_select_minutes);
    mSecondPickerDescription = res.getString(R.string.mdtp_second_picker_description);
    mSelectSeconds = res.getString(R.string.mdtp_select_seconds);
    mSelectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_accent_color_focused);
    if (mIsDualScreenMode) {
        view.findViewById(R.id.next_backgroud).setVisibility(View.VISIBLE);

        tabHost = (TabHost) view.findViewById(R.id.tabHost);
        tabHost.findViewById(R.id.tabHost);
        tabHost.setOnTabChangedListener(this);
        tabHost.setup();
        setNewTab(tabHost, getString(R.string.from), R.string.from, R.id.time_picker, 0);
        setNewTab(tabHost, getString(R.string.to), R.string.to, R.id.time_picker_end, 1);
        tabHost.setCurrentTab(0);
    } else {
        ((TextView) view.findViewById(R.id.previous)).setText(getString(R.string.mdtp_cancel));
        view.findViewById(R.id.done_background).setVisibility(View.VISIBLE);
    }

    doneBackgroudnView = view.findViewById(R.id.done_background);
    nextBackgroundView = view.findViewById(R.id.next_backgroud);
    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourView.setTypeface(TypefaceHelper.get(context, Utils.OSWALD_LIGHT));
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mHourSpaceViewEnd = (TextView) view.findViewById(R.id.hour_space_end);
    mHourViewEnd = (TextView) view.findViewById(R.id.hours_end);
    mHourViewEnd.setOnKeyListener(keyboardListener);
    mHourViewEnd.setTypeface(TypefaceHelper.get(context, Utils.OSWALD_LIGHT));
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteSpaceViewEnd = (TextView) view.findViewById(R.id.minutes_space_end);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mMinuteView.setTypeface(TypefaceHelper.get(context, Utils.OSWALD_LIGHT));
    mMinuteViewEnd = (TextView) view.findViewById(R.id.minutes_end);
    mMinuteViewEnd.setOnKeyListener(keyboardListener);
    mMinuteViewEnd.setTypeface(TypefaceHelper.get(context, Utils.OSWALD_LIGHT));
    mSecondSpaceView = (TextView) view.findViewById(R.id.seconds_space);
    mSecondView = (TextView) view.findViewById(R.id.seconds);
    mSecondView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());
    mInitialTime = roundToNearest(mInitialTime);

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), this, mInitialTime, mIs24HourMode);

    mTimePickerEnd = (RadialPickerLayout) view.findViewById(R.id.time_picker_end);
    mTimePickerEnd.setOnValueSelectedListener(this);
    mTimePickerEnd.setOnKeyListener(keyboardListener);
    //mTimePickerEnd.setVisibility(View.GONE);
    if (mSecondTime != null) {
        mTimePickerEnd.initialize(getActivity(), this, mSecondTime, mIs24HourMode);
    }

    int currentItemShowing = HOUR_INDEX;
    int currentItemShowingEnd = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    /*if (savedInstanceState != null &&
        savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING_END)) {
    currentItemShowingEnd = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING_END);
    }*/
    setCurrentItemShowing(currentItemShowing, false, true, true);
    setCurrentItemShowing(currentItemShowingEnd, false, true, true);
    mTimePicker.invalidate();
    mTimePickerEnd.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tabHost.getCurrentTab() == 1) {
                tabHost.setCurrentTab(0);
            } else {
                setCurrentItemShowing(HOUR_INDEX, true, false, true);
            }
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tabHost.getCurrentTab() == 1) {
                tabHost.setCurrentTab(0);
            } else {
                setCurrentItemShowing(MINUTE_INDEX, true, false, true);
                tryVibrate();
            }
        }
    });
    mSecondView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setCurrentItemShowing(SECOND_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mHourViewEnd.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tabHost.getCurrentTab() == 0) {
                tabHost.setCurrentTab(1);
            } else {
                setCurrentItemShowing(HOUR_INDEX, true, false, true);
                tryVibrate();
            }
        }
    });
    mMinuteViewEnd.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tabHost.getCurrentTab() == 0) {
                tabHost.setCurrentTab(1);
            } else {
                setCurrentItemShowing(MINUTE_INDEX, true, false, true);
                tryVibrate();
            }
        }
    });
    mSecondView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setCurrentItemShowing(SECOND_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mOkButton = (Button) view.findViewById(R.id.ok);
    mOkButton.setOnClickListener(clickListener);
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(context, Utils.ROBOTO_MEDIUM));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(mOkResid);

    mErrorMsg = (TextView) view.findViewById(R.id.time_picker_error_msg);

    mPreviousButton = (Button) view.findViewById(R.id.previous);
    mPreviousButton.setOnClickListener(clickListener);

    mNextButton = (Button) view.findViewById(R.id.next);
    mNextButton.setOnClickListener(clickListener);

    mCancelButton = (Button) view.findViewById(R.id.cancel);
    mCancelButton.setOnClickListener(clickListener);
    mCancelButton.setTypeface(TypefaceHelper.get(context, Utils.ROBOTO_MEDIUM));
    if (mCancelString != null)
        mCancelButton.setText(mCancelString);
    else
        mCancelButton.setText(mCancelResid);
    mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialTime.isAM() ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // Don't do anything if either AM or PM are disabled
                if (isAmDisabled() || isPmDisabled())
                    return;

                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    // Disable seconds picker
    if (!mEnableSeconds) {
        mSecondSpaceView.setVisibility(View.GONE);
        view.findViewById(R.id.separator_seconds).setVisibility(View.GONE);
    }

    // Center stuff depending on what's visible
    if (mIs24HourMode && !mEnableSeconds) {
        // center first separator
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else if (mEnableSeconds) {
        // link separator to minutes
        final View separator = view.findViewById(R.id.separator);
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.minutes_space);
        paramsSeparator.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        separator.setLayoutParams(paramsSeparator);

        if (!mIs24HourMode) {
            // center minutes
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.CENTER_IN_PARENT);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        } else {
            // move minutes to right of center
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.RIGHT_OF, R.id.center_view);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        }
    }

    mAllowAutoAdvance = true;
    setHour(mFirstTime.getHour(), true);
    setMinute(mFirstTime.getMinute());
    setSecond(mFirstTime.getSecond());

    setHourEnd(mSecondTime.getHour(), true);
    setMinuteEnd(mSecondTime.getMinute());
    setSecondEnd(mSecondTime.getSecond());

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.mdtp_deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<>();
    }

    /* // Set the title (if any)
     if (!mTitle.isEmpty()) {
    timePickerHeader.setVisibility(TextView.VISIBLE);
    timePickerHeader.setText(mTitle.toUpperCase(Locale.getDefault()));
     }*/

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mOkButton.setTextColor(mAccentColor);
    mCancelButton.setTextColor(mAccentColor);
    //timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.time_display_background)
            .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.mdtp_white));
    view.findViewById(R.id.time_display).setBackgroundColor(mAccentColor);
    view.findViewById(R.id.time_display_end).setBackgroundColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    int circleBackground = ContextCompat.getColor(context, R.color.mdtp_circle_background);
    int backgroundColor = ContextCompat.getColor(context, R.color.mdtp_background_color);
    int darkBackgroundColor = ContextCompat.getColor(context, R.color.mdtp_light_gray);
    int lightGray = ContextCompat.getColor(context, R.color.mdtp_light_gray);

    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    mTimePickerEnd.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    view.findViewById(R.id.time_picker_dialog)
            .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    return view;
}

From source file:org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    /* TODO better error handling? May cause problems when a key is deleted,
     * because the notification triggers faster than the activity closes.
     *///  ww w.  j av  a2  s  . c  o m

    // Swap the new cursor in. (The framework will take care of closing the
    // old cursor once we return.)
    switch (loader.getId()) {
    case LOADER_ID_UNIFIED: {
        // Avoid NullPointerExceptions...
        if (data.getCount() == 0) {
            return;
        }

        if (data.moveToFirst()) {
            // get name, email, and comment from USER_ID

            String name = data.getString(INDEX_NAME);

            mCollapsingToolbarLayout.setTitle(name != null ? name : getString(R.string.user_id_no_name));

            mMasterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
            mFingerprint = data.getBlob(INDEX_FINGERPRINT);
            mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
            mHasEncrypt = data.getInt(INDEX_HAS_ENCRYPT) != 0;
            mIsRevoked = data.getInt(INDEX_IS_REVOKED) > 0;
            mIsExpired = data.getInt(INDEX_IS_EXPIRED) != 0;
            mIsSecure = data.getInt(INDEX_IS_SECURE) == 1;
            mIsVerified = data.getInt(INDEX_VERIFIED) > 0;

            // queue showing of the main fragment
            showMainFragment();

            // if the refresh animation isn't playing
            if (!mRotate.hasStarted() && !mRotateSpin.hasStarted()) {
                // re-create options menu based on mIsSecret, mIsVerified
                supportInvalidateOptionsMenu();
                // this is done at the end of the animation otherwise
            }

            AsyncTask<Long, Void, Bitmap> photoTask = new AsyncTask<Long, Void, Bitmap>() {
                protected Bitmap doInBackground(Long... mMasterKeyId) {
                    return new ContactHelper(ViewKeyActivity.this).loadPhotoByMasterKeyId(mMasterKeyId[0],
                            true);
                }

                protected void onPostExecute(Bitmap photo) {
                    if (photo == null) {
                        return;
                    }

                    mPhoto.setImageBitmap(photo);
                    mPhoto.setColorFilter(getResources().getColor(R.color.toolbar_photo_tint),
                            PorterDuff.Mode.SRC_ATOP);
                    mPhotoLayout.setVisibility(View.VISIBLE);
                }
            };

            boolean showStatusText = mIsSecure && !mIsExpired && !mIsRevoked;
            if (showStatusText) {
                mStatusText.setVisibility(View.VISIBLE);

                if (mIsSecret) {
                    mStatusText.setText(R.string.view_key_my_key);
                } else if (mIsVerified) {
                    mStatusText.setText(R.string.view_key_verified);
                } else {
                    mStatusText.setText(R.string.view_key_unverified);
                }
            } else {
                mStatusText.setVisibility(View.GONE);
            }

            // Note: order is important
            int color;
            if (mIsRevoked) {
                mStatusImage.setVisibility(View.VISIBLE);
                KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.REVOKED, R.color.icons,
                        true);
                // noinspection deprecation, fix requires api level 23
                color = getResources().getColor(R.color.key_flag_red);

                mActionEncryptFile.setVisibility(View.INVISIBLE);
                mActionEncryptText.setVisibility(View.INVISIBLE);
                hideFab();
                mQrCodeLayout.setVisibility(View.GONE);
            } else if (!mIsSecure) {
                mStatusImage.setVisibility(View.VISIBLE);
                KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.INSECURE,
                        R.color.icons, true);
                // noinspection deprecation, fix requires api level 23
                color = getResources().getColor(R.color.key_flag_red);

                mActionEncryptFile.setVisibility(View.INVISIBLE);
                mActionEncryptText.setVisibility(View.INVISIBLE);
                hideFab();
                mQrCodeLayout.setVisibility(View.GONE);
            } else if (mIsExpired) {
                mStatusImage.setVisibility(View.VISIBLE);
                KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.EXPIRED, R.color.icons,
                        true);
                // noinspection deprecation, fix requires api level 23
                color = getResources().getColor(R.color.key_flag_red);

                mActionEncryptFile.setVisibility(View.INVISIBLE);
                mActionEncryptText.setVisibility(View.INVISIBLE);
                hideFab();
                mQrCodeLayout.setVisibility(View.GONE);
            } else if (mIsSecret) {
                mStatusImage.setVisibility(View.GONE);
                // noinspection deprecation, fix requires api level 23
                color = getResources().getColor(R.color.key_flag_green);
                // reload qr code only if the fingerprint changed
                if (!Arrays.equals(mFingerprint, mQrCodeLoaded)) {
                    loadQrCode(mFingerprint);
                }
                photoTask.execute(mMasterKeyId);
                mQrCodeLayout.setVisibility(View.VISIBLE);

                // and place leftOf qr code
                //                        RelativeLayout.LayoutParams nameParams = (RelativeLayout.LayoutParams)
                //                                mName.getLayoutParams();
                //                        // remove right margin
                //                        nameParams.setMargins(FormattingUtils.dpToPx(this, 48), 0, 0, 0);
                //                        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                //                            nameParams.setMarginEnd(0);
                //                        }
                //                        nameParams.addRule(RelativeLayout.LEFT_OF, R.id.view_key_qr_code_layout);
                //                        mName.setLayoutParams(nameParams);

                RelativeLayout.LayoutParams statusParams = (RelativeLayout.LayoutParams) mStatusText
                        .getLayoutParams();
                statusParams.setMargins(FormattingUtils.dpToPx(this, 48), 0, 0, 0);
                if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    statusParams.setMarginEnd(0);
                }
                statusParams.addRule(RelativeLayout.LEFT_OF, R.id.view_key_qr_code_layout);
                mStatusText.setLayoutParams(statusParams);

                mActionEncryptFile.setVisibility(View.VISIBLE);
                mActionEncryptText.setVisibility(View.VISIBLE);

                showFab();
                // noinspection deprecation (no getDrawable with theme at current minApi level 15!)
                mFab.setImageDrawable(getResources().getDrawable(R.drawable.ic_repeat_white_24dp));
            } else {
                mActionEncryptFile.setVisibility(View.VISIBLE);
                mActionEncryptText.setVisibility(View.VISIBLE);
                mQrCodeLayout.setVisibility(View.GONE);

                if (mIsVerified) {
                    mStatusText.setText(R.string.view_key_verified);
                    mStatusImage.setVisibility(View.VISIBLE);
                    KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.VERIFIED,
                            R.color.icons, true);
                    // noinspection deprecation, fix requires api level 23
                    color = getResources().getColor(R.color.key_flag_green);
                    photoTask.execute(mMasterKeyId);

                    hideFab();
                } else {
                    mStatusText.setText(R.string.view_key_unverified);
                    mStatusImage.setVisibility(View.VISIBLE);
                    KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.UNVERIFIED,
                            R.color.icons, true);
                    // noinspection deprecation, fix requires api level 23
                    color = getResources().getColor(R.color.key_flag_orange);

                    showFab();
                }
            }

            if (mPreviousColor == 0 || mPreviousColor == color) {
                mAppBarLayout.setBackgroundColor(color);
                mCollapsingToolbarLayout.setContentScrimColor(color);
                mCollapsingToolbarLayout.setStatusBarScrimColor(getStatusBarBackgroundColor(color));
                mPreviousColor = color;
            } else {
                ObjectAnimator colorFade = ObjectAnimator.ofObject(mAppBarLayout, "backgroundColor",
                        new ArgbEvaluator(), mPreviousColor, color);
                mCollapsingToolbarLayout.setContentScrimColor(color);
                mCollapsingToolbarLayout.setStatusBarScrimColor(getStatusBarBackgroundColor(color));

                colorFade.setDuration(1200);
                colorFade.start();
                mPreviousColor = color;
            }

            //noinspection deprecation
            mStatusImage.setAlpha(80);

            break;
        }
    }
    }
}

From source file:com.aimfire.demo.CameraActivity.java

private void adjustUIControls(int rotation) {
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mCaptureButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mCaptureButton.setLayoutParams(layoutParams);
    mCaptureButton.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mPvButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.ABOVE, 0);
    layoutParams.addRule(RelativeLayout.BELOW, R.id.capture_button);
    mPvButton.setLayoutParams(layoutParams);
    mPvButton.setRotation(rotation);//from   w w w.java  2 s  .  co m

    /*
    layoutParams = (RelativeLayout.LayoutParams)mFbButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.ABOVE, R.id.capture_button);
    layoutParams.addRule(RelativeLayout.BELOW, 0);
    mFbButton.setLayoutParams(layoutParams);
    mFbButton.setRotation(rotation);
    */

    layoutParams = (RelativeLayout.LayoutParams) mExitButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
    mExitButton.setLayoutParams(layoutParams);
    mExitButton.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mView3DButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mView3DButton.setLayoutParams(layoutParams);
    mView3DButton.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mModeButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.LEFT_OF, 0);
    layoutParams.addRule(RelativeLayout.RIGHT_OF, 0);
    mModeButton.setLayoutParams(layoutParams);
    mModeButton.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mLevelButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    mLevelButton.setLayoutParams(layoutParams);
    mLevelButton.setRotation(rotation);

    CustomToast.setRotation(rotation);
}

From source file:androidx.media.widget.MediaControlView2.java

@SuppressWarnings("deprecation")
private void updateLayoutForSizeChange(int sizeType) {
    mSizeType = sizeType;//from www.  j  a  v  a2s .co  m
    RelativeLayout.LayoutParams timeViewParams = (RelativeLayout.LayoutParams) mTimeView.getLayoutParams();
    SeekBar seeker = (SeekBar) mProgress;
    switch (mSizeType) {
    case SIZE_TYPE_EMBEDDED:
        // Relating to Title Bar
        mTitleBar.setVisibility(View.VISIBLE);
        mBackButton.setVisibility(View.GONE);

        // Relating to Full Screen Button
        mMinimalExtraView.setVisibility(View.GONE);
        mFullScreenButton = mBottomBarRightView.findViewById(R.id.fullscreen);
        mFullScreenButton.setOnClickListener(mFullScreenListener);

        // Relating to Center View
        mCenterView.removeAllViews();
        mBottomBarLeftView.removeView(mTransportControls);
        mBottomBarLeftView.setVisibility(View.GONE);
        mTransportControls = inflateTransportControls(R.layout.embedded_transport_controls);
        mCenterView.addView(mTransportControls);

        // Relating to Progress Bar
        seeker.setThumb(mResources.getDrawable(R.drawable.custom_progress_thumb));
        mProgressBuffer.setVisibility(View.VISIBLE);

        // Relating to Bottom Bar
        mBottomBar.setVisibility(View.VISIBLE);
        if (timeViewParams.getRules()[RelativeLayout.LEFT_OF] != 0) {
            timeViewParams.removeRule(RelativeLayout.LEFT_OF);
            timeViewParams.addRule(RelativeLayout.RIGHT_OF, R.id.bottom_bar_left);
        }
        break;
    case SIZE_TYPE_FULL:
        // Relating to Title Bar
        mTitleBar.setVisibility(View.VISIBLE);
        mBackButton.setVisibility(View.VISIBLE);

        // Relating to Full Screen Button
        mMinimalExtraView.setVisibility(View.GONE);
        mFullScreenButton = mBottomBarRightView.findViewById(R.id.fullscreen);
        mFullScreenButton.setOnClickListener(mFullScreenListener);

        // Relating to Center View
        mCenterView.removeAllViews();
        mBottomBarLeftView.removeView(mTransportControls);
        mTransportControls = inflateTransportControls(R.layout.full_transport_controls);
        mBottomBarLeftView.addView(mTransportControls, 0);
        mBottomBarLeftView.setVisibility(View.VISIBLE);

        // Relating to Progress Bar
        seeker.setThumb(mResources.getDrawable(R.drawable.custom_progress_thumb));
        mProgressBuffer.setVisibility(View.VISIBLE);

        // Relating to Bottom Bar
        mBottomBar.setVisibility(View.VISIBLE);
        if (timeViewParams.getRules()[RelativeLayout.RIGHT_OF] != 0) {
            timeViewParams.removeRule(RelativeLayout.RIGHT_OF);
            timeViewParams.addRule(RelativeLayout.LEFT_OF, R.id.bottom_bar_right);
        }
        break;
    case SIZE_TYPE_MINIMAL:
        // Relating to Title Bar
        mTitleBar.setVisibility(View.GONE);
        mBackButton.setVisibility(View.GONE);

        // Relating to Full Screen Button
        mMinimalExtraView.setVisibility(View.VISIBLE);
        mFullScreenButton = mMinimalExtraView.findViewById(R.id.minimal_fullscreen);
        mFullScreenButton.setOnClickListener(mFullScreenListener);

        // Relating to Center View
        mCenterView.removeAllViews();
        mBottomBarLeftView.removeView(mTransportControls);
        mTransportControls = inflateTransportControls(R.layout.minimal_transport_controls);
        mCenterView.addView(mTransportControls);

        // Relating to Progress Bar
        seeker.setThumb(null);
        mProgressBuffer.setVisibility(View.GONE);

        // Relating to Bottom Bar
        mBottomBar.setVisibility(View.GONE);
        break;
    }
    mTimeView.setLayoutParams(timeViewParams);

    if (isPlaying()) {
        mPlayPauseButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_pause_circle_filled, null));
        mPlayPauseButton.setContentDescription(mResources.getString(R.string.mcv2_pause_button_desc));
    } else {
        mPlayPauseButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_play_circle_filled, null));
        mPlayPauseButton.setContentDescription(mResources.getString(R.string.mcv2_play_button_desc));
    }

    if (mIsFullScreen) {
        mFullScreenButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_fullscreen_exit, null));
    } else {
        mFullScreenButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_fullscreen, null));
    }
}