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
* @return The corresponding mark.
*/
public static synchronized String boolToMark(boolean value)
public static String boolToMark(boolean value)
{
if (value)
return "✔️";

View File

@ -370,8 +370,7 @@ class NavigationActivity : AppCompatActivity() {
}
private fun setMenuForServerSetting() {
if (isOffline())
{
if (isOffline()) {
chatMenuItem?.isVisible = false
bookmarksMenuItem?.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) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE ServerSetting ADD COLUMN chatSupport 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)")
database.execSQL(
"ALTER TABLE ServerSetting ADD COLUMN chatSupport 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,
"ultrasonic-database"
)
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.fallbackToDestructiveMigrationOnDowngrade()
.build()
}

View File

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