Skip to content

Commit

Permalink
feat: Bring back the quick setting tile on Android (#2870)
Browse files Browse the repository at this point in the history
* The quick setting tile is back on Android

* Add a comment about the min sdk for the quick setting/tile
  • Loading branch information
g123k committed Sep 1, 2022
1 parent fc9711b commit 0c7e236
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/smooth_app/android/app/src/main/AndroidManifest.xml
Expand Up @@ -30,7 +30,7 @@
</queries>

<application
android:label="OpenFoodFacts"
android:label="@string/app_name"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:allowBackup="true"
Expand Down Expand Up @@ -58,6 +58,19 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<!-- Quick tile / setting (only available on Android 24+ / Nougat) -->
<service android:name="org.openfoodfacts.app.AppMainTile"
android:exported="true"
android:icon="@drawable/ic_launcher_foreground"
android:label="@string/app_name"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>


<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
Expand Down
@@ -0,0 +1,30 @@
package org.openfoodfacts.app

import android.content.Intent
import android.os.Build
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi
import org.openfoodfacts.scanner.MainActivity

@RequiresApi(Build.VERSION_CODES.N)
class AppMainTile : TileService() {

override fun onStartListening() {
super.onStartListening()

qsTile.state = Tile.STATE_INACTIVE
qsTile.updateTile()
}

override fun onClick() {
super.onClick()

val intent = Intent(this, MainActivity::class.java).apply {
flags += Intent.FLAG_ACTIVITY_NEW_TASK
}

startActivityAndCollapse(intent)
}

}
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">OpenFoodFacts</string>

</resources>

0 comments on commit 0c7e236

Please sign in to comment.