diff options
| author | Benjamin Linskey | 2025-10-03 22:38:08 -0400 |
|---|---|---|
| committer | Benjamin Linskey | 2025-10-03 22:38:08 -0400 |
| commit | c3708414f615f632aa6cbe337d9cdb929378e93d (patch) | |
| tree | bac2914b9bbdd52b868a6dc7ed10f65a3b11ed98 | |
| parent | 20e236f57de6d996366556123a099c540ec27c8e (diff) | |
| download | greek-reference-c3708414f615f632aa6cbe337d9cdb929378e93d.tar.gz | |
Improve navigation bar handling
Removed uses of deprecated method setNavigationBarColor(). Used setNavigationBarContrastEnforced() to enable background on navigation bar.
4 files changed, 13 insertions, 8 deletions
diff --git a/GreekReference/src/main/java/com/benlinskey/greekreference/views/MainActivity.java b/GreekReference/src/main/java/com/benlinskey/greekreference/views/MainActivity.java index 0b9e30c..167c4be 100644 --- a/GreekReference/src/main/java/com/benlinskey/greekreference/views/MainActivity.java +++ b/GreekReference/src/main/java/com/benlinskey/greekreference/views/MainActivity.java @@ -25,6 +25,7 @@ import android.app.SearchManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; @@ -98,6 +99,9 @@ public class MainActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WindowCompat.enableEdgeToEdge(getWindow()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + getWindow().setNavigationBarContrastEnforced(true); + } setContentView(R.layout.activity_item_list); mMainPresenter = new MainPresenter(this, this); @@ -106,8 +110,6 @@ public class MainActivity mLexiconPresenter = new LexiconPresenter(this, this); mSyntaxPresenter = new SyntaxPresenter(this, this); - getWindow().setNavigationBarColor(Color.parseColor("#000000")); - // Set the toolbar to act as the action bar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar); setSupportActionBar(toolbar); diff --git a/GreekReference/src/main/java/com/benlinskey/greekreference/views/PerseusToolActivity.java b/GreekReference/src/main/java/com/benlinskey/greekreference/views/PerseusToolActivity.java index f877c4a..2239e5f 100644 --- a/GreekReference/src/main/java/com/benlinskey/greekreference/views/PerseusToolActivity.java +++ b/GreekReference/src/main/java/com/benlinskey/greekreference/views/PerseusToolActivity.java @@ -70,9 +70,10 @@ public class PerseusToolActivity extends AbstractContainerActivity { getWindow().requestFeature(Window.FEATURE_PROGRESS); super.onCreate(savedInstanceState); WindowCompat.enableEdgeToEdge(getWindow()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + getWindow().setNavigationBarContrastEnforced(true); + } setContentView(R.layout.activity_perseus_tool); - - getWindow().setNavigationBarColor(Color.parseColor("#000000")); // Set the toolbar to act as the action bar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar); diff --git a/GreekReference/src/main/java/com/benlinskey/greekreference/views/SettingsActivity.java b/GreekReference/src/main/java/com/benlinskey/greekreference/views/SettingsActivity.java index ddd25e8..46524ab 100644 --- a/GreekReference/src/main/java/com/benlinskey/greekreference/views/SettingsActivity.java +++ b/GreekReference/src/main/java/com/benlinskey/greekreference/views/SettingsActivity.java @@ -49,10 +49,11 @@ public class SettingsActivity extends AbstractContainerActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WindowCompat.enableEdgeToEdge(getWindow()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + getWindow().setNavigationBarContrastEnforced(true); + } setContentView(R.layout.activity_settings); - getWindow().setNavigationBarColor(Color.parseColor("#000000")); - // Set the toolbar to act as the action bar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar); setSupportActionBar(toolbar); diff --git a/GreekReference/src/main/java/com/benlinskey/greekreference/views/detail/AbstractDetailActivity.java b/GreekReference/src/main/java/com/benlinskey/greekreference/views/detail/AbstractDetailActivity.java index 2f84147..bc06bf3 100644 --- a/GreekReference/src/main/java/com/benlinskey/greekreference/views/detail/AbstractDetailActivity.java +++ b/GreekReference/src/main/java/com/benlinskey/greekreference/views/detail/AbstractDetailActivity.java @@ -50,11 +50,12 @@ public abstract class AbstractDetailActivity extends AbstractContainerActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WindowCompat.enableEdgeToEdge(getWindow()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + getWindow().setNavigationBarContrastEnforced(true); + } setContentView(R.layout.activity_item_detail); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); - - getWindow().setNavigationBarColor(Color.parseColor("#000000")); // Set the toolbar to act as the action bar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar); |