Skip to content

Commit

Permalink
Target API 35 - enable edge to edge mode, update status bar colors (#985
Browse files Browse the repository at this point in the history
)

* Target API 35

* Bump Activity to 1.9.x to get edge to edge support

* Update onboarding screens to draw edge-to-edge

* Set edge to edge for navigation drawer activities

* Set edge-to-edge for open source licenses and more search results

* Adjust settings activities for edge to edge

* Update confirm image suggestion activity for edge to edge

* Remove translucent status theme

* Correctly set status bar appearance

* Remove unused imports

* Update Robolectric for API 35 support
  • Loading branch information
bherbst authored Dec 5, 2024
1 parent f64ddbd commit 67018de
Show file tree
Hide file tree
Showing 26 changed files with 174 additions and 63 deletions.
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ android {

defaultConfig {
applicationId "com.thebluealliance.androidclient"
compileSdk 34
compileSdk 35
minSdkVersion 19
targetSdkVersion 34
targetSdkVersion 35
versionCode versionNum
versionName version.toString()
multiDexEnabled true
Expand Down Expand Up @@ -230,9 +230,9 @@ dependencies {
implementation project(':libImgur')

// Android support libraries
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation("androidx.activity:activity:1.9.3")
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.core:core:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
Expand Down
24 changes: 14 additions & 10 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@
<activity
android:name=".activities.HomeActivity"
android:launchMode="singleTop"
android:theme="@style/AppThemeNoActionBarTranslucentStatus" />
android:theme="@style/AppThemeNoActionBar" />
<activity
android:name=".activities.settings.MyTBAModelSettingsActivity"
android:theme="@style/AppThemeNoActionBarTranslucentLightStatus" />
<activity
android:name=".activities.ViewEventActivity"
android:launchMode="singleTop"
android:parentActivityName=".activities.HomeActivity"
android:theme="@style/AppThemeNoActionBarTranslucentStatus">
android:theme="@style/AppThemeNoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.thebluealliance.androidclient.activities.HomeActivity" />
Expand All @@ -117,7 +117,7 @@
android:name=".activities.ViewTeamActivity"
android:launchMode="standard"
android:parentActivityName=".activities.HomeActivity"
android:theme="@style/AppThemeNoActionBarTranslucentStatus">
android:theme="@style/AppThemeNoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.thebluealliance.androidclient.activities.HomeActivity" />
Expand All @@ -126,48 +126,50 @@
android:name=".activities.ViewMatchActivity"
android:launchMode="standard"
android:parentActivityName=".activities.ViewEventActivity"
android:theme="@style/AppThemeNoActionBarTranslucentStatus">
android:theme="@style/AppThemeNoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.thebluealliance.androidclient.activities.ViewEventActivity" />
</activity>
<activity
android:name=".activities.ViewDistrictActivity"
android:parentActivityName=".activities.HomeActivity"
android:theme="@style/AppThemeNoActionBarTranslucentStatus">
android:theme="@style/AppThemeNoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.thebluealliance.androidclient.activities.HomeActivity" />
</activity>
<activity
android:name=".activities.TeamAtDistrictActivity"
android:parentActivityName=".activities.ViewDistrictActivity"
android:theme="@style/AppThemeNoActionBarTranslucentStatus">
android:theme="@style/AppThemeNoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.thebluealliance.androidclient.activities.ViewDistrictActivity" />
</activity>
<activity
android:name=".activities.settings.SettingsActivity"
android:label="@string/title_activity_settings" />
android:label="@string/title_activity_settings"
android:theme="@style/AppThemeNoActionBar" />
<activity
android:name=".activities.OpenSourceLicensesActivity"
android:label="@string/license_label" />
android:label="@string/license_label"
android:theme="@style/AppThemeNoActionBar" />
<activity
android:name=".activities.ContributorsActivity"
android:theme="@style/AppThemeNoActionBar" />
<activity
android:name=".activities.TeamAtEventActivity"
android:parentActivityName=".activities.ViewEventActivity"
android:theme="@style/AppThemeNoActionBarTranslucentStatus">
android:theme="@style/AppThemeNoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.thebluealliance.androidclient.activities.ViewEventActivity" />
</activity>
<activity
android:name=".activities.SearchResultsActivity"
android:launchMode="singleTop"
android:theme="@style/AppThemeNoActionBarTranslucentStatus"
android:theme="@style/AppThemeNoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
Expand All @@ -188,6 +190,7 @@
<activity
android:name=".activities.settings.DevSettingsActivity"
android:label="@string/title_activity_dev_settings"
android:theme="@style/AppThemeNoActionBar"
android:parentActivityName=".activities.settings.SettingsActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
Expand All @@ -196,6 +199,7 @@
<activity
android:name=".activities.settings.NotificationSettingsActivity"
android:label="@string/notification_settings"
android:theme="@style/AppThemeNoActionBar"
android:parentActivityName=".activities.settings.SettingsActivity"
android:exported="true">
<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import android.view.View;
import android.view.Window;

import androidx.activity.EdgeToEdge;
import androidx.annotation.RawRes;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.view.WindowInsetsControllerCompat;

import com.google.common.base.Predicate;
import com.thebluealliance.androidclient.activities.HomeActivity;
Expand Down Expand Up @@ -482,4 +485,12 @@ public static int getCurrentDarkModePreference(String prefValue) {
return MODE_NIGHT_UNSPECIFIED;
}
}

public static void configureActivityForEdgeToEdge(AppCompatActivity activity) {
EdgeToEdge.enable(activity);

Window window = activity.getWindow();
WindowInsetsControllerCompat insetsController = new WindowInsetsControllerCompat(window, window.getDecorView());
insetsController.setAppearanceLightStatusBars(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
import android.view.ViewTreeObserver;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.ViewCompat;

import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.TbaLogger;
import com.thebluealliance.androidclient.Utilities;
import com.thebluealliance.androidclient.databinding.ActivityConfirmImageSuggestionBinding;
import com.thebluealliance.androidclient.helpers.TeamHelper;
import com.thebluealliance.androidclient.imgur.ImgurSuggestionService;
Expand All @@ -26,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;

import androidx.appcompat.app.AppCompatActivity;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
Expand Down Expand Up @@ -59,6 +58,7 @@ public static Intent newIntent(Context context, Uri imageUri, String teamKey, in
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utilities.configureActivityForEdgeToEdge(this);

mBinding = ActivityConfirmImageSuggestionBinding.inflate(getLayoutInflater());
setContentView(mBinding.getRoot());
Expand All @@ -69,7 +69,6 @@ protected void onCreate(Bundle savedInstanceState) {
// Disable the "confirm" FAB until we have a valid file to submit
mBinding.confirmFab.setEnabled(false);

ViewCompat.setElevation(mBinding.toolbar, getResources().getDimension(R.dimen.toolbar_elevation));
setSupportActionBar(mBinding.toolbar);
// TODO don't use hardcoded string
getSupportActionBar().setTitle("Confirm suggestion");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.ViewCompat;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;

Expand Down Expand Up @@ -55,10 +54,10 @@ public static Intent newInstance(Context c, int mode, String query) {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utilities.configureActivityForEdgeToEdge(this);
setContentView(R.layout.activity_search_results);

toolbar = (Toolbar) findViewById(R.id.toolbar);
ViewCompat.setElevation(toolbar, getResources().getDimension(R.dimen.toolbar_elevation));
setSupportActionBar(toolbar);

/* Report activity start to Analytics */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import androidx.viewpager.widget.ViewPager;

import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.Utilities;
import com.thebluealliance.androidclient.databinding.ActivityMytbaOnboardingBinding;
import com.thebluealliance.androidclient.mytba.MyTbaOnboardingController;
import com.thebluealliance.androidclient.views.MyTBAOnboardingViewPager;
Expand All @@ -36,6 +37,7 @@ public class MyTBAOnboardingActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utilities.configureActivityForEdgeToEdge(this);
mBinding = ActivityMytbaOnboardingBinding.inflate(getLayoutInflater());
setContentView(mBinding.getRoot());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ protected void syncFabVisibilityWithMyTbaEnabled(boolean animate) {
} else {
hideFab(animate);
}
showFab(animate);
}

protected void showFab(boolean animate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import androidx.drawerlayout.widget.DrawerLayout;

import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.Utilities;
import com.thebluealliance.androidclient.activities.settings.SettingsActivity;
import com.thebluealliance.androidclient.fragments.NavigationDrawerFragment;
import com.thebluealliance.androidclient.listitems.NavDrawerItem;
Expand Down Expand Up @@ -66,9 +67,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.activity_navigation_drawer);

Utilities.configureActivityForEdgeToEdge(this);

mDrawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer_layout);
mContentView = (FrameLayout) findViewById(R.id.content);
mDrawerLayout.setStatusBarBackground(R.color.primary_dark);
mDrawerLayout.setStatusBarBackground(R.color.primary);
mDrawerContainer = (ScrimInsetsFrameLayout) findViewById(R.id.navigation_drawer_fragment_container);

handler = new Handler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
import android.view.View;
import android.view.WindowManager;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import com.thebluealliance.androidclient.BuildConfig;
import com.thebluealliance.androidclient.Constants;
import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.TbaLogger;
import com.thebluealliance.androidclient.Utilities;
import com.thebluealliance.androidclient.adapters.FirstLaunchPagerAdapter;
import com.thebluealliance.androidclient.background.firstlaunch.LoadTBADataWorker;
import com.thebluealliance.androidclient.databinding.ActivityOnboardingBinding;
Expand All @@ -34,6 +31,9 @@

import javax.inject.Inject;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import dagger.hilt.android.AndroidEntryPoint;

@AndroidEntryPoint
Expand Down Expand Up @@ -65,6 +65,7 @@ public class OnboardingActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utilities.configureActivityForEdgeToEdge(this);
mBinding = ActivityOnboardingBinding.inflate(getLayoutInflater());
setContentView(mBinding.getRoot());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import android.os.Bundle;
import android.text.Html;
import android.view.MenuItem;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.Utilities;
import com.thebluealliance.androidclient.databinding.ActivityOpenSourceLicensesBinding;

import java.io.BufferedReader;
import java.io.InputStreamReader;
Expand All @@ -16,9 +17,14 @@ public class OpenSourceLicensesActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_open_source_licenses);
TextView text = (TextView) findViewById(R.id.text);
Utilities.configureActivityForEdgeToEdge(this);

ActivityOpenSourceLicensesBinding binding = ActivityOpenSourceLicensesBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

setSupportActionBar(binding.toolbar);
setupActionBar();

try {
BufferedReader br = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.licenses)));
try {
Expand All @@ -31,13 +37,13 @@ protected void onCreate(Bundle savedInstanceState) {
line = br.readLine();
}
String everything = sb.toString();
text.setText(Html.fromHtml(everything));
binding.text.setText(Html.fromHtml(everything));
} finally {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
text.setText("Error reading licenses file.");
binding.text.setText("Error reading licenses file.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.thebluealliance.androidclient.Constants;
import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.TbaLogger;
import com.thebluealliance.androidclient.Utilities;
import com.thebluealliance.androidclient.adapters.FirstLaunchPagerAdapter;
import com.thebluealliance.androidclient.background.firstlaunch.LoadTBADataWorker;
import com.thebluealliance.androidclient.databinding.ActivityRedownloadBinding;
Expand Down Expand Up @@ -55,6 +56,7 @@ public class RedownloadActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utilities.configureActivityForEdgeToEdge(this);
mBinding = ActivityRedownloadBinding.inflate(getLayoutInflater());
setContentView(mBinding.getRoot());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import androidx.appcompat.app.AppCompatActivity;

import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.Utilities;

public class UpdateRequiredActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utilities.configureActivityForEdgeToEdge(this);

setContentView(R.layout.activity_update_required);

findViewById(R.id.update_google_play_button).setOnClickListener(v -> {
Expand Down
Loading

0 comments on commit 67018de

Please sign in to comment.