Skip to content

Commit

Permalink
add camera shortcut option
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Sep 18, 2024
1 parent efabfec commit 7cfbe10
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name=".SettingsActivity"
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/org/witness/proofmode/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
private lateinit var mainBinding: ActivityMainBinding
public lateinit var fab: FloatingActionButton

private val ACTION_OPEN_CAMERA = "org.witness.proofmode.OPEN_CAMERA"

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -76,6 +78,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
)
}



mainBinding = ActivityMainBinding.inflate(layoutInflater)
setContentView(mainBinding.root)
val toolbar = mainBinding.toolbar
Expand Down Expand Up @@ -166,6 +170,11 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
fab.setOnClickListener { view ->
openCamera()
}

if (intent?.action == ACTION_OPEN_CAMERA)
{
openCamera()
}
}

private fun itemsSelected(selected: Boolean) {
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<shortcuts xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="location"
android:enabled="true"
android:icon="@drawable/ic_camera"
android:shortcutShortLabel="@string/camera"
android:shortcutLongLabel="@string/camera"
tools:targetApi="n_mr1">
<intent
android:action="org.witness.proofmode.OPEN_CAMERA"
android:targetPackage="org.witness.proofmode"
android:targetClass="org.witness.proofmode.MainActivity" />
<!-- If your shortcut is associated with multiple intents, include them
here. The last intent in the list determines what the user sees when
they launch this shortcut. -->
<categories android:name="android.shortcut.conversation" />
<capability-binding android:key="actions.intent.CREATE_MESSAGE" />
</shortcut>

<!-- Specify more shortcuts here. -->
</shortcuts>

0 comments on commit 7cfbe10

Please sign in to comment.