Merge branch 'develop' into remove-flash

This commit is contained in:
tzugen 2021-06-14 19:10:56 +02:00 committed by GitHub
commit bc295a825b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 87 additions and 45 deletions

View File

@ -29,7 +29,6 @@ import androidx.preference.PreferenceManager
import com.google.android.material.navigation.NavigationView
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.java.KoinJavaComponent.inject
import org.moire.ultrasonic.R
import org.moire.ultrasonic.data.ActiveServerProvider
import org.moire.ultrasonic.data.ActiveServerProvider.Companion.isOffline
@ -151,7 +150,12 @@ class NavigationActivity : AppCompatActivity() {
showWelcomeScreen = showWelcomeScreen and !areServersMigrated
loadSettings()
showInfoDialog(showWelcomeScreen)
// This is a first run with only the demo entry inside the database
// We set the active server to the demo one and show the welcome dialog
if (showWelcomeScreen) {
showWelcomeDialog()
}
nowPlayingEventListener = object : NowPlayingEventListener {
override fun onDismissNowPlaying() {
@ -313,19 +317,27 @@ class NavigationActivity : AppCompatActivity() {
finish()
}
private fun showInfoDialog(show: Boolean) {
private fun showWelcomeDialog() {
if (!infoDialogDisplayed) {
infoDialogDisplayed = true
if (show) {
AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_info)
.setTitle(R.string.main_welcome_title)
.setMessage(R.string.main_welcome_text)
.setPositiveButton(R.string.common_ok) { dialog, _ ->
dialog.dismiss()
findNavController(R.id.nav_host_fragment).navigate(R.id.settingsFragment)
}.show()
}
AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_info)
.setTitle(R.string.main_welcome_title)
.setMessage(R.string.main_welcome_text_demo)
.setNegativeButton(R.string.main_welcome_cancel) { dialog, _ ->
// Go to the settings screen
dialog.dismiss()
findNavController(R.id.nav_host_fragment).navigate(R.id.settingsFragment)
}
.setPositiveButton(R.string.common_ok) { dialog, _ ->
// Add the demo server
val activeServerProvider: ActiveServerProvider by inject()
val demoIndex = serverSettingsModel.addDemoServer()
activeServerProvider.setActiveServerByIndex(demoIndex)
findNavController(R.id.nav_host_fragment).navigate(R.id.mainFragment)
dialog.dismiss()
}.show()
}
}

View File

@ -12,6 +12,7 @@ import org.moire.ultrasonic.fragment.ServerSettingsModel
import org.moire.ultrasonic.util.Util
const val SP_NAME = "Default_SP"
const val DB_FILENAME = "ultrasonic-database"
/**
* This Koin module contains registration of classes related to permanent storage
@ -23,11 +24,10 @@ val appPermanentStorage = module {
Room.databaseBuilder(
androidContext(),
AppDatabase::class.java,
"ultrasonic-database"
DB_FILENAME
)
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.fallbackToDestructiveMigrationOnDowngrade()
.build()
}

View File

@ -11,6 +11,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.moire.ultrasonic.R
import org.moire.ultrasonic.app.UApp
import org.moire.ultrasonic.data.ActiveServerProvider
import org.moire.ultrasonic.data.ServerSetting
import org.moire.ultrasonic.data.ServerSettingDao
@ -25,20 +27,6 @@ class ServerSettingsModel(
application: Application
) : AndroidViewModel(application) {
companion object {
private const val PREFERENCES_KEY_SERVER_MIGRATED = "serverMigrated"
// These constants were removed from Constants.java as they are deprecated and only used here
private const val PREFERENCES_KEY_JUKEBOX_BY_DEFAULT = "jukeboxEnabled"
private const val PREFERENCES_KEY_SERVER_NAME = "serverName"
private const val PREFERENCES_KEY_SERVER_URL = "serverUrl"
private const val PREFERENCES_KEY_ACTIVE_SERVERS = "activeServers"
private const val PREFERENCES_KEY_USERNAME = "username"
private const val PREFERENCES_KEY_PASSWORD = "password"
private const val PREFERENCES_KEY_ALLOW_SELF_SIGNED_CERTIFICATE = "allowSSCertificate"
private const val PREFERENCES_KEY_LDAP_SUPPORT = "enableLdapSupport"
private const val PREFERENCES_KEY_MUSIC_FOLDER_ID = "musicFolderId"
}
private val appScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
/**
@ -67,8 +55,8 @@ class ServerSettingsModel(
repository.insert(newServerSetting)
index++
Timber.i(
"Imported server from Preferences to Database:" +
" ${newServerSetting.name}"
"Imported server from Preferences to Database: %s",
newServerSetting.name
)
}
}
@ -187,6 +175,23 @@ class ServerSettingsModel(
}
}
/**
* Inserts a new Setting into the database
* @return The id of the demo server
*/
fun addDemoServer(): Int {
val demo = DEMO_SERVER_CONFIG.copy()
runBlocking {
demo.index = (repository.count() ?: 0) + 1
demo.id = (repository.getMaxId() ?: 0) + 1
repository.insert(demo)
Timber.d("Added demo server")
}
return demo.id
}
/**
* Reads up a Server Setting stored in the obsolete Preferences
*/
@ -262,4 +267,36 @@ class ServerSettingsModel(
editor.putBoolean(PREFERENCES_KEY_SERVER_MIGRATED + preferenceId, true)
editor.apply()
}
companion object {
private const val PREFERENCES_KEY_SERVER_MIGRATED = "serverMigrated"
// These constants were removed from Constants.java as they are deprecated and only used here
private const val PREFERENCES_KEY_JUKEBOX_BY_DEFAULT = "jukeboxEnabled"
private const val PREFERENCES_KEY_SERVER_NAME = "serverName"
private const val PREFERENCES_KEY_SERVER_URL = "serverUrl"
private const val PREFERENCES_KEY_ACTIVE_SERVERS = "activeServers"
private const val PREFERENCES_KEY_USERNAME = "username"
private const val PREFERENCES_KEY_PASSWORD = "password"
private const val PREFERENCES_KEY_ALLOW_SELF_SIGNED_CERTIFICATE = "allowSSCertificate"
private const val PREFERENCES_KEY_LDAP_SUPPORT = "enableLdapSupport"
private const val PREFERENCES_KEY_MUSIC_FOLDER_ID = "musicFolderId"
private val DEMO_SERVER_CONFIG = ServerSetting(
id = 0,
index = 0,
name = UApp.applicationContext().getString(R.string.server_menu_demo),
url = "https://demo.ampache.dev",
userName = "ultrasonic_demo",
password = "W7DumQ3ZUR89Se3",
jukeboxByDefault = false,
allowSelfSignedCertificate = false,
ldapSupport = false,
musicFolderId = null,
minimumApiVersion = "1.13.0",
chatSupport = true,
bookmarkSupport = true,
shareSupport = true,
podcastSupport = true
)
}
}

View File

@ -101,7 +101,6 @@
<string name="main.songs_starred">Označené hvězdičkou</string>
<string name="main.songs_title">Skladby</string>
<string name="main.videos">Videa</string>
<string name="main.welcome_text">Vítejte v aplikaci Ultrasonic! Aplikace není ještě nakonfigurována. Poté co nastavíte svůj osobní server (dostupný na <b>subsonic.org</b>), vyberte <i>Správa serverů</i> v <b>Nastavení</b> a připojte aplikaci.</string>
<string name="main.welcome_title">Vítejte!</string>
<string name="menu.about">O aplikaci</string>
<string name="menu.common">Další</string>

View File

@ -100,7 +100,6 @@
<string name="main.songs_starred">Mit Stern</string>
<string name="main.songs_title">Titel</string>
<string name="main.videos">Filme</string>
<string name="main.welcome_text">Willkommen bei Ultrasonic! Die App ist zurzeit unkonfiguriert. Nachdem du deinen Server konfiguriert hast (siehe <b>subsonic.org</b>), bitte <i>Server hinzufügen</i> in den <b>Einstellungen</b> klicken um die Verbindun herzustellen.</string>
<string name="main.welcome_title">Willkommen</string>
<string name="menu.about">Über</string>
<string name="menu.common">Allgemein</string>

View File

@ -111,7 +111,6 @@
<string name="main.songs_starred">Me gusta</string>
<string name="main.songs_title">Canciones</string>
<string name="main.videos">Vídeos</string>
<string name="main.welcome_text">Te damos la bienvenida a Ultrasonic! La aplicación no está configurada actualmente. Después de que hayas configurado tu servidor personal (disponible desde <b>subsonic.org</b>), por favor haz click en <i>Administrar servidores</i> en <b>Configuración</b> para conectarte con él.</string>
<string name="main.welcome_title">¡Saludos!</string>
<string name="menu.about">Acerca de</string>
<string name="menu.common">Común</string>

View File

@ -101,7 +101,6 @@
<string name="main.songs_starred">Favoris</string>
<string name="main.songs_title">Titres</string>
<string name="main.videos">Vidéos</string>
<string name="main.welcome_text">Bienvenue dans Ultrasonic ! L\'application n\'est pas configurée. Après avoir configuré votre serveur personnel (disponible à partir de <b>subsonic.org</b>), veuillez accéder aux <b>Paramètres</b> et modifier la configuration pour vous y connecter.</string>
<string name="main.welcome_title">Bienvenue !</string>
<string name="menu.about">À propos</string>
<string name="menu.common">Général</string>

View File

@ -111,7 +111,6 @@
<string name="main.songs_starred">Csillaggal megjelölt</string>
<string name="main.songs_title">Dalok</string>
<string name="main.videos">Videók</string>
<string name="main.welcome_text">Üdvözli az Ultrasonic! Az alkalmazás még nincs beállítva. Miután konfigurálta saját kiszolgálóját (elérhető: <b>subsonic.org</b>), húzza balról jobbra az oldalsávot, lépjen be a <b>Beállítások</b> menüpontba, és adja meg csatlakozási adatokat!</string>
<string name="main.welcome_title">Üdvözlet!</string>
<string name="menu.about">Névjegy</string>
<string name="menu.common">Általános</string>

View File

@ -111,7 +111,6 @@
<string name="main.songs_starred">Favorieten</string>
<string name="main.songs_title">Nummers</string>
<string name="main.videos">Video\'s</string>
<string name="main.welcome_text">Welkom bij Ultrasonic! De app is nog niet ingesteld. Nadat je je persoonlijke server hebt opgezet (beschikbaar op <b>subsonic.org</b>), kun je naar de <b>Instellingen</b> gaan en drukken op <i>Server toevoegen</i>.</string>
<string name="main.welcome_title">Welkom!</string>
<string name="menu.about">Over</string>
<string name="menu.common">Algemeen</string>

View File

@ -100,7 +100,6 @@
<string name="main.songs_starred">Ulubione</string>
<string name="main.songs_title">Utwory</string>
<string name="main.videos">Klipy wideo</string>
<string name="main.welcome_text">Witaj w Ultrasonic! Obecnie aplikacja nie jest skonfigurowana. Jeśli masz uruchomiony własny serwer (dostępny na <b>subsonic.org</b>), proszę wybrać <i>Dodaj serwer</i> w <b>Ustawieniach</b> aby się z nim połączyć.</string>
<string name="main.welcome_title">Witaj!</string>
<string name="menu.about">O aplikacji</string>
<string name="menu.common">Wspólne</string>

View File

@ -101,7 +101,6 @@
<string name="main.songs_starred">Favoritas</string>
<string name="main.songs_title">Músicas</string>
<string name="main.videos">Vídeos</string>
<string name="main.welcome_text">Bem-vindo ao Ultrasonic! O aplicativo ainda não está configurado. Após configurar seu servidor pessoal (disponível em <b>subsonic.org</b>), clique em <i>Adicionar Servidor</i> em <b>Configurações</b> para a conexão.</string>
<string name="main.welcome_title">Bem-vindo!</string>
<string name="menu.about">Sobre</string>
<string name="menu.common">Comum</string>

View File

@ -100,7 +100,6 @@
<string name="main.songs_starred">Favoritas</string>
<string name="main.songs_title">Músicas</string>
<string name="main.videos">Vídeos</string>
<string name="main.welcome_text">Bem-vindo ao Ultrasonic! O aplicativo ainda não está configurado. Após configurar seu servidor pessoal (disponível em <b>subsonic.org</b>), clique em <i>Adicionar Servidor</i> em <b>Configurações</b> para a conexão.</string>
<string name="main.welcome_title">Bem-vindo!</string>
<string name="menu.about">Sobre</string>
<string name="menu.common">Comum</string>

View File

@ -111,8 +111,9 @@
<string name="main.songs_starred">Starred</string>
<string name="main.songs_title">Songs</string>
<string name="main.videos">Videos</string>
<string name="main.welcome_text">Welcome to Ultrasonic! The app is currently not configured. After you\'ve set up your personal server (available from <b>subsonic.org</b>), please click <i>Manage Servers</i> in <b>Settings</b> to connect to it.</string>
<string name="main.welcome_title">Welcome!</string>
<string name="main.welcome_text_demo">To use Ultrasonic with your own music you will need your <b>own server</b>. \n\n➤ In case you want to try out the app first, it can add a demo server now. \n\n➤ Otherwise you can configure your server in the <b>settings</b>.</string>
<string name="main.welcome_title">Welcome to Ultrasonic!</string>
<string name="main.welcome_cancel">Take me to the settings</string>
<string name="menu.about">About</string>
<string name="menu.common">Common</string>
<string name="menu.deleted_playlist">Deleted playlist %s</string>
@ -342,7 +343,7 @@
<string name="util.bytes_format.gigabyte">0.00 GB</string>
<string name="util.bytes_format.kilobyte">0 KB</string>
<string name="util.bytes_format.megabyte">0.00 MB</string>
<string name="util.no_time">-:--</string>
<string name="util.no_time" tools:ignore="TypographyDashes">-:--</string>
<string name="util.zero_time">0:00</string>
<string name="widget.initial_text">Touch to select music</string>
<string name="widget.sdcard_busy">SD card unavailable</string>
@ -438,6 +439,7 @@
<string name="server_editor.authentication">Authentication</string>
<string name="server_editor.advanced">Advanced settings</string>
<string name="server_editor.disabled_feature">One or more features were disabled because the server doesn\'t support them.\nYou can run this test again anytime.</string>
<string name="server_menu.demo">Demo Server</string>
<plurals name="select_album_n_songs">
<item quantity="one">1 song</item>

View File

@ -70,13 +70,13 @@
a:key="playbackControlSettings"
app:iconSpaceReserved="false">
<CheckBoxPreference
a:defaultValue="false"
a:defaultValue="true"
a:key="useId3Tags"
a:summary="@string/settings.use_id3_summary"
a:title="@string/settings.use_id3"
app:iconSpaceReserved="false"/>
<CheckBoxPreference
a:defaultValue="false"
a:defaultValue="true"
a:key="showArtistPicture"
a:summary="@string/settings.show_artist_picture_summary"
a:title="@string/settings.show_artist_picture"