Fix crash when adding media
This commit is contained in:
parent
481c1ae49b
commit
497ff297d8
|
@ -69,6 +69,11 @@
|
||||||
android:name="app.fedilab.android.services.BackupNotificationInDataBaseService"
|
android:name="app.fedilab.android.services.BackupNotificationInDataBaseService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
|
<receiver android:name=".services.UpgradeReceiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
<receiver
|
<receiver
|
||||||
android:name="app.fedilab.android.services.RestartLiveNotificationReceiver"
|
android:name="app.fedilab.android.services.RestartLiveNotificationReceiver"
|
||||||
android:exported="false">
|
android:exported="false">
|
||||||
|
@ -527,5 +532,6 @@
|
||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
android:resource="@xml/file_paths" />
|
android:resource="@xml/file_paths" />
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
|
@ -7,7 +7,6 @@ import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.transition.Explode;
|
|
||||||
import android.view.ActionMode;
|
import android.view.ActionMode;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
|
|
@ -169,8 +169,7 @@ public class LoginActivity extends BaseActivity {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
package app.fedilab.android.activities;
|
package app.fedilab.android.activities;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -746,7 +745,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
||||||
.makeSceneTransitionAnimation(ShowAccountActivity.this, account_pp, attachment.getUrl());
|
.makeSceneTransitionAnimation(ShowAccountActivity.this, account_pp, attachment.getUrl());
|
||||||
// start the new activity
|
// start the new activity
|
||||||
startActivity(intent, options.toBundle());
|
startActivity(intent, options.toBundle());
|
||||||
}else{
|
} else {
|
||||||
// start the new activity
|
// start the new activity
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1322,13 +1322,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
||||||
|
|
||||||
|
|
||||||
final ImageView imageView = new ImageView(TootActivity.this);
|
final ImageView imageView = new ImageView(TootActivity.this);
|
||||||
try {
|
Random rand = new Random();
|
||||||
imageView.setId(Integer.parseInt(attachment.getId()));
|
int n = rand.nextInt(10000000);
|
||||||
}catch (NumberFormatException e){
|
imageView.setId(n);
|
||||||
Random rand = new Random();
|
attachment.setViewId(n);
|
||||||
int n = rand.nextInt(1000000);
|
|
||||||
imageView.setId(n);
|
|
||||||
}
|
|
||||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||||
if (successfullyUploadedFiles != null && successfullyUploadedFiles.size() > 0) {
|
if (successfullyUploadedFiles != null && successfullyUploadedFiles.size() > 0) {
|
||||||
|
|
||||||
|
@ -2416,7 +2413,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
||||||
dialog.setPositiveButton(R.string.yes, (dialog12, which) -> {
|
dialog.setPositiveButton(R.string.yes, (dialog12, which) -> {
|
||||||
View namebar = findViewById(viewId);
|
View namebar = findViewById(viewId);
|
||||||
for (Attachment attachment : attachments) {
|
for (Attachment attachment : attachments) {
|
||||||
if (Integer.parseInt(attachment.getId()) == viewId) {
|
if (attachment.getViewId() == viewId) {
|
||||||
attachments.remove(attachment);
|
attachments.remove(attachment);
|
||||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
boolean show_media_urls = sharedpreferences.getBoolean(Helper.SET_MEDIA_URLS, false);
|
boolean show_media_urls = sharedpreferences.getBoolean(Helper.SET_MEDIA_URLS, false);
|
||||||
|
|
|
@ -30,7 +30,6 @@ import app.fedilab.android.client.Entities.Peertube;
|
||||||
import app.fedilab.android.client.Entities.RemoteInstance;
|
import app.fedilab.android.client.Entities.RemoteInstance;
|
||||||
import app.fedilab.android.client.Entities.Results;
|
import app.fedilab.android.client.Entities.Results;
|
||||||
import app.fedilab.android.client.Entities.RetrieveFeedsParam;
|
import app.fedilab.android.client.Entities.RetrieveFeedsParam;
|
||||||
import app.fedilab.android.client.Entities.Status;
|
|
||||||
import app.fedilab.android.client.GNUAPI;
|
import app.fedilab.android.client.GNUAPI;
|
||||||
import app.fedilab.android.client.PeertubeAPI;
|
import app.fedilab.android.client.PeertubeAPI;
|
||||||
import app.fedilab.android.helper.FilterToots;
|
import app.fedilab.android.helper.FilterToots;
|
||||||
|
@ -388,7 +387,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
statuses = new StatusCacheDAO(contextReference.get(), db).getStatusFromID(StatusCacheDAO.ARCHIVE_CACHE, filterToots, max_id);
|
statuses = new StatusCacheDAO(contextReference.get(), db).getStatusFromID(StatusCacheDAO.ARCHIVE_CACHE, filterToots, max_id);
|
||||||
if (statuses != null && statuses.size() > 0) {
|
if (statuses != null && statuses.size() > 0) {
|
||||||
for (app.fedilab.android.client.Entities.Status status: statuses) {
|
for (app.fedilab.android.client.Entities.Status status : statuses) {
|
||||||
app.fedilab.android.client.Entities.Status.fillSpan(contextReference, status);
|
app.fedilab.android.client.Entities.Status.fillSpan(contextReference, status);
|
||||||
}
|
}
|
||||||
apiResponse.setStatuses(statuses);
|
apiResponse.setStatuses(statuses);
|
||||||
|
|
|
@ -57,8 +57,8 @@ public class RetrieveNotificationsCacheAsyncTask extends AsyncTask<Void, Void, V
|
||||||
apiResponse = new APIResponse();
|
apiResponse = new APIResponse();
|
||||||
apiResponse.setNotifications(notifications);
|
apiResponse.setNotifications(notifications);
|
||||||
if (notifications != null && notifications.size() > 0) {
|
if (notifications != null && notifications.size() > 0) {
|
||||||
for (Notification notification: notifications) {
|
for (Notification notification : notifications) {
|
||||||
if( notification.getStatus() != null) {
|
if (notification.getStatus() != null) {
|
||||||
app.fedilab.android.client.Entities.Status.fillSpan(contextReference, notification.getStatus());
|
app.fedilab.android.client.Entities.Status.fillSpan(contextReference, notification.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -962,9 +962,9 @@ public class API {
|
||||||
Status status = new Status();
|
Status status = new Status();
|
||||||
try {
|
try {
|
||||||
status.setIn_reply_to_id(resobj.getString("in_reply_to_id"));
|
status.setIn_reply_to_id(resobj.getString("in_reply_to_id"));
|
||||||
if( !resobj.isNull("sensitive")) {
|
if (!resobj.isNull("sensitive")) {
|
||||||
status.setSensitive(resobj.getBoolean("sensitive"));
|
status.setSensitive(resobj.getBoolean("sensitive"));
|
||||||
}else{
|
} else {
|
||||||
status.setSensitive(false);
|
status.setSensitive(false);
|
||||||
}
|
}
|
||||||
status.setSpoiler_text(resobj.getString("spoiler_text"));
|
status.setSpoiler_text(resobj.getString("spoiler_text"));
|
||||||
|
@ -974,7 +974,8 @@ public class API {
|
||||||
status.setVisibility("public");
|
status.setVisibility("public");
|
||||||
}
|
}
|
||||||
status.setContent(context, resobj.getString("text"));
|
status.setContent(context, resobj.getString("text"));
|
||||||
} catch (JSONException ignored) {}
|
} catch (JSONException ignored) {
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1406,7 +1407,7 @@ public class API {
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
private static Account parseAccountResponse(JSONObject resobj) {
|
private static Account parseAccountResponse(JSONObject resobj) {
|
||||||
return parseAccountResponse(resobj, true);
|
return parseAccountResponse(resobj, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1456,7 +1457,7 @@ public class API {
|
||||||
account.setBot(false);
|
account.setBot(false);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(recursive) {
|
if (recursive) {
|
||||||
account.setMoved_to_account(parseAccountResponse(resobj.getJSONObject("moved"), false));
|
account.setMoved_to_account(parseAccountResponse(resobj.getJSONObject("moved"), false));
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class Attachment implements Parcelable {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private String id;
|
private String id;
|
||||||
|
private int viewId;
|
||||||
private String type;
|
private String type;
|
||||||
private String url;
|
private String url;
|
||||||
private String remote_url;
|
private String remote_url;
|
||||||
|
@ -50,8 +51,17 @@ public class Attachment implements Parcelable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getViewId() {
|
||||||
|
return viewId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setViewId(int viewId) {
|
||||||
|
this.viewId = viewId;
|
||||||
|
}
|
||||||
|
|
||||||
protected Attachment(Parcel in) {
|
protected Attachment(Parcel in) {
|
||||||
this.id = in.readString();
|
this.id = in.readString();
|
||||||
|
this.viewId = in.readInt();
|
||||||
this.type = in.readString();
|
this.type = in.readString();
|
||||||
this.url = in.readString();
|
this.url = in.readString();
|
||||||
this.remote_url = in.readString();
|
this.remote_url = in.readString();
|
||||||
|
@ -142,6 +152,7 @@ public class Attachment implements Parcelable {
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeString(this.id);
|
dest.writeString(this.id);
|
||||||
|
dest.writeInt(this.viewId);
|
||||||
dest.writeString(this.type);
|
dest.writeString(this.type);
|
||||||
dest.writeString(this.url);
|
dest.writeString(this.url);
|
||||||
dest.writeString(this.remote_url);
|
dest.writeString(this.remote_url);
|
||||||
|
|
|
@ -255,7 +255,7 @@ public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
});
|
});
|
||||||
if (action != RetrieveAccountsAsyncTask.Type.GROUPS) {
|
if (action != RetrieveAccountsAsyncTask.Type.GROUPS) {
|
||||||
holder.account_pp.setOnClickListener(v -> {
|
holder.account_pp.setOnClickListener(v -> {
|
||||||
if (!crossAction && (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE || action != RetrieveAccountsAsyncTask.Type.CHANNELS)) {
|
if (!crossAction && (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE || action != RetrieveAccountsAsyncTask.Type.CHANNELS)) {
|
||||||
//Avoid to reopen details about the current account
|
//Avoid to reopen details about the current account
|
||||||
if (targetedId == null || !targetedId.equals(account.getId())) {
|
if (targetedId == null || !targetedId.equals(account.getId())) {
|
||||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||||
|
|
|
@ -181,10 +181,10 @@ public class ArtListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||||
.makeSceneTransitionAnimation((Activity)context, holder.art_media, status.getMedia_attachments().get(0).getUrl());
|
.makeSceneTransitionAnimation((Activity) context, holder.art_media, status.getMedia_attachments().get(0).getUrl());
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent, options.toBundle());
|
context.startActivity(intent, options.toBundle());
|
||||||
}else{
|
} else {
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,10 +90,10 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||||
.makeSceneTransitionAnimation((Activity)context, holder.imageView, attachmentsTmp.get((viewHolder.getAdapterPosition())).getUrl());
|
.makeSceneTransitionAnimation((Activity) context, holder.imageView, attachmentsTmp.get((viewHolder.getAdapterPosition())).getUrl());
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent, options.toBundle());
|
context.startActivity(intent, options.toBundle());
|
||||||
}else{
|
} else {
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -757,7 +757,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||||
holder.notification_delete.setOnClickListener(v -> displayConfirmationNotificationDialog(notification));
|
holder.notification_delete.setOnClickListener(v -> displayConfirmationNotificationDialog(notification));
|
||||||
|
|
||||||
|
|
||||||
if( notification.getAccount() != null) {
|
if (notification.getAccount() != null) {
|
||||||
SpannableString wordtoSpan = new SpannableString("@" + notification.getAccount().getAcct());
|
SpannableString wordtoSpan = new SpannableString("@" + notification.getAccount().getAcct());
|
||||||
Pattern hashAcct = Pattern.compile("(@" + notification.getAccount().getAcct() + ")");
|
Pattern hashAcct = Pattern.compile("(@" + notification.getAccount().getAcct() + ")");
|
||||||
|
|
||||||
|
@ -1220,10 +1220,10 @@ public class NotificationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||||
.makeSceneTransitionAnimation((Activity)context, imageView, notification.getStatus().getMedia_attachments().get(finalPosition-1).getUrl());
|
.makeSceneTransitionAnimation((Activity) context, imageView, notification.getStatus().getMedia_attachments().get(finalPosition - 1).getUrl());
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent, options.toBundle());
|
context.startActivity(intent, options.toBundle());
|
||||||
}else{
|
} else {
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,10 +402,10 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||||
.makeSceneTransitionAnimation((Activity)context, holder.art_media, status.getMedia_attachments().get(0).getUrl());
|
.makeSceneTransitionAnimation((Activity) context, holder.art_media, status.getMedia_attachments().get(0).getUrl());
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent, options.toBundle());
|
context.startActivity(intent, options.toBundle());
|
||||||
}else{
|
} else {
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,10 +139,10 @@ public class PixelfedStoriesListAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||||
.makeSceneTransitionAnimation((Activity)context, holder.art_media, attachments.get(0).getUrl());
|
.makeSceneTransitionAnimation((Activity) context, holder.art_media, attachments.get(0).getUrl());
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent, options.toBundle());
|
context.startActivity(intent, options.toBundle());
|
||||||
}else{
|
} else {
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,21 +151,21 @@ public class ScheduledTootsListAdapter extends BaseAdapter implements OnPostActi
|
||||||
Helper.changeDrawableColor(context, R.drawable.ic_mail_outline, R.color.action_light);
|
Helper.changeDrawableColor(context, R.drawable.ic_mail_outline, R.color.action_light);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status.getVisibility() != null)
|
if (status.getVisibility() != null)
|
||||||
switch (status.getVisibility()) {
|
switch (status.getVisibility()) {
|
||||||
case "public":
|
case "public":
|
||||||
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_public);
|
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_public);
|
||||||
break;
|
break;
|
||||||
case "unlisted":
|
case "unlisted":
|
||||||
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_lock_open);
|
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_lock_open);
|
||||||
break;
|
break;
|
||||||
case "private":
|
case "private":
|
||||||
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_lock_outline);
|
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_lock_outline);
|
||||||
break;
|
break;
|
||||||
case "direct":
|
case "direct":
|
||||||
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_mail_outline);
|
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_mail_outline);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
int style;
|
int style;
|
||||||
if (theme == Helper.THEME_DARK) {
|
if (theme == Helper.THEME_DARK) {
|
||||||
|
|
|
@ -112,10 +112,10 @@ public class SliderAdapter extends SliderViewAdapter<SliderAdapter.SliderAdapter
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||||
.makeSceneTransitionAnimation((Activity)contextWeakReference.get(), viewHolder.imageViewBackground, attachments.get((position)).getUrl());
|
.makeSceneTransitionAnimation((Activity) contextWeakReference.get(), viewHolder.imageViewBackground, attachments.get((position)).getUrl());
|
||||||
// start the new activity
|
// start the new activity
|
||||||
contextWeakReference.get().startActivity(intent, options.toBundle());
|
contextWeakReference.get().startActivity(intent, options.toBundle());
|
||||||
}else{
|
} else {
|
||||||
// start the new activity
|
// start the new activity
|
||||||
contextWeakReference.get().startActivity(intent);
|
contextWeakReference.get().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2332,10 +2332,10 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||||
.makeSceneTransitionAnimation((Activity)context, holder.webview_preview, attachment.getUrl());
|
.makeSceneTransitionAnimation((Activity) context, holder.webview_preview, attachment.getUrl());
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent, options.toBundle());
|
context.startActivity(intent, options.toBundle());
|
||||||
}else{
|
} else {
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -3338,7 +3338,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
|
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
|
||||||
.thumbnail(0.1f)
|
.thumbnail(0.1f)
|
||||||
// .dontTransform()
|
// .dontTransform()
|
||||||
.apply(new RequestOptions().transform(new BlurTransformation(50, 3), new RoundedCorners(10)))
|
.apply(new RequestOptions().transform(new BlurTransformation(50, 3), new RoundedCorners(10)))
|
||||||
.into(new CustomTarget<Bitmap>() {
|
.into(new CustomTarget<Bitmap>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -3399,10 +3399,10 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||||
.makeSceneTransitionAnimation((Activity)context, imageView, attachment.getUrl());
|
.makeSceneTransitionAnimation((Activity) context, imageView, attachment.getUrl());
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent, options.toBundle());
|
context.startActivity(intent, options.toBundle());
|
||||||
}else{
|
} else {
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
|
||||||
import com.bumptech.glide.request.target.CustomTarget;
|
import com.bumptech.glide.request.target.CustomTarget;
|
||||||
import com.bumptech.glide.request.transition.Transition;
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
import com.cleveroad.audiovisualization.DbmHandler;
|
import com.cleveroad.audiovisualization.DbmHandler;
|
||||||
|
@ -197,80 +196,86 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
imageView.setTransitionName(attachment.getUrl());
|
imageView.setTransitionName(attachment.getUrl());
|
||||||
}
|
}
|
||||||
Glide.with(context)
|
if (Helper.isValidContextForGlide(context)) {
|
||||||
.asBitmap()
|
Glide.with(context)
|
||||||
.dontTransform()
|
.asBitmap()
|
||||||
.load(preview_url).into(
|
.dontTransform()
|
||||||
new CustomTarget<Bitmap>() {
|
.load(preview_url).into(
|
||||||
@Override
|
new CustomTarget<Bitmap>() {
|
||||||
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
|
@Override
|
||||||
//Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
|
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
|
||||||
imageView.setImageBitmap(resource);
|
//Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
imageView.setImageBitmap(resource);
|
||||||
scheduleStartPostponedTransition(imageView);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
}
|
scheduleStartPostponedTransition(imageView);
|
||||||
if (bgColor != -1) {
|
}
|
||||||
media_fragment_container.setBackgroundColor(bgColor);
|
if (bgColor != -1) {
|
||||||
}
|
media_fragment_container.setBackgroundColor(bgColor);
|
||||||
if( attachment.getType().toLowerCase().compareTo("image") == 0 && !attachment.getUrl().endsWith(".gif")) {
|
}
|
||||||
final Handler handler = new Handler();
|
if (attachment.getType().toLowerCase().compareTo("image") == 0 && !attachment.getUrl().endsWith(".gif")) {
|
||||||
handler.postDelayed(() -> {
|
final Handler handler = new Handler();
|
||||||
pbar_inf.setScaleY(1f);
|
handler.postDelayed(() -> {
|
||||||
imageView.setVisibility(View.VISIBLE);
|
pbar_inf.setScaleY(1f);
|
||||||
pbar_inf.setIndeterminate(true);
|
imageView.setVisibility(View.VISIBLE);
|
||||||
loader.setVisibility(View.VISIBLE);
|
pbar_inf.setIndeterminate(true);
|
||||||
Glide.with(context)
|
loader.setVisibility(View.VISIBLE);
|
||||||
.asBitmap()
|
if (Helper.isValidContextForGlide(context)) {
|
||||||
.dontTransform()
|
Glide.with(context)
|
||||||
.load(url).into(
|
.asBitmap()
|
||||||
new CustomTarget<Bitmap>() {
|
.dontTransform()
|
||||||
@Override
|
.load(url).into(
|
||||||
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
|
new CustomTarget<Bitmap>() {
|
||||||
loader.setVisibility(View.GONE);
|
@Override
|
||||||
Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
|
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
|
||||||
if (imageView.getScale() < 1.1) {
|
loader.setVisibility(View.GONE);
|
||||||
imageView.setImageBitmap(imageCompressed);
|
Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
|
||||||
} else {
|
if (imageView.getScale() < 1.1) {
|
||||||
message_ready.setVisibility(View.VISIBLE);
|
imageView.setImageBitmap(imageCompressed);
|
||||||
|
} else {
|
||||||
|
message_ready.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
message_ready.setOnClickListener(view -> {
|
||||||
|
imageView.setImageBitmap(imageCompressed);
|
||||||
|
message_ready.setVisibility(View.GONE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
message_ready.setOnClickListener(view -> {
|
);
|
||||||
imageView.setImageBitmap(imageCompressed);
|
}
|
||||||
message_ready.setVisibility(View.GONE);
|
}, 1000);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
|
|
||||||
}else if (attachment.getType().toLowerCase().compareTo("image") == 0 && attachment.getUrl().endsWith(".gif")) {
|
} else if (attachment.getType().toLowerCase().compareTo("image") == 0 && attachment.getUrl().endsWith(".gif")) {
|
||||||
loader.setVisibility(View.GONE);
|
loader.setVisibility(View.GONE);
|
||||||
Glide.with(context)
|
if (Helper.isValidContextForGlide(context)) {
|
||||||
.load(url).into(imageView);
|
Glide.with(context)
|
||||||
|
.load(url).into(imageView);
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
scheduleStartPostponedTransition(imageView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
scheduleStartPostponedTransition(imageView);
|
scheduleStartPostponedTransition(imageView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadFailed(@Nullable Drawable errorDrawable){
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
scheduleStartPostponedTransition(imageView);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
);
|
||||||
@Override
|
}
|
||||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
switch (type.toLowerCase()) {
|
switch (type.toLowerCase()) {
|
||||||
case "video":
|
case "video":
|
||||||
case "gifv":
|
case "gifv":
|
||||||
|
@ -427,7 +432,6 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stopTimer();
|
stopTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +503,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
||||||
if (playeraudio != null) {
|
if (playeraudio != null) {
|
||||||
playeraudio.pause();
|
playeraudio.pause();
|
||||||
}
|
}
|
||||||
if( webview_video != null) {
|
if (webview_video != null) {
|
||||||
webview_video.onPause();
|
webview_video.onPause();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -522,7 +526,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
if( webview_video != null) {
|
if (webview_video != null) {
|
||||||
webview_video.destroy();
|
webview_video.destroy();
|
||||||
}
|
}
|
||||||
if (timer != null) {
|
if (timer != null) {
|
||||||
|
@ -551,7 +555,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
||||||
visualizerView.onResume();
|
visualizerView.onResume();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
if( webview_video != null) {
|
if (webview_video != null) {
|
||||||
webview_video.onResume();
|
webview_video.onResume();
|
||||||
}
|
}
|
||||||
if (slidrInterface == null && rootView != null) {
|
if (slidrInterface == null && rootView != null) {
|
||||||
|
@ -571,25 +575,25 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSlideChange(float percent) {
|
public void onSlideChange(float percent) {
|
||||||
if( percent < 0.80 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (percent < 0.80 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
|
||||||
if( imageView != null) {
|
if (imageView != null) {
|
||||||
imageView.setVisibility(View.VISIBLE);
|
imageView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
if(content_audio != null) {
|
if (content_audio != null) {
|
||||||
content_audio.setVisibility(View.GONE);
|
content_audio.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if( videoView != null) {
|
if (videoView != null) {
|
||||||
videoView.setVisibility(View.GONE);
|
videoView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if( webview_video != null) {
|
if (webview_video != null) {
|
||||||
webview_video.setVisibility(View.GONE);
|
webview_video.setVisibility(View.GONE);
|
||||||
webview_video.destroy();
|
webview_video.destroy();
|
||||||
}
|
}
|
||||||
if( webview_container != null) {
|
if (webview_container != null) {
|
||||||
webview_container.setVisibility(View.GONE);
|
webview_container.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if( videoLayout != null) {
|
if (videoLayout != null) {
|
||||||
videoLayout.setVisibility(View.GONE);
|
videoLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
ActivityCompat.finishAfterTransition((AppCompatActivity) context);
|
ActivityCompat.finishAfterTransition((AppCompatActivity) context);
|
||||||
|
@ -616,7 +620,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreDraw() {
|
public boolean onPreDraw() {
|
||||||
imageView.getViewTreeObserver().removeOnPreDrawListener(this);
|
imageView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||||
ActivityCompat.startPostponedEnterTransition((Activity)context);
|
ActivityCompat.startPostponedEnterTransition((Activity) context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2080,7 +2080,9 @@ public class Helper {
|
||||||
*/
|
*/
|
||||||
public static SpannableString clickableElementsDescription(final Context context, String fullContent) {
|
public static SpannableString clickableElementsDescription(final Context context, String fullContent) {
|
||||||
|
|
||||||
|
if (fullContent == null) {
|
||||||
|
return new SpannableString("");
|
||||||
|
}
|
||||||
SpannableString spannableString;
|
SpannableString spannableString;
|
||||||
SpannableString spannableStringT = new SpannableString(fullContent);
|
SpannableString spannableStringT = new SpannableString(fullContent);
|
||||||
Pattern aLink = Pattern.compile("(<\\s?a\\s?href=\"https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[/\\w._-]*)\"\\s?[^.]*<\\s?/\\s?a\\s?>)");
|
Pattern aLink = Pattern.compile("(<\\s?a\\s?href=\"https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[/\\w._-]*)\"\\s?[^.]*<\\s?/\\s?a\\s?>)");
|
||||||
|
|
|
@ -1,4 +1,39 @@
|
||||||
package app.fedilab.android.services;
|
package app.fedilab.android.services;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of Fedilab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
public class UpgradeReceiver {
|
|
||||||
}
|
public class UpgradeReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
||||||
|
if( intent.getAction() != null && intent.getAction().compareTo(Intent.ACTION_MY_PACKAGE_REPLACED) == 0) {
|
||||||
|
Intent streamingServiceIntent = new Intent(context, LiveNotificationDelayedService.class);
|
||||||
|
streamingServiceIntent.putExtra("stop", true);
|
||||||
|
try {
|
||||||
|
context.startService(streamingServiceIntent);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
streamingServiceIntent = new Intent(context, LiveNotificationService.class);
|
||||||
|
streamingServiceIntent.putExtra("stop", true);
|
||||||
|
try {
|
||||||
|
context.startService(streamingServiceIntent);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue