Search in sources :

Example 46 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project todo-mvp-rxjava by albertizzy.

the class TaskDetailFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.taskdetail_frag, container, false);
    setHasOptionsMenu(true);
    mDetailTitle = root.findViewById(R.id.task_detail_title);
    mDetailDescription = root.findViewById(R.id.task_detail_description);
    mDetailCompleteStatus = root.findViewById(R.id.task_detail_complete);
    // Set up floating action button
    FloatingActionButton fab = getActivity().findViewById(R.id.fab_edit_task);
    fab.setOnClickListener(__ -> mPresenter.editTask());
    return root;
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton) TextView(android.widget.TextView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 47 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project todo-mvp-rxjava by albertizzy.

the class TasksFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.tasks_frag, container, false);
    // Set up tasks view
    ListView listView = root.findViewById(R.id.tasks_list);
    listView.setAdapter(mListAdapter);
    mFilteringLabelView = root.findViewById(R.id.filteringLabel);
    mTasksView = root.findViewById(R.id.tasksLL);
    // Set up  no tasks view
    mNoTasksView = root.findViewById(R.id.noTasks);
    mNoTaskIcon = root.findViewById(R.id.noTasksIcon);
    mNoTaskMainView = root.findViewById(R.id.noTasksMain);
    mNoTaskAddView = root.findViewById(R.id.noTasksAdd);
    mNoTaskAddView.setOnClickListener(__ -> showAddTask());
    // TODO lambda
    // mNoTaskAddView.setOnClickListener(new View.OnClickListener() {
    // @Override
    // public void onClick(View __) {
    // showAddTask();
    // }
    // });
    // Set up floating action button
    FloatingActionButton fab = getActivity().findViewById(R.id.fab_add_task);
    fab.setImageResource(R.drawable.ic_add);
    fab.setOnClickListener(__ -> mPresenter.addNewTask());
    // TODO lambda
    // fab.setOnClickListener(new View.OnClickListener() {
    // @Override
    // public void onClick(View __) {
    // mPresenter.addNewTask();
    // }
    // });
    // Set up progress indicator
    final ScrollChildSwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.refresh_layout);
    swipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(getActivity(), R.color.colorPrimary), ContextCompat.getColor(getActivity(), R.color.colorAccent), ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark));
    // Set the scrolling view in the custom SwipeRefreshLayout.
    swipeRefreshLayout.setScrollUpChild(listView);
    swipeRefreshLayout.setOnRefreshListener(() -> mPresenter.loadTasks(false));
    // TODO lambda
    // swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    // @Override
    // public void onRefresh() {
    // mPresenter.loadTasks(false);
    // }
    // });
    setHasOptionsMenu(true);
    return root;
}
Also used : ListView(android.widget.ListView) FloatingActionButton(android.support.design.widget.FloatingActionButton) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) Nullable(android.support.annotation.Nullable)

Example 48 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project Shuttle by timusus.

the class TintHelper method setTintAuto.

@SuppressWarnings("deprecation")
@SuppressLint("PrivateResource")
static void setTintAuto(@NonNull final View view, @ColorInt final int color, boolean background, final boolean isDark) {
    if (!background) {
        if (view instanceof RadioButton) {
            setTint((RadioButton) view, color, isDark);
        } else if (view instanceof SeekBar) {
            setTint((SeekBar) view, color, isDark);
        } else if (view instanceof ProgressBar) {
            setTint((ProgressBar) view, color);
        } else if (view instanceof EditText) {
            setTint((EditText) view, color, isDark);
        } else if (view instanceof CheckBox) {
            setTint((CheckBox) view, color, isDark);
        } else if (view instanceof ImageView) {
            setTint((ImageView) view, color);
        } else if (view instanceof Switch) {
            setTint((Switch) view, color, isDark);
        } else if (view instanceof SwitchCompat) {
            setTint((SwitchCompat) view, color, isDark);
        } else {
            background = true;
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !background && view.getBackground() instanceof RippleDrawable) {
            // Ripples for the above views (e.g. when you tap and hold a switch or checkbox)
            RippleDrawable rd = (RippleDrawable) view.getBackground();
            final int unchecked = ContextCompat.getColor(view.getContext(), isDark ? R.color.ripple_material_dark : R.color.ripple_material_light);
            final int checked = Util.adjustAlpha(color, 0.4f);
            final ColorStateList sl = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_activated, -android.R.attr.state_checked }, new int[] { android.R.attr.state_activated }, new int[] { android.R.attr.state_checked } }, new int[] { unchecked, checked, checked });
            rd.setColor(sl);
        }
    }
    if (background) {
        // Need to tint the background of a view
        if (view instanceof FloatingActionButton || view instanceof Button) {
            setTintSelector(view, color, false, isDark);
        } else if (view.getBackground() != null) {
            Drawable drawable = view.getBackground();
            if (drawable != null) {
                if (view instanceof TextInputEditText) {
                    drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
                } else {
                    drawable = createTintedDrawable(drawable, color);
                    Util.setBackgroundCompat(view, drawable);
                }
            }
        }
    }
}
Also used : TextInputEditText(android.support.design.widget.TextInputEditText) EditText(android.widget.EditText) SeekBar(android.widget.SeekBar) Drawable(android.graphics.drawable.Drawable) RippleDrawable(android.graphics.drawable.RippleDrawable) ColorStateList(android.content.res.ColorStateList) RadioButton(android.widget.RadioButton) SuppressLint(android.annotation.SuppressLint) RippleDrawable(android.graphics.drawable.RippleDrawable) Switch(android.widget.Switch) RadioButton(android.widget.RadioButton) Button(android.widget.Button) FloatingActionButton(android.support.design.widget.FloatingActionButton) CheckBox(android.widget.CheckBox) FloatingActionButton(android.support.design.widget.FloatingActionButton) TextInputEditText(android.support.design.widget.TextInputEditText) ImageView(android.widget.ImageView) ProgressBar(android.widget.ProgressBar) SwitchCompat(android.support.v7.widget.SwitchCompat) SuppressLint(android.annotation.SuppressLint)

