-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Migrate “History and Cache” to Jetpack Compose #11494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
braiso-22
wants to merge
8
commits into
TeamNewPipe:refactor
Choose a base branch
from
braiso-22:history_cache_compose
base: refactor
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2eb85bd
fixed inversed colors of surface for light theme
brais-f c3aa4e7
Added the new compose screen with its components and events
brais-f d01cdb6
Merge branch 'refactor' into history_cache_compose
brais-f 15e6161
fix merge with refactor branch
brais-f 2fe20b9
change code to more compose friendly as @Isira-Seneviratne said
brais-f 7f65f1a
use content from compose fragment library as @Isira-Seneviratne said
brais-f 2211961
Delete old implementation
brais-f 69fa98b
Merge branch 'refactor' into history_cache_compose
brais-f File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/schabi/newpipe/dependency_injection/AppModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package org.schabi.newpipe.dependency_injection | ||
|
|
||
| import android.content.Context | ||
| import android.content.SharedPreferences | ||
| import androidx.preference.PreferenceManager | ||
| import dagger.Module | ||
| import dagger.Provides | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import dagger.hilt.components.SingletonComponent | ||
| import org.schabi.newpipe.error.usecases.OpenErrorActivity | ||
| import javax.inject.Singleton | ||
|
|
||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| object AppModule { | ||
| @Provides | ||
| @Singleton | ||
| fun provideSharedPreferences(@ApplicationContext context: Context): SharedPreferences = | ||
| PreferenceManager.getDefaultSharedPreferences(context) | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| fun provideOpenActivity( | ||
| @ApplicationContext context: Context, | ||
| ): OpenErrorActivity = OpenErrorActivity(context) | ||
| } |
56 changes: 56 additions & 0 deletions
56
app/src/main/java/org/schabi/newpipe/dependency_injection/DatabaseModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package org.schabi.newpipe.dependency_injection | ||
|
|
||
| import android.content.Context | ||
| import androidx.room.Room | ||
| import dagger.Module | ||
| import dagger.Provides | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import dagger.hilt.components.SingletonComponent | ||
| import org.schabi.newpipe.database.AppDatabase | ||
| import org.schabi.newpipe.database.AppDatabase.DATABASE_NAME | ||
| import org.schabi.newpipe.database.Migrations.MIGRATION_1_2 | ||
| import org.schabi.newpipe.database.Migrations.MIGRATION_2_3 | ||
| import org.schabi.newpipe.database.Migrations.MIGRATION_3_4 | ||
| import org.schabi.newpipe.database.Migrations.MIGRATION_4_5 | ||
| import org.schabi.newpipe.database.Migrations.MIGRATION_5_6 | ||
| import org.schabi.newpipe.database.Migrations.MIGRATION_6_7 | ||
| import org.schabi.newpipe.database.Migrations.MIGRATION_7_8 | ||
| import org.schabi.newpipe.database.Migrations.MIGRATION_8_9 | ||
| import org.schabi.newpipe.database.history.dao.SearchHistoryDAO | ||
| import org.schabi.newpipe.database.history.dao.StreamHistoryDAO | ||
| import org.schabi.newpipe.database.stream.dao.StreamDAO | ||
| import org.schabi.newpipe.database.stream.dao.StreamStateDAO | ||
| import javax.inject.Singleton | ||
|
|
||
| @InstallIn(SingletonComponent::class) | ||
| @Module | ||
| class DatabaseModule { | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| fun provideAppDatabase(@ApplicationContext appContext: Context): AppDatabase = | ||
| Room.databaseBuilder( | ||
| appContext, | ||
| AppDatabase::class.java, | ||
| DATABASE_NAME | ||
| ).addMigrations( | ||
| MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, | ||
| MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9 | ||
| ).build() | ||
|
|
||
| @Provides | ||
| fun provideStreamStateDao(appDatabase: AppDatabase): StreamStateDAO = | ||
| appDatabase.streamStateDAO() | ||
|
|
||
| @Provides | ||
| fun providesStreamDao(appDatabase: AppDatabase): StreamDAO = appDatabase.streamDAO() | ||
|
|
||
| @Provides | ||
| fun provideStreamHistoryDao(appDatabase: AppDatabase): StreamHistoryDAO = | ||
| appDatabase.streamHistoryDAO() | ||
|
|
||
| @Provides | ||
| fun provideSearchHistoryDao(appDatabase: AppDatabase): SearchHistoryDAO = | ||
| appDatabase.searchHistoryDAO() | ||
| } |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/org/schabi/newpipe/error/usecases/OpenErrorActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package org.schabi.newpipe.error.usecases | ||
|
|
||
| import android.content.Context | ||
| import android.content.Intent | ||
| import org.schabi.newpipe.error.ErrorActivity | ||
| import org.schabi.newpipe.error.ErrorInfo | ||
|
|
||
| class OpenErrorActivity( | ||
| private val context: Context, | ||
| ) { | ||
| operator fun invoke(errorInfo: ErrorInfo) { | ||
| val intent = Intent(context, ErrorActivity::class.java) | ||
| intent.putExtra(ErrorActivity.ERROR_INFO, errorInfo) | ||
| intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
|
|
||
| context.startActivity(intent) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.