Fix notification issue

This commit is contained in:
tom79 2020-04-16 14:34:45 +02:00
parent 2558342561
commit ebc554b0f5
14 changed files with 198 additions and 206 deletions

View File

@ -359,7 +359,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
set_profile_save.setOnClickListener(v -> {
if (set_profile_name.getText() != null )
if (set_profile_name.getText() != null)
profile_username = set_profile_name.getText().toString().trim();
else
profile_username = "";

View File

@ -809,7 +809,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
SharedPreferences sharedpreferences1 = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
boolean photo_editor = sharedpreferences1.getBoolean(Helper.SET_PHOTO_EDITOR, true);
if( inputContentInfo != null ) {
if (inputContentInfo != null) {
Uri uri = inputContentInfo.getContentUri();
String filename = Helper.getFileName(TootActivity.this, uri);
ContentResolver cr = getContentResolver();

View File

@ -367,13 +367,13 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
apiResponse = new APIResponse();
db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<app.fedilab.android.client.Entities.Status> statuses = new StatusCacheDAO(contextReference.get(), db).getAllStatus(StatusCacheDAO.BOOKMARK_CACHE);
if( statuses != null ) {
if (statuses != null) {
for (app.fedilab.android.client.Entities.Status status : statuses) {
app.fedilab.android.client.Entities.Status.fillSpan(contextReference.get(), status);
app.fedilab.android.client.Entities.Status.makeEmojiPoll(contextReference.get(), status.getReblog() != null ? status.getReblog().getPoll() : status.getPoll());
Account.makeAccountNameEmoji(contextReference.get(), status.getReblog() != null ? status.getReblog().getAccount() : status.getAccount());
}
}else {
} else {
statuses = new ArrayList<>();
}
apiResponse.setStatuses(statuses);

View File

@ -50,12 +50,14 @@ public class SyncBookmarksAsyncTask extends AsyncTask<Void, Void, Void> {
this.type = type;
this.listener = onSyncBookmarksInterface;
}
public SyncBookmarksAsyncTask(Context context, String statusId, OnSyncBookmarksInterface onSyncBookmarksInterface) {
this.contextReference = new WeakReference<>(context);
this.type = sync.REFRESH;
this.statusId = statusId;
this.listener = onSyncBookmarksInterface;
}
@Override
protected Void doInBackground(Void... params) {
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
@ -78,7 +80,7 @@ public class SyncBookmarksAsyncTask extends AsyncTask<Void, Void, Void> {
}
} while (max_id != null);
statusList = new StatusCacheDAO(contextReference.get(), db).getAllStatus(BOOKMARK_CACHE);
} else if (type == sync.EXPORT){
} else if (type == sync.EXPORT) {
List<app.fedilab.android.client.Entities.Status> statuses = new StatusCacheDAO(contextReference.get(), db).getAllStatus(BOOKMARK_CACHE);
if (statuses != null) {
for (app.fedilab.android.client.Entities.Status tmpStatus : statuses) {
@ -91,7 +93,7 @@ public class SyncBookmarksAsyncTask extends AsyncTask<Void, Void, Void> {
}
}
statusList = new StatusCacheDAO(contextReference.get(), db).getAllStatus(BOOKMARK_CACHE);
}else {
} else {
APIResponse apiResponse = new API(contextReference.get()).getStatusbyIdAndCache(statusId);
app.fedilab.android.client.Entities.Status refreshedStatus = apiResponse.getStatuses().get(0);
new StatusCacheDAO(contextReference.get().getApplicationContext(), db).updateStatus(BOOKMARK_CACHE, refreshedStatus);

View File

@ -749,9 +749,9 @@ public class API {
if (!resobj.isNull("in_reply_to_account_id")) {
status.setIn_reply_to_account_id(resobj.get("in_reply_to_account_id").toString());
}
if( resobj.has("sensitive")){
if (resobj.has("sensitive")) {
status.setSensitive(resobj.getBoolean("sensitive"));
}else{
} else {
status.setSensitive(false);
}
status.setSpoiler_text(resobj.get("spoiler_text").toString());
@ -853,7 +853,7 @@ public class API {
}
status.setApplication(application);
status.setAccount(parseAccountResponse(context, resobj.getJSONObject("account")));
status.setAccount(parseAccountResponse(context, resobj.getJSONObject("account"), true));
status.setContent(context, resobj.get("content").toString());
if (!resobj.isNull("favourites_count")) {
status.setFavourites_count(resobj.getInt("favourites_count"));
@ -1236,7 +1236,7 @@ public class API {
} else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
if (!resobj.isNull("account")) {
Account account = parseAccountResponse(context, resobj.getJSONObject("account"));
Account account = parseAccountResponse(context, resobj.getJSONObject("account"), true);
AccountAdmin accountAdmin = new AccountAdmin();
accountAdmin.setId(account.getId());
accountAdmin.setUsername(account.getAcct());
@ -1245,7 +1245,7 @@ public class API {
}
if (!resobj.isNull("actor")) {
Account account = parseAccountResponse(context, resobj.getJSONObject("actor"));
Account account = parseAccountResponse(context, resobj.getJSONObject("actor"), true);
AccountAdmin accountAdmin = new AccountAdmin();
accountAdmin.setId(account.getId());
accountAdmin.setUsername(account.getAcct());
@ -1308,7 +1308,7 @@ public class API {
}
if (!resobj.isNull("account")) {
accountAdmin.setAccount(parseAccountResponse(context, resobj.getJSONObject("account")));
accountAdmin.setAccount(parseAccountResponse(context, resobj.getJSONObject("account"), true));
} else {
Account account = new Account();
account.setId(accountAdmin.getId());
@ -1359,7 +1359,7 @@ public class API {
* @return Account
*/
@SuppressWarnings("InfiniteRecursion")
private static Account parseAccountResponse(Context context, JSONObject resobj) {
private static Account parseAccountResponse(Context context, JSONObject resobj, boolean fetchEmoji) {
Account account = new Account();
try {
@ -1399,7 +1399,7 @@ public class API {
account.setBot(false);
}
try {
account.setMoved_to_account(parseAccountResponse(context, resobj.getJSONObject("moved")));
account.setMoved_to_account(parseAccountResponse(context, resobj.getJSONObject("moved"), true));
} catch (Exception ignored) {
account.setMoved_to_account(null);
}
@ -1420,6 +1420,7 @@ public class API {
}
}
} catch (Exception ignored) {
ignored.printStackTrace();
}
try {
@ -1439,6 +1440,7 @@ public class API {
account.setFields(fieldsMap);
account.setFieldsVerified(fieldsMapVerified);
} catch (Exception ignored) {
ignored.printStackTrace();
}
@ -1478,7 +1480,9 @@ public class API {
} catch (JSONException | ParseException e) {
e.printStackTrace();
}
Account.makeAccountNameEmoji(context, account);
if (fetchEmoji) {
Account.makeAccountNameEmoji(context, account);
}
return account;
}
@ -1606,10 +1610,12 @@ public class API {
notification.setId(resobj.get("id").toString());
notification.setType(resobj.get("type").toString());
notification.setCreated_at(Helper.mstStringToDate(resobj.get("created_at").toString()));
notification.setAccount(parseAccountResponse(context, resobj.getJSONObject("account")));
notification.setAccount(parseAccountResponse(context, resobj.getJSONObject("account"), false));
try {
notification.setStatus(parseStatuses(context, resobj.getJSONObject("status")));
} catch (Exception ignored) {
ignored.printStackTrace();
}
notification.setCreated_at(Helper.mstStringToDate(resobj.get("created_at").toString()));
} catch (JSONException ignored) {
@ -2450,7 +2456,7 @@ public class API {
return null;
}
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/accounts/verify_credentials"), 10, null, prefKeyOauthTokenT);
account = parseAccountResponse(context, new JSONObject(response));
account = parseAccountResponse(context, new JSONObject(response), true);
if (social != null) {
account.setSocial(social.toUpperCase());
}
@ -2482,7 +2488,7 @@ public class API {
String response;
try {
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/accounts/verify_credentials"), 10, null, targetedAccount.getToken());
account = parseAccountResponse(context, new JSONObject(response));
account = parseAccountResponse(context, new JSONObject(response), true);
if (social != null) {
account.setSocial(social.toUpperCase());
}
@ -2578,7 +2584,7 @@ public class API {
account = new Account();
try {
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl(String.format("/accounts/%s", accountId)), 10, null, prefKeyOauthTokenT);
account = parseAccountResponse(context, new JSONObject(response));
account = parseAccountResponse(context, new JSONObject(response), true);
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
e.printStackTrace();
@ -5736,7 +5742,7 @@ public class API {
}
}
if (resobj.has("contact_account")) {
instance.setContactAccount(parseAccountResponse(context, resobj.getJSONObject("contact_account")));
instance.setContactAccount(parseAccountResponse(context, resobj.getJSONObject("contact_account"), true));
}
} catch (JSONException e) {
e.printStackTrace();
@ -5968,7 +5974,7 @@ public class API {
int i = 0;
while (i < jsonArray.length()) {
JSONObject resobj = jsonArray.getJSONObject(i);
Account account = parseAccountResponse(context, resobj);
Account account = parseAccountResponse(context, resobj, true);
accounts.add(account);
i++;
}

View File

@ -245,6 +245,7 @@ public class Account implements Parcelable {
});
} catch (Exception ignored) {
ignored.printStackTrace();
}
}

View File

@ -532,7 +532,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
holder.rated.removeAllViews();
List<Integer> ownvotes = poll.getOwn_votes();
int j = 0;
if ( poll.getOptionsList() != null) {
if (poll.getOptionsList() != null) {
for (PollOptions pollOption : poll.getOptionsList()) {
View item = inflater.inflate(R.layout.layout_poll_item, new LinearLayout(context), false);
double value = ((double) (pollOption.getVotes_count() * 100) / (double) poll.getVoters_count());

View File

@ -45,7 +45,7 @@ public class ReactionAdapter extends RecyclerView.Adapter {
ReactionAdapter(List<Reaction> reactions) {
this.reactions = reactions;
if( reactions == null){
if (reactions == null) {
this.reactions = new ArrayList<>();
}
}
@ -74,13 +74,13 @@ public class ReactionAdapter extends RecyclerView.Adapter {
holder.reaction_emoji.setContentDescription(reaction.getName());
Helper.loadGiF(holder.itemView.getContext(), reaction.getUrl(), holder.reaction_emoji);
if( !reaction.getUrl().contains("gif")) {
if (!reaction.getUrl().contains("gif")) {
Glide.with(holder.itemView.getContext())
.asDrawable()
.load(reaction.getUrl())
.thumbnail(0.1f)
.into(holder.reaction_emoji);
}else{
} else {
Glide.with(holder.itemView.getContext())
.asGif()
.load(reaction.getUrl())

View File

@ -568,7 +568,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
show_account_boosts = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_BOOSTS, true);
show_account_replies = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_REPLIES, true);
}
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS && type != RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS && !Helper.filterToots(statuses.get(position), type, context instanceof ShowAccountActivity, show_account_boosts, show_account_replies)) {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS && type != RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS && !Helper.filterToots(statuses.get(position), type, context instanceof ShowAccountActivity, show_account_boosts, show_account_replies)) {
return HIDDEN_STATUS;
}
if (statuses.get(position).isFocused() && type == RetrieveFeedsAsyncTask.Type.CONTEXT && statuses.get(position).getViewType() != CONSOLE_STATUS)
@ -1270,11 +1270,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
TooltipCompat.setTooltipText(holder.custom_feature_cache, context.getString(R.string.refresh_cache));
holder.custom_feature_cache.setOnClickListener(view -> {
if( type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
new ManageCachedStatusAsyncTask(context, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
}else{
} else {
new SyncBookmarksAsyncTask(context, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@ -2143,7 +2143,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
String url = status.getWebviewURL().replaceAll("&amp;", "&");
try {
holder.status_cardview_webview.loadUrl(url);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
holder.status_cardview_webview.setVisibility(View.VISIBLE);
@ -2159,7 +2159,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
String url = status.getReblog().getWebviewURL().replaceAll("&amp;", "&");
try {
holder.status_cardview_webview.loadUrl(url);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
holder.status_cardview_webview.setVisibility(View.VISIBLE);
@ -3999,7 +3999,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
@Override
public void onRetrieveBookmarks(List<Status> statuses) {
if( statuses != null && statuses.size() > 0 ) {
if (statuses != null && statuses.size() > 0) {
notifyStatusChanged(statuses.get(0));
}
}

View File

@ -15,7 +15,6 @@ package app.fedilab.android.fragments;
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
@ -46,6 +45,7 @@ import java.util.List;
import java.util.Objects;
import app.fedilab.android.R;
import app.fedilab.android.activities.BaseMainActivity;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.asynctasks.ManageFiltersAsyncTask;
import app.fedilab.android.client.APIResponse;
@ -70,7 +70,7 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
private Context context;
private AsyncTask<Void, Void, Void> asyncTask;
private List<Filters> filters;
private RelativeLayout mainLoader;
private FloatingActionButton add_new;
private FilterAdapter filterAdapter;
@ -84,7 +84,6 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
View rootView = inflater.inflate(R.layout.fragment_filters, container, false);
context = getContext();
filters = new ArrayList<>();
lv_filters = rootView.findViewById(R.id.lv_filters);
@ -93,7 +92,7 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
RelativeLayout nextElementLoader = rootView.findViewById(R.id.loading_next_items);
mainLoader.setVisibility(View.VISIBLE);
nextElementLoader.setVisibility(View.GONE);
filterAdapter = new FilterAdapter(filters, textviewNoAction);
filterAdapter = new FilterAdapter(BaseMainActivity.filters, textviewNoAction);
lv_filters.setAdapter(filterAdapter);
asyncTask = new ManageFiltersAsyncTask(context, ManageFiltersAsyncTask.action.GET_ALL_FILTER, null, DisplayFiltersFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
try {
@ -101,114 +100,100 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
} catch (Exception ignored) {
}
if (add_new != null)
add_new.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
int style;
if (theme == Helper.THEME_DARK) {
style = R.style.DialogDark;
} else if (theme == Helper.THEME_BLACK) {
style = R.style.DialogBlack;
} else {
style = R.style.Dialog;
}
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, style);
LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.add_filter, new LinearLayout(context), false);
dialogBuilder.setView(dialogView);
EditText add_phrase = dialogView.findViewById(R.id.add_phrase);
CheckBox context_home = dialogView.findViewById(R.id.context_home);
CheckBox context_public = dialogView.findViewById(R.id.context_public);
CheckBox context_notification = dialogView.findViewById(R.id.context_notification);
CheckBox context_conversation = dialogView.findViewById(R.id.context_conversation);
CheckBox context_whole_word = dialogView.findViewById(R.id.context_whole_word);
CheckBox context_drop = dialogView.findViewById(R.id.context_drop);
Spinner filter_expire = dialogView.findViewById(R.id.filter_expire);
ArrayAdapter<CharSequence> adapterResize = ArrayAdapter.createFromResource(Objects.requireNonNull(getActivity()),
R.array.filter_expire, android.R.layout.simple_spinner_dropdown_item);
filter_expire.setAdapter(adapterResize);
final int[] expire = {-1};
filter_expire.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
expire[0] = -1;
break;
case 1:
expire[0] = 3600;
break;
case 2:
expire[0] = 21600;
break;
case 3:
expire[0] = 43200;
break;
case 4:
expire[0] = 86400;
break;
case 5:
expire[0] = 604800;
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
if (add_phrase.getText() != null && add_phrase.getText().toString().trim().length() > 0) {
Filters filter = new Filters();
ArrayList<String> contextFilter = new ArrayList<>();
if (context_home.isChecked())
contextFilter.add("home");
if (context_public.isChecked())
contextFilter.add("public");
if (context_notification.isChecked())
contextFilter.add("notifications");
if (context_conversation.isChecked())
contextFilter.add("thread");
filter.setContext(contextFilter);
filter.setPhrase(add_phrase.getText().toString());
filter.setExpires_in(expire[0]);
filter.setWhole_word(context_whole_word.isChecked());
filter.setIrreversible(context_drop.isChecked());
new ManageFiltersAsyncTask(context, ManageFiltersAsyncTask.action.CREATE_FILTER, filter, DisplayFiltersFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
dialog.dismiss();
add_new.setEnabled(false);
}
});
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.setTitle(getString(R.string.action_filter_create));
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
//Hide keyboard
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
assert imm != null;
imm.hideSoftInputFromWindow(add_phrase.getWindowToken(), 0);
}
});
if (alertDialog.getWindow() != null)
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
alertDialog.show();
add_new.setOnClickListener(view -> {
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
int style;
if (theme == Helper.THEME_DARK) {
style = R.style.DialogDark;
} else if (theme == Helper.THEME_BLACK) {
style = R.style.DialogBlack;
} else {
style = R.style.Dialog;
}
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, style);
LayoutInflater inflater1 = getLayoutInflater();
View dialogView = inflater1.inflate(R.layout.add_filter, new LinearLayout(context), false);
dialogBuilder.setView(dialogView);
EditText add_phrase = dialogView.findViewById(R.id.add_phrase);
CheckBox context_home = dialogView.findViewById(R.id.context_home);
CheckBox context_public = dialogView.findViewById(R.id.context_public);
CheckBox context_notification = dialogView.findViewById(R.id.context_notification);
CheckBox context_conversation = dialogView.findViewById(R.id.context_conversation);
CheckBox context_whole_word = dialogView.findViewById(R.id.context_whole_word);
CheckBox context_drop = dialogView.findViewById(R.id.context_drop);
Spinner filter_expire = dialogView.findViewById(R.id.filter_expire);
ArrayAdapter<CharSequence> adapterResize = ArrayAdapter.createFromResource(Objects.requireNonNull(getActivity()),
R.array.filter_expire, android.R.layout.simple_spinner_dropdown_item);
filter_expire.setAdapter(adapterResize);
final int[] expire = {-1};
filter_expire.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
expire[0] = -1;
break;
case 1:
expire[0] = 3600;
break;
case 2:
expire[0] = 21600;
break;
case 3:
expire[0] = 43200;
break;
case 4:
expire[0] = 86400;
break;
case 5:
expire[0] = 604800;
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
dialogBuilder.setPositiveButton(R.string.validate, (dialog, id) -> {
if (add_phrase.getText() != null && add_phrase.getText().toString().trim().length() > 0) {
Filters filter = new Filters();
ArrayList<String> contextFilter = new ArrayList<>();
if (context_home.isChecked())
contextFilter.add("home");
if (context_public.isChecked())
contextFilter.add("public");
if (context_notification.isChecked())
contextFilter.add("notifications");
if (context_conversation.isChecked())
contextFilter.add("thread");
filter.setContext(contextFilter);
filter.setPhrase(add_phrase.getText().toString());
filter.setExpires_in(expire[0]);
filter.setWhole_word(context_whole_word.isChecked());
filter.setIrreversible(context_drop.isChecked());
new ManageFiltersAsyncTask(context, ManageFiltersAsyncTask.action.CREATE_FILTER, filter, DisplayFiltersFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
dialog.dismiss();
add_new.setEnabled(false);
});
dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.setTitle(getString(R.string.action_filter_create));
alertDialog.setOnDismissListener(dialogInterface -> {
//Hide keyboard
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
assert imm != null;
imm.hideSoftInputFromWindow(add_phrase.getWindowToken(), 0);
});
if (alertDialog.getWindow() != null)
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
alertDialog.show();
});
return rootView;
}
@ -221,7 +206,7 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
this.context = context;
}
@ -247,7 +232,6 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
}
if (actionType == ManageFiltersAsyncTask.action.GET_ALL_FILTER) {
if (apiResponse.getFilters() != null && apiResponse.getFilters().size() > 0) {
this.filters.addAll(apiResponse.getFilters());
filterAdapter.notifyDataSetChanged();
textviewNoAction.setVisibility(View.GONE);
lv_filters.setVisibility(View.VISIBLE);
@ -257,15 +241,16 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
}
} else if (actionType == ManageFiltersAsyncTask.action.CREATE_FILTER) {
if (apiResponse.getFilters() != null && apiResponse.getFilters().size() > 0) {
this.filters.add(0, apiResponse.getFilters().get(0));
filterAdapter.notifyDataSetChanged();
BaseMainActivity.filters.add(0, apiResponse.getFilters().get(0));
filterAdapter = new FilterAdapter(BaseMainActivity.filters, textviewNoAction);
lv_filters.setAdapter(filterAdapter);
textviewNoAction.setVisibility(View.GONE);
lv_filters.setVisibility(View.VISIBLE);
} else {
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
}
MainActivity.filters = apiResponse.getFilters();
BaseMainActivity.filters = apiResponse.getFilters();
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<ManageTimelines> timelines = new TimelinesDAO(context, db).getDisplayedTimelines();
if (mPageReferenceMap == null) {

View File

@ -1727,7 +1727,7 @@ public class Helper {
if (currrentUserId != null && (!currrentUserId.equals(accountChoice.getId()) || !getLiveInstance(activity).equals(accountChoice.getInstance()))) {
icon = new ImageView(activity);
ImageView finalIcon = icon;
if( isValidContextForGlide(activity)) {
if (isValidContextForGlide(activity)) {
Glide.with(activity)
.asDrawable()
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(270)))

View File

@ -30,57 +30,8 @@ public class MastalabAutoCompleteTextView extends androidx.appcompat.widget.AppC
private float emojiSize;
private boolean emoji;
public MastalabAutoCompleteTextView(Context context) {
super(context);
initView();
}
public MastalabAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
final Paint.FontMetrics fontMetrics = getPaint().getFontMetrics();
final float defaultEmojiSize = fontMetrics.descent - fontMetrics.ascent;
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
emoji = sharedpreferences.getBoolean(Helper.SET_DISPLAY_EMOJI, false);
if (attrs == null) {
emojiSize = defaultEmojiSize;
} else {
@SuppressLint("CustomViewStyleable") final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.EmojiMultiAutoCompleteTextView);
try {
emojiSize = a.getDimension(R.styleable.EmojiMultiAutoCompleteTextView_emojiSize, defaultEmojiSize);
} finally {
a.recycle();
}
}
setText(getText());
initView();
}
public MastalabAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView();
}
private String[] imgTypeString;
private KeyBoardInputCallbackListener keyBoardInputCallbackListener;
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
final InputConnection ic = super.onCreateInputConnection(outAttrs);
EditorInfoCompat.setContentMimeTypes(outAttrs,
imgTypeString);
return InputConnectionCompat.createWrapper(ic, outAttrs, callback);
}
private void initView() {
imgTypeString = new String[]{"image/png",
"image/gif",
"image/jpeg",
"image/webp"};
}
final InputConnectionCompat.OnCommitContentListener callback =
new InputConnectionCompat.OnCommitContentListener() {
@Override
@ -114,9 +65,52 @@ public class MastalabAutoCompleteTextView extends androidx.appcompat.widget.AppC
}
};
public interface KeyBoardInputCallbackListener {
void onCommitContent(InputContentInfoCompat inputContentInfo,
int flags, Bundle opts);
public MastalabAutoCompleteTextView(Context context) {
super(context);
initView();
}
public MastalabAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
final Paint.FontMetrics fontMetrics = getPaint().getFontMetrics();
final float defaultEmojiSize = fontMetrics.descent - fontMetrics.ascent;
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
emoji = sharedpreferences.getBoolean(Helper.SET_DISPLAY_EMOJI, false);
if (attrs == null) {
emojiSize = defaultEmojiSize;
} else {
@SuppressLint("CustomViewStyleable") final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.EmojiMultiAutoCompleteTextView);
try {
emojiSize = a.getDimension(R.styleable.EmojiMultiAutoCompleteTextView_emojiSize, defaultEmojiSize);
} finally {
a.recycle();
}
}
setText(getText());
initView();
}
public MastalabAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView();
}
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
final InputConnection ic = super.onCreateInputConnection(outAttrs);
EditorInfoCompat.setContentMimeTypes(outAttrs,
imgTypeString);
return InputConnectionCompat.createWrapper(ic, outAttrs, callback);
}
private void initView() {
imgTypeString = new String[]{"image/png",
"image/gif",
"image/jpeg",
"image/webp"};
}
public void setKeyBoardInputCallbackListener(KeyBoardInputCallbackListener keyBoardInputCallbackListener) {
@ -131,7 +125,6 @@ public class MastalabAutoCompleteTextView extends androidx.appcompat.widget.AppC
this.imgTypeString = imgTypeString;
}
@Override
@CallSuper
protected void onTextChanged(final CharSequence text, final int start, final int lengthBefore, final int lengthAfter) {
@ -148,7 +141,6 @@ public class MastalabAutoCompleteTextView extends androidx.appcompat.widget.AppC
dispatchKeyEvent(event);
}
@Override
public float getEmojiSize() {
return emojiSize;
@ -192,4 +184,9 @@ public class MastalabAutoCompleteTextView extends androidx.appcompat.widget.AppC
public final void setEmojiSizeRes(@DimenRes final int res, final boolean shouldInvalidate) {
setEmojiSize(getResources().getDimensionPixelSize(res), shouldInvalidate);
}
public interface KeyBoardInputCallbackListener {
void onCommitContent(InputContentInfoCompat inputContentInfo,
int flags, Bundle opts);
}
}

View File

@ -344,7 +344,6 @@ public class LiveNotificationService extends Service implements NetworkStateRece
canNotify = false;
}
if ((userId == null || !userId.equals(account.getId()) || !activityRunning) && liveNotifications && canNotify && notify) {
lastNotification.put(key, notification.getId());
boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
@ -464,6 +463,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
assert e != null;
Helper.notify_user(LiveNotificationService.this, account, intent, BitmapFactory.decodeResource(getResources(),
getMainLogo(LiveNotificationService.this)), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
return false;
@ -472,7 +472,6 @@ public class LiveNotificationService extends Service implements NetworkStateRece
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
Helper.notify_user(LiveNotificationService.this, account, intent, resource, finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
}

View File

@ -100,7 +100,8 @@ public class TimelineCacheDAO {
String instance = Helper.getLiveInstance(context);
try {
return db.delete(Sqlite.TABLE_TIMELINE_CACHE, Sqlite.COL_STATUS_ID + " = \"" + statusId + "\" AND " + Sqlite.COL_INSTANCE + " = \"" + instance + "\" AND " + Sqlite.COL_USER_ID + " = \"" + userId + "\"", null);
}catch (Exception ignored){}
} catch (Exception ignored) {
}
return -1;
}
@ -114,7 +115,8 @@ public class TimelineCacheDAO {
String instance = Helper.getLiveInstance(context);
try {
db.delete(Sqlite.TABLE_TIMELINE_CACHE, Sqlite.COL_DATE + " < \"" + date + "\" AND " + Sqlite.COL_INSTANCE + " = \"" + instance + "\" AND " + Sqlite.COL_USER_ID + " = \"" + userId + "\"", null);
}catch (Exception ignored){}
} catch (Exception ignored) {
}
}
/***