" + e.getLocalizedMessage() + "
", "text/html", "UTF-8"); - } + // Inject color values for WebView body background and links + final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this); + final String backgroundColor = + colorToCSS( + ATHUtil.INSTANCE.resolveColor( + this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff"))); + final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000")); + final String changeLog = + buf.toString() + .replace( + "{style-placeholder}", + String.format( + "body { background-color: %s; color: %s; }", backgroundColor, contentColor)) + .replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this))) + .replace( + "{link-color-active}", + colorToCSS( + ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this)))); + webView.loadData(changeLog, "text/html", "UTF-8"); + } catch (Throwable e) { + webView.loadData( + "" + e.getLocalizedMessage() + "
", "text/html", "UTF-8"); } + } - @Override - public boolean onOptionsItemSelected(@NonNull MenuItem item) { - if (item.getItemId() == android.R.id.home) { - onBackPressed(); - return true; - } - return super.onOptionsItemSelected(item); + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + if (item.getItemId() == android.R.id.home) { + onBackPressed(); + return true; } + return super.onOptionsItemSelected(item); + } - private String colorToCSS(int color) { - return String.format("rgb(%d, %d, %d)", Color.red(color), Color.green(color), - Color.blue(color)); // on API 29, WebView doesn't load with hex colors - } + private String colorToCSS(int color) { + return String.format( + "rgb(%d, %d, %d)", + Color.red(color), + Color.green(color), + Color.blue(color)); // on API 29, WebView doesn't load with hex colors + } } diff --git a/app/src/main/java/io/github/muntashirakon/music/activities/LockScreenActivity.kt b/app/src/main/java/io/github/muntashirakon/music/activities/LockScreenActivity.kt index 872fb3469..0e7f498d8 100644 --- a/app/src/main/java/io/github/muntashirakon/music/activities/LockScreenActivity.kt +++ b/app/src/main/java/io/github/muntashirakon/music/activities/LockScreenActivity.kt @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2020 Hemanth Savarla. + * + * Licensed under the GNU General Public License v3 + * + * This 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. + * + * This software 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. + * + */ package io.github.muntashirakon.music.activities import android.app.KeyguardManager @@ -9,7 +23,8 @@ import android.view.WindowManager import androidx.core.view.ViewCompat import io.github.muntashirakon.music.R import io.github.muntashirakon.music.activities.base.AbsMusicServiceActivity -import io.github.muntashirakon.music.fragments.player.lockscreen.LockScreenPlayerControlsFragment +import io.github.muntashirakon.music.extensions.whichFragment +import io.github.muntashirakon.music.fragments.player.lockscreen.LockScreenControlsFragment import io.github.muntashirakon.music.glide.RetroMusicColoredTarget import io.github.muntashirakon.music.glide.SongGlideRequest import io.github.muntashirakon.music.helper.MusicPlayerRemote @@ -22,21 +37,12 @@ import com.r0adkll.slidr.model.SlidrPosition import kotlinx.android.synthetic.main.activity_lock_screen.* class LockScreenActivity : AbsMusicServiceActivity() { - private var fragment: LockScreenPlayerControlsFragment? = null + private var fragment: LockScreenControlsFragment? = null override fun onCreate(savedInstanceState: Bundle?) { setDrawUnderStatusBar() super.onCreate(savedInstanceState) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { - setShowWhenLocked(true) - setTurnScreenOn(true) - } else { - this.window.addFlags( - WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or - WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or - WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON - ) - } + lockScreenInit() setContentView(R.layout.activity_lock_screen) hideStatusBar() setStatusbarColorAuto() @@ -67,8 +73,7 @@ class LockScreenActivity : AbsMusicServiceActivity() { Slidr.attach(this, config) - fragment = - supportFragmentManager.findFragmentById(R.id.playback_controls_fragment) as LockScreenPlayerControlsFragment? + fragment = whichFragment" + e.getLocalizedMessage() + "
", "text/html", "UTF-8"); } - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - setDrawUnderStatusBar(); - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_whats_new); - setStatusbarColorAuto(); - setNavigationbarColorAuto(); - setTaskDescriptionColorAuto(); - - WebView webView = findViewById(R.id.webView); - Toolbar toolbar = findViewById(R.id.toolbar); - toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface)); - toolbar.setNavigationOnClickListener(v -> onBackPressed()); - ToolbarContentTintHelper.colorBackButton(toolbar); - - try { - StringBuilder buf = new StringBuilder(); - InputStream json = getAssets().open("retro-changelog.html"); - BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8)); - String str; - while ((str = in.readLine()) != null) { - buf.append(str); - } - in.close(); - - // Inject color values for WebView body background and links - final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this); - final int accentColor = ThemeStore.Companion.accentColor(this); - final String backgroundColor = colorToCSS(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff"))); - final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000")); - final String textColor = colorToCSS(Color.parseColor(isDark ? "#60FFFFFF" : "#80000000")); - final String accentColorString = colorToCSS(ThemeStore.Companion.accentColor(this)); - final String accentTextColor = colorToCSS(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.INSTANCE.isColorLight(accentColor))); - final String changeLog = buf.toString() - .replace("{style-placeholder}", String.format("body { background-color: %s; color: %s; } li {color: %s;} .colorHeader {background-color: %s; color: %s;} .tag {color: %s;}", backgroundColor, contentColor, textColor, accentColorString, accentTextColor, accentColorString)) - .replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this))) - .replace("{link-color-active}", colorToCSS(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this)))); - webView.loadData(changeLog, "text/html", "UTF-8"); - } catch (Throwable e) { - webView.loadData("" + e.getLocalizedMessage() + "
", "text/html", "UTF-8"); - } - setChangelogRead(this); - } -} \ No newline at end of file + setChangelogRead(this); + } +} diff --git a/app/src/main/java/io/github/muntashirakon/music/activities/base/AbsBaseActivity.kt b/app/src/main/java/io/github/muntashirakon/music/activities/base/AbsBaseActivity.kt index a797a2809..1f84a568c 100644 --- a/app/src/main/java/io/github/muntashirakon/music/activities/base/AbsBaseActivity.kt +++ b/app/src/main/java/io/github/muntashirakon/music/activities/base/AbsBaseActivity.kt @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2020 Hemanth Savarla. + * + * Licensed under the GNU General Public License v3 + * + * This 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. + * + * This software 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. + * + */ package io.github.muntashirakon.music.activities.base import android.Manifest @@ -12,8 +26,8 @@ import android.view.KeyEvent import android.view.View import androidx.core.app.ActivityCompat import code.name.monkey.appthemehelper.ThemeStore -import com.google.android.material.snackbar.Snackbar import io.github.muntashirakon.music.R +import com.google.android.material.snackbar.Snackbar abstract class AbsBaseActivity : AbsThemeActivity() { private var hadPermissions: Boolean = false @@ -46,7 +60,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() { override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) if (!hasPermissions()) { - //requestPermissions() + // requestPermissions() } } @@ -107,7 +121,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() { this@AbsBaseActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE ) ) { - //User has deny from permission dialog + // User has deny from permission dialog Snackbar.make( snackBarContainer, permissionDeniedMessage!!, diff --git a/app/src/main/java/io/github/muntashirakon/music/activities/base/AbsMusicServiceActivity.kt b/app/src/main/java/io/github/muntashirakon/music/activities/base/AbsMusicServiceActivity.kt index 9d10348df..9d8d3faf2 100644 --- a/app/src/main/java/io/github/muntashirakon/music/activities/base/AbsMusicServiceActivity.kt +++ b/app/src/main/java/io/github/muntashirakon/music/activities/base/AbsMusicServiceActivity.kt @@ -1,25 +1,44 @@ +/* + * Copyright (c) 2020 Hemanth Savarla. + * + * Licensed under the GNU General Public License v3 + * + * This 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. + * + * This software 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. + * + */ package io.github.muntashirakon.music.activities.base import android.Manifest -import android.content.* +import android.content.BroadcastReceiver +import android.content.ComponentName +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.content.ServiceConnection import android.os.Bundle import android.os.IBinder import androidx.lifecycle.lifecycleScope import io.github.muntashirakon.music.R import io.github.muntashirakon.music.db.toPlayCount import io.github.muntashirakon.music.helper.MusicPlayerRemote -import io.github.muntashirakon.music.interfaces.MusicServiceEventListener +import io.github.muntashirakon.music.interfaces.IMusicServiceEventListener import io.github.muntashirakon.music.repository.RealRepository import io.github.muntashirakon.music.service.MusicService.* +import java.lang.ref.WeakReference +import java.util.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.koin.android.ext.android.inject -import java.lang.ref.WeakReference -import java.util.* -abstract class AbsMusicServiceActivity : AbsBaseActivity(), MusicServiceEventListener { +abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventListener { - private val mMusicServiceEventListeners = ArrayListApp version | " + versionName + " |
App version code | " + versionCode + " |
Android build version | " + buildVersion + " |
Android release version | " + releaseVersion + " |
Android SDK version | " + sdkVersion + " |
Android build ID | " + buildID + " |
Device brand | " + brand + " |
Device manufacturer | " + manufacturer + " |
Device name | " + device + " |
Device model | " + model + " |
Device product name | " + product + " |
Device hardware name | " + hardware + " |
ABIs | " + Arrays.toString(abis) + " |
ABIs (32bit) | " + Arrays.toString(abis32Bits) + " |
ABIs (64bit) | " + Arrays.toString(abis64Bits) + " |
Language | " + selectedLang + " |
App version | " + + versionName + + " |
App version code | " + + versionCode + + " |
Android build version | " + + buildVersion + + " |
Android release version | " + + releaseVersion + + " |
Android SDK version | " + + sdkVersion + + " |
Android build ID | " + + buildID + + " |
Device brand | " + + brand + + " |
Device manufacturer | " + + manufacturer + + " |
Device name | " + + device + + " |
Device model | " + + model + + " |
Device product name | " + + product + + " |
Device hardware name | " + + hardware + + " |
ABIs | " + + Arrays.toString(abis) + + " |
ABIs (32bit) | " + + Arrays.toString(abis32Bits) + + " |
ABIs (64bit) | " + + Arrays.toString(abis64Bits) + + " |
Language | " + + selectedLang + + " |
") + .append(key) + .append(" | ") + .append(extraInfo.get(key)) + .append(" |
") - .append(key) - .append(" | ") - .append(extraInfo.get(key)) - .append(" |