Skip to content

Commit 7f1884a

Browse files
committed
Update SDK, dependencies, and improve edge-to-edge UI
Upgraded compile and target SDK versions to 36 and updated several dependencies to their latest versions. Changed themes in AndroidManifest for splash and main activity. Enhanced MainActivity to support edge-to-edge display, improved window insets handling, and made layout setup more robust for configuration changes.
1 parent fe99d2a commit 7f1884a

3 files changed

Lines changed: 53 additions & 42 deletions

File tree

app/build.gradle

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def swvProps = getSwvProperties()
3535

3636
android {
3737
namespace swvProps.getProperty('build.application.id', 'mgks.os.swv')
38-
compileSdk swvProps.getProperty('build.sdk.compile', '35').toInteger()
38+
compileSdk swvProps.getProperty('build.sdk.compile', '36').toInteger()
3939

4040
defaultConfig {
4141
applicationId swvProps.getProperty('build.application.id', 'mgks.os.swv')
4242
minSdk swvProps.getProperty('build.sdk.min', '24').toInteger()
43-
targetSdk swvProps.getProperty('build.sdk.compile', '35').toInteger()
43+
targetSdk swvProps.getProperty('build.sdk.compile', '36').toInteger()
4444
versionCode swvProps.getProperty('build.version.code', '1').toInteger()
4545
versionName swvProps.getProperty('build.version.name', '1.0')
4646
multiDexEnabled true // enable if method count exceeds 64K
@@ -69,20 +69,20 @@ android {
6969

7070
dependencies {
7171
testImplementation 'junit:junit:4.13.2'
72-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
72+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
7373

7474
implementation fileTree(include: ['*.jar'], dir: 'libs')
7575

7676
implementation 'androidx.multidex:multidex:2.0.1'
7777

7878
// Firebase
79-
implementation 'com.google.firebase:firebase-auth:23.2.1'
80-
implementation 'com.google.firebase:firebase-config:22.1.2'
81-
implementation 'com.google.firebase:firebase-messaging:24.1.2'
82-
implementation 'com.google.firebase:firebase-analytics:22.5.0'
79+
implementation 'com.google.firebase:firebase-auth:24.0.1'
80+
implementation 'com.google.firebase:firebase-config:23.0.0'
81+
implementation 'com.google.firebase:firebase-messaging:25.0.0'
82+
implementation 'com.google.firebase:firebase-analytics:23.0.0'
8383

84-
implementation 'com.google.android.gms:play-services-auth:21.3.0'
85-
implementation 'com.google.android.gms:play-services-ads:24.4.0'
84+
implementation 'com.google.android.gms:play-services-auth:21.4.0'
85+
implementation 'com.google.android.gms:play-services-ads:24.5.0'
8686
implementation 'com.google.android.gms:play-services-location:21.3.0'
8787

8888
implementation 'com.google.android.material:material:1.12.0'
@@ -91,8 +91,8 @@ dependencies {
9191
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
9292
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
9393
implementation 'androidx.appcompat:appcompat:1.7.1'
94-
implementation 'androidx.browser:browser:1.8.0'
95-
implementation 'androidx.work:work-runtime:2.10.2'
94+
implementation 'androidx.browser:browser:1.9.0'
95+
implementation 'androidx.work:work-runtime:2.10.3'
9696

9797
// Plugins
9898
implementation 'com.journeyapps:zxing-android-embedded:4.3.0' // ZXing library for QR code scanning

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
android:name=".SWVContext$App"
6565
android:label="@string/app_name"
6666
android:supportsRtl="true"
67-
android:theme="@style/SplashTheme"
67+
android:theme="@style/Theme.App.Starting"
6868
android:hardwareAccelerated="true"
6969
tools:ignore="UnusedAttribute">
7070

@@ -78,7 +78,7 @@
7878
android:name=".MainActivity"
7979
android:configChanges="orientation|screenSize|keyboardHidden|keyboard|navigation|uiMode"
8080
android:windowSoftInputMode="adjustResize"
81-
android:theme="@style/AppTheme"
81+
android:theme="@style/Theme.SmartWebView"
8282
android:exported="true">
8383
<intent-filter>
8484
<action android:name="android.intent.action.MAIN" />

app/src/main/java/mgks/os/swv/MainActivity.java

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,16 @@
7777
import androidx.appcompat.widget.Toolbar;
7878
import androidx.core.app.ActivityCompat;
7979
import androidx.core.content.ContextCompat;
80+
import androidx.core.graphics.Insets;
8081
import androidx.core.splashscreen.SplashScreen;
8182
import androidx.core.view.GravityCompat;
83+
import androidx.core.view.ViewCompat;
84+
import androidx.core.view.WindowCompat;
85+
import androidx.core.view.WindowInsetsCompat;
8286
import androidx.drawerlayout.widget.DrawerLayout;
8387
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
88+
89+
import com.google.android.material.appbar.MaterialToolbar;
8490
import com.google.android.material.navigation.NavigationView;
8591

8692
import java.util.Arrays;
@@ -112,20 +118,21 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
112118
@SuppressLint({"SetJavaScriptEnabled", "WrongViewCast", "JavascriptInterface"})
113119
@Override
114120
protected void onCreate(Bundle savedInstanceState) {
121+
// Secure the app on startup if biometric or auth is forced on launch
115122
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
116123

117-
if (SWVContext.ASWV_LAYOUT == 0 || (SWVContext.ASWV_LAYOUT == 1 && !SWVContext.ASWP_DRAWER_HEADER)) {
118-
setTheme(R.style.Theme_SmartWebView_Fullscreen);
119-
}
120-
121-
final SplashScreen splashScreen = androidx.core.splashscreen.SplashScreen.installSplashScreen(this);
124+
// Enable edge-to-edge display
125+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
122126

123127
super.onCreate(savedInstanceState);
124128

129+
// Handle splash screen
130+
final SplashScreen splashScreen = androidx.core.splashscreen.SplashScreen.installSplashScreen(this);
131+
125132
// If extending splash is enabled, set up a listener
126133
// Keep the splash screen on-screen if the extend feature is enabled
134+
final View content = findViewById(android.R.id.content);
127135
if (SWVContext.ASWP_EXTEND_SPLASH) {
128-
final View content = findViewById(android.R.id.content);
129136
content.getViewTreeObserver().addOnPreDrawListener(
130137
new ViewTreeObserver.OnPreDrawListener() {
131138
@Override
@@ -225,68 +232,72 @@ public boolean onPreDraw() {
225232
initializeWebView();
226233

227234
// Setup features and handle intents
228-
setupFeatures();
229-
handleIncomingIntents();
235+
if (savedInstanceState == null) {
236+
setupFeatures();
237+
handleIncomingIntents();
238+
}
230239

231240
// Debug mode logging
232241
if(SWVContext.SWV_DEBUGMODE){
233242
Log.d(TAG, "URL: "+ SWVContext.CURR_URL+"DEVICE INFO: "+ Arrays.toString(fns.get_info(this)));
234243
}
244+
245+
ViewCompat.setOnApplyWindowInsetsListener(content, (v, windowInsets) -> {
246+
// Get the insets for the system bars (status bar, navigation bar)
247+
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
248+
249+
// Apply the insets as padding to the root view.
250+
// This pushes the entire layout down from the status bar and up from the nav bar.
251+
v.setPadding(insets.left, insets.top, insets.right, insets.bottom);
252+
253+
// Return the insets so that other views can also process them if needed.
254+
return windowInsets;
255+
});
235256
}
236257

237258
/**
238259
* Setup the UI layout based on configuration
239260
*/
240261
private void setupLayout() {
241-
final SwipeRefreshLayout pullRefresh = findViewById(R.id.pullfresh);
242-
// Set content view based on configuration
243262
if (SWVContext.ASWV_LAYOUT == 1) {
244263
setContentView(R.layout.drawer_main);
264+
MaterialToolbar toolbar = findViewById(R.id.toolbar); // Use MaterialToolbar
265+
final SwipeRefreshLayout pullRefresh = findViewById(R.id.pullfresh);
245266

246-
Toolbar toolbar = findViewById(R.id.toolbar);
247-
setSupportActionBar(toolbar);
248-
Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false);
249-
250-
// Conditionally show or hide the header based on config
251267
if (SWVContext.ASWP_DRAWER_HEADER) {
252-
// Header is enabled: Setup Toolbar and Toggle
253268
findViewById(R.id.app_bar).setVisibility(View.VISIBLE);
254269
setSupportActionBar(toolbar);
255270
Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false);
256271

257272
DrawerLayout drawer = findViewById(R.id.drawer_layout);
258-
259273
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.open, R.string.close) {
260274
@Override
261275
public void onDrawerSlide(View drawerView, float slideOffset) {
262276
super.onDrawerSlide(drawerView, slideOffset);
263-
// This is the key part: disable pull-to-refresh while drawer is opening.
264-
if (slideOffset > 0 && pullRefresh.isEnabled()) {
277+
if (pullRefresh != null && slideOffset > 0 && pullRefresh.isEnabled()) {
265278
pullRefresh.setEnabled(false);
266279
}
267280
}
268281

269282
@Override
270283
public void onDrawerClosed(View drawerView) {
271284
super.onDrawerClosed(drawerView);
272-
// Re-enable pull-to-refresh only if the feature is globally enabled.
273-
if (!pullRefresh.isEnabled() && SWVContext.ASWP_PULLFRESH) {
285+
if (pullRefresh != null && !pullRefresh.isEnabled() && SWVContext.ASWP_PULLFRESH) {
274286
pullRefresh.setEnabled(true);
275287
}
276288
}
277289
};
278290
drawer.addDrawerListener(toggle);
279291
toggle.syncState();
280-
281292
} else {
282-
// Header is disabled: Hide the AppBarLayout completely
283293
findViewById(R.id.app_bar).setVisibility(View.GONE);
284294
}
285295

286296
NavigationView navigationView = findViewById(R.id.nav_view);
287297
navigationView.setNavigationItemSelectedListener(this);
288298

289-
// The footer is part of the NavigationView's own view hierarchy.
299+
/*
300+
// Temporarily disabled theme toggle logic
290301
MenuItem switchItem = navigationView.getMenu().findItem(R.id.nav_dark_mode_switch);
291302
SwitchCompat themeSwitch = (SwitchCompat) Objects.requireNonNull(switchItem.getActionView()).findViewById(R.id.drawer_theme_switch);
292303
if (themeSwitch != null) {
@@ -296,21 +307,18 @@ public void onDrawerClosed(View drawerView) {
296307
AppCompatDelegate.setDefaultNightMode(
297308
isChecked ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO
298309
);
310+
recreate();
299311
});
300312
}
313+
*/
301314

302315
} else {
303316
setContentView(R.layout.activity_main);
304317
}
305318

306-
// Initialize UI components
307319
SWVContext.asw_view = findViewById(R.id.msw_view);
308320
adContainer = findViewById(R.id.msw_ad_container);
309321
SWVContext.print_view = findViewById(R.id.print_view);
310-
311-
// Setup window appearance
312-
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
313-
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
314322
}
315323

316324
/**
@@ -779,6 +787,9 @@ public void onConfigurationChanged(@NonNull Configuration newConfig) {
779787
protected void onSaveInstanceState(@NonNull Bundle outState) {
780788
super.onSaveInstanceState(outState);
781789
SWVContext.asw_view.saveState(outState);
790+
if (SWVContext.asw_view.getUrl() != null) {
791+
outState.putString("swv_last_url", SWVContext.asw_view.getUrl());
792+
}
782793
}
783794

784795
@Override

0 commit comments

Comments
 (0)