Search in sources :

Example 1 with BugReportLens

use of com.jakewharton.u2020.ui.bugreport.BugReportLens in project sbt-android by scala-android.

the class DebugAppContainer method bind.

@Override
public ViewGroup bind(final Activity activity) {
    activity.setContentView(R.layout.debug_activity_frame);
    final ViewHolder viewHolder = new ViewHolder();
    ButterKnife.bind(viewHolder, activity);
    final Context drawerContext = new ContextThemeWrapper(activity, R.style.Theme_U2020_Debug);
    final DebugView debugView = new DebugView(drawerContext);
    viewHolder.debugDrawer.addView(debugView);
    // Set up the contextual actions to watch views coming in and out of the content area.
    ContextualDebugActions contextualActions = debugView.getContextualDebugActions();
    contextualActions.setActionClickListener(v -> viewHolder.drawerLayout.closeDrawers());
    viewHolder.content.setOnHierarchyChangeListener(HierarchyTreeChangeListener.wrap(contextualActions));
    viewHolder.drawerLayout.setDrawerShadow(R.drawable.debug_drawer_shadow, GravityCompat.END);
    viewHolder.drawerLayout.setDrawerListener(new DebugDrawerLayout.SimpleDrawerListener() {

        @Override
        public void onDrawerOpened(View drawerView) {
            debugView.onDrawerOpened();
        }
    });
    // Clean up any old screenshots.
    TelescopeLayout.cleanUp(activity);
    viewHolder.telescopeLayout.setLens(new BugReportLens(activity, lumberYard));
    // If you have not seen the debug drawer before, show it with a message
    if (!seenDebugDrawer.get()) {
        viewHolder.drawerLayout.postDelayed(() -> {
            viewHolder.drawerLayout.openDrawer(GravityCompat.END);
            Toast.makeText(drawerContext, R.string.debug_drawer_welcome, Toast.LENGTH_LONG).show();
        }, 1000);
        seenDebugDrawer.set(true);
    }
    final CompositeSubscription subscriptions = new CompositeSubscription();
    setupMadge(viewHolder, subscriptions);
    setupScalpel(viewHolder, subscriptions);
    final Application app = activity.getApplication();
    app.registerActivityLifecycleCallbacks(new EmptyActivityLifecycleCallbacks() {

        @Override
        public void onActivityDestroyed(Activity lifecycleActivity) {
            if (lifecycleActivity == activity) {
                subscriptions.unsubscribe();
                app.unregisterActivityLifecycleCallbacks(this);
            }
        }
    });
    riseAndShine(activity);
    return viewHolder.content;
}
Also used : Context(android.content.Context) EmptyActivityLifecycleCallbacks(com.jakewharton.u2020.util.EmptyActivityLifecycleCallbacks) Activity(android.app.Activity) View(android.view.View) BugReportLens(com.jakewharton.u2020.ui.bugreport.BugReportLens) ContextThemeWrapper(android.view.ContextThemeWrapper) CompositeSubscription(rx.subscriptions.CompositeSubscription) Application(android.app.Application)

Example 2 with BugReportLens

use of com.jakewharton.u2020.ui.bugreport.BugReportLens in project sbt-android by scala-android.

the class TelescopeAppContainer method bind.

@Override
public ViewGroup bind(final Activity activity) {
    activity.setContentView(R.layout.internal_activity_frame);
    ButterKnife.bind(this, activity);
    // Clean up any old screenshots.
    TelescopeLayout.cleanUp(activity);
    telescopeLayout.setLens(new BugReportLens(activity, lumberYard));
    // If you have not seen the telescope dialog before, show it.
    if (!seenTelescopeDialog.get()) {
        telescopeLayout.postDelayed(new Runnable() {

            @Override
            public void run() {
                if (activity.isFinishing()) {
                    return;
                }
                seenTelescopeDialog.set(true);
                showTelescopeDialog(activity);
            }
        }, 1000);
    }
    return telescopeLayout;
}
Also used : BugReportLens(com.jakewharton.u2020.ui.bugreport.BugReportLens)

Example 3 with BugReportLens

use of com.jakewharton.u2020.ui.bugreport.BugReportLens in project u2020 by JakeWharton.

the class DebugViewContainer method forActivity.

