remove old emoji shortcodes

main
Conny Duck 7 years ago
parent 65b7ce1909
commit 09e2746c41
  1. 1881
      app/src/main/java/com/emojione/Emojione.java
  2. 6
      app/src/main/java/com/keylesspalace/tusky/BaseActivity.java
  3. 11
      app/src/main/java/com/keylesspalace/tusky/entity/Account.java
  4. 3
      app/src/main/java/com/keylesspalace/tusky/json/SpannedTypeAdapter.java
  5. 31
      app/src/main/java/com/keylesspalace/tusky/json/StringWithEmoji.java
  6. 38
      app/src/main/java/com/keylesspalace/tusky/json/StringWithEmojiTypeAdapter.java
  7. 12
      app/src/main/java/com/keylesspalace/tusky/service/PullNotificationService.java

File diff suppressed because it is too large Load Diff

@ -36,8 +36,6 @@ import android.view.Menu;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.keylesspalace.tusky.json.SpannedTypeAdapter;
import com.keylesspalace.tusky.json.StringWithEmoji;
import com.keylesspalace.tusky.json.StringWithEmojiTypeAdapter;
import com.keylesspalace.tusky.network.MastodonApi;
import com.keylesspalace.tusky.network.TuskyApi;
import com.keylesspalace.tusky.service.PullNotificationService;
@ -127,8 +125,8 @@ public class BaseActivity extends AppCompatActivity {
protected void createMastodonApi() {
mastodonApiDispatcher = new Dispatcher();
Gson gson = new GsonBuilder().registerTypeAdapter(Spanned.class, new SpannedTypeAdapter())
.registerTypeAdapter(StringWithEmoji.class, new StringWithEmojiTypeAdapter())
Gson gson = new GsonBuilder()
.registerTypeAdapter(Spanned.class, new SpannedTypeAdapter())
.create();
OkHttpClient.Builder okBuilder =

@ -21,7 +21,6 @@ import android.text.Spanned;
import com.google.gson.annotations.SerializedName;
import com.keylesspalace.tusky.util.HtmlUtils;
import com.keylesspalace.tusky.json.StringWithEmoji;
public class Account implements Parcelable {
public String id;
@ -33,7 +32,7 @@ public class Account implements Parcelable {
public String username;
@SerializedName("display_name")
public StringWithEmoji displayName;
public String displayName;
public Spanned note;
@ -71,10 +70,10 @@ public class Account implements Parcelable {
}
public String getDisplayName() {
if (displayName.value.length() == 0) {
if (displayName.length() == 0) {
return localUsername;
}
return displayName.value;
return displayName;
}
@Override
@ -87,7 +86,7 @@ public class Account implements Parcelable {
dest.writeString(id);
dest.writeString(localUsername);
dest.writeString(username);
dest.writeString(displayName.value);
dest.writeString(displayName);
dest.writeString(HtmlUtils.toHtml(note));
dest.writeString(url);
dest.writeString(avatar);
@ -104,7 +103,7 @@ public class Account implements Parcelable {
id = in.readString();
localUsername = in.readString();
username = in.readString();
displayName = new StringWithEmoji(in.readString());
displayName = in.readString();
note = HtmlUtils.fromHtml(in.readString());
url = in.readString();
avatar = in.readString();

@ -18,7 +18,6 @@ package com.keylesspalace.tusky.json;
import android.text.Spanned;
import android.text.SpannedString;
import com.emojione.Emojione;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
@ -33,7 +32,7 @@ public class SpannedTypeAdapter implements JsonDeserializer<Spanned> {
throws JsonParseException {
String string = json.getAsString();
if (string != null) {
return HtmlUtils.fromHtml(Emojione.shortnameToUnicode(string, false));
return HtmlUtils.fromHtml(string);
} else {
return new SpannedString("");
}

@ -1,31 +0,0 @@
/* Copyright 2017 Andrew Dawson
*
* This file is a part of Tusky.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Tusky; if not,
* see <http://www.gnu.org/licenses>. */
package com.keylesspalace.tusky.json;
/**
* This is just a wrapper class for a String.
*
* It was designed to get around the limitation of a Json deserializer which only allows custom
* deserializing based on types, when special handling for a specific field was what was actually
* desired (in this case, display names). So, it was most expedient to just make up a type.
*/
public class StringWithEmoji {
public String value;
public StringWithEmoji(String value) {
this.value = value;
}
}

@ -1,38 +0,0 @@
/* Copyright 2017 Andrew Dawson
*
* This file is a part of Tusky.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Tusky; if not,
* see <http://www.gnu.org/licenses>. */
package com.keylesspalace.tusky.json;
import com.emojione.Emojione;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
/** This is a type-based workaround to allow for shortcode conversion when loading display names. */
public class StringWithEmojiTypeAdapter implements JsonDeserializer<StringWithEmoji> {
@Override
public StringWithEmoji deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
String value = json.getAsString();
if (value != null) {
return new StringWithEmoji(Emojione.shortnameToUnicode(value, false));
} else {
return new StringWithEmoji("");
}
}
}

@ -20,6 +20,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.text.Spanned;
import android.util.Log;
@ -28,8 +29,6 @@ import com.google.gson.GsonBuilder;
import com.keylesspalace.tusky.R;
import com.keylesspalace.tusky.entity.Notification;
import com.keylesspalace.tusky.json.SpannedTypeAdapter;
import com.keylesspalace.tusky.json.StringWithEmoji;
import com.keylesspalace.tusky.json.StringWithEmojiTypeAdapter;
import com.keylesspalace.tusky.network.MastodonApi;
import com.keylesspalace.tusky.util.OkHttpUtils;
import com.keylesspalace.tusky.util.NotificationMaker;
@ -73,15 +72,15 @@ public class PullNotificationService extends IntentService {
mastodonApi.notifications(null, null, null).enqueue(new Callback<List<Notification>>() {
@Override
public void onResponse(Call<List<Notification>> call,
Response<List<Notification>> response) {
public void onResponse(@NonNull Call<List<Notification>> call,
@NonNull Response<List<Notification>> response) {
if (response.isSuccessful()) {
onNotificationsReceived(response.body());
}
}
@Override
public void onFailure(Call<List<Notification>> call, Throwable t) {}
public void onFailure(@NonNull Call<List<Notification>> call, @NonNull Throwable t) {}
});
}
@ -94,7 +93,7 @@ public class PullNotificationService extends IntentService {
OkHttpClient okHttpClient = OkHttpUtils.getCompatibleClientBuilder()
.addInterceptor(new Interceptor() {
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
public okhttp3.Response intercept(@NonNull Chain chain) throws IOException {
Request originalRequest = chain.request();
Request.Builder builder = originalRequest.newBuilder()
@ -109,7 +108,6 @@ public class PullNotificationService extends IntentService {
Gson gson = new GsonBuilder()
.registerTypeAdapter(Spanned.class, new SpannedTypeAdapter())
.registerTypeAdapter(StringWithEmoji.class, new StringWithEmojiTypeAdapter())
.create();
Retrofit retrofit = new Retrofit.Builder()

Loading…
Cancel
Save