Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Commit 26b7c70

Browse files
committed
Update to 1.3
1 parent 3bfdf15 commit 26b7c70

File tree

23 files changed

+258
-63
lines changed

23 files changed

+258
-63
lines changed

README.md

+6-30
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,27 @@ Here is few option to integrate Ultra Debugger in your application.
2626

2727
__1.__ Add in build.gradle:
2828
```groovy
29-
compile 'ru.bartwell:ultradebugger:1.2'
29+
compile 'ru.bartwell:ultradebugger:1.3'
3030
```
3131

3232
__2.__ Add in Application class in onCreate() method:
3333
```groovy
34-
UltraDebugger.start(this);
35-
```
36-
37-
If you need specify custom port, add it as second argument:
38-
39-
```java
40-
UltraDebugger.start(this, 8081);
34+
UltraDebugger.start(this, 8090);
4135
```
4236

4337
##### Add only for debug configurations
4438

4539
__1.__ Add in build.gradle:
4640
```groovy
47-
debugCompile 'ru.bartwell:ultradebugger:1.2'
41+
debugCompile 'ru.bartwell:ultradebugger:1.3'
42+
compile 'ru.bartwell:ultradebugger.wrapper:1.3'
4843
```
4944

5045
__2.__ Add in Application class in onCreate() method:
5146

5247
```java
53-
if (BuildConfig.DEBUG) {
54-
try {
55-
Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
56-
Method method = clazz.getMethod("start", Context.class);
57-
method.invoke(null, this);
58-
} catch (Exception ignored) {
59-
}
60-
}
61-
```
62-
63-
If you need specify custom port, add it as second argument:
64-
65-
```java
66-
if (BuildConfig.DEBUG) {
67-
try {
68-
Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
69-
Method method = clazz.getMethod("start", Context.class, int.class);
70-
method.invoke(null, this, 8081);
71-
} catch (Exception ignored) {
72-
}
73-
}
48+
UltraDebuggerWrapper.setEnabled(BuildConfig.DEBUG);
49+
UltraDebuggerWrapper.start(this, 8090);
7450
```
7551

7652
_Default port number is 8080._

app/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ android {
1616
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1717
}
1818
}
19+
productFlavors {
20+
dev {}
21+
master {}
22+
}
1923
}
2024