Example 49 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project Shuttle by timusus.

the class TintHelper method setTintSelector.

@SuppressWarnings("deprecation")
private static void setTintSelector(@NonNull View view, @ColorInt final int color, final boolean darker, final boolean useDarkTheme) {
    final boolean isColorLight = Util.isColorLight(color);
    final int disabled = ContextCompat.getColor(view.getContext(), useDarkTheme ? R.color.ate_button_disabled_dark : R.color.ate_button_disabled_light);
    final int pressed = Util.shiftColor(color, darker ? 0.9f : 1.1f);
    final int activated = Util.shiftColor(color, darker ? 1.1f : 0.9f);
    final int rippleColor = getDefaultRippleColor(view.getContext(), isColorLight);
    final int textColor = ContextCompat.getColor(view.getContext(), isColorLight ? R.color.ate_primary_text_light : R.color.ate_primary_text_dark);
    final ColorStateList sl;
    if (view instanceof Button) {
        sl = getDisabledColorStateList(color, disabled);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view.getBackground() instanceof RippleDrawable) {
            RippleDrawable rd = (RippleDrawable) view.getBackground();
            rd.setColor(ColorStateList.valueOf(rippleColor));
        }
        // Disabled text color state for buttons, may get overridden later by ATE tags
        final Button button = (Button) view;
        button.setTextColor(getDisabledColorStateList(textColor, ContextCompat.getColor(view.getContext(), useDarkTheme ? R.color.ate_button_text_disabled_dark : R.color.ate_button_text_disabled_light)));
    } else if (view instanceof FloatingActionButton) {
        // FloatingActionButton doesn't support disabled state?
        sl = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_pressed }, new int[] { android.R.attr.state_pressed } }, new int[] { color, pressed });
        final FloatingActionButton fab = (FloatingActionButton) view;
        fab.setRippleColor(rippleColor);
        fab.setBackgroundTintList(sl);
        if (fab.getDrawable() != null)
            fab.setImageDrawable(createTintedDrawable(fab.getDrawable(), textColor));
        return;
    } else {
        sl = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_enabled }, new int[] { android.R.attr.state_enabled }, new int[] { android.R.attr.state_enabled, android.R.attr.state_pressed }, new int[] { android.R.attr.state_enabled, android.R.attr.state_activated }, new int[] { android.R.attr.state_enabled, android.R.attr.state_checked } }, new int[] { disabled, color, pressed, activated, activated });
    }
    Drawable drawable = view.getBackground();
    if (drawable != null) {
        drawable = createTintedDrawable(drawable, sl);
        Util.setBackgroundCompat(view, drawable);
    }
    if (view instanceof TextView && !(view instanceof Button)) {
        final TextView tv = (TextView) view;
        tv.setTextColor(getDisabledColorStateList(textColor, ContextCompat.getColor(view.getContext(), isColorLight ? R.color.ate_text_disabled_light : R.color.ate_text_disabled_dark)));
    }
}
Also used : RadioButton(android.widget.RadioButton) Button(android.widget.Button) FloatingActionButton(android.support.design.widget.FloatingActionButton) Drawable(android.graphics.drawable.Drawable) RippleDrawable(android.graphics.drawable.RippleDrawable) ColorStateList(android.content.res.ColorStateList) FloatingActionButton(android.support.design.widget.FloatingActionButton) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 50 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project react-native-navigation by wix.

the class FloatingActionButtonCoordinator method removeAllViews.

private void removeAllViews() {
    parent.removeView(collapsedFab);
    parent.removeView(expendedFab);
    collapsedFab = null;
    expendedFab = null;
    for (FloatingActionButton action : actions) {
        ((CoordinatorLayout.LayoutParams) action.getLayoutParams()).setBehavior(null);
        parent.removeView(action);
    }
    actions.clear();
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton)

Aggregations

FloatingActionButton (android.support.design.widget.FloatingActionButton)84 View (android.view.View)58 Toolbar (android.support.v7.widget.Toolbar)28 TextView (android.widget.TextView)20 ImageView (android.widget.ImageView)16 Intent (android.content.Intent)13 RecyclerView (android.support.v7.widget.RecyclerView)12 ColorStateList (android.content.res.ColorStateList)9 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 Bundle (android.os.Bundle)7 NavigationView (android.support.design.widget.NavigationView)7 TabLayout (android.support.design.widget.TabLayout)7 ViewPager (android.support.v4.view.ViewPager)7 ActionBar (android.support.v7.app.ActionBar)7 UiController (android.support.test.espresso.UiController)6 ViewAction (android.support.test.espresso.ViewAction)6 AdapterView (android.widget.AdapterView)6 ListView (android.widget.ListView)5 DrawerLayout (android.support.v4.widget.DrawerLayout)4 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)4