|
|
@@ -9,7 +9,14 @@ import androidx.annotation.Nullable;
|
|
|
|
|
|
import com.atmob.app.lib.base.BaseActivity;
|
|
|
import com.atmob.voiceai.databinding.SettingActivityBinding;
|
|
|
+import com.atmob.voiceai.handlers.EventHandler;
|
|
|
+import com.atmob.voiceai.sdk.kochava.KochavaHelper;
|
|
|
+import com.atmob.voiceai.utils.ToastUtil;
|
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+import atmob.reactivex.rxjava3.core.Observable;
|
|
|
+import atmob.reactivex.rxjava3.disposables.Disposable;
|
|
|
import dagger.hilt.android.AndroidEntryPoint;
|
|
|
|
|
|
@AndroidEntryPoint
|
|
|
@@ -17,6 +24,11 @@ public class SettingActivity extends BaseActivity<SettingActivityBinding> {
|
|
|
|
|
|
private SettingViewModel settingViewModel;
|
|
|
|
|
|
+ private int eventTimes = 0;
|
|
|
+ private Disposable eventSubscribe;
|
|
|
+
|
|
|
+ private int attrTimes = 0;
|
|
|
+ private Disposable attrSubscribe;
|
|
|
|
|
|
public static void start(Context context) {
|
|
|
Intent intent = new Intent(context, SettingActivity.class);
|
|
|
@@ -41,8 +53,51 @@ public class SettingActivity extends BaseActivity<SettingActivityBinding> {
|
|
|
private void initView() {
|
|
|
addTopStatusBarHeight(binding.toolbar);
|
|
|
binding.toolbar.setNavigationOnClickListener(v -> finish());
|
|
|
+
|
|
|
+ binding.vEvent.setOnClickListener(v -> {
|
|
|
+ if (eventTimes == 0) {
|
|
|
+ if (eventSubscribe != null) {
|
|
|
+ eventSubscribe.dispose();
|
|
|
+ }
|
|
|
+ eventSubscribe = Observable.timer(5000, TimeUnit.MILLISECONDS)
|
|
|
+ .subscribe(aLong -> eventTimes = 0);
|
|
|
+ eventTimes++;
|
|
|
+ } else if (eventTimes == 10) {
|
|
|
+ showEventInfo();
|
|
|
+ } else {
|
|
|
+ eventTimes++;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ binding.vAttr.setOnClickListener(v -> {
|
|
|
+ if (attrTimes == 0) {
|
|
|
+ if (attrSubscribe != null) {
|
|
|
+ attrSubscribe.dispose();
|
|
|
+ }
|
|
|
+ attrSubscribe = Observable.timer(5000, TimeUnit.MILLISECONDS)
|
|
|
+ .subscribe(aLong -> attrTimes = 0);
|
|
|
+ attrTimes++;
|
|
|
+ } else if (attrTimes == 10) {
|
|
|
+ showAttrInfo();
|
|
|
+ } else {
|
|
|
+ attrTimes++;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showAttrInfo() {
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ sb.append("ka attribute:");
|
|
|
+ sb.append(KochavaHelper.isAttributed());
|
|
|
+ ToastUtil.show(sb.toString(), ToastUtil.LENGTH_SHORT);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showEventInfo() {
|
|
|
+ EventHandler.setToastReport();
|
|
|
+ ToastUtil.show("Event toast is open.", ToastUtil.LENGTH_SHORT);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
protected boolean shouldImmersion() {
|
|
|
return true;
|
|
|
@@ -54,4 +109,15 @@ public class SettingActivity extends BaseActivity<SettingActivityBinding> {
|
|
|
settingViewModel = getViewModelProvider().get(SettingViewModel.class);
|
|
|
binding.setSettingViewModel(settingViewModel);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ if (eventSubscribe != null) {
|
|
|
+ eventSubscribe.dispose();
|
|
|
+ }
|
|
|
+ if (attrSubscribe != null) {
|
|
|
+ attrSubscribe.dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|