Search in sources :

Example 1 with TextView

use of carbon.widget.TextView in project Carbon by ZieIony.

the class Toolbar method setTitle.

/**
     * Set the title of this toolbar.
     * <p>
     * <p>A title should be used as the anchor for a section of content. It should
     * describe or name the content being viewed.</p>
     *
     * @param title Title to set
     */
public void setTitle(CharSequence title) {
    if (!TextUtils.isEmpty(title)) {
        if (mTitleTextView == null) {
            final Context context = getContext();
            mTitleTextView = new TextView(context);
            mTitleTextView.setSingleLine();
            mTitleTextView.setEllipsize(TextUtils.TruncateAt.END);
            if (mTitleTextAppearance != 0) {
                mTitleTextView.setTextAppearance(context, mTitleTextAppearance);
            }
            if (mTitleTextColor != 0) {
                mTitleTextView.setTextColor(mTitleTextColor);
            }
        }
        if (mTitleTextView.getParent() == null) {
            addSystemView(mTitleTextView);
            updateChildVisibilityForExpandedActionView(mTitleTextView);
        }
    } else if (mTitleTextView != null && mTitleTextView.getParent() != null) {
        removeView(mTitleTextView);
    }
    if (mTitleTextView != null) {
        mTitleTextView.setText(title);
    }
    mTitleText = title;
}
Also used : Context(android.content.Context) TextView(carbon.widget.TextView)

Example 2 with TextView

use of carbon.widget.TextView in project Carbon by ZieIony.

the class TableLayout method setAdapter.

public void setAdapter(TableView.Adapter adapter) {
    table.setAdapter(adapter);
    header.removeAllViews();
    for (int i = 0; i < adapter.getColumnCount(); i++) {
        View headerCell = View.inflate(getContext(), R.layout.carbon_tablelayout_header, null);
        TextView tv = headerCell.findViewById(R.id.carbon_tableHeaderText);
        tv.setText(adapter.getColumnName(i));
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, adapter.getColumnWeight(i));
        header.addView(headerCell, params);
    }
    rowNumber.setText("10");
    pageNumbers.setText("1-" + adapter.getItemCount() + " of " + adapter.getItemCount());
}
Also used : TextView(carbon.widget.TextView) TableView(carbon.widget.TableView) View(android.view.View) TextView(carbon.widget.TextView) LinearLayout(carbon.widget.LinearLayout)

Example 3 with TextView

use of carbon.widget.TextView in project Carbon by ZieIony.

the class Toolbar method setSubtitle.

/**
     * Set the subtitle of this toolbar.
     * <p>
     * <p>Subtitles should express extended information about the current content.</p>
     *
     * @param subtitle Subtitle to set
     */
public void setSubtitle(CharSequence subtitle) {
    if (!TextUtils.isEmpty(subtitle)) {
        if (mSubtitleTextView == null) {
            final Context context = getContext();
            mSubtitleTextView = new TextView(context);
            mSubtitleTextView.setSingleLine();
            mSubtitleTextView.setEllipsize(TextUtils.TruncateAt.END);
            if (mSubtitleTextAppearance != 0) {
                mSubtitleTextView.setTextAppearance(context, mSubtitleTextAppearance);
            }
            if (mSubtitleTextColor != 0) {
                mSubtitleTextView.setTextColor(mSubtitleTextColor);
            }
        }
        if (mSubtitleTextView.getParent() == null) {
            addSystemView(mSubtitleTextView);
            updateChildVisibilityForExpandedActionView(mSubtitleTextView);
        }
    } else if (mSubtitleTextView != null && mSubtitleTextView.getParent() != null) {
        removeView(mSubtitleTextView);
    }
    if (mSubtitleTextView != null) {
        mSubtitleTextView.setText(subtitle);
    }
    mSubtitleText = subtitle;
}
Also used : Context(android.content.Context) TextView(carbon.widget.TextView)

Example 4 with TextView

use of carbon.widget.TextView in project Carbon by ZieIony.

the class CollapsingLayout method onNestedScrollByY.

@Override
public int onNestedScrollByY(int dy) {
    DependencyLayout.LayoutParams layoutParams = (DependencyLayout.LayoutParams) getLayoutParams();
    int newHeight = MathUtils.constrain(layoutParams.height - dy, getMinimumHeight(), getMaximumHeight());
    setElevation(MathUtils.map(getMaximumHeight(), getMinimumHeight(), 0, getResources().getDimension(carbon.R.dimen.carbon_elevationToolbar), newHeight));
    int usedDy = layoutParams.height - newHeight;
    layoutParams.height = newHeight;
    setLayoutParams(layoutParams);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    ImageView iconView = (ImageView) toolbar.getIconView();
    TextView titleView = toolbar.getTitleView();
    {
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) iconView.getLayoutParams();
        params.gravity = Gravity.TOP;
        iconView.setLayoutParams(params);
    }
    {
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) titleView.getLayoutParams();
        params.gravity = Gravity.TOP;
        titleView.setLayoutParams(params);
    }
    if (getHeight() == getMinimumHeight() && iconView.getVisibility() != VISIBLE && iconView.getAnimator() == null) {
        iconView.setVisibility(VISIBLE);
    } else if (getHeight() != getMinimumHeight() && iconView.getVisibility() == VISIBLE && iconView.getAnimator() == null) {
        iconView.setVisibility(INVISIBLE);
    }
    titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, MathUtils.map(getMaximumHeight(), getMinimumHeight(), getResources().getDimension(R.dimen.carbon_textSizeHeadline), getResources().getDimension(carbon.R.dimen.carbon_textSizeTitle), newHeight));
    return usedDy;
}
Also used : TextView(carbon.widget.TextView) ImageView(carbon.widget.ImageView) LinearLayout(carbon.widget.LinearLayout) Toolbar(carbon.widget.Toolbar)

