Skip to content

Commit

Permalink
ExactCalculator: Setup for edge to edge support
Browse files Browse the repository at this point in the history
Change-Id: Id77e643af7600fac4599d9641e6bf887f18aa18e
Signed-off-by: Aayush Gupta <[email protected]>
  • Loading branch information
theimpulson authored and mikeNG committed Nov 9, 2024
1 parent f9f0b82 commit b10a222
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
15 changes: 15 additions & 0 deletions res/drawable/activity_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2023 The LineageOS Project
SPDX-License-Identifier: Apache-2.0
-->
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="180">
<shape>
<gradient
android:centerX="-10.0"
android:startColor="@color/display_background_color"
android:endColor="?colorSurface"
android:type="sweep" />
</shape>
</rotate>
1 change: 1 addition & 0 deletions res/layout-land/activity_calculator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:id="@+id/main_calculator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/activity_background"
android:orientation="vertical"
app:layoutDescription="@xml/activity_calculator_scene">

Expand Down
1 change: 1 addition & 0 deletions res/layout/activity_calculator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:id="@+id/main_calculator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/activity_background"
android:orientation="vertical"
app:layoutDescription="@xml/activity_calculator_scene">

Expand Down
15 changes: 15 additions & 0 deletions src/com/android/calculator2/Calculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.motion.widget.MotionLayout;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

Expand Down Expand Up @@ -304,6 +308,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_calculator);
setupEdgeToEdge();
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

// Hide all default options in the ActionBar.
Expand Down Expand Up @@ -1251,4 +1256,14 @@ public void onContextMenuClosed(Menu menu) {
public interface OnDisplayMemoryOperationsListener {
boolean shouldDisplayMemory();
}

private void setupEdgeToEdge() {
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
ViewCompat.setOnApplyWindowInsetsListener(requireViewById(R.id.main_calculator),
(v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(0, insets.top, 0, insets.bottom);
return WindowInsetsCompat.CONSUMED;
});
}
}

0 comments on commit b10a222

Please sign in to comment.