mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-30 23:03:00 +00:00 
			
		
		
		
	Add debug setting to enable Picasso indicators
This commit is contained in:
		| @@ -5,6 +5,7 @@ import android.os.Bundle; | ||||
| import androidx.preference.Preference; | ||||
|  | ||||
| import org.schabi.newpipe.R; | ||||
| import org.schabi.newpipe.util.PicassoHelper; | ||||
|  | ||||
| import leakcanary.LeakCanary; | ||||
|  | ||||
| @@ -15,10 +16,13 @@ public class DebugSettingsFragment extends BasePreferenceFragment { | ||||
|  | ||||
|         final Preference showMemoryLeaksPreference | ||||
|                 = findPreference(getString(R.string.show_memory_leaks_key)); | ||||
|         final Preference showImageIndicatorsPreference | ||||
|                 = findPreference(getString(R.string.show_image_indicators_key)); | ||||
|         final Preference crashTheAppPreference | ||||
|                 = findPreference(getString(R.string.crash_the_app_key)); | ||||
|  | ||||
|         assert showMemoryLeaksPreference != null; | ||||
|         assert showImageIndicatorsPreference != null; | ||||
|         assert crashTheAppPreference != null; | ||||
|  | ||||
|         showMemoryLeaksPreference.setOnPreferenceClickListener(preference -> { | ||||
| @@ -26,6 +30,11 @@ public class DebugSettingsFragment extends BasePreferenceFragment { | ||||
|             return true; | ||||
|         }); | ||||
|  | ||||
|         showImageIndicatorsPreference.setOnPreferenceChangeListener((preference, newValue) -> { | ||||
|             PicassoHelper.setIndicatorsEnabled((Boolean) newValue); | ||||
|             return true; | ||||
|         }); | ||||
|  | ||||
|         crashTheAppPreference.setOnPreferenceClickListener(preference -> { | ||||
|             throw new RuntimeException(); | ||||
|         }); | ||||
|   | ||||
| @@ -100,9 +100,12 @@ public class App extends MultiDexApplication { | ||||
|         ServiceHelper.initServices(this); | ||||
|  | ||||
|         // Initialize image loader | ||||
|         final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); | ||||
|         PicassoHelper.init(this); | ||||
|         PicassoHelper.setShouldLoadImages(PreferenceManager.getDefaultSharedPreferences(this) | ||||
|                 .getBoolean(getString(R.string.download_thumbnail_key), true)); | ||||
|         PicassoHelper.setShouldLoadImages( | ||||
|                 prefs.getBoolean(getString(R.string.download_thumbnail_key), true)); | ||||
|         PicassoHelper.setIndicatorsEnabled(BuildConfig.DEBUG | ||||
|                 && prefs.getBoolean(getString(R.string.show_image_indicators_key), false)); | ||||
|  | ||||
|         configureRxJavaErrorHandler(); | ||||
|  | ||||
|   | ||||
| @@ -71,6 +71,10 @@ public final class PicassoHelper { | ||||
|         picassoInstance.cancelTag(tag); | ||||
|     } | ||||
|  | ||||
|     public static void setIndicatorsEnabled(final boolean enabled) { | ||||
|         picassoInstance.setIndicatorsEnabled(enabled); // useful for debugging | ||||
|     } | ||||
|  | ||||
|     public static void setShouldLoadImages(final boolean shouldLoadImages) { | ||||
|         PicassoHelper.shouldLoadImages = shouldLoadImages; | ||||
|     } | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <resources translatable="false"> | ||||
| <resources xmlns:tools="http://schemas.android.com/tools" translatable="false"> | ||||
|     <!-- App versioning --> | ||||
|     <string name="last_used_version" translatable="false">last_used_version</string> | ||||
|     <string name="last_used_preferences_version" translatable="false">last_used_preferences_version</string> | ||||
| @@ -139,13 +139,13 @@ | ||||
|     <string name="scale_to_square_image_in_notifications_key" translatable="false">scale_to_square_image_in_notifications</string> | ||||
|  | ||||
|     <string name="notification_slot_0_key" translatable="false">notification_slot_0_key</string> | ||||
|     <string name="notification_slot_1_key" translatable="false">notification_slot_1_key</string> | ||||
|     <string name="notification_slot_1_key" translatable="false" tools:ignore="Typos">notification_slot_1_key</string> | ||||
|     <string name="notification_slot_2_key" translatable="false">notification_slot_2_key</string> | ||||
|     <string name="notification_slot_3_key" translatable="false">notification_slot_3_key</string> | ||||
|     <string name="notification_slot_4_key" translatable="false">notification_slot_4_key</string> | ||||
|  | ||||
|     <string name="notification_slot_compact_0_key" translatable="false">notification_slot_compact_0_key</string> | ||||
|     <string name="notification_slot_compact_1_key" translatable="false">notification_slot_compact_1_key</string> | ||||
|     <string name="notification_slot_compact_1_key" translatable="false" tools:ignore="Typos">notification_slot_compact_1_key</string> | ||||
|     <string name="notification_slot_compact_2_key" translatable="false">notification_slot_compact_2_key</string> | ||||
|  | ||||
|     <string name="notification_colorize_key" translatable="false">notification_colorize_key</string> | ||||
| @@ -189,6 +189,7 @@ | ||||
|     <string name="show_original_time_ago_key" translatable="false">show_original_time_ago_key</string> | ||||
|     <string name="disable_media_tunneling_key" translatable="false">disable_media_tunneling_key</string> | ||||
|     <string name="crash_the_app_key" translatable="false">crash_the_app_key</string> | ||||
|     <string name="show_image_indicators_key" translatable="false">show_image_indicators_key</string> | ||||
|  | ||||
|     <!-- THEMES --> | ||||
|     <string name="theme_key" translatable="false">theme</string> | ||||
|   | ||||
| @@ -1,5 +1,7 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <resources> | ||||
| <resources xmlns:tools="http://schemas.android.com/tools" | ||||
|         tools:ignore="MissingTranslation"> | ||||
|  | ||||
|     <string name="main_bg_subtitle">Tap the magnifying glass to get started.</string> | ||||
|     <string name="view_count_text">%1$s views</string> | ||||
|     <string name="upload_date_text">Published on %1$s</string> | ||||
| @@ -526,6 +528,8 @@ | ||||
|     <string name="show_original_time_ago_summary">Original texts from services will be visible in stream items</string> | ||||
|     <string name="disable_media_tunneling_title">Disable media tunneling</string> | ||||
|     <string name="disable_media_tunneling_summary">Disable media tunneling if you experience a black screen or stuttering on video playback</string> | ||||
|     <string name="show_image_indicators_title">Show image indicators</string> | ||||
|     <string name="show_image_indicators_summary">Show Picasso colored ribbons on top of images indicating their source: red for network, blue for disk and green for memory</string> | ||||
|     <string name="crash_the_app">Crash the app</string> | ||||
|     <!-- Subscriptions import/export --> | ||||
|     <string name="import_export_title">Import/export</string> | ||||
|   | ||||
| @@ -42,6 +42,13 @@ | ||||
|         app:singleLineTitle="false" | ||||
|         app:iconSpaceReserved="false" /> | ||||
|  | ||||
|     <SwitchPreferenceCompat | ||||
|         android:defaultValue="false" | ||||
|         android:key="@string/show_image_indicators_key" | ||||
|         android:summary="@string/show_image_indicators_summary" | ||||
|         android:title="@string/show_image_indicators_title" | ||||
|         app:iconSpaceReserved="false" /> | ||||
|  | ||||
|     <Preference | ||||
|         android:key="@string/crash_the_app_key" | ||||
|         android:title="@string/crash_the_app" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Stypox
					Stypox