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:exported="false" />
|
||||
|
||||
<receiver android:name=".services.UpgradeReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name="app.fedilab.android.services.RestartLiveNotificationReceiver"
|
||||
android:exported="false">
|
||||
|
@ -527,5 +532,6 @@
|
|||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
</application>
|
||||
</manifest>
|
|
@ -7,7 +7,6 @@ import android.content.pm.PackageManager;
|
|||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.transition.Explode;
|
||||
import android.view.ActionMode;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
|
|
@ -169,8 +169,7 @@ public class LoginActivity extends BaseActivity {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
package app.fedilab.android.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Intent;
|
||||
|
@ -746,7 +745,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
.makeSceneTransitionAnimation(ShowAccountActivity.this, account_pp, attachment.getUrl());
|
||||
// start the new activity
|
||||
startActivity(intent, options.toBundle());
|
||||
}else{
|
||||
} else {
|
||||
// start the new activity
|
||||
startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -1322,13 +1322,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
|
||||
|
||||
final ImageView imageView = new ImageView(TootActivity.this);
|
||||
try {
|
||||
imageView.setId(Integer.parseInt(attachment.getId()));
|
||||
}catch (NumberFormatException e){
|
||||
Random rand = new Random();
|
||||
int n = rand.nextInt(1000000);
|
||||
int n = rand.nextInt(10000000);
|
||||
imageView.setId(n);
|
||||
}
|
||||
attachment.setViewId(n);
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||
if (successfullyUploadedFiles != null && successfullyUploadedFiles.size() > 0) {
|
||||
|
||||
|
@ -2416,7 +2413,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
dialog.setPositiveButton(R.string.yes, (dialog12, which) -> {
|
||||
View namebar = findViewById(viewId);
|
||||
for (Attachment attachment : attachments) {
|
||||
if (Integer.parseInt(attachment.getId()) == viewId) {
|
||||
if (attachment.getViewId() == viewId) {
|
||||
attachments.remove(attachment);
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
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.Results;
|
||||
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.PeertubeAPI;
|
||||
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();
|
||||
statuses = new StatusCacheDAO(contextReference.get(), db).getStatusFromID(StatusCacheDAO.ARCHIVE_CACHE, filterToots, max_id);
|
||||
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);
|
||||
}
|
||||
apiResponse.setStatuses(statuses);
|
||||
|
|
|
@ -57,8 +57,8 @@ public class RetrieveNotificationsCacheAsyncTask extends AsyncTask<Void, Void, V
|
|||
apiResponse = new APIResponse();
|
||||
apiResponse.setNotifications(notifications);
|
||||
if (notifications != null && notifications.size() > 0) {
|
||||
for (Notification notification: notifications) {
|
||||
if( notification.getStatus() != null) {
|
||||
for (Notification notification : notifications) {
|
||||
if (notification.getStatus() != null) {
|
||||
app.fedilab.android.client.Entities.Status.fillSpan(contextReference, notification.getStatus());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -962,9 +962,9 @@ public class API {
|
|||
Status status = new Status();
|
||||
try {
|
||||
status.setIn_reply_to_id(resobj.getString("in_reply_to_id"));
|
||||
if( !resobj.isNull("sensitive")) {
|
||||
if (!resobj.isNull("sensitive")) {
|
||||
status.setSensitive(resobj.getBoolean("sensitive"));
|
||||
}else{
|
||||
} else {
|
||||
status.setSensitive(false);
|
||||
}
|
||||
status.setSpoiler_text(resobj.getString("spoiler_text"));
|
||||
|
@ -974,7 +974,8 @@ public class API {
|
|||
status.setVisibility("public");
|
||||
}
|
||||
status.setContent(context, resobj.getString("text"));
|
||||
} catch (JSONException ignored) {}
|
||||
} catch (JSONException ignored) {
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -1456,7 +1457,7 @@ public class API {
|
|||
account.setBot(false);
|
||||
}
|
||||
try {
|
||||
if(recursive) {
|
||||
if (recursive) {
|
||||
account.setMoved_to_account(parseAccountResponse(resobj.getJSONObject("moved"), false));
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
|
|
@ -37,6 +37,7 @@ public class Attachment implements Parcelable {
|
|||
}
|
||||
};
|
||||
private String id;
|
||||
private int viewId;
|
||||
private String type;
|
||||
private String 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) {
|
||||
this.id = in.readString();
|
||||
this.viewId = in.readInt();
|
||||
this.type = in.readString();
|
||||
this.url = in.readString();
|
||||
this.remote_url = in.readString();
|
||||
|
@ -142,6 +152,7 @@ public class Attachment implements Parcelable {
|
|||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(this.id);
|
||||
dest.writeInt(this.viewId);
|
||||
dest.writeString(this.type);
|
||||
dest.writeString(this.url);
|
||||
dest.writeString(this.remote_url);
|
||||
|
|
|
@ -181,10 +181,10 @@ public class ArtListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
intent.putExtras(b);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
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
|
||||
context.startActivity(intent, options.toBundle());
|
||||
}else{
|
||||
} else {
|
||||
// start the new activity
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -90,10 +90,10 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
intent.putExtras(b);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
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
|
||||
context.startActivity(intent, options.toBundle());
|
||||
}else{
|
||||
} else {
|
||||
// start the new activity
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -757,7 +757,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
holder.notification_delete.setOnClickListener(v -> displayConfirmationNotificationDialog(notification));
|
||||
|
||||
|
||||
if( notification.getAccount() != null) {
|
||||
if (notification.getAccount() != null) {
|
||||
SpannableString wordtoSpan = new SpannableString("@" + notification.getAccount().getAcct());
|
||||
Pattern hashAcct = Pattern.compile("(@" + notification.getAccount().getAcct() + ")");
|
||||
|
||||
|
@ -1220,10 +1220,10 @@ public class NotificationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
intent.putExtras(b);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
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
|
||||
context.startActivity(intent, options.toBundle());
|
||||
}else{
|
||||
} else {
|
||||
// start the new activity
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -402,10 +402,10 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
intent.putExtras(b);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
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
|
||||
context.startActivity(intent, options.toBundle());
|
||||
}else{
|
||||
} else {
|
||||
// start the new activity
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -139,10 +139,10 @@ public class PixelfedStoriesListAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
intent.putExtras(b);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
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
|
||||
context.startActivity(intent, options.toBundle());
|
||||
}else{
|
||||
} else {
|
||||
// start the new activity
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ public class ScheduledTootsListAdapter extends BaseAdapter implements OnPostActi
|
|||
Helper.changeDrawableColor(context, R.drawable.ic_mail_outline, R.color.action_light);
|
||||
}
|
||||
|
||||
if(status.getVisibility() != null)
|
||||
if (status.getVisibility() != null)
|
||||
switch (status.getVisibility()) {
|
||||
case "public":
|
||||
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_public);
|
||||
|
|
|
@ -112,10 +112,10 @@ public class SliderAdapter extends SliderViewAdapter<SliderAdapter.SliderAdapter
|
|||
intent.putExtras(b);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
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
|
||||
contextWeakReference.get().startActivity(intent, options.toBundle());
|
||||
}else{
|
||||
} else {
|
||||
// start the new activity
|
||||
contextWeakReference.get().startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -2332,10 +2332,10 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
intent.putExtras(b);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||
.makeSceneTransitionAnimation((Activity)context, holder.webview_preview, attachment.getUrl());
|
||||
.makeSceneTransitionAnimation((Activity) context, holder.webview_preview, attachment.getUrl());
|
||||
// start the new activity
|
||||
context.startActivity(intent, options.toBundle());
|
||||
}else{
|
||||
} else {
|
||||
// start the new activity
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
@ -3399,10 +3399,10 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
intent.putExtras(b);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||
.makeSceneTransitionAnimation((Activity)context, imageView, attachment.getUrl());
|
||||
.makeSceneTransitionAnimation((Activity) context, imageView, attachment.getUrl());
|
||||
// start the new activity
|
||||
context.startActivity(intent, options.toBundle());
|
||||
}else{
|
||||
} else {
|
||||
// start the new activity
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ import androidx.core.content.ContextCompat;
|
|||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.cleveroad.audiovisualization.DbmHandler;
|
||||
|
@ -197,6 +196,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
imageView.setTransitionName(attachment.getUrl());
|
||||
}
|
||||
if (Helper.isValidContextForGlide(context)) {
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
.dontTransform()
|
||||
|
@ -212,13 +212,14 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
if (bgColor != -1) {
|
||||
media_fragment_container.setBackgroundColor(bgColor);
|
||||
}
|
||||
if( attachment.getType().toLowerCase().compareTo("image") == 0 && !attachment.getUrl().endsWith(".gif")) {
|
||||
if (attachment.getType().toLowerCase().compareTo("image") == 0 && !attachment.getUrl().endsWith(".gif")) {
|
||||
final Handler handler = new Handler();
|
||||
handler.postDelayed(() -> {
|
||||
pbar_inf.setScaleY(1f);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
pbar_inf.setIndeterminate(true);
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
if (Helper.isValidContextForGlide(context)) {
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
.dontTransform()
|
||||
|
@ -245,13 +246,16 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}, 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);
|
||||
if (Helper.isValidContextForGlide(context)) {
|
||||
Glide.with(context)
|
||||
.load(url).into(imageView);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
scheduleStartPostponedTransition(imageView);
|
||||
}
|
||||
|
@ -259,7 +263,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable){
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
scheduleStartPostponedTransition(imageView);
|
||||
}
|
||||
|
@ -271,6 +275,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
switch (type.toLowerCase()) {
|
||||
case "video":
|
||||
case "gifv":
|
||||
|
@ -427,7 +432,6 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
|
@ -499,7 +503,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
if (playeraudio != null) {
|
||||
playeraudio.pause();
|
||||
}
|
||||
if( webview_video != null) {
|
||||
if (webview_video != null) {
|
||||
webview_video.onPause();
|
||||
}
|
||||
try {
|
||||
|
@ -522,7 +526,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if( webview_video != null) {
|
||||
if (webview_video != null) {
|
||||
webview_video.destroy();
|
||||
}
|
||||
if (timer != null) {
|
||||
|
@ -551,7 +555,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
visualizerView.onResume();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if( webview_video != null) {
|
||||
if (webview_video != null) {
|
||||
webview_video.onResume();
|
||||
}
|
||||
if (slidrInterface == null && rootView != null) {
|
||||
|
@ -571,25 +575,25 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
if(content_audio != null) {
|
||||
if (content_audio != null) {
|
||||
content_audio.setVisibility(View.GONE);
|
||||
}
|
||||
if( videoView != null) {
|
||||
if (videoView != null) {
|
||||
videoView.setVisibility(View.GONE);
|
||||
}
|
||||
if( webview_video != null) {
|
||||
if (webview_video != null) {
|
||||
webview_video.setVisibility(View.GONE);
|
||||
webview_video.destroy();
|
||||
}
|
||||
if( webview_container != null) {
|
||||
if (webview_container != null) {
|
||||
webview_container.setVisibility(View.GONE);
|
||||
}
|
||||
if( videoLayout != null) {
|
||||
if (videoLayout != null) {
|
||||
videoLayout.setVisibility(View.GONE);
|
||||
}
|
||||
ActivityCompat.finishAfterTransition((AppCompatActivity) context);
|
||||
|
@ -616,7 +620,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
@Override
|
||||
public boolean onPreDraw() {
|
||||
imageView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
ActivityCompat.startPostponedEnterTransition((Activity)context);
|
||||
ActivityCompat.startPostponedEnterTransition((Activity) context);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2080,7 +2080,9 @@ public class Helper {
|
|||
*/
|
||||
public static SpannableString clickableElementsDescription(final Context context, String fullContent) {
|
||||
|
||||
|
||||
if (fullContent == null) {
|
||||
return new SpannableString("");
|
||||
}
|
||||
SpannableString spannableString;
|
||||
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?>)");
|
||||
|
|
|
@ -1,4 +1,39 @@
|
|||
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