Skip to content

Commit 49ef831

Browse files
committed
Added barcode scanner shortcut
1 parent 989fb1b commit 49ef831

File tree

17 files changed

+87
-0
lines changed

17 files changed

+87
-0
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,21 @@
222222
</intent-filter>
223223
</activity>
224224

225+
<activity
226+
android:name=".shortcuts.ScannerShortcut"
227+
android:excludeFromRecents="true"
228+
android:exported="true"
229+
android:icon="@mipmap/ic_launcher_scanner"
230+
android:label="@string/scanner"
231+
android:launchMode="singleTop"
232+
android:noHistory="true"
233+
android:theme="@style/AppTheme.Transparent">
234+
<intent-filter>
235+
<action android:name="android.intent.action.MAIN" />
236+
<category android:name="android.intent.category.LAUNCHER" />
237+
</intent-filter>
238+
</activity>
239+
225240
<activity
226241
android:name=".shortcuts.SearchShortcut"
227242
android:excludeFromRecents="true"

app/src/main/java/com/wstxda/gsl/fragments/ManagerFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class ManagerFragment : PreferenceFragmentCompat() {
5151
"music_search_shortcut" to MusicSearchShortcut::class.java,
5252
"password_manager_shortcut" to PasswordManagerShortcut::class.java,
5353
"quick_share_shortcut" to QuickShareShortcut::class.java,
54+
"scanner_shortcut" to ScannerShortcut::class.java,
5455
"search_shortcut" to SearchShortcut::class.java,
5556
"shopping_shortcut" to ShoppingShortcut::class.java,
5657
"travel_shortcut" to TravelShortcut::class.java,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.wstxda.gsl.shortcuts
2+
3+
import android.content.ComponentName
4+
import android.content.Intent
5+
import com.wstxda.gsl.R
6+
import com.wstxda.gsl.activity.ShortcutsActivity
7+
import com.wstxda.gsl.logic.launchShortcuts
8+
import com.wstxda.gsl.logic.showToast
9+
10+
class ScannerShortcut : ShortcutsActivity() {
11+
override fun onCreateInternal() {
12+
if (!launchShortcuts(createBarcodeIntent())) {
13+
showToast(R.string.play_services_not_found)
14+
}
15+
}
16+
17+
private fun createBarcodeIntent() = Intent().apply {
18+
component = ComponentName(
19+
"com.google.android.gms", "com.google.android.gms.mlkit.barcode.v2.ScannerActivity"
20+
)
21+
}
22+
}

app/src/main/java/com/wstxda/gsl/utils/DigitalAssistantShortcuts.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ object DigitalAssistantShortcuts {
1919
"music_search_shortcut" to MusicSearchShortcut::class.java,
2020
"password_manager_shortcut" to PasswordManagerShortcut::class.java,
2121
"quick_share_shortcut" to QuickShareShortcut::class.java,
22+
"scanner_shortcut" to ScannerShortcut::class.java,
2223
"search_shortcut" to SearchShortcut::class.java,
2324
"shopping_shortcut" to ShoppingShortcut::class.java,
2425
"travel_shortcut" to TravelShortcut::class.java,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="108dp"
3+
android:height="108dp"
4+
android:viewportWidth="108"
5+
android:viewportHeight="108">
6+
<path
7+
android:fillColor="#FFB8BECC"
8+
android:pathData="M36.45 45.11c-0.68 0-1.25-0.24-1.73-0.72-0.48-0.47-0.72-1.05-0.72-1.73v-6.2c0-0.69 0.24-1.26 0.72-1.74S35.77 34 36.45 34h6.2c0.69 0 1.27 0.24 1.74 0.72 0.48 0.48 0.72 1.05 0.72 1.73 0 0.68-0.24 1.26-0.72 1.74-0.47 0.48-1.05 0.72-1.73 0.72H38.9v3.75c0 0.68-0.24 1.26-0.72 1.73-0.48 0.48-1.06 0.72-1.74 0.72Zm35.1 0c-0.68 0-1.26-0.24-1.74-0.72-0.48-0.47-0.72-1.05-0.72-1.73V38.9h-3.75c-0.68 0-1.26-0.24-1.73-0.72-0.48-0.48-0.72-1.06-0.72-1.74 0-0.68 0.24-1.25 0.72-1.73 0.47-0.48 1.05-0.72 1.73-0.72h6.2c0.69 0 1.26 0.24 1.74 0.72S74 35.77 74 36.45v6.2c0 0.69-0.24 1.27-0.72 1.74-0.48 0.48-1.05 0.72-1.73 0.72Z" />
9+
<path
10+
android:fillColor="#FF5F6368"
11+
android:pathData="M36.45 74c-0.68 0-1.25-0.24-1.73-0.72S34 72.23 34 71.55v-6.2c0-0.69 0.24-1.27 0.72-1.74 0.48-0.48 1.05-0.72 1.73-0.72 0.68 0 1.26 0.24 1.74 0.72 0.48 0.47 0.72 1.05 0.72 1.73v3.75h3.75c0.68 0 1.26 0.24 1.73 0.72 0.48 0.48 0.72 1.06 0.72 1.74 0 0.68-0.24 1.25-0.72 1.73-0.47 0.48-1.05 0.72-1.73 0.72h-6.2Zm28.9 0c-0.69 0-1.27-0.24-1.74-0.72-0.48-0.48-0.72-1.05-0.72-1.73 0-0.68 0.24-1.26 0.72-1.74 0.47-0.48 1.05-0.72 1.73-0.72h3.75v-3.75c0-0.68 0.24-1.26 0.72-1.73 0.48-0.48 1.06-0.72 1.74-0.72 0.68 0 1.25 0.24 1.73 0.72 0.48 0.47 0.72 1.05 0.72 1.73v6.2c0 0.69-0.24 1.26-0.72 1.74S72.23 74 71.55 74h-6.2Z" />
12+
<path
13+
android:fillColor="#FFF0F2F4"
14+
android:pathData="M37.08 57.08C35.38 57.08 34 55.7 34 54c0-1.7 1.38-3.08 3.08-3.08h33.84c1.7 0 3.08 1.38 3.08 3.08 0 1.7-1.38 3.08-3.08 3.08H37.08Z" />
15+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="108dp"
3+
android:height="108dp"
4+
android:viewportWidth="108"
5+
android:viewportHeight="108">
6+
<path
7+
android:fillColor="@android:color/white"
8+
android:pathData="M36.45 62.89c0.68 0 1.26 0.24 1.74 0.72 0.48 0.47 0.72 1.05 0.72 1.73v3.75h3.75c0.68 0 1.26 0.24 1.73 0.72 0.48 0.48 0.72 1.06 0.72 1.74 0 0.67-0.24 1.25-0.72 1.73-0.47 0.48-1.05 0.72-1.73 0.72h-6.2c-0.68 0-1.26-0.24-1.74-0.72S34 72.22 34 71.55v-6.2c0-0.69 0.24-1.27 0.72-1.74 0.48-0.48 1.06-0.72 1.73-0.72Zm35.1 0c0.67 0 1.25 0.24 1.73 0.72 0.48 0.47 0.72 1.05 0.72 1.73v6.2c0 0.68-0.24 1.26-0.72 1.74S72.22 74 71.55 74h-6.2c-0.69 0-1.27-0.24-1.74-0.72-0.48-0.48-0.72-1.06-0.72-1.73 0-0.68 0.24-1.26 0.72-1.74 0.47-0.48 1.05-0.72 1.73-0.72h3.75v-3.75c0-0.68 0.24-1.26 0.72-1.73 0.48-0.48 1.06-0.72 1.74-0.72Zm-0.63-11.97c1.7 0 3.08 1.38 3.08 3.08 0 1.7-1.38 3.08-3.08 3.08H37.08C35.38 57.08 34 55.7 34 54c0-1.7 1.38-3.08 3.08-3.08h33.84ZM42.66 34c0.68 0 1.26 0.24 1.73 0.72 0.48 0.48 0.72 1.06 0.72 1.73 0 0.68-0.24 1.26-0.72 1.74-0.47 0.48-1.05 0.72-1.73 0.72H38.9v3.75c0 0.68-0.24 1.26-0.72 1.73-0.48 0.48-1.06 0.72-1.74 0.72-0.67 0-1.25-0.24-1.73-0.72-0.48-0.47-0.72-1.05-0.72-1.73v-6.2c0-0.68 0.24-1.26 0.72-1.74S35.78 34 36.45 34h6.2Zm28.89 0c0.67 0 1.25 0.24 1.73 0.72S74 35.78 74 36.45v6.2c0 0.69-0.24 1.27-0.72 1.74-0.48 0.48-1.06 0.72-1.73 0.72-0.68 0-1.26-0.24-1.74-0.72-0.48-0.47-0.72-1.05-0.72-1.73V38.9h-3.75c-0.68 0-1.26-0.24-1.73-0.72-0.48-0.48-0.72-1.06-0.72-1.74 0-0.67 0.24-1.25 0.72-1.73 0.47-0.48 1.05-0.72 1.73-0.72h6.2Z" />
9+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
2+
<background android:drawable="@color/ic_launcher_background_scanner" />
3+
<foreground android:drawable="@drawable/ic_launcher_foreground_scanner" />
4+
<monochrome android:drawable="@drawable/ic_launcher_monochrome_scanner" />
5+
</adaptive-icon>

app/src/main/res/values-ar/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<string name="shopping">التسوّق</string>
6060
<string name="travel">السفر</string>
6161
<string name="finance">الشؤون المالية</string>
62+
<string name="scanner">ماسح ضوئي</string>
6263

6364
<string name="history_shortcut">السجلّ</string>
6465
<string name="settings_shortcut">الإعدادات</string>

app/src/main/res/values-es/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<string name="shopping">Shopping</string>
6060
<string name="travel">Viajes</string>
6161
<string name="finance">Finanzas</string>
62+
<string name="scanner">Escáner</string>
6263

6364
<string name="history_shortcut">Historial</string>
6465
<string name="settings_shortcut">Ajustes</string>

app/src/main/res/values-fa-rIR/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<string name="shopping">خرید</string>
6060
<string name="travel">سفرها</string>
6161
<string name="finance">امور مالی</string>
62+
<string name="scanner">اسکنر</string>
6263

6364
<string name="history_shortcut">تاریخچه</string>
6465
<string name="settings_shortcut">تنظیمات</string>

0 commit comments

Comments
 (0)