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.* import android.view.inputmethod.InputMethodManager import android.widget.Button import android.widget.LinearLayout import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate 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.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.color.DynamicColors import java.util.* class MainActivity : AppCompatActivity() { val TAG = "MainActivity" lateinit var bottomNavigationView: BottomNavigationView lateinit var toolbar: Toolbar lateinit var navController : NavController override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this) RetrofitInstance.url = sharedPreferences.getString("instance", "https://pipedapi.kavin.rocks/")!! SponsorBlockSettings.sponsorBlockEnabled = sharedPreferences.getBoolean("sponsorblock_enabled_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) DynamicColors.applyToActivitiesIfAvailable(application) val languageName = sharedPreferences.getString("language", "sys") if (languageName != "") { var locale = if (languageName != "sys" && "$languageName".length < 3 ){ Locale(languageName) } else if ("$languageName".length > 3) { Locale(languageName?.substring(0,2), languageName?.substring(4,6)) } else { Locale.getDefault() } val res = resources val dm = res.displayMetrics val conf = res.configuration conf.setLocale(locale) Locale.setDefault(locale) res.updateConfiguration(conf, dm) } when (sharedPreferences.getString("theme_togglee", "A")!!) { "A" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) "L" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) "D" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) } //setTheme(R.style.YellowTheme) val connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager val networkInfo=connectivityManager.activeNetworkInfo val isConnected = networkInfo != null && networkInfo.isConnected if (isConnected == false) { setContentView(R.layout.activity_nointernet) findViewById