public class CpuUsageModule extends OverlayModule<CpuUsage> {

    public static final int DEFAULT_INTERVAL = 1000; // 1000ms

    public CpuUsageModule() {
        super(null, null);
    }

    public CpuUsageModule(int interval) {
        super(null, null);
    }

    public CpuUsageModule(int interval, int layoutResId) {
        super(null, null);
    }

    public CpuUsageModule(ViewModule<CpuUsage> viewModule) {
        super(null, null);
    }

    public CpuUsageModule(int interval, ViewModule<CpuUsage> viewModule) {
        super(null, null);
    }
} public class FpsModule extends OverlayModule<Double> {

    public static final int DEFAULT_INTERVAL = 1000; // 1000ms

    public FpsModule() {
        super(null, null);
    }

    public FpsModule(int interval) {
        super(null, null);
    }

    public FpsModule(int interval, int layoutResId) {
        super(null, null);
    }

    public FpsModule(ViewModule<Double> viewModule) {
        super(null, null);
    }

    public FpsModule(int interval, ViewModule<Double> viewModule) {
        super(null, null);
    }
} public class LogcatLine {

    public enum Priority {

        VERBOSE(),
        DEBUG(),
        INFO(),
        WARNING(),
        ERROR(),
        FATAL(),
        ASSERT(),
        SILENT();

        public String getValue() {
            return null;
        }

        public int getIntValue() {
            return 0;
        }

        public static Priority getPriorityFromValue(String value) {
            return VERBOSE;
        }
    }

    public LogcatLine(String rawLine) {

    }

    public String getRawLine() {
        return null;
    }

    public String getDate() {
        return null;
    }

    public String getTime() {
        return null;
    }

    public Priority getPriority() {
        return null;
    }

    public String getTag() {
        return null;
    }

    public int getPid() {
        return 0;
    }

    public int getTid() {
        return 0;
    }

    public String getMessage() {
        return null;
    }
} public interface LogcatLineColorScheme {

    int getTextColor(LogcatLine.Priority priority, String tag);

    LogcatLineColorScheme DEFAULT_COLOR_SCHEME = null;
} public interface LogcatLineFilter {

    boolean shouldFilterOut(LogcatLine.Priority priority, String tag);

    LogcatLineFilter DEFAULT_LINE_FILTER = null;

    class SimpleLogcatLineFilter implements LogcatLineFilter {

        public SimpleLogcatLineFilter(LogcatLine.Priority minPriority) {
        }

        @Override
        public boolean shouldFilterOut(LogcatLine.Priority priority, String tag) {
            return true;
        }
    }
} public class LogcatModule extends OverlayModule<LogcatLine> {

    public static final int DEFAULT_MAX_LINES = 15;

    public LogcatModule() {
        super(null, null);
    }

    public LogcatModule(int maxLines) {
        super(null, null);
    }

    public LogcatModule(int maxLines, LogcatLineFilter lineFilter) {
        super(null, null);
    }

    public LogcatModule(int maxLines, LogcatLineColorScheme colorScheme) {
        super(null, null);
    }

    public LogcatModule(int maxLines, LogcatLineFilter lineFilter, LogcatLineColorScheme colorScheme) {
        super(null, null);
    }

    public LogcatModule(ViewModule<LogcatLine> viewModule) {
        super(null, null);
    }
} public class MemInfoModule extends OverlayModule<MemInfo> {

    public static final int DEFAULT_INTERVAL = 1500; // 1500ms

    public MemInfoModule(@NonNull Context context) {
        super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
    }

    public MemInfoModule(@NonNull Context context, int interval) {
        super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
    }

    public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
        super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
    }

    public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) {
        super(new MemInfoDataModule(context, DEFAULT_INTERVAL), viewModule);
    }

    public MemInfoModule(@NonNull Context context, int interval, @NonNull ViewModule<MemInfo> viewModule) {
        super(new MemInfoDataModule(context, interval), viewModule);
    }
} public class IPAddressModule extends OverlayModule<String> {

    public IPAddressModule(@NonNull Context context) {
        super(new IPAddressDataModule(context), new SimpleViewModule(R.layout.view_overlay_ip));
    }
} public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Timber.d("fab clicked");
                startActivity(new Intent(MainActivity.this, ScrollingActivity.class));
            }
        });

        Timber.d("onCreate() called");
    }

    @Override
    public void onResume() {
        super.onResume();
        Timber.d("onResume() called");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
} public class ScrollingActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scrolling);

        ToolbarSupport.addTo(this);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }
}
import android.app.Activity;
import android.app.Application;
import android.app.Instrumentation;
import android.content.Intent;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.util.Log;
import com.google.android.libraries.cloudtesting.screenshots.ScreenShotter;
import com.ms_square.debugoverlay.modules.CpuUsageModule;
import com.ms_square.debugoverlay.modules.FpsModule;
import com.ms_square.debugoverlay.modules.LogcatLine;
import com.ms_square.debugoverlay.modules.LogcatLineColorScheme;
import com.ms_square.debugoverlay.modules.LogcatLineFilter;
import com.ms_square.debugoverlay.modules.LogcatModule;
import com.ms_square.debugoverlay.modules.MemInfoModule;
import com.ms_square.debugoverlay.sample.IPAddressModule;
import com.ms_square.debugoverlay.sample.MainActivity;
import com.ms_square.debugoverlay.sample.ScrollingActivity;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
            }
        });

        waitForOverlay();
    }

    @Test
    public void installLogcatModule() {
        DebugOverlay.enableDebugLogging(false);

        getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                debugOverlay = new DebugOverlay.Builder(getApplication())
                        .allowSystemLayer(testSystemLayer())
                        .modules(new CpuUsageModule(),
                                new MemInfoModule(getApplication()),
                                new FpsModule(),
                                new LogcatModule(10))
                        .position(Position.BOTTOM)
                        .build();
                debugOverlay.install();
            }
        });

        waitForOverlay();

        Log.v(TAG, "hello world V");
        Log.d(TAG, "hello world D");

        Log.i(TAG, "hello world I");
        Log.w(TAG, "hello world W");

        Log.e(TAG, "hello world E");
        Log.wtf(TAG, "hello world WTF");

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        DebugOverlay.enableDebugLogging(true);
    }

    @Test
    public void installLogcatModuleWCustomColor() {
        getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                debugOverlay = new DebugOverlay.Builder(getApplication())
                        .allowSystemLayer(testSystemLayer())
                        .modules(new LogcatModule(10, new LogcatLineColorScheme() {
                            @Override
                            public int getTextColor(LogcatLine.Priority priority, @NonNull String tag) {
                                return Color.CYAN;
                            }
                        }))
                        .build();
                debugOverlay.install();
            }
        });

        waitForOverlay();
    }

    @Test
    public void installLogcatModuleWCustomFilter() {
        getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                debugOverlay = new DebugOverlay.Builder(getApplication())
                        .allowSystemLayer(testSystemLayer())
                        .modules(new LogcatModule(10, new LogcatLineFilter.SimpleLogcatLineFilter(LogcatLine.Priority.INFO)))
                        .build();
                debugOverlay.install();
            }
        });

        waitForOverlay();
    }

    @Test
    public void installModulesCustomStyle() {
        getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                debugOverlay = new DebugOverlay.Builder(getApplication())
                        .allowSystemLayer(testSystemLayer())
                        .modules(new CpuUsageModule(),
                                new MemInfoModule(getApplication()),
                                new FpsModule())
                        .position(Position.TOP_START)
                        .bgColor(Color.parseColor("#60000000"))
                        .textColor(Color.MAGENTA)
                        .textSize(14f)
                        .textAlpha(.8f)
                        .build();
                debugOverlay.install();
            }
        });

        waitForOverlay();
    }


    @Test
    public void startSecondActivity() {
        getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                debugOverlay = new DebugOverlay.Builder(getApplication())
                        .allowSystemLayer(testSystemLayer())
                        .build();
                debugOverlay.install();
            }
        });

        waitForOverlay();

        Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor(ScrollingActivity.class.getCanonicalName(),