Compare commits

...

3 commits

3 changed files with 19 additions and 8 deletions

2
.gitignore vendored
View file

@ -10,8 +10,6 @@
.DS_Store
/build
/captures
/app
/.gradle
.externalNativeBuild
.cxx
local.properties

View file

@ -11,10 +11,12 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.NotificationCompat
import okhttp3.Call
import okhttp3.Callback
import okhttp3.FormBody
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import org.json.JSONObject
import java.io.IOException
class ShareActivity : AppCompatActivity() {
@ -44,10 +46,16 @@ class ShareActivity : AppCompatActivity() {
private fun sendPostRequest(url: String, token: String, sharedText: String) {
isRequestRunning = true
val fullUrl = "$url/api/recipe/create/url"
val requestBody = FormBody.Builder()
.add("data", sharedText)
.build()
val fullUrl = "$url/api/recipes/create/url"
// Create JSON object for the request body
val jsonBody = JSONObject()
jsonBody.put("includeTags", false) // Set includeTags to false
jsonBody.put("url", sharedText) // Set the URL to the shared text
// Create the request body with JSON media type
val requestBody = jsonBody.toString()
.toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull())
val request = Request.Builder()
.url(fullUrl)
@ -100,7 +108,7 @@ class ShareActivity : AppCompatActivity() {
val notification = NotificationCompat.Builder(this, channelId)
.setContentTitle("Mealie URL Share")
.setContentText(message)
//.setSmallIcon(R.drawable.ic_notification) // Replace with your notification icon
.setSmallIcon(R.drawable.baseline_error_24) // Replace with your notification icon
.setAutoCancel(true)
.build()

View file

@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-2h2v2zM13,13h-2L11,7h2v6z"/>
</vector>