package com.github.libretube import android.app.Activity import android.app.ProgressDialog.show 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.NetworkInfo import android.net.Uri import android.os.Build import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Handler import android.util.Log import android.view.* import android.view.inputmethod.InputMethodManager import android.widget.Button import android.widget.LinearLayout import android.widget.Toast 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 com.google.android.material.bottomnavigation.BottomNavigationView import androidx.navigation.findNavController import androidx.navigation.ui.setupWithNavController import androidx.preference.PreferenceManager import com.google.android.material.color.DynamicColors import java.lang.Exception 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/")!! 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) } 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