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;
}
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());
}
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;
}
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;
}
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();
});
}
Aggregations