Fix emoji issue and memory limit

This commit is contained in:
stom79 2018-09-16 15:05:33 +02:00
parent 4d1d3a0721
commit 8f6a5924f9
9 changed files with 23 additions and 9 deletions

View File

@ -33,6 +33,7 @@
tools:replace="android:allowBackup"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:hardwareAccelerated="true"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"

View File

@ -101,6 +101,7 @@ import fr.gouv.etalab.mastodon.fragments.DisplaySearchFragment;
import fr.gouv.etalab.mastodon.fragments.WhoToFollowFragment;
import fr.gouv.etalab.mastodon.helper.CrossActions;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiAccountInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveInstanceInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMetaDataInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
@ -136,7 +137,7 @@ import android.support.v4.app.FragmentStatePagerAdapter;
public abstract class BaseMainActivity extends BaseActivity
implements NavigationView.OnNavigationItemSelectedListener, OnUpdateAccountInfoInterface, OnRetrieveMetaDataInterface, OnRetrieveInstanceInterface, OnRetrieveRemoteAccountInterface {
implements NavigationView.OnNavigationItemSelectedListener, OnUpdateAccountInfoInterface, OnRetrieveMetaDataInterface, OnRetrieveInstanceInterface, OnRetrieveRemoteAccountInterface, OnRetrieveEmojiAccountInterface {
private FloatingActionButton toot, delete_all, add_new;
private HashMap<String, String> tagTile = new HashMap<>();
@ -1624,6 +1625,12 @@ public abstract class BaseMainActivity extends BaseActivity
}
}
@Override
public void onRetrieveEmojiAccount(Account account) {
TextView displayedName = headerLayout.findViewById(R.id.displayedName);
displayedName.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
}
/**
* Page Adapter for settings

View File

@ -16,7 +16,6 @@ package fr.gouv.etalab.mastodon.client;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;

View File

@ -453,7 +453,6 @@ public class Account implements Parcelable {
public void makeEmojisAccount(final Context context, final OnRetrieveEmojiAccountInterface listener){
if( ((Activity)context).isFinishing() )
return;
@ -461,7 +460,6 @@ public class Account implements Parcelable {
if( account.getDisplay_name() != null)
displayNameSpan = new SpannableString(account.getDisplay_name());
if( account.getFields() != null && account.getFields().size() > 0) {
Iterator it = account.getFields().entrySet().iterator();
while (it.hasNext()) {

View File

@ -1240,8 +1240,9 @@ public class Helper {
activity.startActivity(myIntent);
activity.finish(); //User is logged out to get a new token
}else {
account.makeEmojisAccount(activity, ((BaseMainActivity)activity));
username.setText(String.format("@%s",account.getUsername() + "@" + account.getInstance()));
displayedName.setText(account.getDisplay_name());
displayedName.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
String url = account.getAvatar();
if( url.startsWith("/") ){
url = Helper.getLiveInstanceWithProtocol(activity) + account.getAvatar();
@ -1639,6 +1640,8 @@ public class Helper {
}
}
/**
* Serialized a Status class
* @param status Status to serialize

View File

@ -68,6 +68,7 @@ public class AccountDAO {
values.put(Sqlite.COL_HEADER_STATIC,account.getHeader_static());
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreated_at()));
values.put(Sqlite.COL_INSTANCE, account.getInstance());
values.put(Sqlite.COL_EMOJIS, Helper.emojisToStringStorage(account.getEmojis()));
if( account.getToken() != null)
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
@ -104,6 +105,7 @@ public class AccountDAO {
values.put(Sqlite.COL_HEADER_STATIC,account.getHeader_static());
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreated_at()));
values.put(Sqlite.COL_INSTANCE, account.getInstance());
values.put(Sqlite.COL_EMOJIS, Helper.emojisToStringStorage(account.getEmojis()));
if( account.getToken() != null)
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
@ -239,6 +241,7 @@ public class AccountDAO {
account.setHeader_static(c.getString(c.getColumnIndex(Sqlite.COL_HEADER_STATIC)));
account.setCreated_at(Helper.stringToDate(context, c.getString(c.getColumnIndex(Sqlite.COL_CREATED_AT))));
account.setInstance(c.getString(c.getColumnIndex(Sqlite.COL_INSTANCE)));
account.setEmojis(Helper.restoreEmojisFromString(c.getString(c.getColumnIndex(Sqlite.COL_EMOJIS))));
account.setToken(c.getString(c.getColumnIndex(Sqlite.COL_OAUTHTOKEN)));
//Close the cursor

View File

@ -26,7 +26,7 @@ import android.database.sqlite.SQLiteOpenHelper;
public class Sqlite extends SQLiteOpenHelper {
public static final int DB_VERSION = 12;
public static final int DB_VERSION = 13;
public static final String DB_NAME = "mastodon_etalab_db";
public static SQLiteDatabase db;
private static Sqlite sInstance;
@ -69,7 +69,7 @@ public class Sqlite extends SQLiteOpenHelper {
static final String COL_HEADER_STATIC = "HEADER_STATIC";
static final String COL_INSTANCE = "INSTANCE";
static final String COL_OAUTHTOKEN = "OAUTH_TOKEN";
static final String COL_EMOJIS = "EMOJIS";
private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " ("
@ -79,6 +79,7 @@ public class Sqlite extends SQLiteOpenHelper {
+ COL_NOTE + " TEXT NOT NULL, "+ COL_URL + " TEXT NOT NULL, "
+ COL_AVATAR + " TEXT NOT NULL, "+ COL_AVATAR_STATIC + " TEXT NOT NULL, "
+ COL_HEADER + " TEXT NOT NULL, "+ COL_HEADER_STATIC + " TEXT NOT NULL, "
+ COL_EMOJIS + " TEXT, "
+ COL_INSTANCE + " TEXT NOT NULL, " + COL_OAUTHTOKEN + " TEXT NOT NULL, " + COL_CREATED_AT + " TEXT NOT NULL)";
@ -127,7 +128,6 @@ public class Sqlite extends SQLiteOpenHelper {
static final String COL_IN_REPLY_TO_ACCOUNT_ID = "IN_REPLY_TO_ACCOUNT_ID";
static final String COL_REBLOG = "REBLOG";
static final String COL_CONTENT = "CONTENT";
static final String COL_EMOJIS = "EMOJIS";
static final String COL_REBLOGS_COUNT = "REBLOGS_COUNT";
static final String COL_FAVOURITES_COUNT = "FAVOURITES_COUNT";
static final String COL_REBLOGGED = "REBLOGGED";
@ -224,6 +224,8 @@ public class Sqlite extends SQLiteOpenHelper {
db.execSQL(CREATE_UNIQUE_CACHE_INDEX);
case 11:
db.execSQL(CREATE_TABLE_INSTANCES);
case 12:
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN "+ COL_EMOJIS + " TEXT");
default:
break;
}

View File

@ -585,7 +585,7 @@
<string name="action_filter_delete">Delete filter?</string>
<string name="action_update_filter">Update filter</string>
<string name="action_filter_create">Create filter</string>
<string name="how_to_follow">Who to follow</string>
<string name="how_to_follow">Whom to follow</string>
<string name="action_who_to_follow_empty_content">There is no accounts listed for the moment!</string>
<string name="follow_account">Follow</string>
<string name="select_all">Select all</string>

View File

@ -18,6 +18,7 @@ package fr.gouv.etalab.mastodon.activities;
import com.kobakei.ratethisapp.RateThisApp;
public class MainActivity extends BaseMainActivity {
@Override