Skip to content

Commit 50426bf

Browse files
authored
Update part 2: updating for Android 15 (sdk 35) compatibility (#1737)
2 parents 8da26bc + dd575ff commit 50426bf

30 files changed

+529
-30
lines changed

PasscodeLock/src/main/java/org/wordpress/passcodelock/PasscodeManagePasswordActivity.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package org.wordpress.passcodelock;
22

33
import android.annotation.SuppressLint;
4+
import android.os.Build;
45
import android.os.Bundle;
56
import android.view.View;
67
import android.widget.TextView;
78

89
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
910
import androidx.core.os.CancellationSignal;
11+
import androidx.core.view.WindowCompat;
12+
import androidx.core.view.WindowInsetsControllerCompat;
1013

1114
public class PasscodeManagePasswordActivity extends AbstractPasscodeKeyboardActivity {
1215
public static final String KEY_TYPE = "type";
@@ -17,6 +20,23 @@ public class PasscodeManagePasswordActivity extends AbstractPasscodeKeyboardActi
1720
@Override
1821
protected void onCreate(Bundle savedInstanceState) {
1922
super.onCreate(savedInstanceState);
23+
24+
// Setup edge-to-edge display for Android 15+ compatibility
25+
// This is a fullscreen passcode activity without toolbar
26+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
27+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
28+
29+
WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(
30+
getWindow(),
31+
getWindow().getDecorView()
32+
);
33+
34+
if (controller != null) {
35+
// Dark status bar appearance for the passcode screen background
36+
controller.setAppearanceLightStatusBars(false);
37+
controller.setAppearanceLightNavigationBars(false);
38+
}
39+
}
2040

2141
Bundle extras = getIntent().getExtras();
2242
if (extras != null) {

PasscodeLock/src/main/res/layout/app_passcode_keyboard.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
android:background="@color/passcodelock_background"
77
android:layout_height="match_parent"
88
android:layout_width="match_parent"
9+
android:fitsSystemWindows="false"
910
android:paddingBottom="24dp"
1011
android:paddingLeft="24dp"
1112
android:paddingRight="24dp"
12-
android:paddingTop="32dp">
13+
android:paddingTop="?attr/actionBarSize">
1314

1415
<TextView
1516
android:id="@+id/passcodelock_prompt"

Simplenote/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ android {
4141
versionCode versionProperties.getProperty("versionCode").toInteger()
4242

4343
minSdkVersion 23
44-
targetSdkVersion 34
44+
targetSdkVersion 35
4545
}
4646

4747

Simplenote/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@
164164
android:name="com.automattic.simplenote.PreferencesActivity"
165165
android:configChanges="orientation|keyboardHidden|screenSize"
166166
android:label="Preferences"
167-
android:parentActivityName=".NotesActivity">
167+
android:parentActivityName=".NotesActivity"
168+
android:theme="@style/Theme.Simplestyle">
168169
</activity>
169170

170171
<activity

Simplenote/src/main/java/com/automattic/simplenote/AboutActivity.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import androidx.appcompat.widget.Toolbar;
99

1010
import com.automattic.simplenote.utils.DrawableUtils;
11+
import com.automattic.simplenote.utils.SystemBarUtils;
1112

1213
public class AboutActivity extends AppCompatActivity {
1314
@Override
@@ -24,6 +25,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
2425
this, R.drawable.ic_cross_24dp, android.R.color.white
2526
));
2627
}
28+
29+
// Setup edge-to-edge display with proper WindowInsets handling
30+
// AboutActivity has a dark theme with blue background, so use appropriate appearance
31+
SystemBarUtils.setupEdgeToEdgeWithToolbar(
32+
this,
33+
findViewById(R.id.main_parent_view),
34+
toolbar,
35+
findViewById(R.id.about_fragment),
36+
false, // Dark status bar icons for blue background
37+
false // Dark navigation bar icons for blue background
38+
);
2739
}
2840

2941
@Override

Simplenote/src/main/java/com/automattic/simplenote/AddTagActivity.kt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.automattic.simplenote
22

