Skip to content

Commit

Permalink
FIX #116 : Add dark theme support (trace MainActivity.onNightModeChan…
Browse files Browse the repository at this point in the history
…ged)
  • Loading branch information
Guillaume Husta committed Oct 5, 2019
1 parent f0c6020 commit dc621a1
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
import retrofit2.Callback;
import retrofit2.Response;

import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;

public class MainActivity extends AppCompatActivity
implements SearchView.OnQueryTextListener, SwipeRefreshLayout.OnRefreshListener
{
Expand Down Expand Up @@ -200,6 +205,28 @@ protected void onResume()
Log.d(TAG, "onResume : " + this.getLocalClassName());
}

@Override
protected void onNightModeChanged(int mode)
{
switch (mode)
{
case MODE_NIGHT_NO:
Log.d(TAG, String.format("onNightModeChanged : mode = %s", "MODE_NIGHT_NO"));
break;
case MODE_NIGHT_YES:
Log.d(TAG, String.format("onNightModeChanged : mode = %s", "MODE_NIGHT_YES"));
break;
case MODE_NIGHT_AUTO_BATTERY:
Log.d(TAG, String.format("onNightModeChanged : mode = %s", "MODE_NIGHT_AUTO_BATTERY"));
break;
case MODE_NIGHT_FOLLOW_SYSTEM:
Log.d(TAG, String.format("onNightModeChanged : mode = %s", "MODE_NIGHT_FOLLOW_SYSTEM"));
break;
default:
Log.d(TAG, String.format("onNightModeChanged : mode = %d", mode));
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
Expand Down Expand Up @@ -350,7 +377,7 @@ private void applyTheme(int selectedTheme)
switch (selectedTheme)
{
case 0:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
Expand Down

0 comments on commit dc621a1

Please sign in to comment.