diff --git a/app/build.gradle b/app/build.gradle index 9e5deb2..7ff0f9e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId = "partisan.weforge.xyz.pulse" minSdk = 29 targetSdk = 34 - versionCode = 10 - versionName = "1.3.1" + versionCode = 11 + versionName = "1.3.2" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/partisan/weforge/xyz/pulse/PopupWindow.kt b/app/src/main/java/partisan/weforge/xyz/pulse/PopupWindow.kt index 835f2ab..2c932fa 100644 --- a/app/src/main/java/partisan/weforge/xyz/pulse/PopupWindow.kt +++ b/app/src/main/java/partisan/weforge/xyz/pulse/PopupWindow.kt @@ -9,6 +9,7 @@ import android.net.Uri import android.view.Gravity import android.view.LayoutInflater import android.view.WindowManager +import android.view.ContextThemeWrapper import android.widget.TextView import androidx.annotation.RequiresPermission import java.lang.ref.WeakReference @@ -16,14 +17,14 @@ import java.util.* import kotlin.concurrent.timerTask class PopupWindow( - private val ctx: Context, + ctx: Context, private val service: WeakReference?, ) { - private val prefs = Preferences(ctx) - private val windowManager = ctx.getSystemService(WindowManager::class.java) - private val audioManager = ctx.getSystemService(AudioManager::class.java) - @Suppress("InflateParams") - private val view = LayoutInflater.from(ctx).inflate(R.layout.popup, null) + private val themedCtx = ContextThemeWrapper(ctx, R.style.Theme_Pulse) + private val prefs = Preferences(themedCtx) + private val windowManager = themedCtx.getSystemService(WindowManager::class.java) + private val audioManager = themedCtx.getSystemService(AudioManager::class.java) + private val view = LayoutInflater.from(themedCtx).inflate(R.layout.popup, null) private val layoutParams = WindowManager.LayoutParams().apply { format = PixelFormat.TRANSLUCENT flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE @@ -45,7 +46,7 @@ class PopupWindow( fun preview() { remove() layoutParams.y = prefs.popupPosition - val destinations = mutableListOf( + val destinations = listOf( R.string.destination_signal, R.string.destination_telegram, R.string.destination_threema, @@ -87,33 +88,37 @@ class PopupWindow( } private fun setDescription(id: Int) { - view.findViewById(R.id.description).text = ctx.getString( + view.findViewById(R.id.description).text = themedCtx.getString( R.string.popup, - ctx.getString(id), + themedCtx.getString(id), ) } @RequiresPermission(Manifest.permission.CALL_PHONE) private fun call(data: Uri) { - Intent(Intent.ACTION_VIEW).let { - it.data = data - it.flags = Intent.FLAG_ACTIVITY_NEW_TASK - ctx.startActivity(it) + Intent(Intent.ACTION_VIEW).apply { + this.data = data + flags = Intent.FLAG_ACTIVITY_NEW_TASK + themedCtx.startActivity(this) } } private fun add(): Boolean { try { windowManager?.addView(view, layoutParams) - } catch (exc: WindowManager.BadTokenException) { return false } + } catch (exc: WindowManager.BadTokenException) { + return false + } return true } private fun remove(): Boolean { try { windowManager?.removeView(view) - } catch (exc: IllegalArgumentException) { - } catch (exc: WindowManager.BadTokenException) { return false } + } catch (_: IllegalArgumentException) { + } catch (_: WindowManager.BadTokenException) { + return false + } return true } diff --git a/app/src/main/res/layout/popup.xml b/app/src/main/res/layout/popup.xml index 6035cbb..d682d1a 100644 --- a/app/src/main/res/layout/popup.xml +++ b/app/src/main/res/layout/popup.xml @@ -1,11 +1,14 @@ - + app:cardBackgroundColor="?attr/colorSurface" + android:background="@android:color/white"> + android:textAlignment="center" + tools:text="Popup text" /> diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 3e4e33f..ad74a04 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -7,6 +7,9 @@ @color/teal_200 @color/black - + + @color/white + @color/black + @style/TextAppearance.Material3.BodyMedium \ No newline at end of file