33import android .content .ActivityNotFoundException ;
44import android .content .Intent ;
55import android .content .SharedPreferences ;
6+ import android .graphics .Typeface ;
67import android .net .Uri ;
78import android .os .Bundle ;
89
910import androidx .activity .EdgeToEdge ;
1011import androidx .appcompat .app .AppCompatActivity ;
1112import androidx .appcompat .app .AppCompatDelegate ;
12- import androidx .core .graphics .Insets ;
13- import androidx .core .view .ViewCompat ;
14- import androidx .core .view .WindowInsetsCompat ;
13+ import androidx .core .content .res .ResourcesCompat ;
1514import androidx .preference .PreferenceManager ;
1615import androidx .recyclerview .widget .LinearLayoutManager ;
1716import androidx .recyclerview .widget .RecyclerView ;
1817
1918import com .google .android .gms .oss .licenses .OssLicensesMenuActivity ;
19+ import com .google .android .material .appbar .CollapsingToolbarLayout ;
2020import com .google .android .material .dialog .MaterialAlertDialogBuilder ;
2121
2222import java .util .ArrayList ;
@@ -40,29 +40,23 @@ protected void onCreate(Bundle savedInstanceState) {
4040 EdgeToEdge .enable (this );
4141 setContentView (R .layout .activity_options );
4242
43- ViewCompat .setOnApplyWindowInsetsListener (findViewById (R .id .optionsToolbar ),
44- (v , insets ) -> {
45- Insets systemBars = insets .getInsets (WindowInsetsCompat .Type .systemBars ());
46- v .setPadding (systemBars .left , systemBars .top , systemBars .right , 0 );
47- return insets ;
48- });
49-
50- // Handle bottom padding for RecyclerView to avoid navigation bar overlap
51- ViewCompat .setOnApplyWindowInsetsListener (findViewById (R .id .optionsRecyclerView ), (v ,
52- insets ) -> {
53- Insets systemBars = insets .getInsets (WindowInsetsCompat .Type .systemBars ());
54- v .setPadding (v .getPaddingLeft (), v .getPaddingTop (), v .getPaddingRight (),
55- systemBars .bottom + v .getPaddingBottom ());
56- return insets ;
57- });
58-
59- // Setup Toolbar
60- findViewById (R .id .optionsToolbar ).setOnClickListener (v -> finish ());
61- ((androidx .appcompat .widget .Toolbar ) findViewById (R .id .optionsToolbar )).setNavigationOnClickListener (v -> finish ());
62-
43+ setupToolbar ();
6344 setupRecyclerView ();
6445 }
6546
47+ private void setupToolbar () {
48+ // Add back button
49+ findViewById (R .id .optionsToolbar ).setOnClickListener (v -> finish ());
50+ ((androidx .appcompat .widget .Toolbar ) findViewById (R .id .optionsToolbar ))
51+ .setNavigationOnClickListener (v -> finish ());
52+
53+ // Change the font of the title
54+ CollapsingToolbarLayout collapsingToolbar = findViewById (R .id .collapseToolbar );
55+ Typeface typeface = ResourcesCompat .getFont (this , R .font .ntype82headline );
56+ collapsingToolbar .setExpandedTitleTypeface (typeface );
57+ collapsingToolbar .setCollapsedTitleTypeface (typeface );
58+ }
59+
6660 private void setupRecyclerView () {
6761 RecyclerView recyclerView = findViewById (R .id .optionsRecyclerView );
6862 recyclerView .setLayoutManager (new LinearLayoutManager (this ));
@@ -114,26 +108,29 @@ private void showThemeSelectionDialog() {
114108 AppCompatDelegate .MODE_NIGHT_FOLLOW_SYSTEM );
115109
116110 int checkedItem = 2 ; // Default to System
117- if (currentTheme == AppCompatDelegate .MODE_NIGHT_NO ) checkedItem = 0 ;
118- else if (currentTheme == AppCompatDelegate .MODE_NIGHT_YES ) checkedItem = 1 ;
119-
120- new MaterialAlertDialogBuilder (this ).setTitle (R .string .item_theme ).setSingleChoiceItems (themes , checkedItem , (dialog , which ) -> {
121- int mode ;
122- switch (which ) {
123- case 0 :
124- mode = AppCompatDelegate .MODE_NIGHT_NO ;
125- break ;
126- case 1 :
127- mode = AppCompatDelegate .MODE_NIGHT_YES ;
128- break ;
129- default :
130- mode = AppCompatDelegate .MODE_NIGHT_FOLLOW_SYSTEM ;
131- break ;
132- }
133- prefs .edit ().putInt (PreferenceConstants .THEME , mode ).apply ();
134- AppCompatDelegate .setDefaultNightMode (mode );
135- dialog .dismiss ();
136- }).show ();
111+ if (currentTheme == AppCompatDelegate .MODE_NIGHT_NO )
112+ checkedItem = 0 ;
113+ else if (currentTheme == AppCompatDelegate .MODE_NIGHT_YES )
114+ checkedItem = 1 ;
115+
116+ new MaterialAlertDialogBuilder (this ).setTitle (R .string .item_theme )
117+ .setSingleChoiceItems (themes , checkedItem , (dialog , which ) -> {
118+ int mode ;
119+ switch (which ) {
120+ case 0 :
121+ mode = AppCompatDelegate .MODE_NIGHT_NO ;
122+ break ;
123+ case 1 :
124+ mode = AppCompatDelegate .MODE_NIGHT_YES ;
125+ break ;
126+ default :
127+ mode = AppCompatDelegate .MODE_NIGHT_FOLLOW_SYSTEM ;
128+ break ;
129+ }
130+ prefs .edit ().putInt (PreferenceConstants .THEME , mode ).apply ();
131+ AppCompatDelegate .setDefaultNightMode (mode );
132+ dialog .dismiss ();
133+ }).show ();
137134 }
138135
139136 private void showHapticFeedbackSelectionDialog () {
@@ -145,11 +142,12 @@ private void showHapticFeedbackSelectionDialog() {
145142
146143 int checkedItem = currentHaptic ? 0 : 1 ;
147144
148- new MaterialAlertDialogBuilder (this ).setTitle (R .string .item_haptic_feedback ).setSingleChoiceItems (options , checkedItem , (dialog , which ) -> {
149- boolean enabled = (which == 0 );
150- prefs .edit ().putBoolean (PreferenceConstants .HAPTIC_FEEDBACK , enabled ).apply ();
151- dialog .dismiss ();
152- }).show ();
145+ new MaterialAlertDialogBuilder (this ).setTitle (R .string .item_haptic_feedback )
146+ .setSingleChoiceItems (options , checkedItem , (dialog , which ) -> {
147+ boolean enabled = (which == 0 );
148+ prefs .edit ().putBoolean (PreferenceConstants .HAPTIC_FEEDBACK , enabled ).apply ();
149+ dialog .dismiss ();
150+ }).show ();
153151 }
154152
155153 private void openPlayStore () {
@@ -184,7 +182,10 @@ private void sendFeedbackEmail() {
184182
185183 String deviceInfo = "\n \n \n ------------------------------" + "\n Device Diagnostics " +
186184 "(Please do not delete):" + "\n App Version: " + appVersion + "\n Android Version: "
187- + android .os .Build .VERSION .RELEASE + " (SDK " + android .os .Build .VERSION .SDK_INT + ")" + "\n Manufacturer: " + android .os .Build .MANUFACTURER + "\n Model: " + android .os .Build .MODEL + "\n Product: " + android .os .Build .PRODUCT ;
185+ + android .os .Build .VERSION .RELEASE + " (SDK " + android .os .Build .VERSION .SDK_INT + ")"
186+ + "\n Manufacturer: " + android .os .Build .MANUFACTURER + "\n Model: "
187+ + android .os .Build .MODEL
188+ + "\n Product: " + android .os .Build .PRODUCT ;
188189
189190 Intent intent = new Intent (Intent .ACTION_SENDTO );
190191 intent .setData (Uri .parse ("mailto:" ));
0 commit comments