Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:56:56 +01:00
parent 75dc487a7a
commit 39c29d175b
6317 changed files with 388324 additions and 2 deletions

View file

@ -0,0 +1,13 @@
plugins {
id(ThunderbirdPlugins.Library.android)
}
dependencies {
implementation(projects.legacy.ui.legacy)
implementation(projects.legacy.core)
implementation(projects.core.android.account)
}
android {
namespace = "app.k9mail.feature.widget.shortcut"
}

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<!--
This component is disabled by default. It will be enabled programmatically after an account has been set up.
-->
<activity
android:name="app.k9mail.feature.widget.shortcut.LauncherShortcutActivity"
android:configChanges="locale"
android:label="@string/shortcut_widget_title"
android:enabled="false"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>

View file

@ -0,0 +1,91 @@
package app.k9mail.feature.widget.shortcut
import android.content.Intent
import android.content.res.Resources.Theme
import android.os.Build
import android.os.Bundle
import android.util.TypedValue
import androidx.annotation.AttrRes
import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.graphics.drawable.IconCompat
import com.fsck.k9.activity.AccountList
import com.fsck.k9.activity.MessageList
import net.thunderbird.feature.mail.account.api.BaseAccount
import net.thunderbird.feature.search.legacy.SearchAccount
import app.k9mail.core.ui.legacy.theme2.common.R as CommonR
class LauncherShortcutActivity : AccountList() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setTitle(R.string.shortcut_widget_title)
// finish() immediately if we aren't supposed to be here
if (intent.action != Intent.ACTION_CREATE_SHORTCUT) {
finish()
}
}
override fun onAccountSelected(account: BaseAccount) {
val shortcutIntent = if (account is SearchAccount) {
MessageList.shortcutIntent(this, account.id)
} else {
MessageList.shortcutIntentForAccount(this, account.uuid)
}
val displayName = account.name ?: account.email
val iconResId = theme.resolveDrawableResourceId(CommonR.attr.appLogo)
val shortcutId = account.uuid
val resultIntent = createResultIntent(displayName, iconResId, shortcutIntent, shortcutId)
setResult(RESULT_OK, resultIntent)
finish()
}
private fun createResultIntent(
displayName: String,
iconResId: Int,
shortcutIntent: Intent,
shortcutId: String,
): Intent {
return if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S) {
createResultIntentLegacy(displayName, iconResId, shortcutIntent)
} else {
createResultIntentApi32(shortcutId, displayName, iconResId, shortcutIntent)
}
}
@Suppress("DEPRECATION")
private fun createResultIntentLegacy(displayName: String, iconResId: Int, shortcutIntent: Intent): Intent {
val iconResource = Intent.ShortcutIconResource.fromContext(this, iconResId)
return Intent().apply {
putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent)
putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName)
putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource)
}
}
private fun createResultIntentApi32(
shortcutId: String,
displayName: String,
iconResId: Int,
shortcutIntent: Intent,
): Intent {
val shortcut = ShortcutInfoCompat.Builder(this, shortcutId)
.setShortLabel(displayName)
.setIcon(IconCompat.createWithResource(this, iconResId))
.setIntent(shortcutIntent)
.build()
return ShortcutManagerCompat.createShortcutResultIntent(this, shortcut)
}
private fun Theme.resolveDrawableResourceId(@AttrRes attr: Int): Int {
val typedValue = TypedValue()
resolveAttribute(attr, typedValue, true)
return typedValue.resourceId
}
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">الحسابات</string>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Акаўнты</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Профили</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">অ্যাকাউন্ট</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Kontoù</string>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Comptes</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Conti</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Účty</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Cyfrifon</string>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Konten</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Λογαριασμοί</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Accounts</string>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Kontoj</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Cuentas</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Kontod</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Kontuak</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">حساب‌ها</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Tilit</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Comptes</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Accounts</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Cuntais</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Cunntasan</string>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Računi</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Fiókok</string>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Akun</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Aðgangar</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Account</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">חשבונות</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">アカウント</string>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Тіркелгілер</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">계정</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Paskyros</string>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Kontoer</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Accounts</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Kontoar</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Konta</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Contas</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Contas</string>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Conturi</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Учётные записи</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Kontá</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Računi</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Llogari</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Налози</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Konton</string>
</resources>

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">கணக்குகள்</string>
</resources>

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Hesaplar</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Облікові записи</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">Tài khoản</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">账号</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcut_widget_title">帳戶</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="shortcut_widget_title">Accounts</string>
</resources>