3+
import android.os.Build
34
import android.os.Bundle
45
import android.os.Handler
56
import android.text.method.LinkMovementMethod
@@ -10,10 +11,13 @@ import android.widget.TextView
1011
import androidx.activity.viewModels
1112
import androidx.appcompat.app.AlertDialog
1213
import androidx.appcompat.app.AppCompatActivity
14+
import androidx.core.view.ViewCompat
15+
import androidx.core.view.WindowInsetsCompat
1316
import androidx.core.widget.doAfterTextChanged
1417
import com.automattic.simplenote.databinding.ActivityTagAddBinding
1518
import com.automattic.simplenote.utils.DisplayUtils
1619
import com.automattic.simplenote.utils.HtmlCompat
20+
import com.automattic.simplenote.utils.SystemBarUtils
1721
import com.automattic.simplenote.utils.ThemeUtils
1822
import com.automattic.simplenote.viewmodels.AddTagViewModel
1923
import com.automattic.simplenote.widgets.MorphCircleToRectangle
@@ -27,15 +31,29 @@ class AddTagActivity : AppCompatActivity() {
2731
override fun onCreate(savedInstanceState: Bundle?) {
2832
ThemeUtils.setTheme(this)
2933
super.onCreate(savedInstanceState)
30-
val binding: ActivityTagAddBinding = ActivityTagAddBinding.inflate(layoutInflater)
3134

32-
binding.setObservers()
33-
binding.setupLayout()
34-
binding.setupViews()
35+
with(ActivityTagAddBinding.inflate(layoutInflater)) {
36+
setContentView(root)
37+
setupLayout()
38+
setupViews()
39+
setObservers()
3540

36-
viewModel.start()
41+
viewModel.start()
42+
43+
44+
// Setup edge-to-edge display with proper WindowInsets handling
45+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
46+
SystemBarUtils.setupEdgeToEdgeWithAutoTheming(this@AddTagActivity, root, null, null)
47+
}
48+
49+
// Add minimal IME (keyboard) insets handling for dialog positioning
50+
ViewCompat.setOnApplyWindowInsetsListener(root) { view, insets ->
51+
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
52+
view.setPadding(view.paddingLeft, view.paddingTop, view.paddingRight, imeInsets.bottom)
53+
insets
54+
}
55+
}
3756

38-
setContentView(binding.root)
3957
}
4058

4159
private fun ActivityTagAddBinding.setupViews() {

Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import androidx.appcompat.widget.Toolbar
1313
import androidx.recyclerview.widget.LinearLayoutManager
1414
import com.automattic.simplenote.databinding.ActivityCollaboratorsBinding
1515
import com.automattic.simplenote.utils.CollaboratorsAdapter
16-
import com.automattic.simplenote.utils.CollaboratorsAdapter.*
1716
import com.automattic.simplenote.utils.CollaboratorsAdapter.CollaboratorDataItem.*
17+
import com.automattic.simplenote.utils.DisplayUtils
1818
import com.automattic.simplenote.utils.IntentUtils
19+
import com.automattic.simplenote.utils.SystemBarUtils
1920
import com.automattic.simplenote.utils.toast
2021
import com.automattic.simplenote.viewmodels.CollaboratorsViewModel
2122
import com.automattic.simplenote.viewmodels.CollaboratorsViewModel.Event
@@ -47,6 +48,16 @@ class CollaboratorsActivity : ThemedAppCompatActivity() {
4748
setObservers()
4849

4950
viewModel.loadCollaborators(noteId)
51+
52+
// Setup edge-to-edge display with proper WindowInsets handling
53+
// Use auto-theming to properly handle status bar appearance based on theme
54+
val toolbar = findViewById<Toolbar>(R.id.toolbar)
55+
SystemBarUtils.setupEdgeToEdgeWithAutoTheming(
56+
this@CollaboratorsActivity,
57+
findViewById(R.id.main_parent_view),
58+
toolbar,
59+
collaboratorsList
60+
)
5061
}
5162
}
5263

