aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java33
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java5
4 files changed, 41 insertions, 12 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
index 3a603442..b6fe501a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
@@ -7,6 +7,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
+import android.os.Build;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.Toast;
@@ -157,9 +158,13 @@ public class Infinity extends Application implements LifecycleObserver {
mNetworkWifiStatusReceiver =
new NetworkWifiStatusReceiver(() -> EventBus.getDefault().post(new ChangeNetworkStatusEvent(Utils.getConnectedNetwork(getApplicationContext()))));
- registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
-
- registerReceiver(new WallpaperChangeReceiver(mSharedPreferences), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION), RECEIVER_NOT_EXPORTED);
+ registerReceiver(new WallpaperChangeReceiver(mSharedPreferences), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED), RECEIVER_NOT_EXPORTED);
+ } else {
+ registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
+ registerReceiver(new WallpaperChangeReceiver(mSharedPreferences), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
+ }
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
index 1c10c2ed..6825c311 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
@@ -239,7 +239,7 @@ public class EditProfileActivity extends BaseActivity {
extras.putInt(EditProfileService.EXTRA_POST_TYPE, EditProfileService.EXTRA_POST_TYPE_CHANGE_BANNER);
//TODO: contentEstimatedBytes
- JobInfo jobInfo = EditProfileService.constructJobInfo(this, 100, extras);
+ JobInfo jobInfo = EditProfileService.constructJobInfo(this, 500000, extras);
((JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(jobInfo);
break;
}
@@ -247,7 +247,7 @@ public class EditProfileActivity extends BaseActivity {
extras.putInt(EditProfileService.EXTRA_POST_TYPE, EditProfileService.EXTRA_POST_TYPE_CHANGE_AVATAR);
//TODO: contentEstimatedBytes
- JobInfo jobInfo = EditProfileService.constructJobInfo(this, 100, extras);
+ JobInfo jobInfo = EditProfileService.constructJobInfo(this, 500000, extras);
((JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(jobInfo);
break;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java
index c53356ed..9ad08b40 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java
@@ -1,5 +1,8 @@
package ml.docilealligator.infinityforreddit.activities;
+import android.app.job.JobInfo;
+import android.app.job.JobScheduler;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
@@ -10,6 +13,7 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.os.PersistableBundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -508,7 +512,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
subredditName = binding.subredditNameTextViewSubmitCrosspostActivity.getText().toString();
}
- Intent intent = new Intent(this, SubmitPostService.class);
+ /*Intent intent = new Intent(this, SubmitPostService.class);
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
intent.putExtra(SubmitPostService.EXTRA_TITLE, binding.postTitleEditTextSubmitCrosspostActivity.getText().toString());
@@ -524,7 +528,32 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
intent.putExtra(SubmitPostService.EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS,
binding.receivePostReplyNotificationsSwitchMaterialSubmitCrosspostActivity.isChecked());
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_CROSSPOST);
- ContextCompat.startForegroundService(this, intent);
+ ContextCompat.startForegroundService(this, intent);*/
+
+
+ PersistableBundle extras = new PersistableBundle();
+ extras.putString(SubmitPostService.EXTRA_ACCOUNT, selectedAccount.getJSONModel());
+ extras.putString(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
+ String title = binding.postTitleEditTextSubmitCrosspostActivity.getText().toString();
+ extras.putString(SubmitPostService.EXTRA_TITLE, title);
+ if (post.isCrosspost()) {
+ extras.putString(SubmitPostService.EXTRA_CONTENT, "t3_" + post.getCrosspostParentId());
+ } else {
+ extras.putString(SubmitPostService.EXTRA_CONTENT, post.getFullName());
+ }
+ extras.putString(SubmitPostService.EXTRA_KIND, APIUtils.KIND_CROSSPOST);
+ if (flair != null) {
+ extras.putString(SubmitPostService.EXTRA_FLAIR, flair.getJSONModel());
+ }
+ extras.putInt(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler ? 1 : 0);
+ extras.putInt(SubmitPostService.EXTRA_IS_NSFW, isNSFW ? 1 : 0);
+ extras.putInt(SubmitPostService.EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS,
+ binding.receivePostReplyNotificationsSwitchMaterialSubmitCrosspostActivity.isChecked() ? 1 : 0);
+ extras.putInt(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_CROSSPOST);
+
+ // TODO: contentEstimatedBytes
+ JobInfo jobInfo = SubmitPostService.constructJobInfo(this, title.length() * 2L + 20000, extras);
+ ((JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(jobInfo);
return true;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java
index 456b4efe..6fa3e22d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java
@@ -130,11 +130,6 @@ public class DownloadRedditVideoService extends JobService {
notificationManager.createNotificationChannel(serviceChannel);
int randomNotificationIdOffset = new Random().nextInt(10000);
- startForeground(
- NotificationUtils.DOWNLOAD_REDDIT_VIDEO_NOTIFICATION_ID + randomNotificationIdOffset,
- createNotification(builder, fileNameWithoutExtension + ".mp4")
- );
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
setNotification(params,
NotificationUtils.DOWNLOAD_REDDIT_VIDEO_NOTIFICATION_ID + randomNotificationIdOffset,