Fix some issues
This commit is contained in:
parent
3b35639e59
commit
4abc8aa304
|
@ -16,6 +16,7 @@ package app.fedilab.android.activities;
|
|||
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -185,6 +186,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
}
|
||||
|
||||
|
||||
@SuppressLint("CutPasteId")
|
||||
@Override
|
||||
public void onRetrieveAccount(Account account, Error error) {
|
||||
if (error != null) {
|
||||
|
@ -312,36 +314,33 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
getIntent.setType("image/*");
|
||||
|
||||
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
pickIntent.setType("image/*");
|
||||
Intent pickIntent = new Intent(Intent.ACTION_PICK);
|
||||
pickIntent.setDataAndType(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI,"image/*");
|
||||
|
||||
Intent chooserIntent = Intent.createChooser(getIntent, getString(R.string.toot_select_image));
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
|
||||
startActivityForResult(chooserIntent, PICK_IMAGE_HEADER);
|
||||
});
|
||||
|
||||
set_change_profile_picture.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
set_change_profile_picture.setOnClickListener(v -> {
|
||||
|
||||
if (ContextCompat.checkSelfPermission(EditProfileActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(EditProfileActivity.this,
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_PICTURE);
|
||||
return;
|
||||
}
|
||||
|
||||
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
getIntent.setType("image/*");
|
||||
|
||||
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
pickIntent.setType("image/*");
|
||||
|
||||
Intent chooserIntent = Intent.createChooser(getIntent, getString(R.string.toot_select_image));
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
|
||||
startActivityForResult(chooserIntent, PICK_IMAGE_PROFILE);
|
||||
if (ContextCompat.checkSelfPermission(EditProfileActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(EditProfileActivity.this,
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_PICTURE);
|
||||
return;
|
||||
}
|
||||
|
||||
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
getIntent.setType("image/*");
|
||||
|
||||
Intent pickIntent = new Intent(Intent.ACTION_PICK);
|
||||
pickIntent.setDataAndType(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
||||
|
||||
Intent chooserIntent = Intent.createChooser(getIntent, getString(R.string.toot_select_image));
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
|
||||
startActivityForResult(chooserIntent, PICK_IMAGE_PROFILE);
|
||||
});
|
||||
|
||||
if (!EditProfileActivity.this.isFinishing()) {
|
||||
|
|
|
@ -589,8 +589,7 @@ public class LoginActivity extends BaseActivity {
|
|||
String refresh_token = null;
|
||||
if (resobj.has("refresh_token"))
|
||||
refresh_token = resobj.getString("refresh_token");
|
||||
SharedPreferences sharedpreferences1 = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences1.edit();
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token);
|
||||
editor.apply();
|
||||
//Update the account with the token;
|
||||
|
@ -601,10 +600,9 @@ public class LoginActivity extends BaseActivity {
|
|||
} else {
|
||||
try {
|
||||
resobj = new JSONObject(response);
|
||||
Account account = GNUAPI.parseAccountResponse(LoginActivity.this, resobj);
|
||||
Account account = GNUAPI.parseAccountResponse(resobj);
|
||||
account.setToken(basicAuth);
|
||||
SharedPreferences sharedpreferences1 = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences1.edit();
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, basicAuth);
|
||||
account.setInstance(instance);
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorLi
|
|||
//Set Image Dynamically
|
||||
try {
|
||||
mPhotoEditorView.getSource().setImageURI(uri);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
Toasty.error(PhotoEditorActivity.this, getString(R.string.error)).show();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -109,11 +110,11 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
loader.setVisibility(View.VISIBLE);
|
||||
detailsStatus.setFocused(true);
|
||||
//Some spannable
|
||||
Status.fillSpan(ShowConversationActivity.this, detailsStatus);
|
||||
Status.fillSpan(new WeakReference<>(ShowConversationActivity.this), detailsStatus);
|
||||
if (detailsStatus.getPoll() != null) {
|
||||
Status.makeEmojiPoll(ShowConversationActivity.this, detailsStatus.getPoll());
|
||||
Status.makeEmojiPoll(new WeakReference<>(ShowConversationActivity.this), detailsStatus.getPoll());
|
||||
}
|
||||
Account.makeAccountNameEmoji(ShowConversationActivity.this, detailsStatus.getAccount());
|
||||
Account.makeAccountNameEmoji(new WeakReference<>(ShowConversationActivity.this), detailsStatus.getAccount());
|
||||
|
||||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
public void togglePlaying(View v) {
|
||||
|
||||
if (mCurrentFragment != null) {
|
||||
mCurrentFragment.togglePlaying(v);
|
||||
mCurrentFragment.togglePlaying();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -369,9 +369,9 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
List<app.fedilab.android.client.Entities.Status> statuses = new StatusCacheDAO(contextReference.get(), db).getAllStatus(StatusCacheDAO.BOOKMARK_CACHE);
|
||||
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());
|
||||
app.fedilab.android.client.Entities.Status.fillSpan(contextReference, status);
|
||||
app.fedilab.android.client.Entities.Status.makeEmojiPoll(contextReference, status.getReblog() != null ? status.getReblog().getPoll() : status.getPoll());
|
||||
Account.makeAccountNameEmoji(contextReference, status.getReblog() != null ? status.getReblog().getAccount() : status.getAccount());
|
||||
}
|
||||
} else {
|
||||
statuses = new ArrayList<>();
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.KeyManagementException;
|
||||
|
@ -297,7 +298,7 @@ public class API {
|
|||
* @param resobj JSONObject
|
||||
* @return Peertube
|
||||
*/
|
||||
public static Peertube parsePeertube(Context context, String instance, JSONObject resobj) {
|
||||
public static Peertube parsePeertube(String instance, JSONObject resobj) {
|
||||
Peertube peertube = new Peertube();
|
||||
try {
|
||||
peertube.setId(resobj.get("id").toString());
|
||||
|
@ -332,7 +333,7 @@ public class API {
|
|||
* @param resobj JSONObject
|
||||
* @return Peertube
|
||||
*/
|
||||
private static Peertube parseSinglePeertube(Context context, String instance, JSONObject resobj) {
|
||||
private static Peertube parseSinglePeertube(String instance, JSONObject resobj) {
|
||||
Peertube peertube = new Peertube();
|
||||
try {
|
||||
peertube.setId(resobj.get("id").toString());
|
||||
|
@ -672,7 +673,7 @@ public class API {
|
|||
} catch (JSONException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Status.fillSpan(context, announcement);
|
||||
Status.fillSpan(new WeakReference<>(context), announcement);
|
||||
return announcement;
|
||||
}
|
||||
|
||||
|
@ -717,7 +718,7 @@ public class API {
|
|||
} catch (JSONException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Status.makeEmojiPoll(context, poll);
|
||||
Status.makeEmojiPoll(new WeakReference<>(context), poll);
|
||||
return poll;
|
||||
}
|
||||
|
||||
|
@ -754,7 +755,9 @@ public class API {
|
|||
} else {
|
||||
status.setSensitive(false);
|
||||
}
|
||||
status.setSpoiler_text(resobj.get("spoiler_text").toString());
|
||||
if (resobj.has("spoiler_text")) {
|
||||
status.setSpoiler_text(resobj.get("spoiler_text").toString());
|
||||
}
|
||||
try {
|
||||
status.setVisibility(resobj.get("visibility").toString());
|
||||
} catch (Exception e) {
|
||||
|
@ -775,8 +778,9 @@ public class API {
|
|||
}
|
||||
status.setReactions(reactions);
|
||||
|
||||
|
||||
status.setUrl(resobj.get("url").toString());
|
||||
if (resobj.has("url")) {
|
||||
status.setUrl(resobj.get("url").toString());
|
||||
}
|
||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
||||
//Retrieves attachments
|
||||
if (resobj.has("media_attachments")) {
|
||||
|
@ -807,41 +811,46 @@ public class API {
|
|||
status.setMedia_attachments(attachments);
|
||||
//Retrieves mentions
|
||||
List<Mention> mentions = new ArrayList<>();
|
||||
JSONArray arrayMention = resobj.getJSONArray("mentions");
|
||||
for (int j = 0; j < arrayMention.length(); j++) {
|
||||
JSONObject menObj = arrayMention.getJSONObject(j);
|
||||
Mention mention = new Mention();
|
||||
mention.setId(menObj.get("id").toString());
|
||||
mention.setUrl(menObj.get("url").toString());
|
||||
mention.setAcct(menObj.get("acct").toString());
|
||||
mention.setUsername(menObj.get("username").toString());
|
||||
mentions.add(mention);
|
||||
if (resobj.has("mentions")) {
|
||||
JSONArray arrayMention = resobj.getJSONArray("mentions");
|
||||
for (int j = 0; j < arrayMention.length(); j++) {
|
||||
JSONObject menObj = arrayMention.getJSONObject(j);
|
||||
Mention mention = new Mention();
|
||||
mention.setId(menObj.get("id").toString());
|
||||
mention.setUrl(menObj.get("url").toString());
|
||||
mention.setAcct(menObj.get("acct").toString());
|
||||
mention.setUsername(menObj.get("username").toString());
|
||||
mentions.add(mention);
|
||||
}
|
||||
}
|
||||
status.setMentions(mentions);
|
||||
//Retrieves tags
|
||||
List<Tag> tags = new ArrayList<>();
|
||||
JSONArray arrayTag = resobj.getJSONArray("tags");
|
||||
for (int j = 0; j < arrayTag.length(); j++) {
|
||||
JSONObject tagObj = arrayTag.getJSONObject(j);
|
||||
Tag tag = new Tag();
|
||||
tag.setName(tagObj.get("name").toString());
|
||||
tag.setUrl(tagObj.get("url").toString());
|
||||
tags.add(tag);
|
||||
if (resobj.has("tags")) {
|
||||
JSONArray arrayTag = resobj.getJSONArray("tags");
|
||||
for (int j = 0; j < arrayTag.length(); j++) {
|
||||
JSONObject tagObj = arrayTag.getJSONObject(j);
|
||||
Tag tag = new Tag();
|
||||
tag.setName(tagObj.get("name").toString());
|
||||
tag.setUrl(tagObj.get("url").toString());
|
||||
tags.add(tag);
|
||||
}
|
||||
}
|
||||
status.setTags(tags);
|
||||
//Retrieves emjis
|
||||
List<Emojis> emojiList = new ArrayList<>();
|
||||
try {
|
||||
JSONArray emojisTag = resobj.getJSONArray("emojis");
|
||||
for (int j = 0; j < emojisTag.length(); j++) {
|
||||
JSONObject emojisObj = emojisTag.getJSONObject(j);
|
||||
Emojis emojis = parseEmojis(emojisObj);
|
||||
emojiList.add(emojis);
|
||||
if (resobj.has("emojis")) {
|
||||
try {
|
||||
JSONArray emojisTag = resobj.getJSONArray("emojis");
|
||||
for (int j = 0; j < emojisTag.length(); j++) {
|
||||
JSONObject emojisObj = emojisTag.getJSONObject(j);
|
||||
Emojis emojis = parseEmojis(emojisObj);
|
||||
emojiList.add(emojis);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
status.setEmojis(emojiList);
|
||||
} catch (Exception e) {
|
||||
status.setEmojis(new ArrayList<>());
|
||||
}
|
||||
status.setEmojis(emojiList);
|
||||
//Retrieve Application
|
||||
Application application = new Application();
|
||||
try {
|
||||
|
@ -905,7 +914,7 @@ public class API {
|
|||
e.printStackTrace();
|
||||
}
|
||||
status.setViewType(context);
|
||||
Status.fillSpan(context, status);
|
||||
Status.fillSpan(new WeakReference<>(context), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1099,7 @@ public class API {
|
|||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Status.fillSpan(context, status);
|
||||
Status.fillSpan(new WeakReference<>(context), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -1482,7 +1491,7 @@ public class API {
|
|||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Account.makeAccountNameEmoji(context, account);
|
||||
Account.makeAccountNameEmoji(new WeakReference<>(context), account);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1614,10 +1623,11 @@ public class API {
|
|||
notification.setType(resobj.get("type").toString());
|
||||
notification.setCreated_at(Helper.mstStringToDate(resobj.get("created_at").toString()));
|
||||
notification.setAccount(parseAccountResponse(context, resobj.getJSONObject("account")));
|
||||
try {
|
||||
notification.setStatus(parseStatuses(context, resobj.getJSONObject("status")));
|
||||
} catch (Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
if (resobj.has("status")) {
|
||||
try {
|
||||
notification.setStatus(parseStatuses(context, resobj.getJSONObject("status")));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
notification.setCreated_at(Helper.mstStringToDate(resobj.get("created_at").toString()));
|
||||
} catch (JSONException ignored) {
|
||||
|
@ -1761,7 +1771,7 @@ public class API {
|
|||
if (xpp.getName().compareTo("item") == 0) {
|
||||
if (status != null) {
|
||||
status.setAccount(account);
|
||||
Status.fillSpan(context, status);
|
||||
Status.fillSpan(new WeakReference<>(context), status);
|
||||
statuses.add(status);
|
||||
}
|
||||
account = null;
|
||||
|
@ -1783,7 +1793,7 @@ public class API {
|
|||
while (i < jsonArray.length()) {
|
||||
|
||||
JSONObject resobj = jsonArray.getJSONObject(i);
|
||||
IdentityProof identityProof = parseIdentityProof(context, resobj);
|
||||
IdentityProof identityProof = parseIdentityProof(resobj);
|
||||
i++;
|
||||
identityProofs.add(identityProof);
|
||||
}
|
||||
|
@ -1794,7 +1804,7 @@ public class API {
|
|||
return identityProofs;
|
||||
}
|
||||
|
||||
private IdentityProof parseIdentityProof(Context context, JSONObject jsonObject) {
|
||||
private IdentityProof parseIdentityProof(JSONObject jsonObject) {
|
||||
IdentityProof identityProof = new IdentityProof();
|
||||
try {
|
||||
identityProof.setProfile_url(jsonObject.getString("profile_url"));
|
||||
|
@ -3224,7 +3234,7 @@ public class API {
|
|||
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||
String response = httpsConnection.get(String.format("https://" + instance + "/api/v1/accounts/%s/video-channels", name), 10, null, null);
|
||||
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
|
||||
accounts = parseAccountResponsePeertube(context, instance, jsonArray);
|
||||
accounts = parseAccountResponsePeertube(instance, jsonArray);
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
e.printStackTrace();
|
||||
|
@ -3307,7 +3317,7 @@ public class API {
|
|||
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||
String response = httpsConnection.get(String.format("https://" + instance + "/api/v1/videos/%s", videoId), 10, null, null);
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
peertube = parseSinglePeertube(context, instance, jsonObject);
|
||||
peertube = parseSinglePeertube(instance, jsonObject);
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
e.printStackTrace();
|
||||
|
@ -4553,7 +4563,9 @@ public class API {
|
|||
Status alreadyCached = new TimelineCacheDAO(context, db).getSingle(status.getId());
|
||||
Account account = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
if (alreadyCached != null) {
|
||||
new TimelineCacheDAO(context, db).update(status.getId(), response, account.getId(), account.getInstance());
|
||||
poll = parsePoll(context, new JSONObject(response));
|
||||
status.setPoll(poll);
|
||||
new TimelineCacheDAO(context, db).update(status.getId(), Helper.statusToStringStorage(status), account.getId(), account.getInstance());
|
||||
}
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC);
|
||||
return poll;
|
||||
|
@ -5556,7 +5568,7 @@ public class API {
|
|||
int i = 0;
|
||||
while (i < jsonArray.length()) {
|
||||
JSONObject resobj = jsonArray.getJSONObject(i);
|
||||
Peertube peertube = parsePeertube(context, instance, resobj);
|
||||
Peertube peertube = parsePeertube(instance, resobj);
|
||||
i++;
|
||||
peertubes.add(peertube);
|
||||
}
|
||||
|
@ -5901,7 +5913,7 @@ public class API {
|
|||
return lists;
|
||||
}
|
||||
|
||||
private List<Account> parseAccountResponsePeertube(Context context, String instance, JSONArray jsonArray) {
|
||||
private List<Account> parseAccountResponsePeertube(String instance, JSONArray jsonArray) {
|
||||
List<Account> accounts = new ArrayList<>();
|
||||
try {
|
||||
int i = 0;
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.bumptech.glide.request.transition.Transition;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
@ -199,7 +200,8 @@ public class Account implements Parcelable {
|
|||
this.invited_by_account_id = in.readString();
|
||||
}
|
||||
|
||||
public static void makeAccountNameEmoji(final Context context, Account account) {
|
||||
public static void makeAccountNameEmoji(final WeakReference<Context> contextWeakReference, Account account) {
|
||||
Context context = contextWeakReference.get();
|
||||
if ((context instanceof Activity && ((Activity) context).isFinishing()) || account.getDisplay_name() == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -571,7 +571,7 @@ public class ManageTimelines {
|
|||
}
|
||||
|
||||
popup.setOnDismissListener(menu12 -> {
|
||||
if (displayStatusFragment != null && displayStatusFragment.getUserVisibleHint())
|
||||
if (displayStatusFragment != null && displayStatusFragment.isVisible())
|
||||
displayStatusFragment.refreshFilter();
|
||||
});
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
|
|
|
@ -59,6 +59,7 @@ import com.bumptech.glide.request.target.CustomTarget;
|
|||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -263,15 +264,15 @@ public class Status implements Parcelable {
|
|||
}
|
||||
|
||||
|
||||
public static void fillSpan(Context context, Status status) {
|
||||
Status.transform(context, status);
|
||||
Status.makeEmojis(context, status);
|
||||
Status.makeImage(context, status);
|
||||
public static void fillSpan(WeakReference<Context> contextWeakReference, Status status) {
|
||||
Status.transform(contextWeakReference, status);
|
||||
Status.makeEmojis(contextWeakReference, status);
|
||||
Status.makeImage(contextWeakReference, status);
|
||||
}
|
||||
|
||||
|
||||
private static void transform(Context context, Status status) {
|
||||
|
||||
private static void transform(WeakReference<Context> contextWeakReference, Status status) {
|
||||
Context context = contextWeakReference.get();
|
||||
if (status == null)
|
||||
return;
|
||||
SpannableString spannableStringContent, spannableStringCW;
|
||||
|
@ -849,8 +850,8 @@ public class Status implements Parcelable {
|
|||
status.setContentSpanTranslated(contentSpanTranslated);
|
||||
}
|
||||
|
||||
private static void makeEmojis(final Context context, Status status) {
|
||||
|
||||
private static void makeEmojis(final WeakReference<Context> contextWeakReference, Status status) {
|
||||
Context context = contextWeakReference.get();
|
||||
if (context instanceof Activity && ((Activity) context).isFinishing())
|
||||
return;
|
||||
if (status.getReblog() != null && status.getReblog().getEmojis() == null)
|
||||
|
@ -931,7 +932,8 @@ public class Status implements Parcelable {
|
|||
}
|
||||
}
|
||||
|
||||
public static void makeEmojiPoll(final Context context, Poll poll) {
|
||||
public static void makeEmojiPoll(final WeakReference<Context> contextWeakReference, Poll poll) {
|
||||
Context context = contextWeakReference.get();
|
||||
if ((context instanceof Activity && ((Activity) context).isFinishing()) || poll == null || poll.getOptionsList() == null)
|
||||
return;
|
||||
final List<Emojis> emojis = poll.getEmojis();
|
||||
|
@ -991,8 +993,8 @@ public class Status implements Parcelable {
|
|||
}
|
||||
}
|
||||
|
||||
private static void makeImage(final Context context, Status status) {
|
||||
|
||||
private static void makeImage(final WeakReference<Context> contextWeakReference, Status status) {
|
||||
Context context = contextWeakReference.get();
|
||||
if (context instanceof Activity && ((Activity) context).isFinishing())
|
||||
return;
|
||||
if (status.getAccount() == null)
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.json.JSONObject;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
@ -133,7 +134,7 @@ public class GNUAPI {
|
|||
* @param jsonArray JSONArray
|
||||
* @return List<Account>
|
||||
*/
|
||||
private static List<Account> parseGroups(Context context, JSONArray jsonArray) {
|
||||
private static List<Account> parseGroups(JSONArray jsonArray) {
|
||||
|
||||
List<Account> groups = new ArrayList<>();
|
||||
try {
|
||||
|
@ -141,7 +142,7 @@ public class GNUAPI {
|
|||
while (i < jsonArray.length()) {
|
||||
|
||||
JSONObject resobj = jsonArray.getJSONObject(i);
|
||||
Account group = parseGroups(context, resobj);
|
||||
Account group = parseGroups(resobj);
|
||||
i++;
|
||||
groups.add(group);
|
||||
}
|
||||
|
@ -158,7 +159,7 @@ public class GNUAPI {
|
|||
* @param resobj JSONObject
|
||||
* @return Account
|
||||
*/
|
||||
private static Account parseGroups(Context context, JSONObject resobj) {
|
||||
private static Account parseGroups(JSONObject resobj) {
|
||||
Account group = new Account();
|
||||
try {
|
||||
group.setId(resobj.get("id").toString());
|
||||
|
@ -293,9 +294,9 @@ public class GNUAPI {
|
|||
}
|
||||
status.setApplication(application);
|
||||
if (resobj.has("user"))
|
||||
status.setAccount(parseAccountResponse(context, resobj.getJSONObject("user")));
|
||||
status.setAccount(parseAccountResponse(resobj.getJSONObject("user")));
|
||||
else if (resobj.has("sender"))
|
||||
status.setAccount(parseAccountResponse(context, resobj.getJSONObject("sender")));
|
||||
status.setAccount(parseAccountResponse(resobj.getJSONObject("sender")));
|
||||
if (resobj.has("statusnet_html"))
|
||||
status.setContent(context, resobj.get("statusnet_html").toString());
|
||||
else if (resobj.has("text"))
|
||||
|
@ -346,7 +347,7 @@ public class GNUAPI {
|
|||
e.printStackTrace();
|
||||
}
|
||||
status.setViewType(context);
|
||||
Status.fillSpan(context, status);
|
||||
Status.fillSpan(new WeakReference<>(context), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -357,7 +358,7 @@ public class GNUAPI {
|
|||
* @param resobj JSONObject
|
||||
* @return Account
|
||||
*/
|
||||
public static Account parseAccountResponse(Context context, JSONObject resobj) {
|
||||
public static Account parseAccountResponse(JSONObject resobj) {
|
||||
|
||||
Account account = new Account();
|
||||
try {
|
||||
|
@ -553,7 +554,7 @@ public class GNUAPI {
|
|||
}
|
||||
try {
|
||||
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/account/verify_credentials.json"), 60, null, prefKeyOauthTokenT);
|
||||
account = parseAccountResponse(context, new JSONObject(response));
|
||||
account = parseAccountResponse(new JSONObject(response));
|
||||
if (social != null) {
|
||||
account.setSocial(social.toUpperCase());
|
||||
}
|
||||
|
@ -579,7 +580,7 @@ public class GNUAPI {
|
|||
params.put("user_id", accountId);
|
||||
try {
|
||||
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/users/show.json"), 60, params, prefKeyOauthTokenT);
|
||||
account = parseAccountResponse(context, new JSONObject(response));
|
||||
account = parseAccountResponse(new JSONObject(response));
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
e.printStackTrace();
|
||||
|
@ -619,7 +620,7 @@ public class GNUAPI {
|
|||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||
String response = httpsConnection.get(getAbsoluteUrl("/statusnet/groups/list.json"), 60, params, prefKeyOauthTokenT);
|
||||
accounts = parseGroups(context, new JSONArray(response));
|
||||
accounts = parseGroups(new JSONArray(response));
|
||||
if (accounts.size() > 0) {
|
||||
apiResponse.setSince_id(accounts.get(0).getId());
|
||||
apiResponse.setMax_id(accounts.get(accounts.size() - 1).getId());
|
||||
|
@ -1771,7 +1772,7 @@ public class GNUAPI {
|
|||
Notification notification = new Notification();
|
||||
notification.setType(stringType);
|
||||
notification.setId(st.getId());
|
||||
Status.fillSpan(context, st);
|
||||
Status.fillSpan(new WeakReference<>(context), st);
|
||||
notification.setStatus(st);
|
||||
notification.setAccount(st.getAccount());
|
||||
notifications.add(notification);
|
||||
|
@ -1934,7 +1935,7 @@ public class GNUAPI {
|
|||
int i = 0;
|
||||
while (i < jsonArray.length()) {
|
||||
JSONObject resobj = jsonArray.getJSONObject(i);
|
||||
Account account = parseAccountResponse(context, resobj);
|
||||
Account account = parseAccountResponse(resobj);
|
||||
accounts.add(account);
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -113,10 +113,10 @@ public class ReactionAdapter extends RecyclerView.Adapter implements OnPostActio
|
|||
statusAction = reaction.isMe() ? API.StatusAction.REMOVE_PLEROMA_REACTION : API.StatusAction.ADD_PLEROMA_REACTION;
|
||||
}
|
||||
reaction.setMe(!reaction.isMe());
|
||||
if( reaction.isMe()) {
|
||||
reaction.setCount(reaction.getCount()+1);
|
||||
}else{
|
||||
reaction.setCount(reaction.getCount()-1);
|
||||
if (reaction.isMe()) {
|
||||
reaction.setCount(reaction.getCount() + 1);
|
||||
} else {
|
||||
reaction.setCount(reaction.getCount() - 1);
|
||||
}
|
||||
new PostActionAsyncTask(context, statusAction, this.statusId, null, emojiStr, ReactionAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
});
|
||||
|
|
|
@ -252,12 +252,12 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
swipeRefreshLayout.setEnabled(true);
|
||||
if (context == null)
|
||||
return;
|
||||
if (getUserVisibleHint()) {
|
||||
if (isVisible()) {
|
||||
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
assert mNotificationManager != null;
|
||||
mNotificationManager.cancelAll();
|
||||
}
|
||||
if (getUserVisibleHint() && notifications != null && notifications.size() > 0) {
|
||||
if (isVisible() && notifications != null && notifications.size() > 0) {
|
||||
retrieveMissingNotifications(notifications.get(0).getId());
|
||||
updateNotificationLastId(notifications.get(0).getId());
|
||||
}
|
||||
|
|
|
@ -179,9 +179,9 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
timelineId = bundle.getInt("timelineId");
|
||||
currentfilter = bundle.getString("currentfilter", null);
|
||||
}
|
||||
if (ischannel)
|
||||
if (ischannel) {
|
||||
type = RetrieveFeedsAsyncTask.Type.CHANNEL;
|
||||
|
||||
}
|
||||
|
||||
assert context != null;
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
@ -766,13 +766,13 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
swipeRefreshLayout.setEnabled(true);
|
||||
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME || type == RetrieveFeedsAsyncTask.Type.PF_HOME) {
|
||||
if (getUserVisibleHint()) {
|
||||
if (this.isVisible()) {
|
||||
if (statuses != null && statuses.size() > 0 && asyncTask.getStatus() != AsyncTask.Status.RUNNING) {
|
||||
retrieveMissingToots(statuses.get(0).getId());
|
||||
}
|
||||
}
|
||||
} else if (type == RetrieveFeedsAsyncTask.Type.PUBLIC) {
|
||||
if (getUserVisibleHint()) {
|
||||
if (isVisible()) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, true);
|
||||
editor.apply();
|
||||
|
@ -788,7 +788,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
}
|
||||
} else if (type == RetrieveFeedsAsyncTask.Type.LOCAL) {
|
||||
|
||||
if (getUserVisibleHint()) {
|
||||
if (isVisible()) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + userId + instance, true);
|
||||
editor.apply();
|
||||
|
@ -803,17 +803,17 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
retrieveMissingToots(statuses.get(0).getId());
|
||||
}
|
||||
} else if (type == RetrieveFeedsAsyncTask.Type.DIRECT || type == RetrieveFeedsAsyncTask.Type.GNU_DM) {
|
||||
if (getUserVisibleHint()) {
|
||||
if (isVisible()) {
|
||||
if (statuses != null && statuses.size() > 0)
|
||||
retrieveMissingToots(statuses.get(0).getId());
|
||||
}
|
||||
} else if (type == RetrieveFeedsAsyncTask.Type.CONVERSATION) {
|
||||
if (getUserVisibleHint()) {
|
||||
if (isVisible()) {
|
||||
if (statuses != null && statuses.size() > 0)
|
||||
retrieveMissingToots(statuses.get(0).getId());
|
||||
}
|
||||
} else if (type == RetrieveFeedsAsyncTask.Type.TAG) {
|
||||
if (getUserVisibleHint()) {
|
||||
if (isVisible()) {
|
||||
if (statuses != null && statuses.size() > 0)
|
||||
retrieveMissingToots(statuses.get(0).getId());
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
|
|||
mLayoutManager = new LinearLayoutManager(context);
|
||||
lv_stories.setLayoutManager(mLayoutManager);
|
||||
lv_stories.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
public void onScrolled(@NotNull RecyclerView recyclerView, int dx, int dy) {
|
||||
if (dy > 0) {
|
||||
int visibleItemCount = mLayoutManager.getChildCount();
|
||||
int totalItemCount = mLayoutManager.getItemCount();
|
||||
|
@ -122,17 +122,11 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
|
|||
});
|
||||
|
||||
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
flag_loading = true;
|
||||
swiped = true;
|
||||
String sinceId = null;
|
||||
if (pixelFedStories != null && pixelFedStories.size() > 0)
|
||||
sinceId = pixelFedStories.get(0).getId();
|
||||
if (context != null)
|
||||
asyncTask = new RetrieveStoriesAsyncTask(context, null, type, DisplayStoriesFragment.this).execute();
|
||||
}
|
||||
swipeRefreshLayout.setOnRefreshListener(() -> {
|
||||
flag_loading = true;
|
||||
swiped = true;
|
||||
if (context != null)
|
||||
asyncTask = new RetrieveStoriesAsyncTask(context, null, type, DisplayStoriesFragment.this).execute();
|
||||
});
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
|
@ -159,12 +153,9 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
|
|||
if (context != null)
|
||||
asyncTask = new RetrieveStoriesAsyncTask(context, max_id, type, DisplayStoriesFragment.this).execute();
|
||||
else
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (context != null)
|
||||
asyncTask = new RetrieveStoriesAsyncTask(context, max_id, type, DisplayStoriesFragment.this).execute();
|
||||
}
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
if (context != null)
|
||||
asyncTask = new RetrieveStoriesAsyncTask(context, max_id, type, DisplayStoriesFragment.this).execute();
|
||||
}, 500);
|
||||
return rootView;
|
||||
}
|
||||
|
@ -253,7 +244,7 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
|
|||
swipeRefreshLayout.setEnabled(true);
|
||||
if (context == null)
|
||||
return;
|
||||
if (getUserVisibleHint() && pixelFedStories != null && pixelFedStories.size() > 0) {
|
||||
if (isVisible() && pixelFedStories != null && pixelFedStories.size() > 0) {
|
||||
retrieveMissingNotifications(pixelFedStories.get(0).getId());
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +265,7 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
|
|||
*
|
||||
* @param sinceId String
|
||||
*/
|
||||
void retrieveMissingNotifications(String sinceId) {
|
||||
private void retrieveMissingNotifications(String sinceId) {
|
||||
asyncTask = new RetrieveStoriesAsyncTask(context, null, type, DisplayStoriesFragment.this).execute();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
|
@ -48,7 +47,6 @@ import com.bumptech.glide.request.target.CustomTarget;
|
|||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.cleveroad.audiovisualization.DbmHandler;
|
||||
import com.cleveroad.audiovisualization.GLAudioVisualizationView;
|
||||
import com.github.chrisbanes.photoview.OnMatrixChangedListener;
|
||||
import com.github.chrisbanes.photoview.PhotoView;
|
||||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
|
@ -147,19 +145,16 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
|
||||
url = attachment.getUrl();
|
||||
imageView.setOnMatrixChangeListener(new OnMatrixChangedListener() {
|
||||
@Override
|
||||
public void onMatrixChanged(RectF rect) {
|
||||
canSwipe = (imageView.getScale() == 1);
|
||||
imageView.setOnMatrixChangeListener(rect -> {
|
||||
canSwipe = (imageView.getScale() == 1);
|
||||
|
||||
if (!canSwipe) {
|
||||
if (!((SlideMediaActivity) context).getFullScreen()) {
|
||||
((SlideMediaActivity) context).setFullscreen(true);
|
||||
}
|
||||
((SlideMediaActivity) context).enableSliding(false);
|
||||
} else {
|
||||
((SlideMediaActivity) context).enableSliding(true);
|
||||
if (!canSwipe) {
|
||||
if (!((SlideMediaActivity) context).getFullScreen()) {
|
||||
((SlideMediaActivity) context).setFullscreen(true);
|
||||
}
|
||||
((SlideMediaActivity) context).enableSliding(false);
|
||||
} else {
|
||||
((SlideMediaActivity) context).enableSliding(true);
|
||||
}
|
||||
});
|
||||
ProgressBar pbar_inf = rootView.findViewById(R.id.pbar_inf);
|
||||
|
@ -189,7 +184,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
Bitmap imageCompressed = Helper.compressImageIfNeeded(context, resource);
|
||||
Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
|
||||
imageView.setImageBitmap(imageCompressed);
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
|
@ -198,18 +193,15 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
@Override
|
||||
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
loader.setVisibility(View.GONE);
|
||||
Bitmap imageCompressed = Helper.compressImageIfNeeded(context, resource);
|
||||
Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
|
||||
if (imageView.getScale() < 1.1) {
|
||||
imageView.setImageBitmap(imageCompressed);
|
||||
} else {
|
||||
message_ready.setVisibility(View.VISIBLE);
|
||||
}
|
||||
message_ready.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
imageView.setImageBitmap(imageCompressed);
|
||||
message_ready.setVisibility(View.GONE);
|
||||
}
|
||||
message_ready.setOnClickListener(view -> {
|
||||
imageView.setImageBitmap(imageCompressed);
|
||||
message_ready.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -340,12 +332,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
|
||||
}
|
||||
visualizerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
playeraudio.setOnCompletionListener(MediaSliderFragment.this);
|
||||
}
|
||||
});
|
||||
visualizerView.post(() -> playeraudio.setOnCompletionListener(MediaSliderFragment.this));
|
||||
|
||||
timerView.setText("00:00:00");
|
||||
playView.setVisibility(View.VISIBLE);
|
||||
|
@ -390,12 +377,9 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
|
||||
private void updateTimer() {
|
||||
((Activity) context).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
playerSecondsElapsed++;
|
||||
timerView.setText(formatSeconds(playerSecondsElapsed));
|
||||
}
|
||||
((Activity) context).runOnUiThread(() -> {
|
||||
playerSecondsElapsed++;
|
||||
timerView.setText(formatSeconds(playerSecondsElapsed));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -415,7 +399,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
}
|
||||
|
||||
public void togglePlaying(View v) {
|
||||
public void togglePlaying() {
|
||||
|
||||
HANDLER.postDelayed(() -> {
|
||||
if (isPlaying()) {
|
||||
|
@ -493,9 +477,6 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
}
|
||||
|
||||
public boolean canSwipe() {
|
||||
return canSwipe;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,13 +35,10 @@ import android.database.Cursor;
|
|||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.AudioAttributes;
|
||||
|
@ -74,15 +71,12 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.webkit.URLUtil;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
|
@ -116,8 +110,8 @@ import com.bumptech.glide.request.target.Target;
|
|||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.iceteck.silicompressorr.SiliCompressor;
|
||||
import com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton;
|
||||
import com.oguzdev.circularfloatingactionmenu.library.FloatingActionMenu;
|
||||
|
@ -157,8 +151,6 @@ import java.net.PasswordAuthentication;
|
|||
import java.net.Proxy;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.Security;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
|
@ -1302,8 +1294,6 @@ public class Helper {
|
|||
final ImageView arrow = navigationView.getHeaderView(0).findViewById(R.id.owner_accounts);
|
||||
if (currrentUserId == null)
|
||||
return;
|
||||
|
||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if (!menuAccountsOpened) {
|
||||
arrow.setImageResource(R.drawable.ic_arrow_drop_up);
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
@ -1313,7 +1303,6 @@ public class Helper {
|
|||
navigationView.inflateMenu(R.menu.menu_accounts);
|
||||
Menu mainMenu = navigationView.getMenu();
|
||||
SubMenu currentSubmenu = null;
|
||||
boolean disableGif = sharedpreferences.getBoolean(SET_DISABLE_GIF, false);
|
||||
if (accounts != null)
|
||||
for (final Account account : accounts) {
|
||||
|
||||
|
@ -1332,14 +1321,12 @@ public class Helper {
|
|||
}
|
||||
if (!url.equals("null"))
|
||||
Glide.with(navigationView.getContext())
|
||||
.asBitmap()
|
||||
.asDrawable()
|
||||
.load(account.getAvatar())
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
Drawable drawable = new BitmapDrawable(activity.getResources(), resource);
|
||||
item.setIcon(drawable);
|
||||
item.getIcon().setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY);
|
||||
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
|
||||
item.setIcon(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1540,6 +1527,7 @@ public class Helper {
|
|||
* @param activity Activity
|
||||
* @param userID String - the new user id
|
||||
*/
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public static void changeUser(Activity activity, String userID, String instance, boolean notificationIntent) {
|
||||
|
||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
@ -1701,6 +1689,7 @@ public class Helper {
|
|||
* @param account Account - new account in use
|
||||
* @param headerLayout View - the menu header
|
||||
*/
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public static void updateHeaderAccountInfo(Activity activity, final Account account, final View headerLayout) {
|
||||
|
||||
|
||||
|
@ -1925,7 +1914,7 @@ public class Helper {
|
|||
activity.startActivity(myIntent);
|
||||
activity.finish(); //User is logged out to get a new token
|
||||
} else {
|
||||
Account.makeAccountNameEmoji(activity, account);
|
||||
Account.makeAccountNameEmoji(new WeakReference<>(activity), account);
|
||||
username.setText(String.format("@%s", account.getUsername() + "@" + account.getInstance()));
|
||||
displayedName.setText(account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
loadGiF(activity, account, profilePicture);
|
||||
|
@ -2254,30 +2243,6 @@ public class Helper {
|
|||
return webView;
|
||||
}
|
||||
|
||||
public static String md5(final String s) {
|
||||
final String MD5 = "MD5";
|
||||
try {
|
||||
// Create MD5 Hash
|
||||
MessageDigest digest = java.security.MessageDigest
|
||||
.getInstance(MD5);
|
||||
digest.update(s.getBytes());
|
||||
byte[] messageDigest = digest.digest();
|
||||
|
||||
// Create Hex String
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte aMessageDigest : messageDigest) {
|
||||
StringBuilder h = new StringBuilder(Integer.toHexString(0xFF & aMessageDigest));
|
||||
while (h.length() < 2)
|
||||
h.insert(0, "0");
|
||||
hexString.append(h);
|
||||
}
|
||||
return hexString.toString();
|
||||
|
||||
} catch (NoSuchAlgorithmException ignored) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* change color of a drawable
|
||||
*
|
||||
|
@ -2341,23 +2306,6 @@ public class Helper {
|
|||
imageButton.setColorFilter(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* change color of a drawable
|
||||
*
|
||||
* @param button int the button
|
||||
* @param hexaColor example 0xffff00
|
||||
*/
|
||||
public static void changeButtonTextColor(Context context, Button button, int hexaColor) {
|
||||
if (button == null)
|
||||
return;
|
||||
int color;
|
||||
try {
|
||||
color = context.getResources().getColor(hexaColor);
|
||||
} catch (Resources.NotFoundException e) {
|
||||
color = hexaColor;
|
||||
}
|
||||
button.setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current locale of the device
|
||||
|
@ -2451,6 +2399,7 @@ public class Helper {
|
|||
Date dateEndD = formatter.parse(dateEnd);
|
||||
Date currentDateD = formatter.parse(currentDate);
|
||||
boolean canNotify = false;
|
||||
assert currentDateD != null;
|
||||
if (currentDateD.before(dateEndD) && currentDateD.after(dateIniD) && notification == Helper.ACTION_ACTIVE)
|
||||
canNotify = true;
|
||||
else if (currentDateD.after(dateEndD) && currentDateD.before(dateIniD) && notification == Helper.ACTION_SILENT)
|
||||
|
@ -2551,20 +2500,6 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialized a Locale
|
||||
*
|
||||
* @param serializedLocale String serialized locale
|
||||
* @return Locale
|
||||
*/
|
||||
public static Locale restoreLocaleFromString(String serializedLocale) {
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
return gson.fromJson(serializedLocale, Locale.class);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialized a Locale class
|
||||
|
@ -2662,7 +2597,7 @@ public class Helper {
|
|||
* @param serializedArray String serialized array
|
||||
* @return List<String> list
|
||||
*/
|
||||
public static List restoreArrayFromString(String serializedArray) {
|
||||
public static List<String> restoreArrayFromString(String serializedArray) {
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
return gson.fromJson(serializedArray, List.class);
|
||||
|
@ -2959,49 +2894,6 @@ public class Helper {
|
|||
tableLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a bitmap from a view
|
||||
*
|
||||
* @param view The view to convert
|
||||
* @return Bitmap
|
||||
*/
|
||||
public static Bitmap convertTootIntoBitmap(Context context, String name, View view) {
|
||||
|
||||
if (view.getWidth() == 0 || view.getHeight() == 0) {
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
return null;
|
||||
}
|
||||
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth() + (int) Helper.convertDpToPixel(10, context), view.getHeight() + (int) Helper.convertDpToPixel(30, context), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(returnedBitmap);
|
||||
canvas.drawBitmap(returnedBitmap, view.getWidth() + (int) Helper.convertDpToPixel(10, context), 0, null);
|
||||
Drawable bgDrawable = view.getBackground();
|
||||
if (bgDrawable != null)
|
||||
bgDrawable.draw(canvas);
|
||||
else {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
canvas.drawColor(ContextCompat.getColor(context, R.color.mastodonC1));
|
||||
|
||||
} else if (theme == Helper.THEME_BLACK) {
|
||||
canvas.drawColor(ContextCompat.getColor(context, R.color.black));
|
||||
} else {
|
||||
canvas.drawColor(Color.WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
view.draw(canvas);
|
||||
Paint paint = new Paint();
|
||||
int mastodonC4 = ContextCompat.getColor(context, R.color.mastodonC4);
|
||||
paint.setColor(mastodonC4);
|
||||
paint.setStrokeWidth(12);
|
||||
paint.setTextSize((int) Helper.convertDpToPixel(14, context));
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));
|
||||
canvas.drawText(name + " - #Fedilab", 0, view.getHeight() + (int) Helper.convertDpToPixel(15, context), paint);
|
||||
|
||||
return returnedBitmap;
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public static String withSuffix(long count) {
|
||||
if (count < 1000) return "" + count;
|
||||
|
@ -3021,26 +2913,6 @@ public class Helper {
|
|||
"kMGTPE".charAt(exp - 1));
|
||||
}
|
||||
|
||||
public static Bitmap addBorder(Bitmap resource, Context context) {
|
||||
int w = resource.getWidth();
|
||||
int h = resource.getHeight();
|
||||
int radius = Math.min(h / 2, w / 2);
|
||||
Bitmap output = Bitmap.createBitmap(w + 8, h + 8, Bitmap.Config.ARGB_8888);
|
||||
Paint p = new Paint();
|
||||
p.setAntiAlias(true);
|
||||
Canvas c = new Canvas(output);
|
||||
c.drawARGB(0, 0, 0, 0);
|
||||
p.setStyle(Paint.Style.FILL);
|
||||
c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, p);
|
||||
p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
c.drawBitmap(resource, 4, 4, p);
|
||||
p.setXfermode(null);
|
||||
p.setStyle(Paint.Style.STROKE);
|
||||
p.setColor(ContextCompat.getColor(context, R.color.white));
|
||||
p.setStrokeWidth(3);
|
||||
c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, p);
|
||||
return output;
|
||||
}
|
||||
|
||||
public static String secondsToString(int pTime) {
|
||||
|
||||
|
@ -3443,7 +3315,7 @@ public class Helper {
|
|||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
public static String getRealPathFromURI(Context context, Uri uri) throws URISyntaxException {
|
||||
public static String getRealPathFromURI(Context context, Uri uri) {
|
||||
String selection = null;
|
||||
String[] selectionArgs = null;
|
||||
// Uri is different in versions after KITKAT (Android 4.4), we need to
|
||||
|
@ -3542,7 +3414,7 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
public static Bitmap compressImageIfNeeded(Context context, Bitmap bmToCompress) {
|
||||
public static Bitmap compressImageIfNeeded(Bitmap bmToCompress) {
|
||||
|
||||
int size = bmToCompress.getByteCount();
|
||||
double resizeby = 33554432; //4Mo
|
||||
|
@ -3761,16 +3633,10 @@ public class Helper {
|
|||
}
|
||||
|
||||
|
||||
private static void removeOnGlobalLayoutListener(View v, ViewTreeObserver.OnGlobalLayoutListener listener) {
|
||||
v.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
|
||||
}
|
||||
|
||||
public static int languageSpinnerPosition(Context context) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String defaultLocaleString = sharedpreferences.getString(Helper.SET_DEFAULT_LOCALE_NEW, "NOT_DEFINED");
|
||||
switch (defaultLocaleString) {
|
||||
case "NOT_DEFINED":
|
||||
return 0;
|
||||
case "en":
|
||||
return 1;
|
||||
case "fr":
|
||||
|
@ -4097,13 +3963,6 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
public static Uri getImageUri(Context inContext, Bitmap inImage) {
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
|
||||
String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
|
||||
return Uri.parse(path);
|
||||
}
|
||||
|
||||
public static void initNetCipher(Context context) {
|
||||
Context appContext = context.getApplicationContext();
|
||||
|
||||
|
@ -4407,28 +4266,6 @@ public class Helper {
|
|||
|
||||
}
|
||||
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
Bitmap bitmap;
|
||||
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
|
||||
if (bitmapDrawable.getBitmap() != null) {
|
||||
return bitmapDrawable.getBitmap();
|
||||
}
|
||||
}
|
||||
|
||||
if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
|
||||
bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
|
||||
} else {
|
||||
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static void startStreaming(Context context) {
|
||||
int liveNotifications = Helper.liveNotifType(context);
|
||||
Intent streamingIntent = null;
|
||||
|
|
|
@ -16,7 +16,6 @@ package app.fedilab.android.sqlite;
|
|||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
|
@ -98,7 +97,6 @@ public class PeertubeFavoritesDAO {
|
|||
* @return stored peertube List<Peertube>
|
||||
*/
|
||||
public List<Peertube> getAllPeertube() {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_PEERTUBE_FAVOURITES, null, null, null, null, null, Sqlite.COL_DATE + " DESC");
|
||||
return cursorToListPeertube(c);
|
||||
|
@ -113,7 +111,6 @@ public class PeertubeFavoritesDAO {
|
|||
* @return stored peertube List<Peertube>
|
||||
*/
|
||||
public List<Peertube> getSinglePeertube(Peertube peertube) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_PEERTUBE_FAVOURITES, null, Sqlite.COL_UUID + " = \"" + peertube.getUuid() + "\" AND " + Sqlite.COL_INSTANCE + " = \"" + peertube.getInstance() + "\"", null, null, null, Sqlite.COL_DATE + " DESC");
|
||||
return cursorToListPeertube(c);
|
||||
|
@ -137,7 +134,7 @@ public class PeertubeFavoritesDAO {
|
|||
while (c.moveToNext()) {
|
||||
//Restore cached status
|
||||
try {
|
||||
Peertube peertube = API.parsePeertube(context, c.getString(c.getColumnIndex(Sqlite.COL_INSTANCE)), new JSONObject(c.getString(c.getColumnIndex(Sqlite.COL_CACHE))));
|
||||
Peertube peertube = API.parsePeertube(c.getString(c.getColumnIndex(Sqlite.COL_INSTANCE)), new JSONObject(c.getString(c.getColumnIndex(Sqlite.COL_CACHE))));
|
||||
peertubes.add(peertube);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -47,6 +47,7 @@ public class CustomWebview extends WebView {
|
|||
super(getFixedContext(context), attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public CustomWebview(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) {
|
||||
super(getFixedContext(context), attrs, defStyleAttr, privateBrowsing);
|
||||
}
|
||||
|
|
|
@ -101,9 +101,7 @@ public class MastalabWebViewClient extends WebViewClient {
|
|||
return new WebResourceResponse("text/plain", "utf-8", nothing);
|
||||
|
||||
}
|
||||
} catch (URISyntaxException ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
} catch (URISyntaxException ignored) {}
|
||||
}
|
||||
}
|
||||
return super.shouldInterceptRequest(view, url);
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@
|
|||
<string name="pin_add">Pin this toot?</string>
|
||||
<string name="pin_remove">Unpin this toot?</string>
|
||||
|
||||
|
||||
<string name="more_action_1">Mute</string>
|
||||
<string name="more_action_2">Block</string>
|
||||
<string name="more_action_3">Report</string>
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
</style>
|
||||
|
||||
<style name="Dialog" parent="Cyanea.AlertDialog.Theme.Light">
|
||||
<item name="iconColorMenu">@color/black</item>
|
||||
<item name="iconColor">@color/black</item>
|
||||
<item name="textColor">@color/black</item>
|
||||
<item name="android:textColor">@color/black</item>
|
||||
|
@ -125,6 +126,7 @@
|
|||
</style>
|
||||
|
||||
<style name="DialogDark" parent="Cyanea.AlertDialog.Theme.Dark">
|
||||
<item name="iconColorMenu">@color/dark_icon_theme</item>
|
||||
<item name="iconColor">@color/dark_icon_theme</item>
|
||||
<item name="android:textColor">@color/dark_text</item>
|
||||
<item name="buttonBarButtonStyle">@style/DialogButton</item>
|
||||
|
@ -133,6 +135,7 @@
|
|||
</style>
|
||||
|
||||
<style name="DialogBlack" parent="Cyanea.AlertDialog.Theme.Dark">
|
||||
<item name="iconColorMenu">@color/black_icon_theme</item>
|
||||
<item name="iconColor">@color/black_icon_theme</item>
|
||||
<item name="android:textColor">@color/dark_text</item>
|
||||
<item name="buttonBarButtonStyle">@style/DialogButton</item>
|
||||
|
@ -140,7 +143,7 @@
|
|||
<item name="android:windowBackground">@color/cyanea_primary_reference</item>
|
||||
</style>
|
||||
|
||||
<style name="TransparentLight" parent="Theme.Cyanea.Light">black_icon_theme
|
||||
<style name="TransparentLight" parent="Theme.Cyanea.Light">
|
||||
<item name="iconColor">@color/black</item>
|
||||
<item name="iconColorMenu">@color/black</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
|
|
Loading…
Reference in New Issue