forked from mollyim/mollyim-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable WebP decoding in Signal using libwebp v1.3.2
Co-authored-by: Greyson Parrelli <[email protected]> Co-authored-by: Greyson Parrelli <[email protected]>
- Loading branch information
1 parent
091f7c4
commit a7d9fd1
Showing
59 changed files
with
874 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "libwebp"] | ||
path = libwebp | ||
url = [email protected]:webmproject/libwebp.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2023 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
plugins { | ||
id("signal-sample-app") | ||
kotlin("kapt") | ||
} | ||
|
||
android { | ||
namespace = "org.signal.glide.webp.app" | ||
} | ||
|
||
dependencies { | ||
implementation(project(":glide-webp")) | ||
|
||
implementation(libs.androidx.fragment.ktx) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.compose.material3) | ||
|
||
implementation(libs.glide.glide) | ||
kapt(libs.glide.compiler) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ Copyright 2023 Signal Messenger, LLC | ||
~ SPDX-License-Identifier: AGPL-3.0-only | ||
--> | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.Signal"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.Signal"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
85 changes: 85 additions & 0 deletions
85
glide-webp/app/src/main/java/org/signal/glide/webp/app/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright 2023 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
package org.signal.glide.webp.app | ||
|
||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import androidx.recyclerview.widget.RecyclerView.ViewHolder | ||
import com.bumptech.glide.Glide | ||
import com.bumptech.glide.GlideBuilder | ||
import com.bumptech.glide.load.engine.DiskCacheStrategy | ||
import org.signal.core.util.dp | ||
|
||
/** | ||
* Main activity for this sample app. | ||
*/ | ||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.main_activitiy) | ||
|
||
Glide.init( | ||
this, | ||
GlideBuilder() | ||
.setLogLevel(Log.VERBOSE) | ||
) | ||
|
||
val context = this | ||
|
||
findViewById<RecyclerView>(R.id.list).apply { | ||
adapter = ImageAdapter() | ||
layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) | ||
} | ||
} | ||
|
||
class ImageAdapter : RecyclerView.Adapter<ImageViewHolder>() { | ||
|
||
private val data: List<String> = listOf( | ||
"test_01.webp", | ||
"test_02.webp", | ||
"test_03.webp", | ||
"test_04.webp", | ||
"test_05.webp", | ||
"test_06_lossless.webp", | ||
"test_06_lossy.webp", | ||
"test_07_lossless.webp" | ||
) | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ImageViewHolder { | ||
return ImageViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.image_item, parent, false)) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return data.size | ||
} | ||
|
||
override fun onBindViewHolder(holder: ImageViewHolder, position: Int) { | ||
holder.bind(data[position]) | ||
} | ||
} | ||
|
||
class ImageViewHolder(itemView: View) : ViewHolder(itemView) { | ||
val image: ImageView by lazy { itemView.findViewById(R.id.image) } | ||
|
||
fun bind(filename: String) { | ||
Glide.with(itemView) | ||
.load(Uri.parse("file:///android_asset/$filename")) | ||
.skipMemoryCache(true) | ||
.diskCacheStrategy(DiskCacheStrategy.NONE) | ||
.override(250.dp) | ||
.into(image) | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
glide-webp/app/src/main/java/org/signal/glide/webp/app/SampleAppGlideModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2023 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
package org.signal.glide.webp.app | ||
|
||
import android.content.Context | ||
import com.bumptech.glide.Glide | ||
import com.bumptech.glide.Registry | ||
import com.bumptech.glide.annotation.GlideModule | ||
import com.bumptech.glide.module.AppGlideModule | ||
import org.signal.core.util.logging.Log | ||
|
||
@GlideModule | ||
class SampleAppGlideModule : AppGlideModule() { | ||
override fun registerComponents(context: Context, glide: Glide, registry: Registry) { | ||
Log.e("SPIDERMAN", "AppModule - registerComponents") | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
glide-webp/app/src/main/java/org/signal/glide/webp/app/theme/Color.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright 2023 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
package org.signal.glide.webp.app.theme | ||
|
||
import androidx.compose.ui.graphics.Color | ||
|
||
val Purple80 = Color(0xFFD0BCFF) | ||
val PurpleGrey80 = Color(0xFFCCC2DC) | ||
val Pink80 = Color(0xFFEFB8C8) | ||
|
||
val Purple40 = Color(0xFF6650a4) | ||
val PurpleGrey40 = Color(0xFF625b71) | ||
val Pink40 = Color(0xFF7D5260) |
75 changes: 75 additions & 0 deletions
75
glide-webp/app/src/main/java/org/signal/glide/webp/app/theme/Theme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2023 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
package org.signal.glide.webp.app.theme | ||
|
||
import android.app.Activity | ||
import android.os.Build | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.dynamicDarkColorScheme | ||
import androidx.compose.material3.dynamicLightColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.SideEffect | ||
import androidx.compose.ui.graphics.toArgb | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.platform.LocalView | ||
import androidx.core.view.WindowCompat | ||
|
||
private val DarkColorScheme = darkColorScheme( | ||
primary = Purple80, | ||
secondary = PurpleGrey80, | ||
tertiary = Pink80 | ||
) | ||
|
||
private val LightColorScheme = lightColorScheme( | ||
primary = Purple40, | ||
secondary = PurpleGrey40, | ||
tertiary = Pink40 | ||
|
||
/* Other default colors to override | ||
background = Color(0xFFFFFBFE), | ||
surface = Color(0xFFFFFBFE), | ||
onPrimary = Color.White, | ||
onSecondary = Color.White, | ||
onTertiary = Color.White, | ||
onBackground = Color(0xFF1C1B1F), | ||
onSurface = Color(0xFF1C1B1F), | ||
*/ | ||
) | ||
|
||
@Composable | ||
fun SignalTheme( | ||
darkTheme: Boolean = isSystemInDarkTheme(), | ||
// Dynamic color is available on Android 12+ | ||
dynamicColor: Boolean = true, | ||
content: @Composable () -> Unit | ||
) { | ||
val colorScheme = when { | ||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { | ||
val context = LocalContext.current | ||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) | ||
} | ||
|
||
darkTheme -> DarkColorScheme | ||
else -> LightColorScheme | ||
} | ||
val view = LocalView.current | ||
if (!view.isInEditMode) { | ||
SideEffect { | ||
val window = (view.context as Activity).window | ||
window.statusBarColor = colorScheme.primary.toArgb() | ||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme | ||
} | ||
} | ||
|
||
MaterialTheme( | ||
colorScheme = colorScheme, | ||
typography = Typography, | ||
content = content | ||
) | ||
} |
Oops, something went wrong.