From 5771908f90ada1b2af35f83001f672f8e9ba75f1 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 25 Jun 2018 14:56:02 +0200 Subject: [PATCH 1/3] make Expert preference show/hide all the expert preferences This should make them less scary to people who do not want to see them at all. It also means that there can be quite a few expert preferences without making the list super long for most users. --- .../views/fragments/PreferencesFragment.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java b/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java index a3752021d..29ddebce6 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java +++ b/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java @@ -37,7 +37,9 @@ import android.support.v7.preference.EditTextPreference; import android.support.v7.preference.ListPreference; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceCategory; +import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.SeekBarPreference; +import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.WindowManager; import info.guardianproject.netcipher.NetCipher; @@ -91,6 +93,7 @@ public class PreferencesFragment extends PreferenceFragment private static final int REQUEST_INSTALL_ORBOT = 0x1234; + private PreferenceGroup otherPrefGroup; private LiveSeekBarPreference overWifiSeekBar; private LiveSeekBarPreference overDataSeekBar; private LiveSeekBarPreference updateIntervalSeekBar; @@ -109,6 +112,8 @@ public class PreferencesFragment extends PreferenceFragment Preferences.get().migrateOldPreferences(); addPreferencesFromResource(R.xml.preferences); + otherPrefGroup = (PreferenceGroup) findPreference("pref_category_other"); + useTorCheckPref = (SwitchPreference) findPreference(Preferences.PREF_USE_TOR); enableProxyCheckPref = (SwitchPreference) findPreference(Preferences.PREF_ENABLE_PROXY); updateAutoDownloadPref = findPreference(Preferences.PREF_AUTO_DOWNLOAD_INSTALL_UPDATES); @@ -284,6 +289,15 @@ public class PreferencesFragment extends PreferenceFragment case Preferences.PREF_EXPERT: checkSummary(key, R.string.expert_on); + boolean isExpertMode = Preferences.get().expertMode(); + for (int i = 0; i < otherPrefGroup.getPreferenceCount(); i++) { + Preference pref = otherPrefGroup.getPreference(i); + if (TextUtils.equals(Preferences.PREF_EXPERT, pref.getDependency())) { + pref.setVisible(isExpertMode); + } + RecyclerView recyclerView = getListView(); + recyclerView.smoothScrollToPosition(recyclerView.getAdapter().getItemCount() - 1); + } break; case Preferences.PREF_PRIVILEGED_INSTALLER: @@ -355,9 +369,8 @@ public class PreferencesFragment extends PreferenceFragment // is no benefit showing it to them (it will only be disabled and we can't offer any // way to easily install from here. if (Build.VERSION.SDK_INT > 19 && !installed) { - PreferenceCategory other = (PreferenceCategory) findPreference("pref_category_other"); if (pref != null) { - other.removePreference(pref); + otherPrefGroup.removePreference(pref); } } else { pref.setEnabled(installed); @@ -383,8 +396,7 @@ public class PreferencesFragment extends PreferenceFragment private void initUpdatePrivilegedExtensionPreference() { if (Build.VERSION.SDK_INT > 19) { // this will never work on newer Android versions, so hide it - PreferenceCategory other = (PreferenceCategory) findPreference("pref_category_other"); - other.removePreference(updatePrivilegedExtensionPref); + otherPrefGroup.removePreference(updatePrivilegedExtensionPref); return; } updatePrivilegedExtensionPref.setPersistent(false); From d8d043125b904c33ffb4dc8b39fe7d9ef4d3683a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 25 Jun 2018 15:05:50 +0200 Subject: [PATCH 2/3] add expert preference to disable all notifications This preference is meant for whitelabel builds that are meant to be entirely controlled by the server, without user interaction, e.g. "appliances". Some users have asked for such a thing, so it makes sense to have it available as an expert preference. In general, we want to ensure that installs/updates always show a notification so that the user is aware of what is being installed on their computers. That is the same policy as other app stores like Google Play, etc. --- app/src/basic/res/xml/preferences.xml | 6 ++++++ .../main/java/org/fdroid/fdroid/NotificationHelper.java | 4 ++-- app/src/main/java/org/fdroid/fdroid/Preferences.java | 9 +++++++++ app/src/main/res/values/strings.xml | 4 ++++ app/src/main/res/xml/preferences.xml | 6 ++++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/src/basic/res/xml/preferences.xml b/app/src/basic/res/xml/preferences.xml index c1e62f5ca..6744145bb 100644 --- a/app/src/basic/res/xml/preferences.xml +++ b/app/src/basic/res/xml/preferences.xml @@ -144,6 +144,12 @@ android:summary="@string/keep_install_history_summary" android:defaultValue="false" android:dependency="expert"/> + Updates Unstable updates Suggest updates to unstable versions + Hide all notifications + Prevent all actions from showing in the status bar and notification + drawer. + Keep install history Store a log of all installs and uninstalls in a private store Force old index format diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 84b3c138d..201964225 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -165,6 +165,12 @@ android:summary="@string/keep_install_history_summary" android:defaultValue="false" android:dependency="expert"/> + Date: Thu, 21 Jun 2018 10:09:03 +0200 Subject: [PATCH 3/3] show Updating progress notification based on "available updates" pref The notification that shows the download/parse progress of the index update is now controled by the "Show available updates" preference. That means it will not be shown at all in the notifications bar if that preference is disabled. There will still be the header inside of F-Droid. Ideally, the Updating process would be shown in the Updates tab. --- .../java/org/fdroid/fdroid/UpdateService.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/UpdateService.java b/app/src/main/java/org/fdroid/fdroid/UpdateService.java index 7e431430e..3598aa186 100644 --- a/app/src/main/java/org/fdroid/fdroid/UpdateService.java +++ b/app/src/main/java/org/fdroid/fdroid/UpdateService.java @@ -319,14 +319,14 @@ public class UpdateService extends JobIntentService { } else { notificationBuilder.setProgress(100, 0, true); } - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); break; case STATUS_ERROR_GLOBAL: text = context.getString(R.string.global_error_updating_repos, message); notificationBuilder.setContentText(text) .setCategory(NotificationCompat.CATEGORY_ERROR) .setSmallIcon(android.R.drawable.ic_dialog_alert); - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); Toast.makeText(context, text, Toast.LENGTH_LONG).show(); break; case STATUS_ERROR_LOCAL: @@ -344,7 +344,7 @@ public class UpdateService extends JobIntentService { notificationBuilder.setContentText(text) .setCategory(NotificationCompat.CATEGORY_ERROR) .setSmallIcon(android.R.drawable.ic_dialog_info); - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); Toast.makeText(context, text, Toast.LENGTH_LONG).show(); break; case STATUS_COMPLETE_WITH_CHANGES: @@ -353,12 +353,18 @@ public class UpdateService extends JobIntentService { text = context.getString(R.string.repos_unchanged); notificationBuilder.setContentText(text) .setCategory(NotificationCompat.CATEGORY_SERVICE); - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); break; } } }; + private void setNotification() { + if (Preferences.get().isUpdateNotificationEnabled()) { + notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + } + } + /** * In order to send a {@link Toast} from a {@link IntentService}, we have to do these tricks. */ @@ -404,7 +410,7 @@ public class UpdateService extends JobIntentService { } updating = true; - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); LocalBroadcastManager.getInstance(this).registerReceiver(updateStatusReceiver, new IntentFilter(LOCAL_ACTION_STATUS));