Workaround for bug https://bugreports.qt.io/browse/QTBUG-113461
This commit is contained in:
parent
34a228adbe
commit
1ec50cf6ad
13 changed files with 21 additions and 82 deletions
|
@ -7,7 +7,7 @@ import org.qtproject.qt.android.bindings.QtActivity
|
|||
import org.qtproject.qt.android.bindings.QtApplication
|
||||
import android.app.Application
|
||||
|
||||
class AmneziaApp: Application() {
|
||||
class AmneziaApp: org.qtproject.qt.android.bindings.QtApplication() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
@ -19,4 +19,4 @@ class AmneziaApp: Application() {
|
|||
super.onConfigurationChanged(newConfig)
|
||||
Core.updateNotificationChannels()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
package org.amnezia.vpn.qt;
|
||||
|
||||
import android.Manifest
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.ComponentName
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
|
@ -73,10 +71,6 @@ class VPNActivity : org.qtproject.qt.android.bindings.QtActivity() {
|
|||
@JvmStatic fun saveFileAs(fileContent: String, suggestedName: String) {
|
||||
VPNActivity.getInstance().saveFile(fileContent, suggestedName)
|
||||
}
|
||||
|
||||
@JvmStatic fun putTextToClipboard(text: String) {
|
||||
VPNActivity.getInstance().putToClipboard(text)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -109,18 +103,6 @@ class VPNActivity : org.qtproject.qt.android.bindings.QtActivity() {
|
|||
startActivityForResult(intent, CREATE_FILE_ACTION_CODE)
|
||||
}
|
||||
|
||||
override fun getSystemService(name: String): Any? {
|
||||
return if (Build.VERSION.SDK_INT >= 29 && name == "clipboard") {
|
||||
// QT will always attempt to read the clipboard if content is there.
|
||||
// since we have no use of the clipboard in android 10+
|
||||
// we _can_ return null
|
||||
// And we definitely should since android 12 displays clipboard access.
|
||||
null
|
||||
} else {
|
||||
super.getSystemService(name)
|
||||
}
|
||||
}
|
||||
|
||||
external fun handleBackButton(): Boolean
|
||||
|
||||
external fun onServiceMessage(actionCode: Int, body: String?)
|
||||
|
@ -317,15 +299,4 @@ class VPNActivity : org.qtproject.qt.android.bindings.QtActivity() {
|
|||
|
||||
tmpFileContentToSave = ""
|
||||
}
|
||||
|
||||
private fun putToClipboard(text: String) {
|
||||
this.runOnUiThread {
|
||||
val clipboard = applicationContext.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager?
|
||||
|
||||
if (clipboard != null) {
|
||||
val clip: ClipData = ClipData.newPlainText("", text)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package org.amnezia.vpn.qt;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.amnezia.vpn.shadowsocks.core.Core;
|
||||
import org.amnezia.vpn.shadowsocks.core.VpnManager;
|
||||
|
||||
public class VPNApplication extends org.qtproject.qt.android.bindings.QtApplication {
|
||||
private static VPNApplication instance;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
VPNApplication.instance = this;
|
||||
// Core.INSTANCE.init(this, VPNActivity.class);
|
||||
// VpnManager.Companion.getInstance().init(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
// Core.INSTANCE.updateNotificationChannels();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue