Fix Dialog after Background on Android

This commit is contained in:
Florian Märkl 2019-10-01 13:21:22 +02:00
commit 08456d56b5
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
3 changed files with 14 additions and 1 deletions

View file

@ -99,6 +99,11 @@ JNIEXPORT jstring JNICALL Java_com_metallic_chiaki_lib_ChiakiNative_quitReasonTo
return E->NewStringUTF(env, chiaki_quit_reason_string((ChiakiQuitReason)value));
}
JNIEXPORT jboolean JNICALL Java_com_metallic_chiaki_lib_ChiakiNative_quitReasonIsStopped(JNIEnv *env, jobject obj, jint value)
{
return value == CHIAKI_QUIT_REASON_STOPPED;
}
typedef struct android_chiaki_session_t
{
ChiakiSession session;

View file

@ -33,6 +33,7 @@ class ChiakiNative
}
@JvmStatic external fun errorCodeToString(value: Int): String
@JvmStatic external fun quitReasonToString(value: Int): String
@JvmStatic external fun quitReasonIsStopped(value: Int): Boolean
@JvmStatic external fun sessionCreate(result: SessionCreateResult, connectInfo: ConnectInfo, javaSession: Session)
@JvmStatic external fun sessionFree(ptr: Long)
@JvmStatic external fun sessionStart(ptr: Long): Int
@ -96,6 +97,11 @@ data class ControllerState constructor(
class QuitReason(val value: Int)
{
override fun toString() = ChiakiNative.quitReasonToString(value)
/**
* whether the reason is CHIAKI_QUIT_REASON_STOPPED
*/
val isStopped = ChiakiNative.quitReasonIsStopped(value)
}
sealed class Event

View file

@ -22,6 +22,7 @@ import android.app.Dialog
import android.content.DialogInterface
import android.graphics.Matrix
import android.os.Bundle
import android.speech.tts.TextToSpeech
import android.util.Log
import android.view.KeyEvent
import android.view.View
@ -33,6 +34,7 @@ import com.metallic.chiaki.*
import com.metallic.chiaki.R
import com.metallic.chiaki.lib.ConnectInfo
import com.metallic.chiaki.lib.LoginPinRequestEvent
import com.metallic.chiaki.lib.QuitReason
import com.metallic.chiaki.touchcontrols.TouchControlsFragment
import kotlinx.android.synthetic.main.activity_stream.*
@ -138,7 +140,7 @@ class StreamActivity : AppCompatActivity()
{
is StreamStateQuit ->
{
if(dialogContents != StreamQuitDialog)
if(!state.reason.isStopped && dialogContents != StreamQuitDialog)
{
dialog?.dismiss()
val reasonStr = state.reasonString