fix IllegalArgumentException caused by missing theming

Exception java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
  at com.google.android.material.internal.ThemeEnforcement.checkTheme (ThemeEnforcement.java:247)
  at com.google.android.material.internal.ThemeEnforcement.checkAppCompatTheme (ThemeEnforcement.java:212)
  at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme (ThemeEnforcement.java:147)
  at com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes (ThemeEnforcement.java:114)
  at com.google.android.material.textfield.TextInputLayout.<init> (TextInputLayout.java:472)
  at com.google.android.material.textfield.TextInputLayout.<init> (TextInputLayout.java:451)
  at com.google.android.material.textfield.TextInputLayout.<init> (TextInputLayout.java:447)
  at com.nextcloud.talk.settings.SettingsActivity.askForPhoneNumber (SettingsActivity.kt:935)
  at com.nextcloud.talk.settings.SettingsActivity.access$askForPhoneNumber (SettingsActivity.kt:105)
  at com.nextcloud.talk.settings.SettingsActivity$checkForPhoneNumber$1.onNext (SettingsActivity.kt:915)
  at com.nextcloud.talk.settings.SettingsActivity$checkForPhoneNumber$1.onNext (SettingsActivity.kt:908)
  at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal (ObservableObserveOn.java:201)
  at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run (ObservableObserveOn.java:255)
  at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run (HandlerScheduler.java:124)
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:211)
  at android.os.Looper.loop (Looper.java:300)
  at android.app.ActivityThread.main (ActivityThread.java:8294)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:580)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1028)

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-07-06 13:31:12 +02:00
parent 09b6e4098f
commit 5974278e84
2 changed files with 6 additions and 1 deletions

View file

@ -54,6 +54,7 @@ import android.widget.EditText
import android.widget.LinearLayout
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.view.ContextThemeWrapper
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.work.OneTimeWorkRequest
@ -1012,7 +1013,7 @@ class SettingsActivity : BaseActivity() {
val phoneNumberLayoutWrapper = LinearLayout(context)
phoneNumberLayoutWrapper.orientation = LinearLayout.VERTICAL
phoneNumberLayoutWrapper.setPadding(PHONE_NUMBER_SIDE_PADDING, 0, PHONE_NUMBER_SIDE_PADDING, 0)
val phoneNumberInputLayout = TextInputLayout(context)
val phoneNumberInputLayout = TextInputLayout(ContextThemeWrapper(this, R.style.TextInputLayoutTheme))
val phoneNumberField = EditText(context)
phoneNumberInputLayout.setHelperTextColor(
ColorStateList.valueOf(resources!!.getColor(R.color.nc_darkRed, null))

View file

@ -233,6 +233,10 @@
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="TextInputLayoutTheme" parent="Theme.AppCompat">
<item name="colorSurface">@color/bg_default</item>
</style>
<style name="FullScreenTextTheme" parent="AppTheme">
<item name="android:navigationBarColor">@color/bg_default</item>
</style>