mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Convert SignalService, Database, Group, Payment, and other remaining protos to wire.
This commit is contained in:
committed by
Alex Hart
parent
a6b7d0bcc5
commit
efbd5cab85
@@ -14,12 +14,12 @@ public final class ChatWallpaperFactory {
|
||||
private ChatWallpaperFactory() {}
|
||||
|
||||
public static @NonNull ChatWallpaper create(@NonNull Wallpaper model) {
|
||||
if (model.hasSingleColor()) {
|
||||
return buildForSingleColor(model.getSingleColor(), model.getDimLevelInDarkTheme());
|
||||
} else if (model.hasLinearGradient()) {
|
||||
return buildForLinearGradinent(model.getLinearGradient(), model.getDimLevelInDarkTheme());
|
||||
} else if (model.hasFile()) {
|
||||
return buildForFile(model.getFile(), model.getDimLevelInDarkTheme());
|
||||
if (model.singleColor != null) {
|
||||
return buildForSingleColor(model.singleColor, model.dimLevelInDarkTheme);
|
||||
} else if (model.linearGradient != null) {
|
||||
return buildForLinearGradinent(model.linearGradient, model.dimLevelInDarkTheme);
|
||||
} else if (model.file_ != null) {
|
||||
return buildForFile(model.file_, model.dimLevelInDarkTheme);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public final class ChatWallpaperFactory {
|
||||
public static @NonNull ChatWallpaper updateWithDimming(@NonNull ChatWallpaper wallpaper, float dimLevelInDarkTheme) {
|
||||
Wallpaper model = wallpaper.serialize();
|
||||
|
||||
return create(model.toBuilder().setDimLevelInDarkTheme(dimLevelInDarkTheme).build());
|
||||
return create(model.newBuilder().dimLevelInDarkTheme(dimLevelInDarkTheme).build());
|
||||
}
|
||||
|
||||
public static @NonNull ChatWallpaper create(@NonNull Uri uri) {
|
||||
@@ -36,25 +36,25 @@ public final class ChatWallpaperFactory {
|
||||
}
|
||||
|
||||
private static @NonNull ChatWallpaper buildForSingleColor(@NonNull Wallpaper.SingleColor singleColor, float dimLevelInDarkTheme) {
|
||||
return new SingleColorChatWallpaper(singleColor.getColor(), dimLevelInDarkTheme);
|
||||
return new SingleColorChatWallpaper(singleColor.color, dimLevelInDarkTheme);
|
||||
}
|
||||
|
||||
private static @NonNull ChatWallpaper buildForLinearGradinent(@NonNull Wallpaper.LinearGradient gradient, float dimLevelInDarkTheme) {
|
||||
int[] colors = new int[gradient.getColorsCount()];
|
||||
int[] colors = new int[gradient.colors.size()];
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
colors[i] = gradient.getColors(i);
|
||||
colors[i] = gradient.colors.get(i);
|
||||
}
|
||||
|
||||
float[] positions = new float[gradient.getPositionsCount()];
|
||||
float[] positions = new float[gradient.positions.size()];
|
||||
for (int i = 0; i < positions.length; i++) {
|
||||
positions[i] = gradient.getPositions(i);
|
||||
positions[i] = gradient.positions.get(i);
|
||||
}
|
||||
|
||||
return new GradientChatWallpaper(gradient.getRotation(), colors, positions, dimLevelInDarkTheme);
|
||||
return new GradientChatWallpaper(gradient.rotation, colors, positions, dimLevelInDarkTheme);
|
||||
}
|
||||
|
||||
private static @NonNull ChatWallpaper buildForFile(@NonNull Wallpaper.File file, float dimLevelInDarkTheme) {
|
||||
Uri uri = Uri.parse(file.getUri());
|
||||
Uri uri = Uri.parse(file.uri);
|
||||
return new UriChatWallpaper(uri, dimLevelInDarkTheme);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ import androidx.annotation.NonNull;
|
||||
import org.thoughtcrime.securesms.components.RotatableGradientDrawable;
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.Wallpaper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class GradientChatWallpaper implements ChatWallpaper, Parcelable {
|
||||
@@ -112,22 +114,26 @@ public final class GradientChatWallpaper implements ChatWallpaper, Parcelable {
|
||||
|
||||
@Override
|
||||
public @NonNull Wallpaper serialize() {
|
||||
Wallpaper.LinearGradient.Builder builder = Wallpaper.LinearGradient.newBuilder();
|
||||
Wallpaper.LinearGradient.Builder builder = new Wallpaper.LinearGradient.Builder();
|
||||
|
||||
builder.setRotation(degrees);
|
||||
builder.rotation(degrees);
|
||||
|
||||
for (int color : colors) {
|
||||
builder.addColors(color);
|
||||
List<Integer> colors = new ArrayList<>(this.colors.length);
|
||||
for (int color : this.colors) {
|
||||
colors.add(color);
|
||||
}
|
||||
builder.colors(colors);
|
||||
|
||||
for (float position : positions) {
|
||||
builder.addPositions(position);
|
||||
List<Float> positions = new ArrayList<>(this.positions.length);
|
||||
for (float position : this.positions) {
|
||||
positions.add(position);
|
||||
}
|
||||
builder.positions(positions);
|
||||
|
||||
return Wallpaper.newBuilder()
|
||||
.setLinearGradient(builder)
|
||||
.setDimLevelInDarkTheme(dimLevelInDarkTheme)
|
||||
.build();
|
||||
return new Wallpaper.Builder()
|
||||
.linearGradient(builder.build())
|
||||
.dimLevelInDarkTheme(dimLevelInDarkTheme)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,14 +61,14 @@ public final class SingleColorChatWallpaper implements ChatWallpaper, Parcelable
|
||||
|
||||
@Override
|
||||
public @NonNull Wallpaper serialize() {
|
||||
Wallpaper.SingleColor.Builder builder = Wallpaper.SingleColor.newBuilder();
|
||||
Wallpaper.SingleColor.Builder builder = new Wallpaper.SingleColor.Builder();
|
||||
|
||||
builder.setColor(color);
|
||||
builder.color(color);
|
||||
|
||||
return Wallpaper.newBuilder()
|
||||
.setSingleColor(builder)
|
||||
.setDimLevelInDarkTheme(dimLevelInDarkTheme)
|
||||
.build();
|
||||
return new Wallpaper.Builder()
|
||||
.singleColor(builder.build())
|
||||
.dimLevelInDarkTheme(dimLevelInDarkTheme)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.wallpaper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -22,16 +21,11 @@ import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.Wallpaper;
|
||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.util.ByteUnit;
|
||||
import org.thoughtcrime.securesms.util.LRUCache;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
final class UriChatWallpaper implements ChatWallpaper, Parcelable {
|
||||
|
||||
@@ -126,10 +120,10 @@ final class UriChatWallpaper implements ChatWallpaper, Parcelable {
|
||||
|
||||
@Override
|
||||
public @NonNull Wallpaper serialize() {
|
||||
return Wallpaper.newBuilder()
|
||||
.setFile(Wallpaper.File.newBuilder().setUri(uri.toString()))
|
||||
.setDimLevelInDarkTheme(dimLevelInDarkTheme)
|
||||
.build();
|
||||
return new Wallpaper.Builder()
|
||||
.file_(new Wallpaper.File.Builder().uri(uri.toString()).build())
|
||||
.dimLevelInDarkTheme(dimLevelInDarkTheme)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user