basic Install History viewer, available only when logging is enabled
This provides a super simple way to view the install history directly in F-Droid.
This commit is contained in:
parent
460720c7f3
commit
7043627a3a
@ -24,6 +24,16 @@
|
|||||||
android:targetPackage="@string/applicationId"
|
android:targetPackage="@string/applicationId"
|
||||||
android:targetClass="org.fdroid.fdroid.views.ManageReposActivity"/>
|
android:targetClass="org.fdroid.fdroid.views.ManageReposActivity"/>
|
||||||
</android.support.v7.preference.PreferenceScreen>
|
</android.support.v7.preference.PreferenceScreen>
|
||||||
|
<android.support.v7.preference.PreferenceScreen
|
||||||
|
android:key="installHistory"
|
||||||
|
android:visible="false"
|
||||||
|
android:title="@string/install_history"
|
||||||
|
android:summary="@string/install_history_summary">
|
||||||
|
<intent
|
||||||
|
android:action="android.intent.action.MAIN"
|
||||||
|
android:targetPackage="@string/applicationId"
|
||||||
|
android:targetClass="org.fdroid.fdroid.views.InstallHistoryActivity"/>
|
||||||
|
</android.support.v7.preference.PreferenceScreen>
|
||||||
</android.support.v7.preference.PreferenceCategory>
|
</android.support.v7.preference.PreferenceCategory>
|
||||||
|
|
||||||
<android.support.v7.preference.PreferenceCategory android:title="@string/updates">
|
<android.support.v7.preference.PreferenceCategory android:title="@string/updates">
|
||||||
|
@ -550,6 +550,12 @@
|
|||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".views.main.MainActivity"/>
|
android:value=".views.main.MainActivity"/>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".views.InstallHistoryActivity"
|
||||||
|
android:parentActivityName=".views.main.MainActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".views.main.MainActivity"/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".AboutActivity" android:theme="@style/Theme.AppCompat.Light.Dialog"/>
|
<activity android:name=".AboutActivity" android:theme="@style/Theme.AppCompat.Light.Dialog"/>
|
||||||
<activity android:name=".installer.FileInstallerActivity" android:theme="@style/AppThemeTransparent"/>
|
<activity android:name=".installer.FileInstallerActivity" android:theme="@style/AppThemeTransparent"/>
|
||||||
|
@ -28,7 +28,7 @@ import android.net.Uri;
|
|||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import org.fdroid.fdroid.BuildConfig;
|
||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
import org.fdroid.fdroid.data.Apk;
|
import org.fdroid.fdroid.data.Apk;
|
||||||
|
|
||||||
@ -47,7 +47,8 @@ import java.util.List;
|
|||||||
public class InstallHistoryService extends IntentService {
|
public class InstallHistoryService extends IntentService {
|
||||||
public static final String TAG = "InstallHistoryService";
|
public static final String TAG = "InstallHistoryService";
|
||||||
|
|
||||||
public static final Uri LOG_URI = Uri.parse("content://org.fdroid.fdroid.installer/install_history/all");
|
public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".installer";
|
||||||
|
public static final Uri LOG_URI = Uri.parse("content://" + AUTHORITY + "/install_history/all");
|
||||||
|
|
||||||
private static BroadcastReceiver broadcastReceiver;
|
private static BroadcastReceiver broadcastReceiver;
|
||||||
|
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Blue Jay Wireless
|
||||||
|
* Copyright (C) 2018 Senecto Limited
|
||||||
|
*
|
||||||
|
* 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.views;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.ParcelFileDescriptor;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.fdroid.fdroid.R;
|
||||||
|
import org.fdroid.fdroid.installer.InstallHistoryService;
|
||||||
|
|
||||||
|
import java.io.FileDescriptor;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
public class InstallHistoryActivity extends AppCompatActivity {
|
||||||
|
public static final String TAG = "InstallHistoryActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_install_history);
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
toolbar.setTitle(getString(R.string.install_history));
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
String text = "";
|
||||||
|
try {
|
||||||
|
ContentResolver resolver = getContentResolver();
|
||||||
|
|
||||||
|
Cursor cursor = resolver.query(InstallHistoryService.LOG_URI, null, null, null, null);
|
||||||
|
if (cursor != null) {
|
||||||
|
cursor.moveToFirst();
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
ParcelFileDescriptor pfd = resolver.openFileDescriptor(InstallHistoryService.LOG_URI, "r");
|
||||||
|
FileDescriptor fd = pfd.getFileDescriptor();
|
||||||
|
FileInputStream fileInputStream = new FileInputStream(fd);
|
||||||
|
text = IOUtils.toString(fileInputStream, Charset.defaultCharset());
|
||||||
|
} catch (IOException | SecurityException | IllegalStateException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
TextView textView = findViewById(R.id.text);
|
||||||
|
textView.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.install_history, menu);
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menu_delete:
|
||||||
|
getContentResolver().delete(InstallHistoryService.LOG_URI, null, null);
|
||||||
|
TextView textView = findViewById(R.id.text);
|
||||||
|
textView.setText("");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
@ -337,10 +337,13 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
|
|
||||||
case Preferences.PREF_KEEP_INSTALL_HISTORY:
|
case Preferences.PREF_KEEP_INSTALL_HISTORY:
|
||||||
CheckBoxPreference p = (CheckBoxPreference) findPreference(key);
|
CheckBoxPreference p = (CheckBoxPreference) findPreference(key);
|
||||||
|
Preference installHistory = findPreference("installHistory");
|
||||||
if (p.isChecked()) {
|
if (p.isChecked()) {
|
||||||
InstallHistoryService.register(getActivity());
|
InstallHistoryService.register(getActivity());
|
||||||
|
installHistory.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
InstallHistoryService.unregister(getActivity());
|
InstallHistoryService.unregister(getActivity());
|
||||||
|
installHistory.setVisible(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
40
app/src/main/res/layout/activity_install_history.xml
Normal file
40
app/src/main/res/layout/activity_install_history.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".views.InstallHistoryActivity">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:id="@+id/app_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppThemeLight.AppBarOverlay">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"/>
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<android.support.v4.widget.NestedScrollView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:context=".views.InstallHistoryActivity"
|
||||||
|
tools:showIn="@layout/activity_install_history">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"/>
|
||||||
|
|
||||||
|
</android.support.v4.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
7
app/src/main/res/menu/install_history.xml
Normal file
7
app/src/main/res/menu/install_history.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_delete"
|
||||||
|
android:icon="@android:drawable/ic_delete"
|
||||||
|
android:title="@string/delete"/>
|
||||||
|
</menu>
|
@ -24,6 +24,8 @@
|
|||||||
<string name="hide_all_notifications_summary">Prevent all actions from showing in the status bar and notification
|
<string name="hide_all_notifications_summary">Prevent all actions from showing in the status bar and notification
|
||||||
drawer.
|
drawer.
|
||||||
</string>
|
</string>
|
||||||
|
<string name="install_history">Install history</string>
|
||||||
|
<string name="install_history_summary">View the private log of all installs and uninstalls</string>
|
||||||
<string name="keep_install_history">Keep install history</string>
|
<string name="keep_install_history">Keep install history</string>
|
||||||
<string name="keep_install_history_summary">Store a log of all installs and uninstalls in a private store</string>
|
<string name="keep_install_history_summary">Store a log of all installs and uninstalls in a private store</string>
|
||||||
<string name="send_version_and_uuid">Send version and UUID to servers</string>
|
<string name="send_version_and_uuid">Send version and UUID to servers</string>
|
||||||
|
@ -24,6 +24,16 @@
|
|||||||
android:targetPackage="@string/applicationId"
|
android:targetPackage="@string/applicationId"
|
||||||
android:targetClass="org.fdroid.fdroid.views.ManageReposActivity"/>
|
android:targetClass="org.fdroid.fdroid.views.ManageReposActivity"/>
|
||||||
</android.support.v7.preference.PreferenceScreen>
|
</android.support.v7.preference.PreferenceScreen>
|
||||||
|
<android.support.v7.preference.PreferenceScreen
|
||||||
|
android:key="installHistory"
|
||||||
|
android:visible="false"
|
||||||
|
android:title="@string/install_history"
|
||||||
|
android:summary="@string/install_history_summary">
|
||||||
|
<intent
|
||||||
|
android:action="android.intent.action.MAIN"
|
||||||
|
android:targetPackage="@string/applicationId"
|
||||||
|
android:targetClass="org.fdroid.fdroid.views.InstallHistoryActivity"/>
|
||||||
|
</android.support.v7.preference.PreferenceScreen>
|
||||||
</android.support.v7.preference.PreferenceCategory>
|
</android.support.v7.preference.PreferenceCategory>
|
||||||
|
|
||||||
<android.support.v7.preference.PreferenceCategory android:title="@string/updates">
|
<android.support.v7.preference.PreferenceCategory android:title="@string/updates">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user