Merge pull request #364 from Bnyro/fixes

noInternetActivity settings btn and fixes
This commit is contained in:
Bnyro 2022-06-04 12:43:16 +02:00 committed by GitHub
commit e31ef218c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
@ -79,6 +80,10 @@ class MainActivity : AppCompatActivity() {
findViewById<Button>(R.id.retry_button).setOnClickListener {
recreate()
}
findViewById<ImageView>(R.id.noInternet_settingsImageView).setOnClickListener {
val intent = Intent(this, SettingsActivity::class.java)
startActivity(intent)
}
} else {
setContentView(R.layout.activity_main)
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT

View File

@ -156,6 +156,19 @@ class SettingsActivity :
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
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")
fetchInstance()
instance?.setOnPreferenceChangeListener { _, newValue ->

View File

@ -4,6 +4,15 @@
android:layout_width="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
android:id="@+id/noInternet_imageView"
android:layout_width="200dp"
@ -16,7 +25,7 @@
app:srcCompat="@drawable/ic_wifi_off" />
<TextView
android:id="@+id/textView"
android:id="@+id/noInternet_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/noInternet"
@ -32,5 +41,6 @@
android:text="@string/retry"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
app:layout_constraintTop_toBottomOf="@+id/noInternet_textView" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

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