diff --git a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java new file mode 100644 index 0000000..6d01f9b --- /dev/null +++ b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java @@ -0,0 +1,32 @@ +package net.schueller.peertube.activity; + +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatDelegate; + +import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; +import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; + +public class CommonActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Set Night Mode + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); + AppCompatDelegate.setDefaultNightMode(sharedPref.getBoolean("pref_dark_mode", false) ? + AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO); + + // Set theme + setTheme(getResources().getIdentifier( + sharedPref.getString(THEME_PREF_KEY, DEFAULT_THEME), + "style", + getPackageName()) + ); + } + +} diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java index df82443..641757d 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java @@ -71,7 +71,7 @@ import retrofit2.Response; import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; -public class VideoListActivity extends AppCompatActivity { +public class VideoListActivity extends CommonActivity { private String TAG = "VideoListActivity"; @@ -98,18 +98,6 @@ public class VideoListActivity extends AppCompatActivity { super.onCreate(savedInstanceState); - // Set Night Mode - SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); - AppCompatDelegate.setDefaultNightMode(sharedPref.getBoolean("pref_dark_mode", false) ? - AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO); - - // Set theme - setTheme(getResources().getIdentifier( - sharedPref.getString(THEME_PREF_KEY, DEFAULT_THEME), - "style", - getPackageName()) - ); - setContentView(R.layout.activity_video_list); filter = null;