Skip to content

Commit 190e690

Browse files
authored
Fix/post context menu (#231)
* fix: post-context-menu * fix: user id with post * fix: removed redundant code * fix: images * fix: profile data * fix: profile data * fix: image cover * fix: logout
1 parent 32d4e30 commit 190e690

File tree

18 files changed

+1161
-16
lines changed

18 files changed

+1161
-16
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* THIS FILE IS AUTO-GENERATED. DO NOT MODIFY!! */
2+
3+
// Copyright 2020-2023 Tauri Programme within The Commons Conservancy
4+
// SPDX-License-Identifier: Apache-2.0
5+
// SPDX-License-Identifier: MIT
6+
7+
@file:Suppress("unused")
8+
9+
package com.eid_wallet.app
10+
11+
import android.webkit.*
12+
13+
class Ipc(val webViewClient: RustWebViewClient) {
14+
@JavascriptInterface
15+
fun postMessage(message: String?) {
16+
message?.let {m ->
17+
// we're not using WebView::getUrl() here because it needs to be executed on the main thread
18+
// and it would slow down the Ipc
19+
// so instead we track the current URL on the webview client
20+
this.ipc(webViewClient.currentUrl, m)
21+
}
22+
}
23+
24+
companion object {
25+
init {
26+
System.loadLibrary("eid_wallet_lib")
27+
}
28+
}
29+
30+
private external fun ipc(url: String, message: String)
31+
32+
33+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/* THIS FILE IS AUTO-GENERATED. DO NOT MODIFY!! */
2+
3+
// Copyright 2020-2023 Tauri Programme within The Commons Conservancy
4+
// SPDX-License-Identifier: Apache-2.0
5+
// SPDX-License-Identifier: MIT
6+
7+
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
8+
9+
package com.eid_wallet.app
10+
11+
// taken from https://github.com/ionic-team/capacitor/blob/6658bca41e78239347e458175b14ca8bd5c1d6e8/android/capacitor/src/main/java/com/getcapacitor/Logger.java
12+
13+
import android.text.TextUtils
14+
import android.util.Log
15+
16+
class Logger {
17+
companion object {
18+
private const val LOG_TAG_CORE = "Tauri"
19+
20+
fun tags(vararg subtags: String): String {
21+
return if (subtags.isNotEmpty()) {
22+
LOG_TAG_CORE + "/" + TextUtils.join("/", subtags)
23+
} else LOG_TAG_CORE
24+
}
25+
26+
fun verbose(message: String) {
27+
verbose(LOG_TAG_CORE, message)
28+
}
29+
30+
private fun verbose(tag: String, message: String) {
31+
if (!shouldLog()) {
32+
return
33+
}
34+
Log.v(tag, message)
35+
}
36+
37+
fun debug(message: String) {
38+
debug(LOG_TAG_CORE, message)
39+
}
40+
41+
fun debug(tag: String, message: String) {
42+
if (!shouldLog()) {
43+
return
44+
}
45+
Log.d(tag, message)
46+
}
47+
48+
fun info(message: String) {
49+
info(LOG_TAG_CORE, message)
50+
}
51+
52+
fun info(tag: String, message: String) {
53+
if (!shouldLog()) {
54+
return
55+
}
56+
Log.i(tag, message)
57+
}
58+
59+
fun warn(message: String) {
60+
warn(LOG_TAG_CORE, message)
61+
}
62+
63+
fun warn(tag: String, message: String) {
64+
if (!shouldLog()) {
65+
return
66+
}
67+
Log.w(tag, message)
68+
}
69+
70+
fun error(message: String) {
71+
error(LOG_TAG_CORE, message, null)
72+
}
73+
74+
fun error(message: String, e: Throwable?) {
75+
error(LOG_TAG_CORE, message, e)
76+
}
77+
78+
fun error(tag: String, message: String, e: Throwable?) {
79+
if (!shouldLog()) {
80+
return
81+
}
82+
Log.e(tag, message, e)
83+
}
84+
85+
private fun shouldLog(): Boolean {
86+
return BuildConfig.DEBUG
87+
}
88+
}
89+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/* THIS FILE IS AUTO-GENERATED. DO NOT MODIFY!! */
2+
3+
// Copyright 2020-2023 Tauri Programme within The Commons Conservancy
4+
// SPDX-License-Identifier: Apache-2.0
5+
// SPDX-License-Identifier: MIT
6+
7+
package com.eid_wallet.app
8+
9+
// taken from https://github.com/ionic-team/capacitor/blob/6658bca41e78239347e458175b14ca8bd5c1d6e8/android/capacitor/src/main/java/com/getcapacitor/PermissionHelper.java
10+
11+
import android.content.Context
12+
import android.content.pm.PackageManager
13+
import android.os.Build
14+
import androidx.core.app.ActivityCompat
15+
import java.util.ArrayList
16+
17+
object PermissionHelper {
18+
/**
19+
* Checks if a list of given permissions are all granted by the user
20+
*
21+
* @param permissions Permissions to check.
22+
* @return True if all permissions are granted, false if at least one is not.
23+
*/
24+
fun hasPermissions(context: Context?, permissions: Array<String>): Boolean {
25+
for (perm in permissions) {
26+
if (ActivityCompat.checkSelfPermission(
27+
context!!,
28+
perm
29+
) != PackageManager.PERMISSION_GRANTED
30+
) {
31+
return false
32+
}
33+
}
34+
return true
35+
}
36+
37+
/**
38+
* Check whether the given permission has been defined in the AndroidManifest.xml
39+
*
40+
* @param permission A permission to check.
41+
* @return True if the permission has been defined in the Manifest, false if not.
42+
*/
43+
fun hasDefinedPermission(context: Context, permission: String): Boolean {
44+
var hasPermission = false
45+
val requestedPermissions = getManifestPermissions(context)
46+
if (!requestedPermissions.isNullOrEmpty()) {
47+
val requestedPermissionsList = listOf(*requestedPermissions)
48+
val requestedPermissionsArrayList = ArrayList(requestedPermissionsList)
49+
if (requestedPermissionsArrayList.contains(permission)) {
50+
hasPermission = true
51+
}
52+
}
53+
return hasPermission
54+
}
55+
56+
/**
57+
* Check whether all of the given permissions have been defined in the AndroidManifest.xml
58+
* @param context the app context
59+
* @param permissions a list of permissions
60+
* @return true only if all permissions are defined in the AndroidManifest.xml
61+
*/
62+
fun hasDefinedPermissions(context: Context, permissions: Array<String>): Boolean {
63+
for (permission in permissions) {
64+
if (!hasDefinedPermission(context, permission)) {
65+
return false
66+
}
67+
}
68+
return true
69+
}
70+
71+
/**
72+
* Get the permissions defined in AndroidManifest.xml
73+
*
74+
* @return The permissions defined in AndroidManifest.xml
75+
*/
76+
private fun getManifestPermissions(context: Context): Array<String>? {
77+
var requestedPermissions: Array<String>? = null
78+
try {
79+
val pm = context.packageManager
80+
val packageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
81+
pm.getPackageInfo(context.packageName, PackageManager.PackageInfoFlags.of(PackageManager.GET_PERMISSIONS.toLong()))
82+
} else {
83+
@Suppress("DEPRECATION")
84+
pm.getPackageInfo(context.packageName, PackageManager.GET_PERMISSIONS)
85+
}
86+
if (packageInfo != null) {
87+
requestedPermissions = packageInfo.requestedPermissions
88+
}
89+
} catch (_: Exception) {
90+
}
91+
return requestedPermissions
92+
}
93+
94+
/**
95+
* Given a list of permissions, return a new list with the ones not present in AndroidManifest.xml
96+
*
97+
* @param neededPermissions The permissions needed.
98+
* @return The permissions not present in AndroidManifest.xml
99+
*/
100+
fun getUndefinedPermissions(context: Context, neededPermissions: Array<String?>): Array<String?> {
101+
val undefinedPermissions = ArrayList<String?>()
102+
val requestedPermissions = getManifestPermissions(context)
103+
if (!requestedPermissions.isNullOrEmpty()) {
104+
val requestedPermissionsList = listOf(*requestedPermissions)
105+
val requestedPermissionsArrayList = ArrayList(requestedPermissionsList)
106+
for (permission in neededPermissions) {
107+
if (!requestedPermissionsArrayList.contains(permission)) {
108+
undefinedPermissions.add(permission)
109+
}
110+
}
111+
var undefinedPermissionArray = arrayOfNulls<String>(undefinedPermissions.size)
112+
undefinedPermissionArray = undefinedPermissions.toArray(undefinedPermissionArray)
113+
return undefinedPermissionArray
114+
}
115+
return neededPermissions
116+
}
117+
}

0 commit comments

Comments
 (0)