-
Notifications
You must be signed in to change notification settings - Fork 132
feat(widget): add adaptive card & circular desktop widgets #1006
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
SteveZMTstudios
wants to merge
12
commits into
FoedusProgramme:beta
Choose a base branch
from
SteveZMTstudios:feat/desktop-widgets
base: beta
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
12 commits
Select commit
Hold shift + click to select a range
3312803
feat(widget): add adaptive card & circular desktop widgets
SteveZMTstudios b896234
fix(widget): complete playback service updates and clean extraneous s…
SteveZMTstudios a42ee69
refactor(widget): decouple widget view building and state handling in…
SteveZMTstudios 9ec0981
refactor(widget): remove circular progress bar and switch to event-dr…
SteveZMTstudios 3431091
refactor(widget): remove unused createMediaSessionBitmapLoader method
SteveZMTstudios cfeb2ee
fix(widget): pass prefs and notification lyric callback to EndedWorka…
SteveZMTstudios 12cd5d1
fix(widget): clean leftover unused methods and restore notification l…
SteveZMTstudios eeffa81
refactor(widget): reuse controller.setRating for favorite toggle
SteveZMTstudios 5acc5c2
fix(widget): address PR review comments
SteveZMTstudios 1e84dda
fix(widget): address review v3 layout fixes, storage isolation, and a…
SteveZMTstudios 4c290ee
feat(widget): add widget theme settings, preview images, and fix cove…
SteveZMTstudios 5c830a9
fix(widget): adjusted the button display for narrow cards.
SteveZMTstudios 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 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
81 changes: 81 additions & 0 deletions
81
app/src/main/java/org/akanework/gramophone/ui/CardWidgetProvider.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,81 @@ | ||
| /* | ||
| * Copyright (C) 2026 SteveZMTstudios | ||
| * | ||
| * Gramophone is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * Gramophone is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package org.akanework.gramophone.ui | ||
|
|
||
| import android.appwidget.AppWidgetManager | ||
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.widget.RemoteViews | ||
| import androidx.media3.common.Player | ||
| import org.akanework.gramophone.logic.GramophonePlaybackService | ||
| import org.akanework.gramophone.ui.widget.BaseWidgetProvider | ||
| import org.akanework.gramophone.ui.widget.CardWidgetActions | ||
| import org.akanework.gramophone.ui.widget.CardWidgetPlaybackState | ||
| import org.akanework.gramophone.ui.widget.CardWidgetStore | ||
| import org.akanework.gramophone.ui.widget.CardWidgetViewsBuilder | ||
| import org.akanework.gramophone.ui.widget.DesktopWidgetManager | ||
|
|
||
| class CardWidgetProvider : BaseWidgetProvider() { | ||
|
|
||
| override fun buildViews( | ||
| context: Context, | ||
| appWidgetManager: AppWidgetManager, | ||
| appWidgetId: Int, | ||
| state: CardWidgetPlaybackState, | ||
| actions: CardWidgetActions | ||
| ): RemoteViews { | ||
| return CardWidgetViewsBuilder.buildCardResponsiveRemoteViews( | ||
| context, appWidgetManager, appWidgetId, state, actions | ||
| ) | ||
| } | ||
|
|
||
| override fun onReceive(context: Context, intent: Intent) { | ||
| super.onReceive(context, intent) | ||
| val action = intent.action ?: return | ||
| handleWidgetAction(context, action) | ||
| } | ||
|
|
||
| private fun handleWidgetAction(context: Context, action: String) { | ||
| val service = GramophonePlaybackService.instanceForWidgetAndLyricsOnly | ||
| val player = service?.endedWorkaroundPlayer | ||
| if (service != null && player != null) { | ||
| when (action) { | ||
| ACTION_REPEAT -> { | ||
| player.repeatMode = nextRepeatMode(player.repeatMode) | ||
| } | ||
| ACTION_SHUFFLE -> { | ||
| player.shuffleModeEnabled = !player.shuffleModeEnabled | ||
| } | ||
| ACTION_FAVORITE -> { | ||
| service.toggleCurrentItemFavorite() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
|
|
||
| fun nextRepeatMode(currentMode: Int): Int = when (currentMode) { | ||
| Player.REPEAT_MODE_OFF -> Player.REPEAT_MODE_ALL | ||
| Player.REPEAT_MODE_ALL -> Player.REPEAT_MODE_ONE | ||
| Player.REPEAT_MODE_ONE -> Player.REPEAT_MODE_OFF | ||
| else -> Player.REPEAT_MODE_OFF | ||
| } | ||
| } | ||
| } | ||
|
|
41 changes: 41 additions & 0 deletions
41
app/src/main/java/org/akanework/gramophone/ui/CircleWidgetProvider.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,41 @@ | ||
| /* | ||
| * Copyright (C) 2026 SteveZMTstudios | ||
| * | ||
| * Gramophone is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * Gramophone is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package org.akanework.gramophone.ui | ||
|
|
||
| import android.appwidget.AppWidgetManager | ||
| import android.content.Context | ||
| import android.widget.RemoteViews | ||
| import org.akanework.gramophone.ui.widget.BaseWidgetProvider | ||
| import org.akanework.gramophone.ui.widget.CardWidgetActions | ||
| import org.akanework.gramophone.ui.widget.CardWidgetPlaybackState | ||
| import org.akanework.gramophone.ui.widget.CardWidgetViewsBuilder | ||
|
|
||
| class CircleWidgetProvider : BaseWidgetProvider() { | ||
|
|
||
| override fun buildViews( | ||
| context: Context, | ||
| appWidgetManager: AppWidgetManager, | ||
| appWidgetId: Int, | ||
| state: CardWidgetPlaybackState, | ||
| actions: CardWidgetActions | ||
| ): RemoteViews { | ||
| return CardWidgetViewsBuilder.buildCircleResponsiveRemoteViews( | ||
| context, appWidgetManager, appWidgetId, state, actions | ||
| ) | ||
| } | ||
| } |
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.