Search in sources :

Example 1 with ImageView

use of carbon.widget.ImageView 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 ImageView

use of carbon.widget.ImageView 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 3 with ImageView

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

the class PowerMenuActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_powermenu);
    powerMenu = findViewById(R.id.powerMenu);
    final FrameLayout transitionLayout = (FrameLayout) findViewById(R.id.transition);
    findViewById(R.id.button).setOnClickListener(view -> {
        if (powerMenu.getVisibility() == View.VISIBLE)
            return;
        for (int i = 0; i < transitionLayout.getChildCount(); i++) transitionLayout.getChildAt(i).setVisibility(i == 0 ? View.VISIBLE : View.GONE);
        final List<View> viewsWithTag = ((LinearLayout) transitionLayout.getChildAt(0)).findViewsWithTag("animate");
        Stream.of(viewsWithTag).forEach(v -> v.setVisibility(View.INVISIBLE));
        powerMenu.setVisibility(View.VISIBLE);
        view.getHandler().postDelayed(() -> {
            Stream.of(viewsWithTag).forEach(v -> {
                v.getHandler().postDelayed(() -> {
                    v.setVisibility(View.VISIBLE);
                }, viewsWithTag.indexOf(v) * 40);
            });
        }, 200);
    });
    findViewById(R.id.powerOff).setOnClickListener(view -> {
        final List<View> viewsWithTag = ((FrameLayout) transitionLayout.getChildAt(1)).findViewsWithTag("animate");
        for (int i = 0; i < viewsWithTag.size(); i++) viewsWithTag.get(i).setVisibility(View.INVISIBLE);
        view.getHandler().postDelayed(() -> {
            for (int i = 0; i < viewsWithTag.size(); i++) {
                final int finalI = i;
                view.getHandler().postDelayed(() -> viewsWithTag.get(finalI).setVisibility(View.VISIBLE), i * 20);
            }
        }, 400);
        view.getHandler().postDelayed(() -> powerMenu.setVisibility(View.INVISIBLE), 3000);
    });
    findViewById(R.id.reboot).setOnClickListener(view -> {
        final List<View> viewsWithTag = ((FrameLayout) transitionLayout.getChildAt(2)).findViewsWithTag("animate");
        for (int i = 0; i < viewsWithTag.size(); i++) viewsWithTag.get(i).setVisibility(View.INVISIBLE);
        view.getHandler().postDelayed(() -> {
            for (int i = 0; i < viewsWithTag.size(); i++) {
                final int finalI = i;
                view.getHandler().postDelayed(() -> viewsWithTag.get(finalI).setVisibility(View.VISIBLE), i * 20);
            }
        }, 400);
        view.getHandler().postDelayed(() -> powerMenu.setVisibility(View.INVISIBLE), 3000);
    });
    findViewById(R.id.airplaneMode).setOnClickListener(view -> {
        final List<View> viewsWithTag = ((FrameLayout) transitionLayout.getChildAt(3)).findViewsWithTag("animate");
        for (int i = 0; i < viewsWithTag.size(); i++) viewsWithTag.get(i).setVisibility(View.INVISIBLE);
        view.getHandler().postDelayed(() -> {
            for (int i = 0; i < viewsWithTag.size(); i++) {
                final int finalI = i;
                view.getHandler().postDelayed(() -> viewsWithTag.get(finalI).setVisibility(View.VISIBLE), i * 20);
            }
        }, 400);
        view.getHandler().postDelayed(() -> {
            airplaneMode = !airplaneMode;
            TextView amStatus = (TextView) findViewById(R.id.airplaneModeStatus);
            amStatus.setText("Airplane Mode is " + (airplaneMode ? "on" : "off"));
            ImageView airplaneModeIcon = (ImageView) 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(0xffffffff);
            ((ImageView) view).setTint(getResources().getColor(R.color.carbon_black_54));
        } else {
            vibration = true;
            view.setBackgroundColor(0xff00695D);
            ((ImageView) view).setTint(0xffffffff);
            Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
            vibrator.vibrate(500);
        }
        powerMenu.postInvalidate();
    });
    findViewById(R.id.volume).setOnClickListener(view -> {
        if (volume) {
            volume = false;
            view.setBackgroundColor(0xffffffff);
            ((ImageView) view).setTint(getResources().getColor(R.color.carbon_black_54));
        } else {
            volume = true;
            view.setBackgroundColor(0xff00695D);
            ((ImageView) view).setTint(0xffffffff);
            view.playSoundEffect(SoundEffectConstants.CLICK);
        }
        powerMenu.postInvalidate();
    });
}
Also used : FrameLayout(carbon.widget.FrameLayout) TextView(carbon.widget.TextView) ImageView(carbon.widget.ImageView) Vibrator(android.os.Vibrator) View(android.view.View) ImageView(carbon.widget.ImageView) TextView(carbon.widget.TextView) LinearLayout(carbon.widget.LinearLayout)

Aggregations

ImageView (carbon.widget.ImageView)3 View (android.view.View)2 LinearLayout (carbon.widget.LinearLayout)2 TextView (carbon.widget.TextView)2 Toolbar (carbon.widget.Toolbar)2 Activity (android.app.Activity)1 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 Vibrator (android.os.Vibrator)1 ViewGroup (android.view.ViewGroup)1 Carbon (carbon.Carbon)1 DebugOverlay (carbon.internal.DebugOverlay)1 CheckBox (carbon.widget.CheckBox)1 FrameLayout (carbon.widget.FrameLayout)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1