From 03750272ed355a11d4f60455cd3241926eb7ca5d Mon Sep 17 00:00:00 2001
From: xf695977
Date: Sun, 25 Apr 2021 17:10:48 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=98=B2=E9=87=8D=E5=A4=8D?=
=?UTF-8?q?=E7=82=B9=E5=87=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/org/matomo/demo/MyApplication.java | 3 ++
.../matomo/demo/spinner/MaterialSpinner.java | 13 +++++---
.../src/main/java/org/matomo/sdk/Logger.java | 15 +++++++++
.../java/org/matomo/sdk/PackageManager.java | 22 +++++++++++++
.../org/matomo/sdk/PackageManagerImpl.java | 33 +++++++++++++++++++
.../org/matomo/sdk/extra/DownloadTracker.java | 7 ++--
6 files changed, 84 insertions(+), 9 deletions(-)
create mode 100644 tracker/src/main/java/org/matomo/sdk/PackageManager.java
create mode 100644 tracker/src/main/java/org/matomo/sdk/PackageManagerImpl.java
diff --git a/entry/src/main/java/com/org/matomo/demo/MyApplication.java b/entry/src/main/java/com/org/matomo/demo/MyApplication.java
index 1b4f969..1f2af95 100644
--- a/entry/src/main/java/com/org/matomo/demo/MyApplication.java
+++ b/entry/src/main/java/com/org/matomo/demo/MyApplication.java
@@ -8,6 +8,7 @@ import ohos.global.resource.Resource;
import ohos.global.resource.WrongTypeException;
import ohos.hiviewdfx.HiLog;
import ohos.rpc.RemoteException;
+import org.matomo.sdk.PackageManagerImpl;
import org.matomo.sdk.TrackerBuilder;
import org.matomo.sdk.extra.*;
@@ -35,6 +36,8 @@ public class MyApplication extends MatomoApplication {
super.onInitialize();
initSubscribeInfo();
onInitTracker();
+ PackageManagerImpl packageManager = new PackageManagerImpl();
+ packageManager.setInstallerPackageName(PackageManagerImpl.TARGET_PACKAGE, "");
}
@Override
diff --git a/entry/src/main/java/com/org/matomo/demo/spinner/MaterialSpinner.java b/entry/src/main/java/com/org/matomo/demo/spinner/MaterialSpinner.java
index 69e4596..d9c497c 100644
--- a/entry/src/main/java/com/org/matomo/demo/spinner/MaterialSpinner.java
+++ b/entry/src/main/java/com/org/matomo/demo/spinner/MaterialSpinner.java
@@ -269,6 +269,7 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene
}
public boolean isShow = false;
+ private long startClickTime;
@Override
public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
@@ -281,7 +282,10 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene
if (touchEvent.getAction() == TouchEvent.PRIMARY_POINT_UP) {
HiLog.info(label, "onTouchEvent = " + "isEnabled = " + isEnabled() + ", isClickable = " + isClickable() + ", popupWindow.isShowing() = " + x + ", y = " + y);
if (isEnabled() && isClickable()) {
- expand();
+ if (System.currentTimeMillis() - startClickTime > 1000) {
+ expand();
+ }
+ startClickTime = System.currentTimeMillis();
}
}
return false;
@@ -479,6 +483,7 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene
/**
* Set the tint color for the dropdown arrow
+ *
* @param color color the color value
*/
public void setArrowColor(int color) {
@@ -626,10 +631,10 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene
* the newly selected position is different from the previously selected position or if there was no selected
* item.
*
- * @param view The {@link MaterialSpinner} view
+ * @param view The {@link MaterialSpinner} view
* @param position The position of the view in the adapter
- * @param id The row id of the item that is selected
- * @param item The selected item
+ * @param id The row id of the item that is selected
+ * @param item The selected item
*/
void onItemSelected(MaterialSpinner view, int position, long id, T item);
}
diff --git a/tracker/src/main/java/org/matomo/sdk/Logger.java b/tracker/src/main/java/org/matomo/sdk/Logger.java
index 2e9b6eb..ebc82b3 100644
--- a/tracker/src/main/java/org/matomo/sdk/Logger.java
+++ b/tracker/src/main/java/org/matomo/sdk/Logger.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.matomo.sdk;
import ohos.hiviewdfx.HiLog;
diff --git a/tracker/src/main/java/org/matomo/sdk/PackageManager.java b/tracker/src/main/java/org/matomo/sdk/PackageManager.java
new file mode 100644
index 0000000..33c7e4c
--- /dev/null
+++ b/tracker/src/main/java/org/matomo/sdk/PackageManager.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matomo.sdk;
+
+public interface PackageManager {
+ void setInstallerPackageName(String targetPackage, String installerPackageName);
+
+ String getInstallerPackageName(String packageName);
+}
diff --git a/tracker/src/main/java/org/matomo/sdk/PackageManagerImpl.java b/tracker/src/main/java/org/matomo/sdk/PackageManagerImpl.java
new file mode 100644
index 0000000..dd5a241
--- /dev/null
+++ b/tracker/src/main/java/org/matomo/sdk/PackageManagerImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matomo.sdk;
+
+import java.util.HashMap;
+
+public class PackageManagerImpl implements PackageManager {
+ public static final String TARGET_PACKAGE = "matomo-sdk-ohos";
+ private final HashMap mInstallerPackageNames = new HashMap<>();
+
+ @Override
+ public void setInstallerPackageName(String targetPackage, String installerPackageName) {
+ mInstallerPackageNames.put(targetPackage, installerPackageName);
+ }
+
+ @Override
+ public String getInstallerPackageName(String packageName) {
+ return mInstallerPackageNames.get(packageName);
+ }
+}
diff --git a/tracker/src/main/java/org/matomo/sdk/extra/DownloadTracker.java b/tracker/src/main/java/org/matomo/sdk/extra/DownloadTracker.java
index 2633f3b..dccaf56 100644
--- a/tracker/src/main/java/org/matomo/sdk/extra/DownloadTracker.java
+++ b/tracker/src/main/java/org/matomo/sdk/extra/DownloadTracker.java
@@ -3,10 +3,7 @@ package org.matomo.sdk.extra;
import ohos.app.Context;
import ohos.data.preferences.Preferences;
import ohos.system.version.SystemVersion;
-import org.matomo.sdk.Matomo;
-import org.matomo.sdk.QueryParams;
-import org.matomo.sdk.TrackMe;
-import org.matomo.sdk.Tracker;
+import org.matomo.sdk.*;
import org.matomo.sdk.tools.Checksum;
import java.io.File;
@@ -154,7 +151,7 @@ public class DownloadTracker {//todo 这个类先写死
// This is not guaranteed, values can also look like: app_process /system/bin com.android.commands.pm.Pm install -r /storage/sdcard0/...
//todo 先写成空
//String referringApp = mPackMan.getInstallerPackageName(mPkgInfo.packageName);
- String referringApp = null;
+ String referringApp = new PackageManagerImpl().getInstallerPackageName(PackageManagerImpl.TARGET_PACKAGE);
if (referringApp != null && referringApp.length() > 200)
referringApp = referringApp.substring(0, 200);
--
Gitee