package com.github.libretube import android.app.Activity import android.content.Context import android.content.Intent import android.content.pm.ActivityInfo import android.content.res.Configuration import android.net.ConnectivityManager import android.net.Uri import android.os.Build import android.os.Bundle import android.os.Handler import android.util.Log import android.util.TypedValue import android.view.View import android.view.WindowInsets import android.view.WindowInsetsController import android.view.WindowManager import android.view.inputmethod.InputMethodManager import android.widget.Button import android.widget.ImageView import android.widget.LinearLayout import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.constraintlayout.motion.widget.MotionLayout import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.os.bundleOf import androidx.core.text.HtmlCompat import androidx.fragment.app.Fragment import androidx.navigation.NavController import androidx.navigation.findNavController import androidx.navigation.ui.setupWithNavController import androidx.preference.PreferenceManager import com.github.libretube.fragments.PlayerFragment import com.github.libretube.fragments.isFullScreen import com.github.libretube.preferences.SponsorBlockSettings import com.github.libretube.util.CronetHelper import com.github.libretube.util.LocaleHelper import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.ThemeHelper import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.color.DynamicColors class MainActivity : AppCompatActivity() { val TAG = "MainActivity" lateinit var bottomNavigationView: BottomNavigationView lateinit var toolbar: Toolbar lateinit var navController: NavController override fun onCreate(savedInstanceState: Bundle?) { DynamicColors.applyToActivityIfAvailable(this) super.onCreate(savedInstanceState) CronetHelper.initCronet(this.applicationContext) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this) RetrofitInstance.url = sharedPreferences.getString("selectInstance", "https://pipedapi.kavin.rocks/")!! SponsorBlockSettings.sponsorBlockEnabled = sharedPreferences.getBoolean("sb_enabled_key", false) SponsorBlockSettings.sponsorNotificationsEnabled = sharedPreferences.getBoolean("sb_notifications_key", false) SponsorBlockSettings.introEnabled = sharedPreferences.getBoolean("intro_category_key", false) SponsorBlockSettings.selfPromoEnabled = sharedPreferences.getBoolean("selfpromo_category_key", false) SponsorBlockSettings.interactionEnabled = sharedPreferences.getBoolean("interaction_category_key", false) SponsorBlockSettings.sponsorsEnabled = sharedPreferences.getBoolean("sponsors_category_key", false) SponsorBlockSettings.outroEnabled = sharedPreferences.getBoolean("outro_category_key", false) ThemeHelper().updateTheme(this) LocaleHelper().updateLanguage(this) val connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager val networkInfo = connectivityManager.activeNetworkInfo val isConnected = networkInfo != null && networkInfo.isConnected if (!isConnected) { setContentView(R.layout.activity_nointernet) findViewById