diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index eae2723ad..d4bfaeb67 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -468,6 +468,9 @@
+
diff --git a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java
index 610779db5..81b96cbed 100644
--- a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java
+++ b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java
@@ -56,6 +56,7 @@ import org.fdroid.fdroid.compat.PRNGFixes;
import org.fdroid.fdroid.data.AppProvider;
import org.fdroid.fdroid.data.InstalledAppProviderService;
import org.fdroid.fdroid.data.Repo;
+import org.fdroid.fdroid.installer.InstallHistoryService;
import org.fdroid.fdroid.net.IconDownloader;
import org.fdroid.fdroid.net.WifiStateChangeService;
@@ -299,6 +300,9 @@ public class FDroidApp extends Application {
});
configureTor(Preferences.get().isTorEnabled());
+
+ // TODO enable this based on a preference
+ InstallHistoryService.register(this);
}
@TargetApi(18)
diff --git a/app/src/main/java/org/fdroid/fdroid/installer/InstallHistoryService.java b/app/src/main/java/org/fdroid/fdroid/installer/InstallHistoryService.java
new file mode 100644
index 000000000..a6789538b
--- /dev/null
+++ b/app/src/main/java/org/fdroid/fdroid/installer/InstallHistoryService.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2016 Blue Jay Wireless
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.fdroid.fdroid.installer;
+
+import android.app.IntentService;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Process;
+import android.support.v4.content.LocalBroadcastManager;
+import android.text.TextUtils;
+
+import org.fdroid.fdroid.R;
+import org.fdroid.fdroid.Utils;
+import org.fdroid.fdroid.data.Apk;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Saves all activity of installs and uninstalls to the database for later use, like
+ * displaying in some kind of history viewer or reporting to a "popularity contest"
+ * app tracker.
+ */
+public class InstallHistoryService extends IntentService {
+ public static final String TAG = "InstallHistoryService";
+
+ private static BroadcastReceiver broadcastReceiver;
+
+ public static void register(Context context) {
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addDataScheme("http");
+ intentFilter.addDataScheme("https");
+ intentFilter.addDataScheme("package");
+ intentFilter.addAction(Installer.ACTION_INSTALL_STARTED);
+ intentFilter.addAction(Installer.ACTION_INSTALL_COMPLETE);
+ intentFilter.addAction(Installer.ACTION_INSTALL_INTERRUPTED);
+ intentFilter.addAction(Installer.ACTION_INSTALL_USER_INTERACTION);
+ intentFilter.addAction(Installer.ACTION_UNINSTALL_STARTED);
+ intentFilter.addAction(Installer.ACTION_UNINSTALL_COMPLETE);
+ intentFilter.addAction(Installer.ACTION_UNINSTALL_INTERRUPTED);
+ intentFilter.addAction(Installer.ACTION_UNINSTALL_USER_INTERACTION);
+
+ broadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ queue(context, intent);
+ }
+ };
+ LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
+ localBroadcastManager.registerReceiver(broadcastReceiver, intentFilter);
+ }
+
+ public static void unregister(Context context) {
+ LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
+ localBroadcastManager.unregisterReceiver(broadcastReceiver);
+ }
+
+ public static void queue(Context context, Intent intent) {
+ Utils.debugLog(TAG, "queue " + intent);
+ intent.setClass(context, InstallHistoryService.class);
+ context.startService(intent);
+ }
+
+ public InstallHistoryService() {
+ super("InstallHistoryService");
+ }
+
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ Utils.debugLog(TAG, "onHandleIntent " + intent);
+ if (intent == null) {
+ return;
+ }
+
+ Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
+ long timestamp = System.currentTimeMillis();
+ Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
+ String packageName = apk.packageName;
+ int versionCode = apk.versionCode;
+
+ List values = new ArrayList<>(4);
+ values.add(String.valueOf(timestamp));
+ values.add(packageName);
+ values.add(String.valueOf(versionCode));
+ values.add(intent.getAction());
+
+ File logFile = new File(getFilesDir(), getString(R.string.install_history_log_file));
+ FileWriter fw = null;
+ PrintWriter out = null;
+ try {
+ fw = new FileWriter(logFile, true);
+ out = new PrintWriter(fw);
+ out.println(TextUtils.join(",", values));
+ } catch (IOException e) {
+ Utils.debugLog(TAG, e.getMessage());
+ } finally {
+ Utils.closeQuietly(out);
+ Utils.closeQuietly(fw);
+ }
+ }
+}
diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml
index 00e6b1e2d..33ee1d38a 100644
--- a/app/src/main/res/values/donottranslate.xml
+++ b/app/src/main/res/values/donottranslate.xml
@@ -7,7 +7,7 @@
https://gitlab.com/fdroid/fdroidclient
team@f-droid.org
GNU General Public License version\u00A03 or later
-
+
transition_app_item_icon
https://
@@ -15,6 +15,8 @@
%1$s on F-Droid
+ all
+
- 0
- 1