Skip to content

Commit 4c39bdf

Browse files
committed
build: configure project and manifest for browser
- Update project name to Feather - Configure intent filters for web browsing - Add network permissions and configuration changes - Update ProGuard rules for Room and WebView - Integrate BrowserViewModel and BrowserScreen into MainActivity
1 parent b962019 commit 4c39bdf

4 files changed

Lines changed: 69 additions & 43 deletions

File tree

app/proguard-rules.pro

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
# Add project specific ProGuard rules here.
2-
# You can control the set of applied configuration files using the
3-
# proguardFiles setting in build.gradle.
4-
#
5-
# For more details, see
6-
# http://developer.android.com/guide/developing/tools/proguard.html
72

8-
# If your project uses WebView with JS, uncomment the following
9-
# and specify the fully qualified class name to the JavaScript interface
10-
# class:
11-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12-
# public *;
13-
#}
3+
# Keep Room entity and DAO implementations
4+
-keep class * extends androidx.room.RoomDatabase
5+
-dontwarn androidx.room.paging.**
6+
-keep class com.example.data.model.** { *; }
7+
-keep class com.example.browser.** { *; }
148

15-
# Uncomment this to preserve the line number information for
16-
# debugging stack traces.
17-
#-keepattributes SourceFile,LineNumberTable
9+
# WebKit / JavaScript Interfaces
10+
-keepattributes JavascriptInterface
11+
-keepclassmembers class * {
12+
@android.webkit.JavascriptInterface <methods>;
13+
}
14+
15+
# Preserve Line Numbers for Crash Reports
16+
-keepattributes SourceFile,LineNumberTable
17+
-renamesourcefileattribute SourceFile
1818

19-
# If you keep the line number information, uncomment this to
20-
# hide the original source file name.
21-
#-renamesourcefileattribute SourceFile

app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

5+
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7+
58
<application
69
android:allowBackup="true"
710
android:dataExtractionRules="@xml/data_extraction_rules"
@@ -15,12 +18,20 @@
1518
android:name=".MainActivity"
1619
android:exported="true"
1720
android:label="@string/app_name"
18-
android:theme="@style/Theme.MyApplication">
21+
android:theme="@style/Theme.MyApplication"
22+
android:windowSoftInputMode="adjustResize"
23+
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden">
1924
<intent-filter>
2025
<action android:name="android.intent.action.MAIN" />
21-
2226
<category android:name="android.intent.category.LAUNCHER" />
2327
</intent-filter>
28+
<intent-filter>
29+
<action android:name="android.intent.action.VIEW" />
30+
<category android:name="android.intent.category.DEFAULT" />
31+
<category android:name="android.intent.category.BROWSABLE" />
32+
<data android:scheme="http" />
33+
<data android:scheme="https" />
34+
</intent-filter>
2435
</activity>
2536
</application>
2637

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,57 @@
11
package com.example
22

3+
import android.content.Intent
34
import android.os.Bundle
45
import androidx.activity.ComponentActivity
56
import androidx.activity.compose.setContent
67
import androidx.activity.enableEdgeToEdge
8+
import androidx.activity.viewModels
79
import androidx.compose.foundation.layout.fillMaxSize
8-
import androidx.compose.foundation.layout.padding
9-
import androidx.compose.material3.Scaffold
10-
import androidx.compose.material3.Text
11-
import androidx.compose.runtime.Composable
10+
import androidx.compose.runtime.LaunchedEffect
11+
import androidx.compose.runtime.getValue
1212
import androidx.compose.ui.Modifier
13-
import androidx.compose.ui.tooling.preview.Preview
13+
import androidx.lifecycle.compose.collectAsStateWithLifecycle
14+
import com.example.browser.BrowserViewModel
15+
import com.example.ui.BrowserScreen
1416
import com.example.ui.theme.MyApplicationTheme
1517

1618
class MainActivity : ComponentActivity() {
17-
override fun onCreate(savedInstanceState: Bundle?) {
18-
super.onCreate(savedInstanceState)
19-
enableEdgeToEdge()
20-
setContent {
21-
MyApplicationTheme {
22-
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
23-
Greeting(name = "Android", modifier = Modifier.padding(innerPadding))
19+
20+
private val viewModel: BrowserViewModel by viewModels()
21+
22+
override fun onCreate(savedInstanceState: Bundle?) {
23+
super.onCreate(savedInstanceState)
24+
enableEdgeToEdge()
25+
26+
handleIntent(intent)
27+
28+
setContent {
29+
val themeMode by viewModel.themeMode.collectAsStateWithLifecycle()
30+
val useMaterialYou by viewModel.useMaterialYou.collectAsStateWithLifecycle()
31+
32+
MyApplicationTheme(
33+
themeMode = themeMode,
34+
useMaterialYou = useMaterialYou
35+
) {
36+
BrowserScreen(
37+
viewModel = viewModel,
38+
modifier = Modifier.fillMaxSize()
39+
)
40+
}
2441
}
25-
}
2642
}
27-
}
28-
}
2943

30-
@Composable
31-
fun Greeting(name: String, modifier: Modifier = Modifier) {
32-
Text(text = "Hello $name!", modifier = modifier)
33-
}
44+
override fun onNewIntent(intent: Intent) {
45+
super.onNewIntent(intent)
46+
setIntent(intent)
47+
handleIntent(intent)
48+
}
3449

35-
@Preview(showBackground = true)
36-
@Composable
37-
fun GreetingPreview() {
38-
MyApplicationTheme { Greeting("Android") }
50+
private fun handleIntent(intent: Intent?) {
51+
val action = intent?.action
52+
val data = intent?.dataString
53+
if (action == Intent.ACTION_VIEW && !data.isNullOrBlank()) {
54+
viewModel.navigateTo(data)
55+
}
56+
}
3957
}

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ dependencyResolutionManagement {
2222
}
2323
}
2424

25-
rootProject.name = "Browser"
25+
rootProject.name = "Feather"
2626

2727
include(":app")

0 commit comments

Comments
 (0)