@Override
public ViewGroup forActivity(final Activity activity) {
    activity.setContentView(R.layout.debug_activity_frame);
    final ViewHolder viewHolder = new ViewHolder();
    ButterKnife.bind(viewHolder, activity);
    final Context drawerContext = new ContextThemeWrapper(activity, R.style.Theme_U2020_Debug);
    final DebugView debugView = new DebugView(drawerContext);
    viewHolder.debugDrawer.addView(debugView);
    // Set up the contextual actions to watch views coming in and out of the content area.
    ContextualDebugActions contextualActions = debugView.getContextualDebugActions();
    contextualActions.setActionClickListener(v -> viewHolder.drawerLayout.closeDrawers());
    viewHolder.content.setOnHierarchyChangeListener(HierarchyTreeChangeListener.wrap(contextualActions));
    viewHolder.drawerLayout.setDrawerShadow(R.drawable.debug_drawer_shadow, GravityCompat.END);
    viewHolder.drawerLayout.setDrawerListener(new DebugDrawerLayout.SimpleDrawerListener() {

        @Override
        public void onDrawerOpened(View drawerView) {
            debugView.onDrawerOpened();
        }
    });
    // Clean up any old screenshots.
    TelescopeLayout.cleanUp(activity);
    viewHolder.telescopeLayout.setLens(new BugReportLens(activity, lumberYard));
    // If you have not seen the debug drawer before, show it with a message
    if (!seenDebugDrawer.get()) {
        viewHolder.drawerLayout.postDelayed(() -> {
            viewHolder.drawerLayout.openDrawer(GravityCompat.END);
            Toast.makeText(drawerContext, R.string.debug_drawer_welcome, Toast.LENGTH_LONG).show();
        }, 1000);
        seenDebugDrawer.set(true);
    }
    final CompositeSubscription subscriptions = new CompositeSubscription();
    setupMadge(viewHolder, subscriptions);
    setupScalpel(viewHolder, subscriptions);
    final Application app = activity.getApplication();
    app.registerActivityLifecycleCallbacks(new EmptyActivityLifecycleCallbacks() {

        @Override
        public void onActivityDestroyed(Activity lifecycleActivity) {
            if (lifecycleActivity == activity) {
                subscriptions.unsubscribe();
                app.unregisterActivityLifecycleCallbacks(this);
            }
        }
    });
    riseAndShine(activity);
    return viewHolder.content;
}
Also used : Context(android.content.Context) EmptyActivityLifecycleCallbacks(com.jakewharton.u2020.util.EmptyActivityLifecycleCallbacks) Activity(android.app.Activity) BindView(butterknife.BindView) View(android.view.View) BugReportLens(com.jakewharton.u2020.ui.bugreport.BugReportLens) ContextThemeWrapper(android.view.ContextThemeWrapper) CompositeSubscription(rx.subscriptions.CompositeSubscription) Application(android.app.Application)

Example 4 with BugReportLens

use of com.jakewharton.u2020.ui.bugreport.BugReportLens in project u2020 by JakeWharton.

the class TelescopeViewContainer method forActivity.

@Override
public ViewGroup forActivity(final Activity activity) {
    activity.setContentView(R.layout.internal_activity_frame);
    ButterKnife.bind(this, activity);
    // Clean up any old screenshots.
    TelescopeLayout.cleanUp(activity);
    telescopeLayout.setLens(new BugReportLens(activity, lumberYard));
    // If you have not seen the telescope dialog before, show it.
    if (!seenTelescopeDialog.get()) {
        telescopeLayout.postDelayed(new Runnable() {

            @Override
            public void run() {
                if (activity.isFinishing()) {
                    return;
                }
                seenTelescopeDialog.set(true);
                showTelescopeDialog(activity);
            }
        }, 1000);
    }
    return telescopeLayout;
}
Also used : BugReportLens(com.jakewharton.u2020.ui.bugreport.BugReportLens)

Aggregations

BugReportLens (com.jakewharton.u2020.ui.bugreport.BugReportLens)4 Activity (android.app.Activity)2 Application (android.app.Application)2 Context (android.content.Context)2 ContextThemeWrapper (android.view.ContextThemeWrapper)2 View (android.view.View)2 EmptyActivityLifecycleCallbacks (com.jakewharton.u2020.util.EmptyActivityLifecycleCallbacks)2 CompositeSubscription (rx.subscriptions.CompositeSubscription)2 BindView (butterknife.BindView)1