@@ -79,6 +90,9 @@ class CollaboratorsActivity : ThemedAppCompatActivity() {
7990
collaboratorsList.setEmptyView(empty.root)
8091

8192
buttonAddCollaborator.setOnClickListener { viewModel.clickAddCollaborator() }
93+
buttonAddCollaborator.setOnApplyWindowInsetsListener { view, insets ->
94+
DisplayUtils.applyWindowInsetsForFloatingActionButton(insets, resources, view)
95+
}
8296

8397
empty.image.setImageResource(R.drawable.ic_collaborate_24dp)
8498
empty.title.text = getString(R.string.no_collaborators)

Simplenote/src/main/java/com/automattic/simplenote/NoteEditorActivity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.automattic.simplenote.utils.DisplayUtils;
3737
import com.automattic.simplenote.utils.IntentUtils;
3838
import com.automattic.simplenote.utils.NetworkUtils;
39+
import com.automattic.simplenote.utils.SystemBarUtils;
3940
import com.automattic.simplenote.utils.WidgetUtils;
4041
import com.automattic.simplenote.widgets.NoteEditorViewPager;
4142
import com.automattic.simplenote.widgets.RobotoMediumTextView;
@@ -230,6 +231,15 @@ public void onPageScrollStateChanged(int state) {
230231
"note_list_widget_note_tapped"
231232
);
232233
}
234+
235+
// Setup edge-to-edge display with proper WindowInsets handling
236+
// Use auto-theming to properly handle status bar appearance based on theme
237+
SystemBarUtils.setupEdgeToEdgeWithAutoTheming(
238+
this,
239+
findViewById(R.id.main_parent_view),
240+
toolbar,
241+
findViewById(R.id.pager)
242+
);
233243
}
234244

235245
@Override

Simplenote/src/main/java/com/automattic/simplenote/NoteEditorFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
import com.automattic.simplenote.utils.TagsMultiAutoCompleteTextView;
8383
import com.automattic.simplenote.utils.TagsMultiAutoCompleteTextView.OnTagAddedListener;
8484
import com.automattic.simplenote.utils.TextHighlighter;
85+
import com.automattic.simplenote.utils.SystemBarUtils;
8586
import com.automattic.simplenote.utils.ThemeUtils;
8687
import com.automattic.simplenote.utils.WidgetUtils;
8788
import com.automattic.simplenote.viewmodels.NoteEditorViewModel;
@@ -204,7 +205,7 @@ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
204205
DrawableUtils.tintMenuWithAttribute(getActivity(), menu, R.attr.toolbarIconColor);
205206
}
206207

207-
requireActivity().getWindow().setStatusBarColor(ThemeUtils.getColorFromAttribute(requireContext(), R.attr.mainBackgroundColor));
208+
SystemBarUtils.setStatusBarColor(requireActivity(), ThemeUtils.getColorFromAttribute(requireContext(), R.attr.mainBackgroundColor));
208209
return true;
209210
}
210211

@@ -279,7 +280,7 @@ public void onDestroyActionMode(ActionMode mode) {
279280
}
280281

281282
new Handler().postDelayed(
282-
() -> requireActivity().getWindow().setStatusBarColor(
283+
() -> SystemBarUtils.setStatusBarColor(requireActivity(),
283284
getResources().getColor(android.R.color.transparent, requireActivity().getTheme())),
284285
requireContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)
285286
);

Simplenote/src/main/java/com/automattic/simplenote/NoteListFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
import com.automattic.simplenote.utils.SimplenoteLinkify;
8181
import com.automattic.simplenote.utils.StrUtils;
8282
import com.automattic.simplenote.utils.TextHighlighter;
83+
import com.automattic.simplenote.utils.SystemBarUtils;
8384
import com.automattic.simplenote.utils.ThemeUtils;
8485
import com.automattic.simplenote.utils.WidgetUtils;
8586
import com.automattic.simplenote.widgets.RobotoRegularTextView;
@@ -193,7 +194,7 @@ public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
193194
inflater.inflate(R.menu.bulk_edit, menu);
194195
DrawableUtils.tintMenuWithAttribute(getActivity(), menu, R.attr.actionModeTextColor);
195196
mActionMode = actionMode;
196-
requireActivity().getWindow().setStatusBarColor(ThemeUtils.getColorFromAttribute(requireContext(), R.attr.mainBackgroundColor));
197+
SystemBarUtils.setStatusBarColor(requireActivity(), ThemeUtils.getColorFromAttribute(requireContext(), R.attr.mainBackgroundColor));
197198
return true;
198199
}
199200

@@ -304,7 +305,7 @@ public void onDestroyActionMode(ActionMode mode) {
304305
new Runnable() {
305306
@Override
306307
public void run() {
307-
requireActivity().getWindow().setStatusBarColor(getResources().getColor(android.R.color.transparent, requireActivity().getTheme()));
308+
SystemBarUtils.setStatusBarColor(requireActivity(), getResources().getColor(android.R.color.transparent, requireActivity().getTheme()));
308309
}
309310
},
310311
requireContext().getResources().getInteger(android.R.integer.config_longAnimTime)

0 commit comments

Comments
 (0)