NewPipe icon indicating copy to clipboard operation
NewPipe copied to clipboard

Migrate “History and Cache” to Jetpack Compose

Open braiso-22 opened this issue 1 year ago • 3 comments

What is it?

  • [ ] Bugfix (user facing)
  • [ ] Feature (user facing)
  • [x] Codebase improvement (dev facing)
  • [ ] Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Added daggerHilt DI
  • Changed the History and cache setting screen to use compose

Before/After Screenshots/Screen Record

  • Before: Captura de pantalla 2024-09-01 a las 18 44 50 image

  • After: Captura de pantalla 2024-09-01 a las 18 39 49 image

Fixes the following issue(s)

  • Fixes #

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

braiso-22 avatar Sep 01 '24 17:09 braiso-22

@snaik20 can you review this PR?

braiso-22 avatar Sep 02 '24 19:09 braiso-22

I rebased on current refactor & squashed, but I can’t get it to work. The hilt library is throwing weird injection errors:

/home/philip/kot/android/NewPipe/app/build/generated/hilt/component_sources/debug/org/schabi/newpipe/App_HiltComponents.java:144: error: [Dagger/DuplicateBindings] android.content.SharedPreferences is bound multiple times:
  public abstract static class SingletonC implements FragmentGetContextFix.FragmentGetContextFixEntryPoint,
                         ^
          @Provides @Singleton android.content.SharedPreferences org.schabi.newpipe.AppModule.providesSharedPreference(@dagger.hilt.android.qualifiers.ApplicationContext android.content.Context)
          @Provides @Singleton android.content.SharedPreferences org.schabi.newpipe.dependency_injection.AppModule.provideSharedPreferences(@dagger.hilt.android.qualifiers.ApplicationContext android.content.Context)
      android.content.SharedPreferences is injected at
          org.schabi.newpipe.settings.viewmodel.SettingsViewModel(…, preferenceManager)
      org.schabi.newpipe.settings.viewmodel.SettingsViewModel is injected at
          org.schabi.newpipe.settings.viewmodel.SettingsViewModel_HiltModules.BindsModule.binds(vm)
      @dagger.hilt.android.internal.lifecycle.HiltViewModelMap java.util.Map<java.lang.Class<?>,javax.inject.Provider<androidx.lifecycle.ViewModel>> is requested at
          dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.ViewModelFactoriesEntryPoint.getHiltViewModelMap() [org.schabi.newpipe.App_HiltComponents.SingletonC → org.schabi.newpipe.App_HiltComponents.ActivityRetainedC → org.schabi.newpipe.App_HiltComponents.ViewModelC]
  It is also requested at:
      org.schabi.newpipe.settings.dependency_injection.SettingsModule.provideGetBooleanPreference(sharedPreferences, …)
      org.schabi.newpipe.settings.dependency_injection.SettingsModule.provideGetStringPreference(sharedPreferences, …)
      org.schabi.newpipe.settings.dependency_injection.SettingsModule.provideUpdateBooleanPreference(sharedPreferences, …)
      org.schabi.newpipe.settings.dependency_injection.SettingsModule.provideUpdateStringPreference(sharedPreferences, …)

Profpatsch avatar Nov 20 '24 15:11 Profpatsch

Something I noticed: the old implementation seems to be still around, don’t we want to remove it?

Profpatsch avatar Nov 20 '24 15:11 Profpatsch

Hey @braiso-22, do you have time to address the reviews and complete this PR? Thanks in advance :-)

Stypox avatar Oct 01 '25 01:10 Stypox

Hey @braiso-22, do you have time to address the reviews and complete this PR? Thanks in advance :-)

Sorry for leaving this PR unattended for so long! Life has been a bit crazy lately and I completely forgot about it. I'll get back to it soon

braiso-22 avatar Oct 03 '25 10:10 braiso-22

Totally understandable, thanks!

Stypox avatar Oct 03 '25 16:10 Stypox

I rebased on current refactor & squashed, but I can’t get it to work. The hilt library is throwing weird injection errors:

/home/philip/kot/android/NewPipe/app/build/generated/hilt/component_sources/debug/org/schabi/newpipe/App_HiltComponents.java:144: error: [Dagger/DuplicateBindings] android.content.SharedPreferences is bound multiple times:
  public abstract static class SingletonC implements FragmentGetContextFix.FragmentGetContextFixEntryPoint,
                         ^
          @Provides @Singleton android.content.SharedPreferences org.schabi.newpipe.AppModule.providesSharedPreference(@dagger.hilt.android.qualifiers.ApplicationContext android.content.Context)
          @Provides @Singleton android.content.SharedPreferences org.schabi.newpipe.dependency_injection.AppModule.provideSharedPreferences(@dagger.hilt.android.qualifiers.ApplicationContext android.content.Context)
      android.content.SharedPreferences is injected at
          org.schabi.newpipe.settings.viewmodel.SettingsViewModel(…, preferenceManager)
      org.schabi.newpipe.settings.viewmodel.SettingsViewModel is injected at
          org.schabi.newpipe.settings.viewmodel.SettingsViewModel_HiltModules.BindsModule.binds(vm)
      @dagger.hilt.android.internal.lifecycle.HiltViewModelMap java.util.Map<java.lang.Class<?>,javax.inject.Provider<androidx.lifecycle.ViewModel>> is requested at
          dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.ViewModelFactoriesEntryPoint.getHiltViewModelMap() [org.schabi.newpipe.App_HiltComponents.SingletonC → org.schabi.newpipe.App_HiltComponents.ActivityRetainedC → org.schabi.newpipe.App_HiltComponents.ViewModelC]
  It is also requested at:
      org.schabi.newpipe.settings.dependency_injection.SettingsModule.provideGetBooleanPreference(sharedPreferences, …)
      org.schabi.newpipe.settings.dependency_injection.SettingsModule.provideGetStringPreference(sharedPreferences, …)
      org.schabi.newpipe.settings.dependency_injection.SettingsModule.provideUpdateBooleanPreference(sharedPreferences, …)
      org.schabi.newpipe.settings.dependency_injection.SettingsModule.provideUpdateStringPreference(sharedPreferences, …)

fixed in the latest commit

braiso-22 avatar Oct 04 '25 19:10 braiso-22

Something I noticed: the old implementation seems to be still around, don’t we want to remove it?

Do you mean the xml view? I don't know how do we proceed in this case @Isira-Seneviratne what do i do?

braiso-22 avatar Oct 04 '25 19:10 braiso-22

Hi @Stypox and @Isira-Seneviratne, I think this PR is ready for another review. I’ve addressed some of the comments, and for the ones that seemed out of scope, I’ve added explanations in my replies. Could you please take another look?

braiso-22 avatar Oct 11 '25 17:10 braiso-22

The pipeline started failing on the ktLint Gradle task in a class I didn’t modify. I’ve merged my branch with the refactor branch again and fixed the two errors reported by the pipeline. You can approve it again.

braiso-22 avatar Oct 11 '25 21:10 braiso-22