Some fixes
This commit is contained in:
parent
890b9b64a6
commit
df320324e2
|
@ -74,6 +74,7 @@ import com.jaredrummler.cyanea.Cyanea;
|
|||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -131,7 +132,7 @@ import es.dmoral.toasty.Toasty;
|
|||
public abstract class BaseMainActivity extends BaseActivity implements NetworkStateReceiver.NetworkStateReceiverListener {
|
||||
|
||||
public static String currentInstance, currentToken, currentUserID, client_id, client_secret, software;
|
||||
public static List<Emoji> emojis;
|
||||
public static HashMap<String, List<Emoji>> emojis = new HashMap<>();
|
||||
public static Account.API api;
|
||||
public static boolean admin;
|
||||
public static WeakReference<Account> accountWeakReference;
|
||||
|
@ -731,10 +732,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
binding.toolbarSearch.setOnSearchClickListener(v -> binding.tabLayout.setVisibility(View.VISIBLE));
|
||||
//For receiving data from other activities
|
||||
LocalBroadcastManager.getInstance(BaseMainActivity.this).registerReceiver(broadcast_data, new IntentFilter(Helper.BROADCAST_DATA));
|
||||
if (emojis == null) {
|
||||
if (emojis == null || !emojis.containsKey(MainActivity.currentInstance)) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
emojis = new EmojiInstance(BaseMainActivity.this).getEmojiList(BaseMainActivity.currentInstance);
|
||||
emojis.put(currentInstance, new EmojiInstance(BaseMainActivity.this).getEmojiList(BaseMainActivity.currentInstance));
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ package app.fedilab.android.activities;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import static app.fedilab.android.BaseMainActivity.currentInstance;
|
||||
import static app.fedilab.android.BaseMainActivity.emojis;
|
||||
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
|
@ -24,7 +25,6 @@ import android.view.MenuItem;
|
|||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.client.entities.api.EmojiInstance;
|
||||
import app.fedilab.android.databinding.ActivityAnnouncementBinding;
|
||||
|
@ -59,10 +59,10 @@ public class AnnouncementActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_tags, new FragmentMastodonAnnouncement(), null, null, null);
|
||||
if (emojis == null) {
|
||||
if (emojis == null || !emojis.containsKey(currentInstance)) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
emojis = new EmojiInstance(AnnouncementActivity.this).getEmojiList(BaseMainActivity.currentInstance);
|
||||
emojis.put(currentInstance, new EmojiInstance(AnnouncementActivity.this).getEmojiList(currentInstance));
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ package app.fedilab.android.activities;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import static app.fedilab.android.BaseMainActivity.currentInstance;
|
||||
import static app.fedilab.android.BaseMainActivity.emojis;
|
||||
import static app.fedilab.android.ui.drawer.ComposeAdapter.prepareDraft;
|
||||
|
||||
import android.Manifest;
|
||||
|
@ -63,6 +65,7 @@ import app.fedilab.android.BaseMainActivity;
|
|||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.client.entities.api.Attachment;
|
||||
import app.fedilab.android.client.entities.api.Context;
|
||||
import app.fedilab.android.client.entities.api.EmojiInstance;
|
||||
import app.fedilab.android.client.entities.api.Mention;
|
||||
import app.fedilab.android.client.entities.api.ScheduledStatus;
|
||||
import app.fedilab.android.client.entities.api.Status;
|
||||
|
@ -199,7 +202,15 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
if (token == null) {
|
||||
token = account.token;
|
||||
}
|
||||
|
||||
if (emojis == null || !emojis.containsKey(currentInstance)) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
emojis.put(currentInstance, new EmojiInstance(ComposeActivity.this).getEmojiList(currentInstance));
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
StatusesVM statusesVM = new ViewModelProvider(ComposeActivity.this).get(StatusesVM.class);
|
||||
//Empty compose
|
||||
List<Status> statusDraftList = new ArrayList<>();
|
||||
|
@ -207,10 +218,10 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
statusDraftList.add(status);
|
||||
|
||||
if (statusReplyId != null && statusDraft != null) {//Delete and redraft
|
||||
statusesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReplyId)
|
||||
statusesVM.getStatus(currentInstance, BaseMainActivity.currentToken, statusReplyId)
|
||||
.observe(ComposeActivity.this, status1 -> {
|
||||
if (status1 != null) {
|
||||
statusesVM.getContext(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReplyId)
|
||||
statusesVM.getContext(currentInstance, BaseMainActivity.currentToken, statusReplyId)
|
||||
.observe(ComposeActivity.this, statusContext -> {
|
||||
if (statusContext != null) {
|
||||
initializeContextRedraftView(statusContext, status1);
|
||||
|
@ -297,7 +308,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
|
||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||
binding.recyclerView.setAdapter(composeAdapter);
|
||||
statusesVM.getContext(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReply.id)
|
||||
statusesVM.getContext(currentInstance, BaseMainActivity.currentToken, statusReply.id)
|
||||
.observe(ComposeActivity.this, this::initializeContextView);
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
|
@ -639,7 +650,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
delayToPass = (date.getTime() - new Date().getTime());
|
||||
}
|
||||
Data inputData = new Data.Builder()
|
||||
.putString(Helper.ARG_INSTANCE, BaseMainActivity.currentInstance)
|
||||
.putString(Helper.ARG_INSTANCE, currentInstance)
|
||||
.putString(Helper.ARG_TOKEN, BaseMainActivity.currentToken)
|
||||
.putString(Helper.ARG_USER_ID, BaseMainActivity.currentUserID)
|
||||
.putLong(Helper.ARG_STATUS_DRAFT_ID, statusDraft.id)
|
||||
|
|
|
@ -150,12 +150,12 @@ public class AnnouncementAdapter extends RecyclerView.Adapter<AnnouncementAdapte
|
|||
builder.setTitle(R.string.insert_emoji);
|
||||
if (emojis != null && emojis.size() > 0) {
|
||||
GridView gridView = new GridView(context);
|
||||
gridView.setAdapter(new EmojiAdapter(emojis));
|
||||
gridView.setAdapter(new EmojiAdapter(emojis.get(MainActivity.currentInstance)));
|
||||
gridView.setNumColumns(5);
|
||||
gridView.setOnItemClickListener((parent, view, index, id) -> {
|
||||
String emojiStr = emojis.get(index).shortcode;
|
||||
String url = emojis.get(index).url;
|
||||
String static_url = emojis.get(index).static_url;
|
||||
String emojiStr = emojis.get(MainActivity.currentInstance).get(index).shortcode;
|
||||
String url = emojis.get(MainActivity.currentInstance).get(index).url;
|
||||
String static_url = emojis.get(MainActivity.currentInstance).get(index).static_url;
|
||||
boolean alreadyAdded = false;
|
||||
for (Reaction reaction : announcement.reactions) {
|
||||
if (reaction.name.compareTo(emojiStr) == 0) {
|
||||
|
|
|
@ -83,6 +83,7 @@ import java.util.regex.Pattern;
|
|||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.ComposeActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.client.entities.api.Attachment;
|
||||
import app.fedilab.android.client.entities.api.Emoji;
|
||||
import app.fedilab.android.client.entities.api.EmojiInstance;
|
||||
|
@ -1005,16 +1006,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
}
|
||||
} else if (getItemViewType(position) == TYPE_COMPOSE) {
|
||||
Status statusDraft = statusList.get(position);
|
||||
//Fill emoji and instance info
|
||||
if (emojis == null) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
emojis = new EmojiInstance(context).getEmojiList(BaseMainActivity.currentInstance);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
ComposeViewHolder holder = (ComposeViewHolder) viewHolder;
|
||||
|
||||
|
@ -1235,10 +1227,10 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
builder.setTitle(R.string.insert_emoji);
|
||||
if (emojis != null && emojis.size() > 0) {
|
||||
GridView gridView = new GridView(context);
|
||||
gridView.setAdapter(new EmojiAdapter(emojis));
|
||||
gridView.setAdapter(new EmojiAdapter(emojis.get(MainActivity.currentInstance)));
|
||||
gridView.setNumColumns(5);
|
||||
gridView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
holder.binding.content.getText().insert(holder.binding.content.getSelectionStart(), " :" + emojis.get(position).shortcode + ": ");
|
||||
holder.binding.content.getText().insert(holder.binding.content.getSelectionStart(), " :" + emojis.get(MainActivity.currentInstance).get(position).shortcode + ": ");
|
||||
alertDialogEmoji.dismiss();
|
||||
});
|
||||
gridView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
|
||||
|
|
Loading…
Reference in New Issue