noInternetActivity settings btn and fixes

This commit is contained in:
Bnyro 2022-06-04 12:41:05 +02:00
parent 19b6527066
commit 24b72059a6
4 changed files with 31 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import android.view.WindowInsetsController
import android.view.WindowManager import android.view.WindowManager
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.Button import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
@ -79,6 +80,10 @@ class MainActivity : AppCompatActivity() {
findViewById<Button>(R.id.retry_button).setOnClickListener { findViewById<Button>(R.id.retry_button).setOnClickListener {
recreate() recreate()
} }
findViewById<ImageView>(R.id.noInternet_settingsImageView).setOnClickListener {
val intent = Intent(this, SettingsActivity::class.java)
startActivity(intent)
}
} else { } else {
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT

View File

@ -156,6 +156,19 @@ class SettingsActivity :
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.settings, rootKey) setPreferencesFromResource(R.xml.settings, rootKey)
val region = findPreference<Preference>("region")
region?.setOnPreferenceChangeListener { _, _ ->
requireMainActivityRestart = true
true
}
val language = findPreference<ListPreference>("language")
language?.setOnPreferenceChangeListener { _, _ ->
restartMainActivity(requireContext())
true
}
val instance = findPreference<ListPreference>("instance") val instance = findPreference<ListPreference>("instance")
fetchInstance() fetchInstance()
instance?.setOnPreferenceChangeListener { _, newValue -> instance?.setOnPreferenceChangeListener { _, newValue ->

View File

@ -4,6 +4,15 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ImageView
android:id="@+id/noInternet_settingsImageView"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="16dp"
android:src="@drawable/ic_settings"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:id="@+id/noInternet_imageView" android:id="@+id/noInternet_imageView"
android:layout_width="200dp" android:layout_width="200dp"
@ -16,7 +25,7 @@
app:srcCompat="@drawable/ic_wifi_off" /> app:srcCompat="@drawable/ic_wifi_off" />
<TextView <TextView
android:id="@+id/textView" android:id="@+id/noInternet_textView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/noInternet" android:text="@string/noInternet"
@ -32,5 +41,6 @@
android:text="@string/retry" android:text="@string/retry"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" /> app:layout_constraintTop_toBottomOf="@+id/noInternet_textView" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -44,6 +44,6 @@
<color name="purple_dark_accentLight">#7E57C2</color> <color name="purple_dark_accentLight">#7E57C2</color>
<color name="purple_dark_accentDark">#311B92</color> <color name="purple_dark_accentDark">#311B92</color>
<color name="purple_dark_background">#050409</color> <color name="purple_dark_background">#1D0B20</color>
</resources> </resources>