add save activity to handle saves from android browser

This commit is contained in:
Satindar Dhillon
2022-08-11 23:29:30 -07:00
parent 70d4b3caad
commit 6c859430de
4 changed files with 66 additions and 4 deletions

View File

@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
package="app.omnivore.omnivore">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".OmnivoreApplication"
android:allowBackup="true"
@ -22,11 +24,28 @@
android:theme="@style/Theme.Omnivore">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<activity
android:name=".SaveActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -11,6 +11,7 @@ import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object AppModule {
@Singleton
@Provides
fun provideDataStoreRepository(

View File

@ -34,7 +34,7 @@ class LoginViewModel @Inject constructor(
DatastoreKeys.omnivoreAuthCookieString, result.body()?.authCookieString!!
)
}
datastoreRepo.getString(DatastoreKeys.omnivoreAuthToken)?.let {
Log.d(ContentValues.TAG, it)
}

View File

@ -0,0 +1,42 @@
package app.omnivore.omnivore
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import app.omnivore.omnivore.ui.theme.OmnivoreTheme
class SaveActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
var text: String? = null
when (intent?.action) {
Intent.ACTION_SEND -> {
if (intent.type?.startsWith("text/") == true) {
intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
text = it
}
}
}
else -> {
// Handle other intents, such as being started from the home screen
}
}
setContent {
OmnivoreTheme {
// A surface container using the 'background' color from the theme
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background) {
Text(text = text ?: "no text extracted")
}
}
}
}
}