Search in sources :

Example 1 with Toolbar

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

the class Samples method initToolbar.

public static void initToolbar(final Activity activity, String title) {
    final DebugOverlay overlay = new DebugOverlay(activity);
    Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
    toolbar.setTitle(title);
    final ImageView debug = (ImageView) activity.findViewById(R.id.debug);
    if (debug != null) {
        debug.setTint(Carbon.getThemeColor(activity, R.attr.carbon_colorDisabled));
        debug.setOnClickListener(new View.OnClickListener() {

            boolean debugEnabled = false;

            @Override
            public void onClick(View view) {
                if (!debugEnabled) {
                    debug.setTint(Carbon.getThemeColor(activity, R.attr.carbon_iconColor));
                    overlay.show();
                    debugEnabled = true;
                } else {
                    debug.setTint(Carbon.getThemeColor(activity, R.attr.carbon_colorDisabled));
                    overlay.dismiss();
                    debugEnabled = false;
                }
            }
        });
    }
    CheckBox checkBox = (CheckBox) activity.findViewById(R.id.enabled);
    if (checkBox != null)
        checkBox.setOnCheckedChangeListener((compoundButton, checked) -> {
            List<View> views = findViewsWithTag((ViewGroup) activity.getWindow().getDecorView().getRootView(), "enable");
            for (View v : views) v.setEnabled(checked);
        });
}
Also used : CheckBox(carbon.widget.CheckBox) Context(android.content.Context) List(java.util.List) Carbon(carbon.Carbon) SharedPreferences(android.content.SharedPreferences) Toolbar(carbon.widget.Toolbar) DebugOverlay(carbon.internal.DebugOverlay) View(android.view.View) ImageView(carbon.widget.ImageView) Activity(android.app.Activity) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) CheckBox(carbon.widget.CheckBox) ViewGroup(android.view.ViewGroup) DebugOverlay(carbon.internal.DebugOverlay) List(java.util.List) ArrayList(java.util.ArrayList) ImageView(carbon.widget.ImageView) View(android.view.View) ImageView(carbon.widget.ImageView) Toolbar(carbon.widget.Toolbar)

Example 2 with Toolbar

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

the class ToolbarActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_toolbar);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setIconVisible(true);
    setSupportActionBar(toolbar);
    setTitle("Toolbar");
}
Also used : Toolbar(carbon.widget.Toolbar)

Example 3 with Toolbar

use of carbon.widget.Toolbar 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 4 with Toolbar

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

the class ButtonsUsageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_buttonsusage);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setIconVisible(true);
    ProgressBar progress = (ProgressBar) findViewById(R.id.progress);
    progress.setProgress(0.8f);
}
Also used : ProgressBar(carbon.widget.ProgressBar) Toolbar(carbon.widget.Toolbar)

Example 5 with Toolbar

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

the class SearchToolbarActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    List<DefaultAvatarTextItem> items = generateItems();
    RowListAdapter<DefaultAvatarTextItem> adapter = new RowListAdapter<>(items, AvatarTextRow::new);
    RecyclerView recyclerView = findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter);
    searchEditText = findViewById(R.id.searchEditText);
    searchEditText.setDataProvider(new ListSearchAdapter<DefaultAvatarTextItem>(items) {

        @NotNull
        @Override
        public String[] getItemWords(DefaultAvatarTextItem item) {
            return new String[] { item.getText() };
        }
    });
    searchEditText.setOnFilterListener((SearchEditText.OnFilterListener<DefaultAvatarTextItem>) filterResults -> {
        if (filterResults == null) {
            adapter.setItems(items);
        } else if (filterResults.size() == 2) {
            adapter.setItems(new ArrayList<>());
        } else {
            adapter.setItems(filterResults);
        }
    });
    findViewById(R.id.clear).setOnClickListener(v -> searchEditText.setText(""));
    searchBar = findViewById(R.id.searchbar);
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setOnMenuItemClicked((view, item, position) -> openSearch(view));
    closeButton = findViewById(R.id.close);
    closeButton.setOnClickListener(v -> closeSearch());
}
Also used : ThemedActivity(tk.zielony.carbonsamples.ThemedActivity) Bundle(android.os.Bundle) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SampleAnnotation(tk.zielony.carbonsamples.SampleAnnotation) Drawable(android.graphics.drawable.Drawable) StringNameGenerator(tk.zielony.randomdata.person.StringNameGenerator) ArrayList(java.util.ArrayList) AvatarTextRow(carbon.component.AvatarTextRow) SearchEditText(carbon.widget.SearchEditText) DrawableAvatarGenerator(tk.zielony.randomdata.person.DrawableAvatarGenerator) List(java.util.List) RecyclerView(carbon.widget.RecyclerView) ListSearchAdapter(carbon.widget.ListSearchAdapter) Toolbar(carbon.widget.Toolbar) RandomData(tk.zielony.randomdata.RandomData) R(tk.zielony.carbonsamples.R) DefaultAvatarTextItem(carbon.component.DefaultAvatarTextItem) View(android.view.View) RowListAdapter(carbon.recycler.RowListAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) NotNull(org.jetbrains.annotations.NotNull) FrameLayout(carbon.widget.FrameLayout) DefaultAvatarTextItem(carbon.component.DefaultAvatarTextItem) RowListAdapter(carbon.recycler.RowListAdapter) AvatarTextRow(carbon.component.AvatarTextRow) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) NotNull(org.jetbrains.annotations.NotNull) SearchEditText(carbon.widget.SearchEditText) RecyclerView(carbon.widget.RecyclerView) Toolbar(carbon.widget.Toolbar)

Aggregations

Toolbar (carbon.widget.Toolbar)7 View (android.view.View)3 List (java.util.List)3 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 Carbon (carbon.Carbon)2 RowListAdapter (carbon.recycler.RowListAdapter)2 ImageView (carbon.widget.ImageView)2 RecyclerView (carbon.widget.RecyclerView)2 ArrayList (java.util.ArrayList)2 R (tk.zielony.carbonsamples.R)2 SampleAnnotation (tk.zielony.carbonsamples.SampleAnnotation)2 ThemedActivity (tk.zielony.carbonsamples.ThemedActivity)2 RandomData (tk.zielony.randomdata.RandomData)2 StringNameGenerator (tk.zielony.randomdata.person.StringNameGenerator)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 Activity (android.app.Activity)1 Context (android.content.Context)1