Search in sources :

Example 1 with DebugOverlay

use of carbon.internal.DebugOverlay 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)

Aggregations

Activity (android.app.Activity)1 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 Carbon (carbon.Carbon)1 DebugOverlay (carbon.internal.DebugOverlay)1 CheckBox (carbon.widget.CheckBox)1 ImageView (carbon.widget.ImageView)1 Toolbar (carbon.widget.Toolbar)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1