Commit b769ff41 authored by Daniel Sonck's avatar Daniel Sonck
Browse files

[THFMA-27] Add responsive widget layout

- The widget now allows dynamic content based on the width for supported
Android versions
- Updated release notes and description
parent 3ddc178b
...@@ -2,14 +2,20 @@ package fm.touhou.touhoufm.widget ...@@ -2,14 +2,20 @@ package fm.touhou.touhoufm.widget
import android.app.PendingIntent import android.app.PendingIntent
import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_IDS
import android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH
import android.appwidget.AppWidgetProvider import android.appwidget.AppWidgetProvider
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.support.v4.media.MediaMetadataCompat.* import android.support.v4.media.MediaMetadataCompat.*
import android.support.v4.media.session.PlaybackStateCompat import android.support.v4.media.session.PlaybackStateCompat
import android.support.v4.media.session.PlaybackStateCompat.ACTION_PLAY_PAUSE import android.support.v4.media.session.PlaybackStateCompat.ACTION_PLAY_PAUSE
import android.support.v4.media.session.PlaybackStateCompat.STATE_PLAYING import android.support.v4.media.session.PlaybackStateCompat.STATE_PLAYING
import android.view.View.GONE
import android.view.View.VISIBLE
import android.widget.RemoteViews import android.widget.RemoteViews
import androidx.media.session.MediaButtonReceiver import androidx.media.session.MediaButtonReceiver
import fm.touhou.touhoufm.BuildConfig import fm.touhou.touhoufm.BuildConfig
...@@ -23,7 +29,42 @@ import fm.touhou.touhoufm.utils.buildPkgString ...@@ -23,7 +29,42 @@ import fm.touhou.touhoufm.utils.buildPkgString
*/ */
open class ControlsWidget : AppWidgetProvider() { open class ControlsWidget : AppWidgetProvider() {
protected open fun getLayout(): Int { protected open fun getLayout(): Int {
return R.layout.controls_widget return R.layout.widget_full
}
override fun onAppWidgetOptionsChanged(context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int, newOptions: Bundle?) {
updateLayout(appWidgetManager, appWidgetId)
super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions)
}
private fun updateLayout(appWidgetManager: AppWidgetManager, appWidgetId: Int) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
val options = appWidgetManager.getAppWidgetOptions(appWidgetId)
val minWidth = getCellsForSize(options.getInt(OPTION_APPWIDGET_MIN_WIDTH))
val views = RemoteViews(BuildConfig.APPLICATION_ID, getLayout())
minWidth.let {
if (it > 0) {
views.setViewVisibility(R.id.song_info, if (it > 3) VISIBLE else GONE)
views.setViewVisibility(R.id.button_play, if (it > 2) VISIBLE else GONE)
appWidgetManager.partiallyUpdateAppWidget(appWidgetId, views)
}
}
}
}
private fun getCellsForSize(size: Int): Int {
var n = 2
while (70 * n - 30 < size) {
++n
}
return n - 1
} }
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) { override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
...@@ -31,7 +72,7 @@ open class ControlsWidget : AppWidgetProvider() { ...@@ -31,7 +72,7 @@ open class ControlsWidget : AppWidgetProvider() {
onReceive(context, Intent(ACTION_WIDGET_INIT)) onReceive(context, Intent(ACTION_WIDGET_INIT))
context.sendBroadcast(Intent(ACTION_WIDGET_INIT).setPackage(BuildConfig.APPLICATION_ID)) context.sendBroadcast(Intent(ACTION_WIDGET_INIT).setPackage(BuildConfig.APPLICATION_ID).putExtra(EXTRA_APPWIDGET_IDS, appWidgetIds))
// There may be multiple widgets active, so update all of them // There may be multiple widgets active, so update all of them
// updateAppWidget(context, appWidgetManager, appWidgetIds) // updateAppWidget(context, appWidgetManager, appWidgetIds)
} }
...@@ -116,6 +157,7 @@ open class ControlsWidget : AppWidgetProvider() { ...@@ -116,6 +157,7 @@ open class ControlsWidget : AppWidgetProvider() {
val EXTRA_MEDIA_METADATA = "media".buildPkgString() val EXTRA_MEDIA_METADATA = "media".buildPkgString()
val EXTRA_PLAYBACK_STATE = "playback".buildPkgString() val EXTRA_PLAYBACK_STATE = "playback".buildPkgString()
val EXTRA_WIDGET_WIDTH = "width".buildPkgString()
} }
} }
Deze applicatie verbindt met de TouHou.FM radio. Deze radio streamt originele en doujin muziek van Touhou Project door TeamShanghaiAlice.
Dit is momenteel een Alpha versie. Niet alles is geïmplementeerd en er kunnen bugs zijn.
Voor bugs, suggesties, hulp, positieve of negatieve berichten, stuur deze naar app@touhou.fm.
Luister naar de radio direct vanaf je telefoon, tablet of ander apparaat
Radiospeler voor TouHou.FM
\ No newline at end of file
Fixed memoryleak in decoder causing slowness of the OS and random app crashes Fixed metadata information
Newer streaming technology which should improve streaming over low bandwidth connections. Stability improvements
\ No newline at end of file Added widget support
\ No newline at end of file
Une nouvelle technologie de streaming qui devrait améliorer le streaming avec des connexions à bas débits. Une meilleure mise en page qui rend plus facile l'accès aux paramètres, la connexion à votre compte et est plus cohérente pour les images. Correction des métadonnées des musiques
\ No newline at end of file Amélioration de la stabilité
Implémentation d'un widget
\ No newline at end of file
Új streamelési technológia mely magasabb minőségű hangot eredményez alacsonyabb sávszélességű csatlakozásoknál. Javított törzsadat információ
Jobb grafikai kezelőfelület mely konzisztensebb a telefon két módja közt. Nőtt a stabilitást
Widget támogatás hozzáadva
\ No newline at end of file
Metadata informatie gefixt
Stabiliteitsverbeteringen
Widget ondersteuning toegevoegd
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<LinearLayout <LinearLayout
android:id="@+id/song_info"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -32,5 +32,22 @@ ...@@ -32,5 +32,22 @@
<string name="unknown_album">Unknown Album</string> <string name="unknown_album">Unknown Album</string>
<string name="unknown_artist">Unknown Artist</string> <string name="unknown_artist">Unknown Artist</string>
<string name="unknown_circle">Unknown Circle</string> <string name="unknown_circle">Unknown Circle</string>
<string name="category_advanced_summary">Settings for power users</string>
<string name="category_advanced_title">Advanced</string>
<string name="category_streaming_summary">Tweaks for streaming quality and data cost</string>
<string name="category_streaming_title">Streaming</string>
<string name="home">Home</string>
<string name="keep_metadata_alive_summary">Keep the connection open to receive metadata updates. Will use data even when stopped</string>
<string name="keep_metadata_alive_title">Always request metadata</string>
<string name="settings">Settings</string>
<string name="show_data_summary">Show the data usage from streaming</string>
<string name="show_data_title">Data usage</string>
<string name="stream_custom_title">Use custom stream server</string>
<string name="stream_host_summary">Which address to use for streaming</string>
<string name="stream_host_title">Streaming Host</string>
<string name="stream_port_summary">Which port to use for streaming</string>
<string name="stream_port_title">Streaming Port</string>
<string name="streaming_rate_summary">Maximum bitrate to use</string>
<string name="streaming_rate_title">Streaming Bitrate</string>
</resources> </resources>
\ No newline at end of file
...@@ -30,4 +30,21 @@ ...@@ -30,4 +30,21 @@
<string name="unknown_album">Ismeretlen album</string> <string name="unknown_album">Ismeretlen album</string>
<string name="unknown_circle">Ismeretlen kör</string> <string name="unknown_circle">Ismeretlen kör</string>
<string name="unknown_song">"Ismeretlen szám "</string> <string name="unknown_song">"Ismeretlen szám "</string>
<string name="home">Főmenű</string>
<string name="settings">Beállítások</string>
<string name="stream_port_summary">Melyik portot szeretné streaminghez használni</string>
<string name="stream_port_title">Streaming Port</string>
<string name="stream_custom_title">Egyéni stream server használata</string>
<string name="stream_host_summary">Melyik címet szeretné streameléshez használni</string>
<string name="stream_host_title">Streaming Host</string>
<string name="category_advanced_summary">Beállítások erőfelhasználóknak</string>
<string name="category_advanced_title">Haladó</string>
<string name="keep_metadata_alive_summary">Hagyja a csatlakozást életben a törzsadat frissítéséhez. Még akkor is felhasznál adatot, ha meg van állítva</string>
<string name="keep_metadata_alive_title">Mindig kérjen törzsadatot</string>
<string name="show_data_summary">Mutassa a streamelésből származó adathasználatot</string>
<string name="show_data_title">Adathasználat</string>
<string name="streaming_rate_title">Streaming bitráta</string>
<string name="streaming_rate_summary">Maximum használandó bitráta</string>
<string name="category_streaming_title">Streaming</string>
<string name="category_streaming_summary">A streamelés árával és minőségével kapcsolatos beállítások</string>
</resources> </resources>
\ No newline at end of file
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
<string name="label_pause">Pause</string> <string name="label_pause">Pause</string>
<string name="label_play">Play</string> <string name="label_play">Play</string>
<string name="label_play_pause">Play and pause toggle</string> <string name="label_play_pause">Play and pause toggle</string>
<string name="time_format">%2$d:%1$02d</string> <string name="time_format">%2$d:%1$02d</string><!-- MM:SS -->
<string name="album_format">( %1$s )</string> <string name="album_format">( %1$s )</string><!-- ( <album name> ) -->
<string name="artist_circle_format">%1$s ( %2$s )</string> <string name="artist_circle_format">%1$s ( %2$s )</string><!-- <artist name> ( <circle name> ) -->
<string name="unknown_song">Unknown Song</string> <string name="unknown_song">Unknown Song</string>
<string name="unknown_album">Unknown Album</string> <string name="unknown_album">Unknown Album</string>
<string name="unknown_artist">Unknown Artist</string> <string name="unknown_artist">Unknown Artist</string>
......
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/widget_full"
android:minHeight="40dp"
android:minWidth="40dp"
android:previewImage="@drawable/example_appwidget_preview"
android:resizeMode="horizontal"
android:updatePeriodMillis="1000" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/controls_widget" android:initialKeyguardLayout="@layout/widget_full"
android:initialLayout="@layout/controls_widget" android:initialLayout="@layout/widget_full"
android:minHeight="40dp" android:minHeight="40dp"
android:minWidth="110dp" android:minWidth="40dp"
android:previewImage="@drawable/example_appwidget_preview" android:previewImage="@drawable/example_appwidget_preview"
android:resizeMode="horizontal|vertical" android:resizeMode="horizontal"
android:updatePeriodMillis="1000" android:updatePeriodMillis="1000"
android:widgetCategory="home_screen" /> android:widgetCategory="home_screen" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/controls_widget" android:initialLayout="@layout/widget_full"
android:minHeight="40dp" android:minHeight="40dp"
android:minWidth="110dp" android:minWidth="300dp"
android:previewImage="@drawable/example_appwidget_preview" android:previewImage="@drawable/example_appwidget_preview"
android:resizeMode="horizontal|vertical" android:resizeMode="horizontal"
android:updatePeriodMillis="1000" /> android:updatePeriodMillis="1000" />
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment