Skip to content

Commit

Permalink
Dark Mode done
Browse files Browse the repository at this point in the history
  • Loading branch information
briceln committed Nov 19, 2018
1 parent fbd18c7 commit 7bb79f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/src/main/java/brice_bastien/epicture/SplashScreen.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package brice_bastien.epicture;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.preference.PreferenceManager;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
Expand All @@ -17,18 +20,24 @@ public class SplashScreen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);

SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
Boolean switchPref = sharedPrefs.getBoolean(SettingsActivity.KEY_PREF_EXAMPLE_SWITCH, false);
if (switchPref) {
setTheme(R.style.AppTheme_DARK);
setTheme(R.style.AppTheme_DARK_NoActionBar);
getWindow().setNavigationBarColor(getResources().getColor(R.color.colorAccentDarker));
} else {
setTheme(R.style.AppTheme);
setTheme(R.style.AppTheme_NoActionBar);
getWindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimary));
}

setContentView(R.layout.activity_splash_screen);

ConstraintLayout layout = findViewById(R.id.splash_background);
if (switchPref) {
layout.setBackground(new ColorDrawable(Color.BLACK));
}

sharedPreferences = getSharedPreferences(getString(R.string.user_info_pref), Context.MODE_PRIVATE);

int SPLASH_TIME_OUT = 2000;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_splash_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/splash_background"
android:background="@color/ic_launcher_background"
tools:context=".SplashScreen">

Expand Down

0 comments on commit 7bb79f7

Please sign in to comment.