Example 5 with TextView

use of carbon.widget.TextView in project Carbon by ZieIony.

the class PowerMenuActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initToolbar();
    button = findViewById(R.id.button);
    powerMenu = findViewById(R.id.powerMenu);
    transition = findViewById(R.id.transition);
    screenPowerMenu = findViewById(R.id.screen_powerMenu);
    screenPowerOff = findViewById(R.id.screen_powerOff);
    screenReboot = findViewById(R.id.screen_reboot);
    screenAirplaneMode = findViewById(R.id.screen_airplaneMode);
    button.setOnClickListener(view -> {
        if (powerMenu.getVisibility() == View.VISIBLE)
            return;
        for (int i = 0; i < transition.getChildCount(); i++) transition.getChildAt(i).setVisibility(i == 0 ? View.VISIBLE : View.GONE);
        final List<View> viewsWithTag = screenPowerMenu.findViewsWithTag("animate");
        Stream.of(viewsWithTag).forEach(v -> v.setVisibility(View.INVISIBLE));
        Animator animator = powerMenu.animateVisibility(View.VISIBLE);
        animator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                Stream.of(viewsWithTag).forEach(v -> {
                    v.getHandler().postDelayed(() -> {
                        if (v instanceof AnimatedView) {
                            ((AnimatedView) v).animateVisibility(View.VISIBLE);
                        } else {
                            v.setVisibility(View.VISIBLE);
                        }
                    }, viewsWithTag.indexOf(v) * 40);
                });
            }
        });
    });
    findViewById(R.id.powerOff).setOnClickListener(view -> {
        final List<View> viewsWithTag = screenPowerOff.findViewsWithTag("animate");
        Stream.of(viewsWithTag).forEach(v -> v.setVisibility(View.INVISIBLE));
        screenPowerOff.setVisibility(View.VISIBLE);
        Animator circularReveal = screenPowerOff.createCircularReveal(view.findViewById(R.id.powerOffIcon), 0, RevealView.MAX_RADIUS);
        circularReveal.setDuration(400);
        circularReveal.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                Stream.of(viewsWithTag).forEach(v -> {
                    view.getHandler().postDelayed(() -> {
                        if (v instanceof AnimatedView) {
                            ((AnimatedView) v).animateVisibility(View.VISIBLE);
                        } else {
                            v.setVisibility(View.VISIBLE);
                        }
                    }, viewsWithTag.indexOf(v) * 20);
                });
            }
        });
        circularReveal.start();
        view.getHandler().postDelayed(() -> powerMenu.animateVisibility(View.INVISIBLE), 3000);
    });
    findViewById(R.id.reboot).setOnClickListener(view -> {
        final List<View> viewsWithTag = screenReboot.findViewsWithTag("animate");
        Stream.of(viewsWithTag).forEach(v -> v.setVisibility(View.INVISIBLE));
        screenReboot.setVisibility(View.VISIBLE);
        Animator circularReveal = screenReboot.createCircularReveal(view.findViewById(R.id.rebootIcon), 0, RevealView.MAX_RADIUS);
        circularReveal.setDuration(400);
        circularReveal.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                Stream.of(viewsWithTag).forEach(v -> {
                    view.getHandler().postDelayed(() -> {
                        if (v instanceof AnimatedView) {
                            ((AnimatedView) v).animateVisibility(View.VISIBLE);
                        } else {
                            v.setVisibility(View.VISIBLE);
                        }
                    }, viewsWithTag.indexOf(v) * 20);
                });
            }
        });
        circularReveal.start();
        view.getHandler().postDelayed(() -> powerMenu.animateVisibility(View.INVISIBLE), 3000);
    });
    findViewById(R.id.airplaneMode).setOnClickListener(view -> {
        final List<View> viewsWithTag = screenAirplaneMode.findViewsWithTag("animate");
        Stream.of(viewsWithTag).forEach(v -> v.setVisibility(View.INVISIBLE));
        screenAirplaneMode.setVisibility(View.VISIBLE);
        Animator circularReveal = screenAirplaneMode.createCircularReveal(view.findViewById(R.id.airplaneModeIcon), 0, RevealView.MAX_RADIUS);
        circularReveal.setDuration(400);
        circularReveal.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                Stream.of(viewsWithTag).forEach(v -> {
                    view.getHandler().postDelayed(() -> {
                        if (v instanceof AnimatedView) {
                            ((AnimatedView) v).animateVisibility(View.VISIBLE);
                        } else {
                            v.setVisibility(View.VISIBLE);
                        }
                    }, viewsWithTag.indexOf(v) * 20);
                });
            }
        });
        circularReveal.start();
        view.getHandler().postDelayed(() -> {
            Animator circularReveal2 = screenAirplaneMode.createCircularReveal(view.findViewById(R.id.airplaneModeIcon), RevealView.MAX_RADIUS, 0);
            circularReveal2.setDuration(400);
            circularReveal2.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    screenAirplaneMode.setVisibility(View.INVISIBLE);
                }
            });
            circularReveal2.start();
            airplaneMode = !airplaneMode;
            TextView amStatus = findViewById(R.id.airplaneModeStatus);
            amStatus.setText("Airplane PopupMode is " + (airplaneMode ? "on" : "off"));
            ImageView airplaneModeIcon = view.findViewById(R.id.airplaneModeIcon);
            airplaneModeIcon.setImageResource(airplaneMode ? R.raw.ic_airplanemode_on_24px : R.raw.ic_airplanemode_off_24px);
        }, 3000);
    });
    findViewById(R.id.vibration).setOnClickListener(view -> {
        if (vibration) {
            vibration = false;
            view.setBackgroundColor(Carbon.getThemeColor(PowerMenuActivity.this, android.R.attr.colorBackground));
            ((ImageView) view).setTint(Carbon.getThemeColor(PowerMenuActivity.this, R.attr.carbon_iconColor));
        } else {
            vibration = true;
            view.setBackgroundColor(getResources().getColor(R.color.carbon_black_54o));
            ((ImageView) view).setTint(Carbon.getThemeColor(PowerMenuActivity.this, R.attr.carbon_iconColorInverse));
            Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
            vibrator.vibrate(500);
        }
        powerMenu.postInvalidate();
    });
    findViewById(R.id.volume).setOnClickListener(view -> {
        if (volume) {
            volume = false;
            view.setBackgroundColor(Carbon.getThemeColor(PowerMenuActivity.this, android.R.attr.colorBackground));
            ((ImageView) view).setTint(Carbon.getThemeColor(PowerMenuActivity.this, R.attr.carbon_iconColor));
        } else {
            volume = true;
            view.setBackgroundColor(getResources().getColor(R.color.carbon_black_54o));
            ((ImageView) view).setTint(Carbon.getThemeColor(PowerMenuActivity.this, R.attr.carbon_iconColorInverse));
            view.playSoundEffect(SoundEffectConstants.CLICK);
        }
        powerMenu.postInvalidate();
    });
}
Also used : Context(android.content.Context) ThemedActivity(tk.zielony.carbonsamples.ThemedActivity) Bundle(android.os.Bundle) Button(carbon.widget.Button) Stream(com.annimon.stream.Stream) AnimatedView(carbon.animation.AnimatedView) LinearLayout(carbon.widget.LinearLayout) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SampleAnnotation(tk.zielony.carbonsamples.SampleAnnotation) RevealView(carbon.view.RevealView) SoundEffectConstants(android.view.SoundEffectConstants) List(java.util.List) Carbon(carbon.Carbon) R(tk.zielony.carbonsamples.R) View(android.view.View) ImageView(carbon.widget.ImageView) TextView(carbon.widget.TextView) Vibrator(android.os.Vibrator) FrameLayout(carbon.widget.FrameLayout) AnimatedView(carbon.animation.AnimatedView) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) TextView(carbon.widget.TextView) ImageView(carbon.widget.ImageView) Vibrator(android.os.Vibrator) AnimatedView(carbon.animation.AnimatedView) RevealView(carbon.view.RevealView) View(android.view.View) ImageView(carbon.widget.ImageView) TextView(carbon.widget.TextView)

Aggregations

TextView (carbon.widget.TextView)5 Context (android.content.Context)3 LinearLayout (carbon.widget.LinearLayout)3 View (android.view.View)2 ImageView (carbon.widget.ImageView)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 Bundle (android.os.Bundle)1 Vibrator (android.os.Vibrator)1 SoundEffectConstants (android.view.SoundEffectConstants)1 Carbon (carbon.Carbon)1 AnimatedView (carbon.animation.AnimatedView)1 RevealView (carbon.view.RevealView)1 Button (carbon.widget.Button)1 FrameLayout (carbon.widget.FrameLayout)1 TableView (carbon.widget.TableView)1 Toolbar (carbon.widget.Toolbar)1 Stream (com.annimon.stream.Stream)1 List (java.util.List)1 R (tk.zielony.carbonsamples.R)1