mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Use some Compat classes
This commit is contained in:
parent
6247868949
commit
b98291c05d
@ -14,6 +14,7 @@ import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@ -248,7 +249,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
|
||||
|
||||
@Subscribe
|
||||
public void onRecreateActivityEvent(RecreateActivityEvent recreateActivityEvent) {
|
||||
recreate();
|
||||
ActivityCompat.recreate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,7 @@ import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@ -1144,7 +1145,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
|
||||
@Subscribe
|
||||
public void onRecreateActivityEvent(RecreateActivityEvent recreateActivityEvent) {
|
||||
recreate();
|
||||
ActivityCompat.recreate(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -22,6 +22,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
@ -528,11 +529,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
}
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(intent);
|
||||
} else {
|
||||
startService(intent);
|
||||
}
|
||||
ContextCompat.startForegroundService(this, intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
@ -449,7 +450,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
||||
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TEXT_OR_LINK);
|
||||
startService(intent);
|
||||
ContextCompat.startForegroundService(this, intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@ -466,7 +467,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
||||
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TEXT_OR_LINK);
|
||||
startService(intent);
|
||||
ContextCompat.startForegroundService(this, intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
@ -528,11 +529,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_VIDEO);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(intent);
|
||||
} else {
|
||||
startService(intent);
|
||||
}
|
||||
ContextCompat.startForegroundService(this, intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
@ -192,6 +193,6 @@ public class SettingsActivity extends BaseActivity implements
|
||||
|
||||
@Subscribe
|
||||
public void onRecreateActivityEvent(RecreateActivityEvent recreateActivityEvent) {
|
||||
recreate();
|
||||
ActivityCompat.recreate(this);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
@ -520,7 +521,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
||||
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_CROSSPOST);
|
||||
startService(intent);
|
||||
ContextCompat.startForegroundService(this, intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
|
||||
|
||||
isDownloading = true;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (ContextCompat.checkSelfPermission(this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
@ -341,11 +341,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
|
||||
intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, isGif ? DownloadMediaService.EXTRA_MEDIA_TYPE_GIF : DownloadMediaService.EXTRA_MEDIA_TYPE_IMAGE);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, mImageFileName);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, mSubredditName);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(intent);
|
||||
} else {
|
||||
startService(intent);
|
||||
}
|
||||
ContextCompat.startForegroundService(this, intent);
|
||||
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ public class ViewVideoActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
isDownloading = true;
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (ContextCompat.checkSelfPermission(this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
@ -472,29 +472,20 @@ public class ViewVideoActivity extends AppCompatActivity {
|
||||
private void download() {
|
||||
isDownloading = false;
|
||||
|
||||
Intent intent;
|
||||
if (videoType != VIDEO_TYPE_NORMAL) {
|
||||
Intent intent = new Intent(this, DownloadMediaService.class);
|
||||
intent = new Intent(this, DownloadMediaService.class);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_URL, videoDownloadUrl);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_VIDEO);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, videoFileName);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(intent);
|
||||
} else {
|
||||
startService(intent);
|
||||
}
|
||||
} else {
|
||||
Intent intent = new Intent(this, DownloadRedditVideoService.class);
|
||||
intent = new Intent(this, DownloadRedditVideoService.class);
|
||||
intent.putExtra(DownloadRedditVideoService.EXTRA_VIDEO_URL, videoDownloadUrl);
|
||||
intent.putExtra(DownloadRedditVideoService.EXTRA_POST_ID, id);
|
||||
intent.putExtra(DownloadRedditVideoService.EXTRA_SUBREDDIT, subredditName);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(intent);
|
||||
} else {
|
||||
startService(intent);
|
||||
}
|
||||
}
|
||||
ContextCompat.startForegroundService(this, intent);
|
||||
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.bottomsheetfragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -49,7 +50,7 @@ public class SetAsWallpaperBottomSheetFragment extends RoundedBottomSheetDialogF
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
homeScreenTextvView.setVisibility(View.VISIBLE);
|
||||
lockScreenTextView.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -21,7 +21,8 @@ public class LollipopBugFixedWebView extends WebView{
|
||||
|
||||
// To fix Android Lollipop WebView problem create a new configuration on that Android version only
|
||||
private static Context getFixedContext(Context context) {
|
||||
if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) // Android Lollipop 5.0 & 5.1
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP
|
||||
|| Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) // Android Lollipop 5.0 & 5.1
|
||||
return context.createConfigurationContext(new Configuration());
|
||||
return context;
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public class ViewImgurImageFragment extends Fragment {
|
||||
|
||||
isDownloading = true;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (ContextCompat.checkSelfPermission(activity,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
@ -238,11 +238,7 @@ public class ViewImgurImageFragment extends Fragment {
|
||||
intent.putExtra(DownloadMediaService.EXTRA_URL, imgurMedia.getLink());
|
||||
intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_IMAGE);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, imgurMedia.getFileName());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
activity.startForegroundService(intent);
|
||||
} else {
|
||||
activity.startService(intent);
|
||||
}
|
||||
ContextCompat.startForegroundService(activity, intent);
|
||||
Toast.makeText(activity, R.string.download_started, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class ViewImgurVideoFragment extends Fragment {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_download_view_imgur_video_fragment) {
|
||||
isDownloading = true;
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (ContextCompat.checkSelfPermission(activity,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
@ -189,11 +189,7 @@ public class ViewImgurVideoFragment extends Fragment {
|
||||
intent.putExtra(DownloadMediaService.EXTRA_URL, imgurMedia.getLink());
|
||||
intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_VIDEO);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, imgurMedia.getFileName());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
activity.startForegroundService(intent);
|
||||
} else {
|
||||
activity.startService(intent);
|
||||
}
|
||||
ContextCompat.startForegroundService(activity, intent);
|
||||
Toast.makeText(activity, R.string.download_started, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
||||
|
||||
isDownloading = true;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (ContextCompat.checkSelfPermission(activity,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
@ -272,11 +272,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
||||
intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, media.mediaType == Post.Gallery.TYPE_GIF ? DownloadMediaService.EXTRA_MEDIA_TYPE_GIF: DownloadMediaService.EXTRA_MEDIA_TYPE_IMAGE);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, media.fileName);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
activity.startForegroundService(intent);
|
||||
} else {
|
||||
activity.startService(intent);
|
||||
}
|
||||
ContextCompat.startForegroundService(activity, intent);
|
||||
Toast.makeText(activity, R.string.download_started, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_download_view_reddit_gallery_video_fragment) {
|
||||
isDownloading = true;
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (ContextCompat.checkSelfPermission(activity,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
@ -193,11 +193,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment {
|
||||
intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_VIDEO);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, galleryVideo.fileName);
|
||||
intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
activity.startForegroundService(intent);
|
||||
} else {
|
||||
activity.startService(intent);
|
||||
}
|
||||
ContextCompat.startForegroundService(activity, intent);
|
||||
Toast.makeText(activity, R.string.download_started, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ public class DownloadMediaService extends Service {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
String destinationFileDirectory = getDownloadLocation(mediaType);
|
||||
if (destinationFileDirectory.equals("")) {
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
File directory = getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
||||
if (directory != null) {
|
||||
String directoryPath = separateDownloadFolder && subredditName != null && !subredditName.equals("") ? directory.getAbsolutePath() + "/Infinity/" + subredditName + "/" : directory.getAbsolutePath() + "/Infinity/";
|
||||
@ -235,7 +235,7 @@ public class DownloadMediaService extends Service {
|
||||
int mediaType) throws IOException {
|
||||
ContentResolver contentResolver = getContentResolver();
|
||||
if (isDefaultDestination) {
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
InputStream inputStream = body.byteStream();
|
||||
OutputStream outputStream = new FileOutputStream(destinationFileUriString);
|
||||
byte[] fileReader = new byte[4096];
|
||||
|
@ -146,7 +146,7 @@ public class DownloadRedditVideoService extends Service {
|
||||
String destinationFileUriString;
|
||||
boolean isDefaultDestination;
|
||||
if (destinationFileDirectory.equals("")) {
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
File destinationDirectory = getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
||||
if (destinationDirectory != null) {
|
||||
String destinationDirectoryPath = separateDownloadFolder ? destinationDirectory.getAbsolutePath() + "/Infinity/" + subredditName + "/" : destinationDirectory.getAbsolutePath() + "/Infinity/";
|
||||
@ -396,7 +396,7 @@ public class DownloadRedditVideoService extends Service {
|
||||
boolean isDefaultDestination) throws IOException {
|
||||
ContentResolver contentResolver = getContentResolver();
|
||||
if (isDefaultDestination) {
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
InputStream in = new FileInputStream(srcPath);
|
||||
OutputStream out = new FileOutputStream(destinationFileUriString);
|
||||
byte[] buf = new byte[1024];
|
||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
@ -30,7 +31,7 @@ public class FontPreferenceFragment extends PreferenceFragmentCompat {
|
||||
if (fontFamilyPreference != null) {
|
||||
fontFamilyPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||
activity.recreate();
|
||||
ActivityCompat.recreate(activity);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -52,7 +53,7 @@ public class FontPreferenceFragment extends PreferenceFragmentCompat {
|
||||
if (fontSizePreference != null) {
|
||||
fontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||
activity.recreate();
|
||||
ActivityCompat.recreate(activity);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.ListPreference;
|
||||
@ -109,7 +110,7 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat {
|
||||
amoledDarkSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_NO) {
|
||||
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||
activity.recreate();
|
||||
ActivityCompat.recreate(activity);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.utils;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
@ -36,7 +37,7 @@ public class NotificationUtils {
|
||||
Context context, String title, String content,
|
||||
String summary, String channelId, String channelName,
|
||||
String group, int color) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
@ -56,7 +57,7 @@ public class NotificationUtils {
|
||||
public static NotificationCompat.Builder buildSummaryNotification(Context context, NotificationManagerCompat notificationManager,
|
||||
String title, String content, String channelId,
|
||||
String channelName, String group, int color) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@ -17,6 +16,7 @@ import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
@ -135,13 +135,10 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static void setHTMLWithImageToTextView(TextView textView, String content, boolean enlargeImage) {
|
||||
Spannable html;
|
||||
GlideImageGetter glideImageGetter = new GlideImageGetter(textView, enlargeImage);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
html = (Spannable) Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
|
||||
} else {
|
||||
html = (Spannable) Html.fromHtml(content, glideImageGetter, null);
|
||||
}
|
||||
Spannable html = (Spannable) HtmlCompat.fromHtml(
|
||||
content, HtmlCompat.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
|
||||
|
||||
textView.setText(html);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user