Skip to content

Commit

Permalink
move mainApplication to MainActivity to prevent popup window
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Jan 7, 2020
1 parent ea26d02 commit 7095eb5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'org.nanohttpd:nanohttpd:2.3.1'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'

// test
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
android:label="@string/app_name"
android:persistent="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
android:name=".MainApplication">
android:usesCleartextTraffic="true">
<activity
android:name=".IdentifyActivity"
android:excludeFromRecents="true"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/github/uiautomator/FloatView.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void show() {
windowManager.getDefaultDisplay().getSize(size);
int screenWidth = size.x;
int screenHeight = size.y;
int minWidthHeight = size.x > size.y ? size.y : size.x;

WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.packageName = context.getPackageName();
Expand All @@ -99,8 +100,8 @@ public void show() {
params.type = mType;
params.format = PixelFormat.RGBA_8888;
params.gravity = Gravity.LEFT | Gravity.TOP;
params.width = screenWidth / 10;
params.height = screenWidth / 10;
params.width = minWidthHeight / 10;
params.height = minWidthHeight / 10;
params.x = screenWidth - sideGap() - params.width;
params.y = screenHeight / 3 * 2;
params.alpha = 0.5f;
Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/com/github/uiautomator/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.github.uiautomator.util.MemoryManager;
import com.github.uiautomator.util.OkhttpManager;
import com.github.uiautomator.util.Permissons4App;
import com.tendcloud.tenddata.TCAgent;

import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -80,12 +81,24 @@ public void handleMessage(Message msg) {
}
};

private void initTCAgent() {
TCAgent.LOG_ON = true;
// App ID: 在TalkingData创建应用后,进入数据报表页中,在“系统设置”-“编辑应用”页面里查看App ID。
// 渠道 ID: 是渠道标识符,可通过不同渠道单独追踪数据。
TCAgent.init(this, BuildConfig.buildTendId, BuildConfig.buildChannel);
// 如果已经在AndroidManifest.xml配置了App ID和渠道ID,调用TCAgent.init(this)即可;或与AndroidManifest.xml中的对应参数保持一致。
TCAgent.setReportUncaughtExceptions(true);
Log.i(TAG, "TCAgent init done");
}

@RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

this.initTCAgent();

tvAgentStatus = findViewById(R.id.atx_agent_status);

Button btnFinish = findViewById(R.id.btn_finish);
Expand Down Expand Up @@ -172,7 +185,7 @@ public void stopUiautomator(View view) {
.url(ATX_AGENT_URL + "/uiautomator")
.delete()
.build();
okhttpManager.newCall(request,new Callback() {
okhttpManager.newCall(request, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
Expand Down Expand Up @@ -210,7 +223,7 @@ private void uiToaster(final String msg) {
handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, msg , Toast.LENGTH_SHORT).show();
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@

import com.tendcloud.tenddata.TCAgent;

public class MainApplication extends Application {
private static final String TAG = ">>>>>MainApplication";
@Override
public class TCAgentApplication extends Application {
private static final String TAG = "TCAgentApplication";

@Override
public void onCreate() {
super.onCreate();
// JLibrary.InitEntry(this); //移动安全联盟统一SDK初始化
// JLibrary.InitEntry(this); //移动安全联盟统一SDK初始化
TCAgent.LOG_ON = true;
// App ID: 在TalkingData创建应用后,进入数据报表页中,在“系统设置”-“编辑应用”页面里查看App ID。
// 渠道 ID: 是渠道标识符,可通过不同渠道单独追踪数据。
TCAgent.init(this, BuildConfig.buildTendId, BuildConfig.buildChannel);
// 如果已经在AndroidManifest.xml配置了App ID和渠道ID,调用TCAgent.init(this)即可;或与AndroidManifest.xml中的对应参数保持一致。
TCAgent.setReportUncaughtExceptions(true);
Log.e(TAG, "TCAgent init over>>>>>");
Log.i(TAG, "TCAgent init done");
}
}

0 comments on commit 7095eb5

Please sign in to comment.