Skip to content

Commit

Permalink
detect night mode
Browse files Browse the repository at this point in the history
  • Loading branch information
thekirankumar committed Jan 5, 2018
1 parent 9434972 commit c00eede
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.thekirankumar.youtubeauto;

import android.app.UiModeManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
Expand Down Expand Up @@ -165,6 +166,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
boolean isNight = getResources().getBoolean(R.bool.isNight);
//FirebaseAnalytics.getInstance(getContext()).logEvent("CarFragment_created", null);

final MainCarActivity mainCarActivity = (MainCarActivity) getContext();
Expand Down Expand Up @@ -339,6 +341,7 @@ public void onClick(View v) {
webView.setWebViewClient(new CustomWebViewClient());
final VideoEnabledWebChromeClient videoEnabledWebChromeClient = new VideoEnabledWebChromeClient(webViewContainer, fullScreenVideoView, new ProgressBar(getContext()), webView);
webView.setWebChromeClient(videoEnabledWebChromeClient);
webView.getSettings().setUserAgentString("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36");
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setTextSize(WebSettings.TextSize.LARGER);
handler.post(new Runnable() {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-night/values.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="isNight">true</bool>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/values.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="isNight">false</bool>
</resources>

0 comments on commit c00eede

Please sign in to comment.