Fix theme between flavors

This commit is contained in:
Thomas 2022-05-10 10:47:51 +02:00
parent af53071b08
commit ed3d978b03
28 changed files with 144 additions and 94 deletions

View File

@ -0,0 +1,59 @@
package app.fedilab.fedilabtube.helper;
/* Copyright 2022 Thomas Schneider
*
* This file is a part of TubeLab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import androidx.appcompat.app.AppCompatActivity;
import app.fedilab.fedilabtube.R;
public class Theme {
public static void setTheme(AppCompatActivity activity, String instance, boolean noActionBar) {
switch (instance) {
case "tube-institutionnel.apps.education.fr":
activity.setTheme(noActionBar? R.style.InstitutionnelNoActionBar:R.style.Institutionnel);
break;
case "tube-maternelle.apps.education.fr":
activity.setTheme(noActionBar?R.style.MaternelleNoActionBar:R.style.Maternelle);
break;
case "tube-arts-lettres-sciences-humaines.apps.education.fr":
activity.setTheme(noActionBar?R.style.ArtNoActionBar:R.style.Art);
break;
case "tube-sciences-technologies.apps.education.fr":
activity.setTheme(noActionBar?R.style.SciencesNoActionBar:R.style.Sciences);
break;
case "tube-education-physique-et-sportive.apps.education.fr":
activity.setTheme(noActionBar?R.style.EducationNoActionBar:R.style.Education);
break;
case "tube-enseignement-professionnel.apps.education.fr":
activity.setTheme(noActionBar?R.style.EnseignementProNoActionBar:R.style.EnseignementPro);
break;
case "tube-langues-vivantes.apps.education.fr":
activity.setTheme(noActionBar?R.style.LanguesNoActionBar:R.style.Langues);
break;
case "tube-action-educative.apps.education.fr":
activity.setTheme(noActionBar?R.style.ActionEducativeNoActionBar:R.style.ActionEducative);
break;
case "tube-cycle-2.apps.education.fr":
activity.setTheme(noActionBar?R.style.Cycle2NoActionBar:R.style.Cycle2);
break;
case "tube-cycle-3.apps.education.fr":
activity.setTheme(noActionBar?R.style.Cycle3NoActionBar:R.style.Cycle3);
break;
default:
activity.setTheme(noActionBar?R.style.AppThemeNoActionBar:R.style.AppTheme);
}
}
}

View File

@ -0,0 +1,26 @@
package app.fedilab.fedilabtube.helper;
/* Copyright 2022 Thomas Schneider
*
* This file is a part of TubeLab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import androidx.appcompat.app.AppCompatActivity;
import app.fedilab.fedilabtube.R;
public class Theme {
@SuppressWarnings("unused")
public static void setTheme(AppCompatActivity activity, String instance, boolean noActionBar) {
activity.setTheme(noActionBar?R.style.AppThemeNoActionBar:R.style.AppTheme);
}
}

View File

@ -24,28 +24,6 @@
<item name="android:colorBackground">@android:color/black</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColor">?attr/colorOnBackground</item>
<item name="backgroundView">@color/backgroundDark</item>
<item name="android:windowBackground">@android:color/black</item>
<item name="android:colorBackground">@android:color/black</item>
</style>
<style name="AppThemeNoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="backgroundView">@color/backgroundDark</item>
<item name="android:textColor">?attr/colorOnBackground</item>
<item name="android:windowBackground">@android:color/black</item>
<item name="android:colorBackground">@android:color/black</item>
</style>

View File

@ -34,13 +34,14 @@ import app.fedilab.fedilabtube.BuildConfig;
import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
public class AboutActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);

View File

@ -54,6 +54,7 @@ import app.fedilab.fedilabtube.fragment.DisplayNotificationsFragment;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.SwitchAccountHelper;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.sqlite.AccountDAO;
import app.fedilab.fedilabtube.sqlite.Sqlite;
@ -65,7 +66,7 @@ public class AccountActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
binding = ActivityAccountBinding.inflate(getLayoutInflater());
View view = binding.getRoot();

View File

@ -35,6 +35,7 @@ import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
import app.fedilab.fedilabtube.drawer.PlaylistAdapter;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
@ -49,7 +50,7 @@ public class AllLocalPlaylistsActivity extends BaseActivity implements PlaylistA
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_all_playlist);

View File

@ -67,6 +67,7 @@ import app.fedilab.fedilabtube.databinding.AddPlaylistBinding;
import app.fedilab.fedilabtube.drawer.PlaylistAdapter;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
import es.dmoral.toasty.Toasty;
@ -91,7 +92,7 @@ public class AllPlaylistsActivity extends BaseActivity implements PlaylistAdapte
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
binding = ActivityAllPlaylistBinding.inflate(getLayoutInflater());
View viewRoot = binding.getRoot();
setContentView(viewRoot);

View File

@ -48,6 +48,7 @@ import app.fedilab.fedilabtube.client.entities.InstanceParams;
import app.fedilab.fedilabtube.drawer.InstanceAdapter;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.RoundedBackgroundSpan;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.viewmodel.InstancesVM;
import es.dmoral.toasty.Toasty;
@ -69,7 +70,7 @@ public class InstancePickerActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@ -26,6 +26,7 @@ import app.fedilab.fedilabtube.client.data.PlaylistData;
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
import es.dmoral.toasty.Toasty;
@ -36,7 +37,7 @@ public class LocalPlaylistsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@ -56,6 +56,7 @@ import app.fedilab.fedilabtube.databinding.ActivityLoginBinding;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import es.dmoral.toasty.Toasty;
@ -72,7 +73,7 @@ public class LoginActivity extends BaseActivity {
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
binding = ActivityLoginBinding.inflate(getLayoutInflater());
View view = binding.getRoot();

View File

@ -84,6 +84,7 @@ import app.fedilab.fedilabtube.helper.HelperAcadInstance;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.PlaylistExportHelper;
import app.fedilab.fedilabtube.helper.SwitchAccountHelper;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.services.RetrieveInfoService;
import app.fedilab.fedilabtube.sqlite.AccountDAO;
import app.fedilab.fedilabtube.sqlite.Sqlite;
@ -227,7 +228,7 @@ public class MainActivity extends BaseMainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(MainActivity.this, HelperInstance.getLiveInstance(this),true);
Theme.setTheme(MainActivity.this, HelperInstance.getLiveInstance(this),true);
super.onCreate(savedInstanceState);
binding = super.binding;

View File

@ -39,6 +39,7 @@ import app.fedilab.fedilabtube.databinding.ActivityManageInstancesBinding;
import app.fedilab.fedilabtube.drawer.AboutInstanceAdapter;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.sqlite.Sqlite;
import app.fedilab.fedilabtube.sqlite.StoredInstanceDAO;
import app.fedilab.fedilabtube.viewmodel.InfoInstanceVM;
@ -53,7 +54,7 @@ public class ManageInstancesActivity extends BaseActivity implements AboutInstan
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
binding = ActivityManageInstancesBinding.inflate(getLayoutInflater());
View view = binding.getRoot();

View File

@ -41,6 +41,7 @@ import app.fedilab.fedilabtube.client.entities.Token;
import app.fedilab.fedilabtube.client.mastodon.RetrofitMastodonAPI;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import es.dmoral.toasty.Toasty;
@ -79,7 +80,7 @@ public class MastodonWebviewConnectActivity extends BaseActivity {
@SuppressLint("SetJavaScriptEnabled")
public void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview_connect);
Bundle b = getIntent().getExtras();

View File

@ -57,6 +57,7 @@ import app.fedilab.fedilabtube.databinding.ActivityMyAccountSettingsBinding;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.worker.WorkHelper;
import es.dmoral.toasty.Toasty;
@ -71,7 +72,7 @@ public class MyAccountActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
binding = ActivityMyAccountSettingsBinding.inflate(getLayoutInflater());
View view = binding.getRoot();

View File

@ -161,6 +161,7 @@ import app.fedilab.fedilabtube.helper.CacheDataSourceFactory;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.sqlite.AccountDAO;
import app.fedilab.fedilabtube.sqlite.Sqlite;
import app.fedilab.fedilabtube.viewmodel.CaptionsVM;
@ -296,7 +297,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
binding = super.binding;
videoOrientationType = videoOrientation.LANDSCAPE;

View File

@ -60,6 +60,7 @@ import app.fedilab.fedilabtube.client.entities.VideoParams;
import app.fedilab.fedilabtube.databinding.ActivityPeertubeEditBinding;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
import app.fedilab.fedilabtube.viewmodel.MyVideoVM;
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
@ -86,7 +87,7 @@ public class PeertubeEditUploadActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
binding = ActivityPeertubeEditBinding.inflate(getLayoutInflater());
View view = binding.getRoot();

View File

@ -43,6 +43,7 @@ import app.fedilab.fedilabtube.client.entities.AccountCreation;
import app.fedilab.fedilabtube.databinding.ActivityRegisterPeertubeBinding;
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import es.dmoral.toasty.Toasty;
public class PeertubeRegisterActivity extends BaseActivity {
@ -55,7 +56,7 @@ public class PeertubeRegisterActivity extends BaseActivity {
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
binding = ActivityRegisterPeertubeBinding.inflate(getLayoutInflater());
View mainView = binding.getRoot();

View File

@ -65,6 +65,7 @@ import app.fedilab.fedilabtube.client.entities.UserMe;
import app.fedilab.fedilabtube.databinding.ActivityPeertubeUploadBinding;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
import es.dmoral.toasty.Toasty;
@ -84,7 +85,7 @@ public class PeertubeUploadActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@ -26,6 +26,7 @@ import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.PlaylistExportHelper;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
import es.dmoral.toasty.Toasty;
@ -37,7 +38,7 @@ public class PlaylistsActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@ -34,6 +34,7 @@ import app.fedilab.fedilabtube.databinding.ActivitySearchResultBinding;
import app.fedilab.fedilabtube.fragment.DisplayChannelsFragment;
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import es.dmoral.toasty.Toasty;
@ -45,7 +46,7 @@ public class SearchActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
binding = ActivitySearchResultBinding.inflate(getLayoutInflater());
View view = binding.getRoot();

View File

@ -46,6 +46,7 @@ import app.fedilab.fedilabtube.fragment.DisplaySepiaSearchFragment;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
public class SepiaSearchActivity extends BaseActivity {
@ -58,7 +59,7 @@ public class SepiaSearchActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
binding = ActivitySepiaSearchBinding.inflate(getLayoutInflater());
View rootView = binding.getRoot();

View File

@ -5,6 +5,7 @@ import android.view.MenuItem;
import app.fedilab.fedilabtube.fragment.SettingsFragment;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
/* Copyright 2020 Thomas Schneider
*
@ -26,7 +27,7 @@ public class SettingsActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@ -54,6 +54,7 @@ import app.fedilab.fedilabtube.fragment.DisplayChannelsFragment;
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.viewmodel.AccountsVM;
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
@ -74,7 +75,7 @@ public class ShowAccountActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_account);
setTitle("");

View File

@ -71,6 +71,7 @@ import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.sqlite.AccountDAO;
import app.fedilab.fedilabtube.sqlite.Sqlite;
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
@ -99,7 +100,7 @@ public class ShowChannelActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_channel);
setTitle("");

View File

@ -39,6 +39,7 @@ import app.fedilab.fedilabtube.databinding.ActivityVideosTimelineBinding;
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
@ -50,7 +51,7 @@ public class VideosTimelineActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
ActivityVideosTimelineBinding binding = ActivityVideosTimelineBinding.inflate(getLayoutInflater());
View mainView = binding.getRoot();

View File

@ -37,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.webview.CustomWebview;
import app.fedilab.fedilabtube.webview.MastalabWebChromeClient;
import app.fedilab.fedilabtube.webview.MastalabWebViewClient;
@ -53,7 +54,7 @@ public class WebviewActivity extends BaseActivity {
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
Bundle b = getIntent().getExtras();

View File

@ -45,6 +45,7 @@ import app.fedilab.fedilabtube.client.entities.OauthParams;
import app.fedilab.fedilabtube.client.entities.Token;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
public class WebviewConnectActivity extends BaseActivity {
@ -75,7 +76,7 @@ public class WebviewConnectActivity extends BaseActivity {
@SuppressLint("SetJavaScriptEnabled")
public void onCreate(Bundle savedInstanceState) {
HelperInstance.setTheme(this, HelperInstance.getLiveInstance(this),false);
Theme.setTheme(this, HelperInstance.getLiveInstance(this),false);
super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
WebView.setWebContentsDebuggingEnabled(true);

View File

@ -1,15 +1,4 @@
package app.fedilab.fedilabtube.helper;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Locale;
import app.fedilab.fedilabtube.BuildConfig;
import app.fedilab.fedilabtube.R;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of TubeLab
@ -24,6 +13,17 @@ import app.fedilab.fedilabtube.R;
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import android.content.SharedPreferences;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Locale;
import app.fedilab.fedilabtube.BuildConfig;
import app.fedilab.fedilabtube.R;
public class HelperInstance {
@ -42,43 +42,6 @@ public class HelperInstance {
}
}
public static void setTheme(AppCompatActivity activity, String instance, boolean noActionBar) {
switch (instance) {
case "tube-institutionnel.apps.education.fr":
activity.setTheme(noActionBar?R.style.InstitutionnelNoActionBar:R.style.Institutionnel);
break;
case "tube-maternelle.apps.education.fr":
activity.setTheme(noActionBar?R.style.MaternelleNoActionBar:R.style.Maternelle);
break;
case "tube-arts-lettres-sciences-humaines.apps.education.fr":
activity.setTheme(noActionBar?R.style.ArtNoActionBar:R.style.Art);
break;
case "tube-sciences-technologies.apps.education.fr":
activity.setTheme(noActionBar?R.style.SciencesNoActionBar:R.style.Sciences);
break;
case "tube-education-physique-et-sportive.apps.education.fr":
activity.setTheme(noActionBar?R.style.EducationNoActionBar:R.style.Education);
break;
case "tube-enseignement-professionnel.apps.education.fr":
activity.setTheme(noActionBar?R.style.EnseignementProNoActionBar:R.style.EnseignementPro);
break;
case "tube-langues-vivantes.apps.education.fr":
activity.setTheme(noActionBar?R.style.LanguesNoActionBar:R.style.Langues);
break;
case "tube-action-educative.apps.education.fr":
activity.setTheme(noActionBar?R.style.ActionEducativeNoActionBar:R.style.ActionEducative);
break;
case "tube-cycle-2.apps.education.fr":
activity.setTheme(noActionBar?R.style.Cycle2NoActionBar:R.style.Cycle2);
break;
case "tube-cycle-3.apps.education.fr":
activity.setTheme(noActionBar?R.style.Cycle3NoActionBar:R.style.Cycle3);
break;
default:
activity.setTheme(noActionBar?R.style.AppThemeNoActionBar:R.style.AppTheme);
}
}
/**
* Get a default instance host name depending of the device locale