Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#225 - update navigation bar and icons color based on preference theme #231

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import android.Manifest;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
Expand All @@ -48,12 +50,15 @@
import androidx.preference.PreferenceManager;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.Toolbar;

import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

Expand Down Expand Up @@ -135,6 +140,7 @@ public void onTabSelected(TabLayout.Tab tab) {
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
bottomSheetBehavior.setHideable(false);
bottomSheet.setFocusable(false);
updateNavigationBarColor(getWindow(),getApplicationContext());
}

@Override
Expand Down Expand Up @@ -831,4 +837,21 @@ public void onToggleLock() {
}
//Update();
}

/**
* Updates the navigation bar background and icon colors to match the bottom bar background based on the theme.
*/
public void updateNavigationBarColor(Window window, Context applicationContext) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (window != null && applicationContext instanceof Application) {
// Retrieve the preferred color theme from shared preferences and check if it's "1"
if (TextUtils.equals("1", PreferenceManager.getDefaultSharedPreferences(applicationContext).getString("prefColorTheme", "2"))) {
window.setNavigationBarColor(getResources().getColor(R.color.colorRecControlBackground,getTheme()));
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
} else {
window.setNavigationBarColor(getResources().getColor(R.color.colorRecControlBackground,getTheme()));
}
}
}
}
}