Fix crash when adding media

This commit is contained in:
Thomas 2020-07-08 09:48:45 +02:00
parent 481c1ae49b
commit 497ff297d8
21 changed files with 188 additions and 136 deletions

View File

@ -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>

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
imageView.setId(n);
}
Random rand = new Random();
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);

View File

@ -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);

View File

@ -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());
}
}

View File

@ -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;
}
@ -1406,7 +1407,7 @@ public class API {
* @return Account
*/
private static Account parseAccountResponse(JSONObject resobj) {
return parseAccountResponse(resobj, true);
return parseAccountResponse(resobj, true);
}
/**
@ -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) {

View File

@ -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);

View File

@ -255,7 +255,7 @@ public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
});
if (action != RetrieveAccountsAsyncTask.Type.GROUPS) {
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
if (targetedId == null || !targetedId.equals(account.getId())) {
Intent intent = new Intent(context, ShowAccountActivity.class);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -151,21 +151,21 @@ public class ScheduledTootsListAdapter extends BaseAdapter implements OnPostActi
Helper.changeDrawableColor(context, R.drawable.ic_mail_outline, R.color.action_light);
}
if(status.getVisibility() != null)
switch (status.getVisibility()) {
case "public":
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_public);
break;
case "unlisted":
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_lock_open);
break;
case "private":
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_lock_outline);
break;
case "direct":
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_mail_outline);
break;
}
if (status.getVisibility() != null)
switch (status.getVisibility()) {
case "public":
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_public);
break;
case "unlisted":
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_lock_open);
break;
case "private":
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_lock_outline);
break;
case "direct":
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_mail_outline);
break;
}
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
int style;
if (theme == Helper.THEME_DARK) {

View File

@ -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);
}

View File

@ -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);
}
@ -3338,7 +3338,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
.asBitmap()
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
.thumbnail(0.1f)
// .dontTransform()
// .dontTransform()
.apply(new RequestOptions().transform(new BlurTransformation(50, 3), new RoundedCorners(10)))
.into(new CustomTarget<Bitmap>() {
@Override
@ -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);
}

View File

@ -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,80 +196,86 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageView.setTransitionName(attachment.getUrl());
}
Glide.with(context)
.asBitmap()
.dontTransform()
.load(preview_url).into(
new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
//Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
imageView.setImageBitmap(resource);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
scheduleStartPostponedTransition(imageView);
}
if (bgColor != -1) {
media_fragment_container.setBackgroundColor(bgColor);
}
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);
Glide.with(context)
.asBitmap()
.dontTransform()
.load(url).into(
new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
loader.setVisibility(View.GONE);
Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
if (imageView.getScale() < 1.1) {
imageView.setImageBitmap(imageCompressed);
} else {
message_ready.setVisibility(View.VISIBLE);
if (Helper.isValidContextForGlide(context)) {
Glide.with(context)
.asBitmap()
.dontTransform()
.load(preview_url).into(
new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
//Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
imageView.setImageBitmap(resource);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
scheduleStartPostponedTransition(imageView);
}
if (bgColor != -1) {
media_fragment_container.setBackgroundColor(bgColor);
}
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()
.load(url).into(
new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
loader.setVisibility(View.GONE);
Bitmap imageCompressed = Helper.compressImageIfNeeded(resource);
if (imageView.getScale() < 1.1) {
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);
});
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
}
);
}, 1000);
);
}
}, 1000);
}else if (attachment.getType().toLowerCase().compareTo("image") == 0 && attachment.getUrl().endsWith(".gif")) {
loader.setVisibility(View.GONE);
Glide.with(context)
.load(url).into(imageView);
} 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);
}
}
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
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) {
scheduleStartPostponedTransition(imageView);
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
}
);
);
}
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;
}
});

View File

@ -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?>)");

View File

@ -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) {}
}
}
}