Skip to content

Commit

Permalink
Fixed add WhatsApp Stickers in new design
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluchu committed Oct 23, 2023
1 parent 61ae787 commit b47b5dc
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 197 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
minSdk = 22
targetSdk = 34
versionCode = 1
versionName = "2.0.1"
versionName = "3.0.0"
vectorDrawables.useSupportLibrary = true
contentProviderAuthority = "$applicationId.provider.StickerContentProvider"
manifestPlaceholders["contentProviderAuthority"] = contentProviderAuthority
Expand Down Expand Up @@ -80,6 +80,7 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
implementation("androidx.browser:browser:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
implementation("com.google.accompanist:accompanist-permissions:0.32.0")

implementation(libs.bundles.hilt)
implementation(libs.bundles.coil)
Expand Down
14 changes: 0 additions & 14 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name=".WaStickersOnline"
Expand All @@ -26,23 +24,11 @@
</intent-filter>
</activity>

<activity
android:name=".features.details.view.StickerDetailsActivity"
android:parentActivityName=".features.sticker.view.MainActivity"
android:screenOrientation="portrait"
tools:ignore="UnusedAttribute">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".features.sticker.view.MainActivity" />
</activity>

<provider
android:name="com.jeluchu.wastickersonline.features.sticker.provider.StickerContentProvider"
android:authorities="${contentProviderAuthority}"
android:enabled="true"
android:exported="true"
android:readPermission="com.whatsapp.sticker.READ" />

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ package com.jeluchu.wastickersonline.core.extensions

import android.Manifest
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.PackageManager
import android.widget.Toast
import androidx.core.app.ActivityCompat
import com.jeluchu.wastickersonline.BuildConfig
import com.jeluchu.wastickersonline.core.utils.Stickers
import com.jeluchu.wastickersonline.features.sticker.models.StickerPack

val Activity.permissionStorage: Unit
get() {
Expand All @@ -19,4 +25,22 @@ val Activity.permissionStorage: Unit
1
)
}
}
}

fun Activity.addStickers(stickerPack: StickerPack) {
val intent = Intent().apply {
action = "com.whatsapp.intent.action.ENABLE_STICKER_PACK"
putExtra(Stickers.packId, stickerPack.identifier.toString())
putExtra(Stickers.authority, BuildConfig.CONTENT_PROVIDER_AUTHORITY)
putExtra(Stickers.packName, stickerPack.name)
}
try {
startActivityForResult(intent, 200)
} catch (e: ActivityNotFoundException) {
Toast.makeText(
this,
"No se añadió el paquete de stickers. Si deseas añadirlo, instala o actualiza WhatsApp.",
Toast.LENGTH_LONG
).show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun NavGraphBuilder.detailsNav(nav: Destinations) {
arguments = listOf(navArgument(NavArgs.Sticker.key) { type = StickerPackType })
) {
StickersDetailsView(
//onBackClick = { nav.goBack(it) },
onBackClick = { nav.goBack(it) },
//onItemClick = {}
//onSearchClick = { /*openActivityFromRight(SearchActivity::class.java)*/ },
//onCategoryClick = { /*showDialogFragment(CategoryDialogFragment())*/ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ object LocalShared {

object Stickers {
const val stickers = "stickers"
const val stickerPacks = "sticker_packs"
}

}

object Database {
const val cache = "WaStickersOnlineCache-db"
const val favourites = "WaStickersOnlineFavourites-db"
}

object Stickers {
const val packId = "sticker_pack_id"
const val authority = "sticker_pack_authority"
const val packName = "sticker_pack_name"
const val stickerpack = "stickerpack"

}

This file was deleted.

Loading

0 comments on commit b47b5dc

Please sign in to comment.