-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Migrate “History and Cache” to Jetpack Compose #11494
base: refactor
Are you sure you want to change the base?
Conversation
@snaik20 can you review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty decent, thank you! In particular, the addition of Hilt will be useful.
That being said, I've suggested some improvements.
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) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better as a static method in the error activity class itself.
val clickModifier = if (enabled) { | ||
Modifier.clickable { onClick() } | ||
} else { | ||
Modifier | ||
} | ||
Row( | ||
modifier = clickModifier.then(modifier), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val clickModifier = if (enabled) { | |
Modifier.clickable { onClick() } | |
} else { | |
Modifier | |
} | |
Row( | |
modifier = clickModifier.then(modifier), | |
Row( | |
modifier = Modifier | |
.clickable(enabled, onClick = onClick) | |
.then(modifier), |
) = ComposeView(requireContext()).apply { | ||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) | ||
setContent { | ||
AppTheme { | ||
HistoryCacheSettingsScreen( | ||
modifier = Modifier.fillMaxSize() | ||
) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) = ComposeView(requireContext()).apply { | |
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) | |
setContent { | |
AppTheme { | |
HistoryCacheSettingsScreen( | |
modifier = Modifier.fillMaxSize() | |
) | |
} | |
} | |
} | |
) = content { | |
AppTheme { | |
HistoryCacheSettingsScreen(modifier = Modifier.fillMaxSize()) | |
} | |
} |
This requires the Fragment Compose dependency.
package org.schabi.newpipe.settings.domain.usecases.get_preference | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
fun interface GetPreference<T> { | ||
operator fun invoke(key: Int, defaultValue: T): Flow<T> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using DataStore might be a better option instead of adding custom classes for handling preferences.
89576ad
to
c3aa4e7
Compare
I rebased on current refactor & squashed, but I can’t get it to work. The hilt library is throwing weird injection errors:
|
Something I noticed: the old implementation seems to be still around, don’t we want to remove it? |
What is it?
Description of the changes in your PR
Before/After Screenshots/Screen Record
Before:
After:
Fixes the following issue(s)
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