2125
dependencies {

app/src/main/AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
android:label="@string/app_name"
1010
android:supportsRtl="true"
1111
android:theme="@style/AppTheme"
12-
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
12+
tools:ignore="AllowBackup,GoogleAppIndexingWarning"
13+
tools:overrideLibrary="android.support.v7.appcompat">
1314
<activity android:name=".MainActivity">
1415
<intent-filter>
1516
<action android:name="android.intent.action.MAIN"/>

app/src/main/java/ru/bartwell/ultradebugger/sampleapp/DebuggerApplication.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import android.app.Application;
44

5-
import ru.bartwell.ultradebugger.UltraDebugger;
5+
import ru.bartwell.ultradebugger.wrapper.UltraDebuggerWrapper;
66

77
/**
88
* Created by BArtWell on 01.01.2017.
@@ -12,6 +12,7 @@ public class DebuggerApplication extends Application {
1212
@Override
1313
public void onCreate() {
1414
super.onCreate();
15-
UltraDebugger.start(this, 8081);
15+
UltraDebuggerWrapper.setEnabled(BuildConfig.FLAVOR.equals("dev"));
16+
UltraDebuggerWrapper.start(this, 8081);
1617
}
1718
}

app/src/main/java/ru/bartwell/ultradebugger/sampleapp/MainActivity.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
import java.util.Random;
1313

14-
import ru.bartwell.ultradebugger.UltraDebugger;
15-
import ru.bartwell.ultradebugger.module.logger.Logger;
14+
import ru.bartwell.ultradebugger.wrapper.UltraDebuggerWrapper;
1615

1716
public class MainActivity extends AppCompatActivity {
1817

@@ -24,12 +23,12 @@ protected void onCreate(Bundle savedInstanceState) {
2423
setContentView(R.layout.activity_main);
2524

2625
// Fill information about IP and port
27-
String ip = UltraDebugger.getIp();
26+
String ip = UltraDebuggerWrapper.getIp();
2827
String address;
2928
if (TextUtils.isEmpty(ip)) {
30-
address = getString(R.string.unknown_ip_format, UltraDebugger.getPort());
29+
address = getString(R.string.unknown_ip);
3130
} else {
32-
address = getString(R.string.ip_format, ip, UltraDebugger.getPort());
31+
address = getString(R.string.ip_format, ip, UltraDebuggerWrapper.getPort());
3332
}
3433
((TextView) findViewById(R.id.url)).setText(address);
3534

@@ -53,13 +52,13 @@ public void showToast(String text) {
5352
@Override
5453
protected void onResume() {
5554
super.onResume();
56-
Logger.saveValue(this, "RandomValue", new Random().nextInt(100));
57-
Logger.addLog(this, "onResume");
55+
UltraDebuggerWrapper.saveValue(this, "RandomValue", new Random().nextInt(100));
56+
UltraDebuggerWrapper.addLog(this, "onResume");
5857
}
5958

6059
@Override
6160
protected void onPause() {
62-
Logger.addLog(this, "onPause");
61+
UltraDebuggerWrapper.addLog(this, "onPause");
6362
super.onPause();
6463
}
6564
}

app/src/main/res/layout/activity_main.xml

-10
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,4 @@
2222
android:layout_gravity="center_horizontal"
2323
android:layout_marginTop="15dp"
2424
tools:text="http://xxx.xxx.xxx.xxx:8080"/>
25-
26-
<TextView
27-
style="@style/TextAppearance.AppCompat.Small"
28-
android:layout_width="wrap_content"
29-
android:layout_height="wrap_content"
30-
android:layout_gravity="end"
31-
android:layout_marginEnd="15dp"
32-
android:layout_marginRight="15dp"
33-
android:layout_marginTop="15dp"
34-
android:text="@string/ip_note"/>
3525
</LinearLayout>

app/src/main/res/values/strings.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<resources>
22
<string name="app_name">Ultra Debugger Sample App</string>
33
<string name="type_address_description">Please connect your smartphone and computer to same network, open browser on computer and type address:</string>
4-
<string name="ip_note">Change xxx.xxx.xxx.xxx to IP of your smartphone</string>
5-
<string name="unknown_ip_format">http://xxx.xxx.xxx.xxx:%d</string>
4+
<string name="unknown_ip">Unknown IP address</string>
65
<string name="ip_format">http://%1$s:%2$d</string>
76
</resources>

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.0'
8+
classpath 'com.android.tools.build:gradle:2.3.3'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ org.gradle.jvmargs=-Xmx1536m
1616
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1717
# org.gradle.parallel=true
1818

19-
VERSION_NAME=1.2
20-
VERSION_CODE=3
19+
VERSION_NAME=1.3
20+
VERSION_CODE=4
2121
GROUP=ru.bartwell
2222

2323
POM_DESCRIPTION=Ultra Debugger is an open source modules-based android library for application debugging.

logger/src/main/java/ru/bartwell/ultradebugger/module/logger/Logger.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,27 @@
44
import android.support.annotation.NonNull;
55
import android.support.annotation.Nullable;
66

7+
import java.io.PrintWriter;
8+
import java.io.StringWriter;
9+
710
/**
811
* Created by BArtWell on 24.02.2017.
912
*/
1013

1114
public class Logger {
1215
public static void addLog(@NonNull Context context, @NonNull String text) {
13-
StorageHelper.addLog(context, text);
16+
addLog(context, text, null);
17+
}
18+
19+
public static void addLog(@NonNull Context context, @NonNull String text, @Nullable Throwable throwable) {
20+
if (throwable == null) {
21+
StorageHelper.addLog(context, text);
22+
} else {
23+
StringWriter stringWriter = new StringWriter();
24+
PrintWriter printWriter = new PrintWriter(stringWriter);
25+
throwable.printStackTrace(printWriter);
26+
addLog(context, text + "\n" + stringWriter.toString() + "\n");
27+
}
1428
}
1529

1630
public static void saveValue(@NonNull Context context, @NonNull String key, @Nullable Object value) {

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':app', ':ultradebugger', ':sqlite', ':sharedpreferences', ':base', ':reflection', ':info', ':files', ':logger'
1+
include ':app', ':ultradebugger', ':sqlite', ':sharedpreferences', ':base', ':reflection', ':info', ':files', ':logger', ':wrapper'

shared.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ android {
55
defaultConfig {
66
minSdkVersion 9
77
targetSdkVersion 25
8-
versionCode 3
9-
versionName "1.2"
8+
versionCode 4
9+
versionName "1.3"
1010

1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212

ultradebugger/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ android {
1818
dependencies {
1919
compile fileTree(include: ['*.jar'], dir: 'libs')
2020
compile 'org.nanohttpd:nanohttpd:2.3.1'
21+
compile project(':wrapper')
2122
compile project(':base')
2223
compile project(':sqlite')
2324
compile project(':sharedpreferences')

ultradebugger/src/main/java/ru/bartwell/ultradebugger/UltraDebugger.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ru.bartwell.ultradebugger;
22

33
import android.content.Context;
4+
import android.support.annotation.NonNull;
45
import android.text.TextUtils;
56
import android.util.Log;
67

@@ -17,19 +18,19 @@ public class UltraDebugger {
1718
private static String sIp;
1819
private static int sPort;
1920

20-
public static void start(Context context) {
21+
public static void start(@NonNull Context context) {
2122
start(context, HttpServer.DEFAULT_PORT);
2223
}
2324

24-
public static void start(Context context, int port) {
25+
public static void start(@NonNull Context context, int port) {
2526
sIp = IpUtils.getIpV4();
2627
sPort = port;
2728
addLogInfo(port);
2829
ModulesManager.newInstance(context);
2930
ServerService.start(context, port);
3031
}
3132

32-
public static void stop(Context context) {
33+
public static void stop(@NonNull Context context) {
3334
ServerService.stop(context);
3435
}
3536

wrapper/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

wrapper/build.gradle

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apply plugin: 'com.android.library'
2+
3+
apply from: "../shared.gradle"
4+
5+
dependencies {
6+
compile fileTree(dir: 'libs', include: ['*.jar'])
7+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
8+
exclude group: 'com.android.support', module: 'support-annotations'
9+
})
10+
compile 'com.android.support:appcompat-v7:25.2.0'
11+
testCompile 'junit:junit:4.12'
12+
}
13+
14+
apply from: '../maven_push.gradle'

wrapper/gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
POM_NAME=Ultra Debugger Wrapper
2+
POM_ARTIFACT_ID=ultradebugger.wrapper
3+
POM_PACKAGING=aar

wrapper/proguard-rules.pro

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in C:\Users\BArtWell\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
18+
19+
# Uncomment this to preserve the line number information for
20+
# debugging stack traces.
21+
#-keepattributes SourceFile,LineNumberTable
22+
23+
# If you keep the line number information, uncomment this to
24+
# hide the original source file name.
25+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package ru.bartwell.ultradebugger.wrapper;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("ru.bartwell.ultradebugger.wrapper.test", appContext.getPackageName());
25+
}
26+
}

wrapper/src/main/AndroidManifest.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
3+
package="ru.bartwell.ultradebugger.wrapper"
4+
>
5+
6+
<application android:allowBackup="true"
7+
android:label="@string/app_name"
8+
android:supportsRtl="true"
9+
>
10+
11+
</application>
12+
13+
</manifest>

0 commit comments

Comments
 (0)