Fix lintFormat + remove synchronized

This commit is contained in:
Maxence G 2021-05-25 18:51:00 +02:00
parent 1b7f48c53a
commit 070e0ac792
No known key found for this signature in database
GPG Key ID: DC1FD9409E3FE284
5 changed files with 50 additions and 26 deletions

View File

@ -365,7 +365,7 @@ public class Util
* @param value Is true or false * @param value Is true or false
* @return The corresponding mark. * @return The corresponding mark.
*/ */
public static synchronized String boolToMark(boolean value) public static String boolToMark(boolean value)
{ {
if (value) if (value)
return "✔️"; return "✔️";

View File

@ -370,8 +370,7 @@ class NavigationActivity : AppCompatActivity() {
} }
private fun setMenuForServerSetting() { private fun setMenuForServerSetting() {
if (isOffline()) if (isOffline()) {
{
chatMenuItem?.isVisible = false chatMenuItem?.isVisible = false
bookmarksMenuItem?.isVisible = false bookmarksMenuItem?.isVisible = false
sharesMenuItem?.isVisible = false sharesMenuItem?.isVisible = false

View File

@ -27,9 +27,17 @@ val MIGRATION_1_2: Migration = object : Migration(1, 2) {
val MIGRATION_2_3: Migration = object : Migration(2, 3) { val MIGRATION_2_3: Migration = object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) { override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE ServerSetting ADD COLUMN chatSupport INTEGER NOT NULL DEFAULT(1)") database.execSQL(
database.execSQL("ALTER TABLE ServerSetting ADD COLUMN bookmarkSupport INTEGER NOT NULL DEFAULT(1)") "ALTER TABLE ServerSetting ADD COLUMN chatSupport INTEGER NOT NULL DEFAULT(1)"
database.execSQL("ALTER TABLE ServerSetting ADD COLUMN shareSupport INTEGER NOT NULL DEFAULT(1)") )
database.execSQL("ALTER TABLE ServerSetting ADD COLUMN podcastSupport INTEGER NOT NULL DEFAULT(1)") database.execSQL(
"ALTER TABLE ServerSetting ADD COLUMN bookmarkSupport INTEGER NOT NULL DEFAULT(1)"
)
database.execSQL(
"ALTER TABLE ServerSetting ADD COLUMN shareSupport INTEGER NOT NULL DEFAULT(1)"
)
database.execSQL(
"ALTER TABLE ServerSetting ADD COLUMN podcastSupport INTEGER NOT NULL DEFAULT(1)"
)
} }
} }

View File

@ -25,8 +25,8 @@ val appPermanentStorage = module {
AppDatabase::class.java, AppDatabase::class.java,
"ultrasonic-database" "ultrasonic-database"
) )
.addMigrations(MIGRATION_1_2) .addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3) .addMigrations(MIGRATION_2_3)
.fallbackToDestructiveMigrationOnDowngrade() .fallbackToDestructiveMigrationOnDowngrade()
.build() .build()
} }

View File

@ -303,7 +303,8 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
@Throws(Throwable::class) @Throws(Throwable::class)
override fun doInBackground(): String { override fun doInBackground(): String {
var progressString = """ var progressString =
"""
|%s - ${activity.resources.getString(R.string.button_bar_chat)} |%s - ${activity.resources.getString(R.string.button_bar_chat)}
|%s - ${activity.resources.getString(R.string.button_bar_bookmarks)} |%s - ${activity.resources.getString(R.string.button_bar_bookmarks)}
|%s - ${activity.resources.getString(R.string.button_bar_shares)} |%s - ${activity.resources.getString(R.string.button_bar_shares)}
@ -345,30 +346,42 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
true true
} catch (e: Throwable) { false } } catch (e: Throwable) { false }
updateProgress(String.format(progressString, updateProgress(
String.format(
progressString,
Util.boolToMark(currentServerSetting!!.chatSupport), Util.boolToMark(currentServerSetting!!.chatSupport),
"", "", "")) "", "", ""
)
)
currentServerSetting!!.bookmarkSupport = try { currentServerSetting!!.bookmarkSupport = try {
subsonicApiClient.api.getBookmarks().execute() subsonicApiClient.api.getBookmarks().execute()
true true
} catch (e: Throwable) { false } } catch (e: Throwable) { false }
updateProgress(String.format(progressString, updateProgress(
String.format(
progressString,
Util.boolToMark(currentServerSetting!!.chatSupport), Util.boolToMark(currentServerSetting!!.chatSupport),
Util.boolToMark(currentServerSetting!!.bookmarkSupport), Util.boolToMark(currentServerSetting!!.bookmarkSupport),
"", "")) "", ""
)
)
currentServerSetting!!.shareSupport = try { currentServerSetting!!.shareSupport = try {
subsonicApiClient.api.getShares().execute() subsonicApiClient.api.getShares().execute()
true true
} catch (e: Throwable) { false } } catch (e: Throwable) { false }
updateProgress(String.format(progressString, updateProgress(
String.format(
progressString,
Util.boolToMark(currentServerSetting!!.chatSupport), Util.boolToMark(currentServerSetting!!.chatSupport),
Util.boolToMark(currentServerSetting!!.bookmarkSupport), Util.boolToMark(currentServerSetting!!.bookmarkSupport),
Util.boolToMark(currentServerSetting!!.shareSupport), Util.boolToMark(currentServerSetting!!.shareSupport),
"")) ""
)
)
currentServerSetting!!.podcastSupport = try { currentServerSetting!!.podcastSupport = try {
subsonicApiClient.api.getPodcasts().execute() subsonicApiClient.api.getPodcasts().execute()
@ -376,27 +389,31 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
} catch (e: Throwable) { false } } catch (e: Throwable) { false }
// Finalize String before displaying it to Dialog // Finalize String before displaying it to Dialog
progressString = String.format(progressString, progressString = String.format(
Util.boolToMark(currentServerSetting!!.chatSupport), progressString,
Util.boolToMark(currentServerSetting!!.bookmarkSupport), Util.boolToMark(currentServerSetting!!.chatSupport),
Util.boolToMark(currentServerSetting!!.shareSupport), Util.boolToMark(currentServerSetting!!.bookmarkSupport),
Util.boolToMark(currentServerSetting!!.podcastSupport)) Util.boolToMark(currentServerSetting!!.shareSupport),
Util.boolToMark(currentServerSetting!!.podcastSupport)
)
updateProgress(progressString) updateProgress(progressString)
val licenseResponse = subsonicApiClient.api.getLicense().execute() val licenseResponse = subsonicApiClient.api.getLicense().execute()
ApiCallResponseChecker.checkResponseSuccessful(licenseResponse) ApiCallResponseChecker.checkResponseSuccessful(licenseResponse)
if (!licenseResponse.body()!!.license.valid) { if (!licenseResponse.body()!!.license.valid) {
progressString += "\n${activity.resources.getString(R.string.settings_testing_unlicensed)}" progressString += "\n" +
activity.resources.getString(R.string.settings_testing_unlicensed)
} }
return progressString return progressString
} }
override fun done(responseString: String) { override fun done(responseString: String) {
Util.showDialog( Util.showDialog(
activity, activity,
android.R.drawable.ic_dialog_info, android.R.drawable.ic_dialog_info,
R.string.settings_testing_ok, R.string.settings_testing_ok,
responseString) responseString
)
} }
override fun error(error: Throwable) { override fun error(error: Throwable) {