Loading app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentNotificationsSettings.java +27 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,11 @@ import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceScreen; import org.unifiedpush.android.connector.UnifiedPush; import java.util.ArrayList; import java.util.List; import app.fedilab.android.R; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.PushHelper; Loading Loading @@ -96,17 +101,33 @@ public class FragmentNotificationsSettings extends PreferenceFragmentCompat impl if (SET_NOTIFICATION_DELAY_VALUE != null) { preferenceScreen.removePreferenceRecursively("SET_NOTIFICATION_DELAY_VALUE"); } ListPreference SET_PUSH_DISTRIBUTOR = findPreference("SET_PUSH_DISTRIBUTOR"); if (SET_PUSH_DISTRIBUTOR != null) { preferenceScreen.removePreferenceRecursively("SET_PUSH_DISTRIBUTOR"); } return; } else if (SET_NOTIFICATION_TYPE != null && SET_NOTIFICATION_TYPE.getValue().equals(notificationValues[1])) { ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference(getString(R.string.SET_NOTIFICATION_DELAY_VALUE)); if (SET_NOTIFICATION_DELAY_VALUE != null) { SET_NOTIFICATION_DELAY_VALUE.getContext().setTheme(Helper.dialogStyle()); } ListPreference SET_PUSH_DISTRIBUTOR = findPreference("SET_PUSH_DISTRIBUTOR"); if (SET_PUSH_DISTRIBUTOR != null) { preferenceScreen.removePreferenceRecursively("SET_PUSH_DISTRIBUTOR"); } } else { ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference("SET_NOTIFICATION_DELAY_VALUE"); if (SET_NOTIFICATION_DELAY_VALUE != null) { preferenceScreen.removePreferenceRecursively("SET_NOTIFICATION_DELAY_VALUE"); } ListPreference SET_PUSH_DISTRIBUTOR = findPreference(getString(R.string.SET_PUSH_DISTRIBUTOR)); if (SET_PUSH_DISTRIBUTOR != null) { SET_PUSH_DISTRIBUTOR.getContext().setTheme(Helper.dialogStyle()); List<String> distributors = UnifiedPush.getDistributors(requireActivity(), new ArrayList<>()); SET_PUSH_DISTRIBUTOR.setValue(UnifiedPush.getDistributor(requireActivity())); SET_PUSH_DISTRIBUTOR.setEntries(distributors.toArray(new String[0])); SET_PUSH_DISTRIBUTOR.setEntryValues(distributors.toArray(new String[0])); } } Preference button_mention = findPreference("button_mention"); Loading Loading @@ -198,13 +219,18 @@ public class FragmentNotificationsSettings extends PreferenceFragmentCompat impl } if (key.compareToIgnoreCase(getString(R.string.SET_LED_COLOUR_VAL)) == 0) { try { int value = Integer.parseInt(key); int value = sharedPreferences.getInt(key, 0); sharedPreferences.edit().putInt(getString(R.string.SET_LED_COLOUR_VAL), value).apply(); } catch (NumberFormatException e) { e.printStackTrace(); } } if (key.compareToIgnoreCase(getString(R.string.SET_PUSH_DISTRIBUTOR)) == 0) { String distributor = sharedPreferences.getString(key, ""); UnifiedPush.saveDistributor(requireActivity(), distributor); PushHelper.startStreaming(requireActivity()); } } } Loading app/src/main/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -770,6 +770,7 @@ <string name="SET_NSFW_TIMEOUT" translatable="false">SET_NSFW_TIMEOUT</string> <string name="SET_NOTIFICATION_TYPE" translatable="false">SET_NOTIFICATION_TYPE</string> <string name="SET_NOTIFICATION_DELAY_VALUE" translatable="false">SET_NOTIFICATION_DELAY_VALUE</string> <string name="SET_PUSH_DISTRIBUTOR" translatable="false">SET_PUSH_DISTRIBUTOR</string> <string-array name="SET_NOTIFICATION_TYPE_VALUE" translatable="false"> <item>PUSH_NOTIFICATIONS</item> Loading Loading @@ -1438,4 +1439,5 @@ <string name="import_settings">Import settings</string> <string name="permission_missing">Permission not granted!</string> <string name="load_settings">Load exported settings</string> <string name="push_distributors">Push distributor</string> </resources> app/src/main/res/xml/pref_notifications.xml +7 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,13 @@ app:summary="@string/set_push_notifications_delay" app:title="@string/type_of_notifications_delay_title" app:useSimpleSummaryProvider="true" /> <ListPreference app:dialogTitle="@string/select_distributors" app:iconSpaceReserved="false" app:key="@string/SET_PUSH_DISTRIBUTOR" app:title="@string/push_distributors" app:useSimpleSummaryProvider="true" /> </PreferenceCategory> Loading Loading
app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentNotificationsSettings.java +27 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,11 @@ import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceScreen; import org.unifiedpush.android.connector.UnifiedPush; import java.util.ArrayList; import java.util.List; import app.fedilab.android.R; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.PushHelper; Loading Loading @@ -96,17 +101,33 @@ public class FragmentNotificationsSettings extends PreferenceFragmentCompat impl if (SET_NOTIFICATION_DELAY_VALUE != null) { preferenceScreen.removePreferenceRecursively("SET_NOTIFICATION_DELAY_VALUE"); } ListPreference SET_PUSH_DISTRIBUTOR = findPreference("SET_PUSH_DISTRIBUTOR"); if (SET_PUSH_DISTRIBUTOR != null) { preferenceScreen.removePreferenceRecursively("SET_PUSH_DISTRIBUTOR"); } return; } else if (SET_NOTIFICATION_TYPE != null && SET_NOTIFICATION_TYPE.getValue().equals(notificationValues[1])) { ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference(getString(R.string.SET_NOTIFICATION_DELAY_VALUE)); if (SET_NOTIFICATION_DELAY_VALUE != null) { SET_NOTIFICATION_DELAY_VALUE.getContext().setTheme(Helper.dialogStyle()); } ListPreference SET_PUSH_DISTRIBUTOR = findPreference("SET_PUSH_DISTRIBUTOR"); if (SET_PUSH_DISTRIBUTOR != null) { preferenceScreen.removePreferenceRecursively("SET_PUSH_DISTRIBUTOR"); } } else { ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference("SET_NOTIFICATION_DELAY_VALUE"); if (SET_NOTIFICATION_DELAY_VALUE != null) { preferenceScreen.removePreferenceRecursively("SET_NOTIFICATION_DELAY_VALUE"); } ListPreference SET_PUSH_DISTRIBUTOR = findPreference(getString(R.string.SET_PUSH_DISTRIBUTOR)); if (SET_PUSH_DISTRIBUTOR != null) { SET_PUSH_DISTRIBUTOR.getContext().setTheme(Helper.dialogStyle()); List<String> distributors = UnifiedPush.getDistributors(requireActivity(), new ArrayList<>()); SET_PUSH_DISTRIBUTOR.setValue(UnifiedPush.getDistributor(requireActivity())); SET_PUSH_DISTRIBUTOR.setEntries(distributors.toArray(new String[0])); SET_PUSH_DISTRIBUTOR.setEntryValues(distributors.toArray(new String[0])); } } Preference button_mention = findPreference("button_mention"); Loading Loading @@ -198,13 +219,18 @@ public class FragmentNotificationsSettings extends PreferenceFragmentCompat impl } if (key.compareToIgnoreCase(getString(R.string.SET_LED_COLOUR_VAL)) == 0) { try { int value = Integer.parseInt(key); int value = sharedPreferences.getInt(key, 0); sharedPreferences.edit().putInt(getString(R.string.SET_LED_COLOUR_VAL), value).apply(); } catch (NumberFormatException e) { e.printStackTrace(); } } if (key.compareToIgnoreCase(getString(R.string.SET_PUSH_DISTRIBUTOR)) == 0) { String distributor = sharedPreferences.getString(key, ""); UnifiedPush.saveDistributor(requireActivity(), distributor); PushHelper.startStreaming(requireActivity()); } } } Loading
app/src/main/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -770,6 +770,7 @@ <string name="SET_NSFW_TIMEOUT" translatable="false">SET_NSFW_TIMEOUT</string> <string name="SET_NOTIFICATION_TYPE" translatable="false">SET_NOTIFICATION_TYPE</string> <string name="SET_NOTIFICATION_DELAY_VALUE" translatable="false">SET_NOTIFICATION_DELAY_VALUE</string> <string name="SET_PUSH_DISTRIBUTOR" translatable="false">SET_PUSH_DISTRIBUTOR</string> <string-array name="SET_NOTIFICATION_TYPE_VALUE" translatable="false"> <item>PUSH_NOTIFICATIONS</item> Loading Loading @@ -1438,4 +1439,5 @@ <string name="import_settings">Import settings</string> <string name="permission_missing">Permission not granted!</string> <string name="load_settings">Load exported settings</string> <string name="push_distributors">Push distributor</string> </resources>
app/src/main/res/xml/pref_notifications.xml +7 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,13 @@ app:summary="@string/set_push_notifications_delay" app:title="@string/type_of_notifications_delay_title" app:useSimpleSummaryProvider="true" /> <ListPreference app:dialogTitle="@string/select_distributors" app:iconSpaceReserved="false" app:key="@string/SET_PUSH_DISTRIBUTOR" app:title="@string/push_distributors" app:useSimpleSummaryProvider="true" /> </PreferenceCategory> Loading