-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Bring back the quick setting tile on Android (#2870)
* The quick setting tile is back on Android * Add a comment about the min sdk for the quick setting/tile
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/smooth_app/android/app/src/main/kotlin/org/openfoodfacts/app/AppMainTile.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
packages/smooth_app/android/app/src/main/res/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">OpenFoodFacts</string> | ||
|
||
</resources> |