diff --git a/.gitignore b/.gitignore index d796120..aa724b7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,6 @@ .DS_Store /build /captures -/app -/.gradle .externalNativeBuild .cxx local.properties diff --git a/app/src/main/java/org/seanandroid/mealieurlshare/ShareActivity.kt b/app/src/main/java/org/seanandroid/mealieurlshare/ShareActivity.kt index ac42eb4..7349a06 100644 --- a/app/src/main/java/org/seanandroid/mealieurlshare/ShareActivity.kt +++ b/app/src/main/java/org/seanandroid/mealieurlshare/ShareActivity.kt @@ -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() diff --git a/app/src/main/res/drawable/baseline_error_24.xml b/app/src/main/res/drawable/baseline_error_24.xml new file mode 100644 index 0000000..aef9dd2 --- /dev/null +++ b/app/src/main/res/drawable/baseline_error_24.xml @@ -0,0 +1,5 @@ + + + + +