Skip to content

Commit

Permalink
feat: 修改圈选提示框文案和样式
Browse files Browse the repository at this point in the history
  • Loading branch information
LitterSun committed Dec 3, 2020
1 parent 1d2a0e3 commit 9015c2a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 17 deletions.
1 change: 0 additions & 1 deletion demos/demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ task jacocoTestReport(type: JacocoReport, group: 'Reporting', dependsOn: 'connec

dependencies {
androidTestUtil libraries.test.orchestrator
androidTestImplementation fileTree(dir: '../../thirdLibs', include: ['*.jar'])
androidTestImplementation libraries.test.androidx_junit
androidTestImplementation libraries.test.androidx_runner
androidTestImplementation libraries.test.espresso_core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.reflect.Whitebox;

import java.io.IOException;
import java.util.HashMap;
Expand Down Expand Up @@ -438,14 +439,15 @@ public void hybridUserIdChangeTest() {
}

@Test
public void hybridDomChangedTest() {
public void hybridDomChangedTest() throws Exception {
AtomicBoolean receivedEvent = new AtomicBoolean(false);
WebView webView = launchMockWebView();
SuperWebView<WebView> superWebView = Whitebox.invokeMethod(SuperWebView.class, "make", webView);
HybridBridgeProvider.get().registerDomChangedListener(new OnDomChangedListener() {
@Override
public void onDomChanged() {
TrackHelper.postToUiThread(() ->
HybridBridgeProvider.get().getWebViewDomTree(SuperWebView.make(webView), new Callback<JSONObject>() {
HybridBridgeProvider.get().getWebViewDomTree(superWebView, new Callback<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
receivedEvent.set(result != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public class CircleServiceTest extends WebServicesTest {
@BeforeAppOnCreate
public static void beforeAppOnCreate() {
DataHelper.deleteEventsDatabase();
DemoApplication.setConfiguration(new TestTrackConfiguration("growing.b6e4218d94f2bffc"));
DemoApplication.setConfiguration(new TestTrackConfiguration("growing.d80871b41ef40518"));
}

@Test
public void circleServiceTest() {
String uri = "growing.b6e4218d94f2bffc://growingio/webservice?serviceType=circle&wsUrl=" + Uri.encode(getWsUrl());
String uri = "growing.d80871b41ef40518://growingio/webservice?serviceType=circle&wsUrl=" + Uri.encode(getWsUrl());
Intent intent = new Intent();
intent.setData(Uri.parse(uri));
ActivityScenario.launch(intent);
Expand Down Expand Up @@ -132,8 +132,7 @@ public void circleServiceTest() {
});
TrackHelper.waitUiThreadForIdleSync();

onView(withText("圈选")).check(matches(isDisplayed()));
onView(withText("您是否要退出圈选?")).check(matches(isDisplayed()));
onView(withText("取消")).perform(click());
onView(withText("正在进行圈选")).check(matches(isDisplayed()));
onView(withText("继续圈选")).perform(click());
}
}
2 changes: 1 addition & 1 deletion demos/demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="growing.b6e4218d94f2bffc" />
<data android:scheme="growing.d80871b41ef40518" />

<action android:name="android.intent.action.VIEW" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void onViewInitFinished(boolean b) {
}

if (sConfiguration == null) {
sConfiguration = new AutotrackConfiguration("demoProjectId", "growing.b6e4218d94f2bffc")
sConfiguration = new AutotrackConfiguration("bfc5d6a3693a110d", "growing.d80871b41ef40518")
.setUploadExceptionEnabled(false)
.setDebugEnabled(true)
.setOaidEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
import com.growingio.android.sdk.autotrack.webservices.ScreenshotProvider;
import com.growingio.android.sdk.autotrack.webservices.circle.entity.CircleScreenshot;
import com.growingio.android.sdk.track.ContextProvider;
import com.growingio.android.sdk.track.SDKConfig;
import com.growingio.android.sdk.track.async.Callback;
import com.growingio.android.sdk.track.async.Disposable;
import com.growingio.android.sdk.track.log.Logger;
import com.growingio.android.sdk.track.providers.ActivityStateProvider;
import com.growingio.android.sdk.track.providers.AppInfoProvider;
import com.growingio.android.sdk.track.utils.SystemUtil;
import com.growingio.android.sdk.track.utils.ThreadUtils;
import com.growingio.android.sdk.track.webservices.BaseWebSocketService;
Expand All @@ -52,7 +54,7 @@ protected void onReady() {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
mTipView.setContent(R.string.growing_tracker_is_circling);
mTipView.setContent(R.string.growing_autotracker_is_circling);
mTipView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -69,16 +71,19 @@ private void showExitDialog() {
Logger.e(TAG, "showExitDialog: ForegroundActivity is NULL");
return;
}

String message = activity.getString(R.string.growing_autotracker_app_version) + AppInfoProvider.get().getAppVersion() + "\n"
+ activity.getString(R.string.growing_autotracker_sdk_version) + SDKConfig.SDK_VERSION;
new AlertDialog.Builder(activity)
.setTitle(R.string.growing_autotracker_circle)
.setMessage(R.string.growing_autotracker_exit_circle)
.setPositiveButton(R.string.growing_autotracker_ok, new DialogInterface.OnClickListener() {
.setTitle(R.string.growing_autotracker_is_circling)
.setMessage(message)
.setPositiveButton(R.string.growing_autotracker_exit_circle, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
exit();
}
})
.setNegativeButton(R.string.growing_autotracker_cancel, null)
.setNegativeButton(R.string.growing_autotracker_continue_circle, null)
.create()
.show();
}
Expand All @@ -92,11 +97,44 @@ private void exit() {
protected void onFailed() {
super.onFailed();
Logger.e(TAG, "Start CircleService Failed");
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
showQuitedDialog();
}
});
}

@Override
protected void onQuited() {
end();
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
showQuitedDialog();
}
});
}

private void showQuitedDialog() {
Activity activity = ActivityStateProvider.get().getForegroundActivity();
if (activity == null) {
Logger.e(TAG, "showQuitedDialog: ForegroundActivity is NULL");
return;
}
new AlertDialog.Builder(activity)
.setTitle(R.string.growing_tracker_device_unconnected)
.setMessage(R.string.growing_autotracker_circle_unconnected)
.setPositiveButton(R.string.growing_autotracker_exit_circle, null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
SystemUtil.killAppProcess(ContextProvider.getApplicationContext());
}
})
.setCancelable(false)
.create()
.show();
}

@Override
Expand Down
7 changes: 6 additions & 1 deletion growingio-autotracker-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>
<string name="growing_autotracker_is_circling">正在进行圈选</string>
<string name="growing_autotracker_circle">圈选</string>
<string name="growing_autotracker_exit_circle">您是否要退出圈选?</string>
<string name="growing_autotracker_ok">确定</string>
<string name="growing_autotracker_cancel">取消</string>
<string name="growing_autotracker_continue_circle">继续圈选</string>
<string name="growing_autotracker_exit_circle">退出圈选</string>
<string name="growing_autotracker_circle_unconnected">当前设备已与电脑端断开连接,如需继续圈选请扫码重新连接</string>
<string name="growing_autotracker_app_version">APP版本:</string>
<string name="growing_autotracker_sdk_version">SDK版本:</string>
</resources>
2 changes: 1 addition & 1 deletion growingio-tracker-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<resources>
<string name="growing_tracker_drag_tip">如有遮挡请拖动此条</string>
<string name="growing_tracker_connecting_to_web">正在和Web端建立连接....</string>
<string name="growing_tracker_is_circling">正在圈选</string>
<string name="growing_tracker_connected_to_web_failed">和Web端建立连接失败,请重新尝试</string>
<string name="growing_tracker_device_unconnected">设备以断开连接</string>
</resources>

0 comments on commit 9015c2a

Please sign in to comment.