Skip to content

Commit

Permalink
feat: Make LinkSheet an In-App browser, major refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
1fexd committed May 16, 2023
1 parent e641a1e commit a04ce60
Show file tree
Hide file tree
Showing 59 changed files with 1,882 additions and 1,177 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
.cxx
local.properties
build/
app/release
app/release
.ignored/
debug/
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ android {

dependencies {
implementation("io.insert-koin:koin-android:3.2.0")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.21")

implementation("androidx.room:room-runtime:2.5.1")
implementation("androidx.webkit:webkit:1.6.1")
Expand Down
274 changes: 274 additions & 0 deletions app/schemas/com.tasomaniac.openwith.data.LinkSheetDatabase/8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
{
"formatVersion": 1,
"database": {
"version": 8,
"identityHash": "1eb61a33caf910569e8136d58d27ef0f",
"entities": [
{
"tableName": "openwith",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `host` TEXT NOT NULL, `packageName` TEXT, `component` TEXT NOT NULL, `alwaysPreferred` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "host",
"columnName": "host",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "packageName",
"columnName": "packageName",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "component",
"columnName": "component",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "alwaysPreferred",
"columnName": "alwaysPreferred",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"_id"
]
},
"indices": [
{
"name": "index_openwith_host",
"unique": true,
"columnNames": [
"host"
],
"orders": [],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_openwith_host` ON `${TABLE_NAME}` (`host`)"
}
],
"foreignKeys": []
},
{
"tableName": "app_selection_history",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `host` TEXT NOT NULL, `packageName` TEXT NOT NULL, `lastUsed` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "host",
"columnName": "host",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "packageName",
"columnName": "packageName",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "lastUsed",
"columnName": "lastUsed",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"_id"
]
},
"indices": [
{
"name": "index_app_selection_history_host_lastUsed",
"unique": true,
"columnNames": [
"host",
"lastUsed"
],
"orders": [],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_app_selection_history_host_lastUsed` ON `${TABLE_NAME}` (`host`, `lastUsed`)"
}
],
"foreignKeys": []
},
{
"tableName": "whitelisted_browser",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `packageName` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "packageName",
"columnName": "packageName",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"_id"
]
},
"indices": [
{
"name": "index_whitelisted_browser_packageName",
"unique": true,
"columnNames": [
"packageName"
],
"orders": [],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_whitelisted_browser_packageName` ON `${TABLE_NAME}` (`packageName`)"
}
],
"foreignKeys": []
},
{
"tableName": "resolved_redirect",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`shortUrl` TEXT NOT NULL, `resolvedUrl` TEXT NOT NULL, PRIMARY KEY(`shortUrl`, `resolvedUrl`))",
"fields": [
{
"fieldPath": "shortUrl",
"columnName": "shortUrl",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "resolvedUrl",
"columnName": "resolvedUrl",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"shortUrl",
"resolvedUrl"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "lib_redirect_default",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serviceKey` TEXT NOT NULL, `frontendKey` TEXT NOT NULL, `instanceUrl` TEXT NOT NULL, PRIMARY KEY(`serviceKey`))",
"fields": [
{
"fieldPath": "serviceKey",
"columnName": "serviceKey",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "frontendKey",
"columnName": "frontendKey",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "instanceUrl",
"columnName": "instanceUrl",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"serviceKey"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "lib_redirect_service_state",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serviceKey` TEXT NOT NULL, `enabled` INTEGER NOT NULL, PRIMARY KEY(`serviceKey`))",
"fields": [
{
"fieldPath": "serviceKey",
"columnName": "serviceKey",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "enabled",
"columnName": "enabled",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"serviceKey"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "disable_in_app_browser_in_selected",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `packageName` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "packageName",
"columnName": "packageName",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"_id"
]
},
"indices": [
{
"name": "index_disable_in_app_browser_in_selected_packageName",
"unique": true,
"columnNames": [
"packageName"
],
"orders": [],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_disable_in_app_browser_in_selected_packageName` ON `${TABLE_NAME}` (`packageName`)"
}
],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '1eb61a33caf910569e8136d58d27ef0f')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ import fe.linksheet.data.dao.*
import fe.linksheet.data.entity.*

@Database(
entities = [PreferredApp::class, AppSelectionHistory::class, WhitelistedBrowser::class, ResolvedRedirect::class, LibRedirectDefault::class, LibRedirectServiceState::class],
version = 7,
entities = [
PreferredApp::class, AppSelectionHistory::class, WhitelistedBrowser::class,
ResolvedRedirect::class, LibRedirectDefault::class, LibRedirectServiceState::class,
DisableInAppBrowserInSelected::class
],
version = 8,
autoMigrations = [
AutoMigration(from = 2, to = 3),
AutoMigration(from = 3, to = 4),
AutoMigration(from = 4, to = 5),
AutoMigration(from = 5, to = 6),
AutoMigration(from = 6, to = 7)
AutoMigration(from = 6, to = 7),
AutoMigration(from = 7, to = 8)
],
exportSchema = true
)
Expand All @@ -28,6 +33,7 @@ abstract class LinkSheetDatabase : RoomDatabase() {
abstract fun appSelectionHistoryDao(): AppSelectionHistoryDao

abstract fun whitelistedBrowsersDao(): WhitelistedBrowsersDao
abstract fun disableInAppBrowserInSelectedDao(): DisableInAppBrowserInSelectedDao
abstract fun resolvedRedirectDao(): ResolvedRedirectDao

abstract fun libRedirectDefaultDao(): LibRedirectDefaultDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.tasomaniac.openwith.extension

import android.content.Intent

fun Intent.isHttp() = "http" == scheme || "https" == scheme
fun Intent.isSchemeTypicallySupportedByBrowsers() = "http" == scheme || "https" == scheme
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.net.Uri
import fe.linksheet.activity.bottomsheet.BottomSheetViewModel
import fe.linksheet.module.downloader.Downloader

data class IntentResolverResult(
data class BottomSheetResult(
val uri: Uri?,
val resolved: List<DisplayActivityInfo>,
val filteredItem: DisplayActivityInfo?,
Expand Down
Loading

0 comments on commit a04ce60

Please sign in to comment.