From 067fc68402d93b7db71ccfdb03bfef04e7243b65 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 23 Jan 2024 16:02:28 +0100 Subject: [PATCH] clean --- .../mastodon/activities/ContextActivity.java | 2 +- .../mastodon/activities/HashTagActivity.java | 2 +- .../activities/InstanceHealthActivity.kt | 100 +++++++++--------- .../mastodon/activities/MediaActivity.java | 26 ++--- .../activities/SearchResultTabActivity.java | 2 +- .../mastodon/client/entities/api/Status.java | 1 - .../client/entities/app/CachedBundle.java | 10 +- .../mastodon/helper/BlurHashDecoder.kt | 32 +++--- .../helper/CacheDataSourceFactory.java | 5 +- .../android/mastodon/helper/Helper.java | 2 +- .../mastodon/helper/SpannableHelper.java | 4 +- .../mastodon/ui/drawer/ComposeAdapter.java | 4 +- .../mastodon/ui/drawer/StatusAdapter.java | 2 - .../ui/drawer/StatusDirectMessageAdapter.java | 1 - .../mastodon/ui/drawer/TagsSearchAdapter.java | 4 +- .../ui/fragment/media/FragmentMedia.java | 10 +- .../fragment/media/FragmentMediaProfile.java | 5 +- .../timeline/FragmentMastodonContext.java | 3 +- .../timeline/FragmentMastodonTimeline.java | 4 +- .../timeline/FragmentProfileTimeline.java | 3 +- .../FedilabProfilePageAdapter.java | 6 +- .../viewmodel/mastodon/AccountsVM.java | 3 +- .../peertube/activities/PeertubeActivity.java | 4 +- .../activities/PeertubeMainActivity.java | 4 +- .../peertube/client/RetrofitPeertubeAPI.java | 1 - .../peertube/helper/TrackSelectionDialog.java | 1 - 26 files changed, 114 insertions(+), 127 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java index d97ab67f..8f6e2161 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java @@ -127,7 +127,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon loadRemotelyConversation(true); invalidateOptionsMenu(); } - if(currentAccount != null) { + if (currentAccount != null) { MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); } } diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java index db07020a..c87ee4c1 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java @@ -88,7 +88,7 @@ public class HashTagActivity extends BaseActivity { } private void initializeAfterBundle(Bundle bundle) { - if( bundle != null) { + if (bundle != null) { tag = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null); } if (tag == null) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/InstanceHealthActivity.kt b/app/src/main/java/app/fedilab/android/mastodon/activities/InstanceHealthActivity.kt index 1a0bd5c5..a0290ba9 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/InstanceHealthActivity.kt +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/InstanceHealthActivity.kt @@ -60,63 +60,63 @@ class InstanceHealthActivity : DialogFragment() { private fun checkInstance() { val instanceSocialVM = - ViewModelProvider(this@InstanceHealthActivity)[InstanceSocialVM::class.java] + ViewModelProvider(this@InstanceHealthActivity)[InstanceSocialVM::class.java] instanceSocialVM.getInstances(BaseMainActivity.currentInstance.trim { it <= ' ' }) - .observe(this@InstanceHealthActivity) { instanceSocialList: InstanceSocial? -> - val instance = instanceSocialList?.instances?.firstOrNull { instance -> - instance.name.equals( - BaseMainActivity.currentInstance.trim { it <= ' ' }, - ignoreCase = true - ) + .observe(this@InstanceHealthActivity) { instanceSocialList: InstanceSocial? -> + val instance = instanceSocialList?.instances?.firstOrNull { instance -> + instance.name.equals( + BaseMainActivity.currentInstance.trim { it <= ' ' }, + ignoreCase = true + ) + } + if (instance != null) { + instance.thumbnail?.takeIf { it != "null" }?.let { thumbnail -> + Glide.with(this@InstanceHealthActivity) + .asBitmap() + .placeholder(R.drawable.default_banner) + .load(thumbnail) + .into(binding.backgroundImage) } - if (instance != null) { - instance.thumbnail?.takeIf { it != "null" }?.let { thumbnail -> - Glide.with(this@InstanceHealthActivity) - .asBitmap() - .placeholder(R.drawable.default_banner) - .load(thumbnail) - .into(binding.backgroundImage) - } - binding.name.text = instance.name - if (instance.up) { - binding.up.setText(R.string.is_up) - binding.up.setTextColor( - ThemeHelper.getAttColor( - requireContext(), - R.attr.colorPrimary - ) + binding.name.text = instance.name + if (instance.up) { + binding.up.setText(R.string.is_up) + binding.up.setTextColor( + ThemeHelper.getAttColor( + requireContext(), + R.attr.colorPrimary ) - } else { - binding.up.setText(R.string.is_down) - binding.up.setTextColor( - ThemeHelper.getAttColor( - requireContext(), - R.attr.colorError - ) - ) - } - binding.uptime.text = getString( - R.string.instance_health_uptime, - instance.uptime * 100 - ) - if (instance.checked_at != null) - binding.checkedAt.text = - getString( - R.string.instance_health_checkedat, - Helper.dateToString(instance.checked_at) - ) - binding.values.text = getString( - R.string.instance_health_indication, - instance.version, - Helper.withSuffix(instance.active_users.toLong()), - Helper.withSuffix(instance.statuses.toLong()) ) } else { - binding.instanceData.isVisible = false - binding.noInstance.isVisible = true + binding.up.setText(R.string.is_down) + binding.up.setTextColor( + ThemeHelper.getAttColor( + requireContext(), + R.attr.colorError + ) + ) } - binding.loader.isVisible = false + binding.uptime.text = getString( + R.string.instance_health_uptime, + instance.uptime * 100 + ) + if (instance.checked_at != null) + binding.checkedAt.text = + getString( + R.string.instance_health_checkedat, + Helper.dateToString(instance.checked_at) + ) + binding.values.text = getString( + R.string.instance_health_indication, + instance.version, + Helper.withSuffix(instance.active_users.toLong()), + Helper.withSuffix(instance.statuses.toLong()) + ) + } else { + binding.instanceData.isVisible = false + binding.noInstance.isVisible = true } + binding.loader.isVisible = false + } } override fun onDestroyView() { diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java index f19dc11b..9e0cd5f2 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java @@ -196,7 +196,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.mediaDescriptionTranslated.setText(translated); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); binding.mediaDescription.setVisibility(View.GONE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } else { @@ -206,14 +206,14 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload }); if (attachments.get(mediaPosition - 1).translation != null) { binding.mediaDescription.setVisibility(View.GONE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setText(attachments.get(mediaPosition - 1).translation); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); } else { binding.mediaDescription.setVisibility(View.VISIBLE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); @@ -245,7 +245,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.mediaDescriptionTranslated.setText(translated); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); binding.mediaDescription.setVisibility(View.GONE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } else { @@ -256,21 +256,21 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload if (!fullscreen) { if (attachments.get(position).translation != null) { binding.mediaDescription.setVisibility(View.GONE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setText(attachments.get(position).translation); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); } else { binding.mediaDescription.setVisibility(View.VISIBLE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); } } else { binding.mediaDescription.setVisibility(View.GONE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); @@ -428,14 +428,14 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.mediaDescription.setText(linkify(MediaActivity.this, description), TextView.BufferType.SPANNABLE); if (attachments.get(binding.mediaViewpager.getCurrentItem()).translation != null) { binding.mediaDescription.setVisibility(View.GONE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setText(attachments.get(binding.mediaViewpager.getCurrentItem()).translation); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); } else { binding.mediaDescription.setVisibility(View.VISIBLE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); @@ -449,7 +449,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload } binding.mediaDescriptionTranslated.setVisibility(View.GONE); binding.mediaDescription.setVisibility(View.GONE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } @@ -458,7 +458,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.translate.setVisibility(View.GONE); binding.mediaDescriptionTranslated.setVisibility(View.GONE); binding.mediaDescription.setVisibility(View.GONE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } @@ -509,7 +509,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload if (!fullscreen) { showSystemUI(); binding.mediaDescription.setVisibility(View.VISIBLE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.translate.setVisibility(View.VISIBLE); @@ -519,7 +519,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload } else { hideSystemUI(); binding.mediaDescription.setVisibility(View.GONE); - if(mCurrentFragment != null) { + if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.translate.setVisibility(View.GONE); diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/SearchResultTabActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/SearchResultTabActivity.java index 438eb327..796d4040 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/SearchResultTabActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/SearchResultTabActivity.java @@ -132,7 +132,7 @@ public class SearchResultTabActivity extends BaseBarActivity { inflater.inflate(R.menu.menu_search, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); - if(searchView == null) { + if (searchView == null) { return true; } if (search != null) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java index 3c6598ec..cb3437ea 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java @@ -28,7 +28,6 @@ import java.lang.ref.WeakReference; import java.util.Date; import java.util.List; -import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.SpannableHelper; import de.timfreiheit.mathjax.android.MathJaxView; diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java index d414269c..870ea680 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java @@ -108,7 +108,8 @@ public class CachedBundle { Account account = null; try { account = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT); - }catch (ClassCastException ignored){} + } catch (ClassCastException ignored) { + } if (account != null) { bundleAccount.putSerializable(Helper.ARG_ACCOUNT, account); valuesAccount.put(Sqlite.COL_BUNDLE, serializeBundle(bundleAccount)); @@ -127,7 +128,8 @@ public class CachedBundle { Status status = null; try { status = (Status) bundle.getSerializable(Helper.ARG_STATUS); - }catch (ClassCastException ignored){} + } catch (ClassCastException ignored) { + } if (status != null) { bundleStatus.putSerializable(Helper.ARG_STATUS, status); valuesAccount.put(Sqlite.COL_BUNDLE, serializeBundle(bundleStatus)); @@ -170,7 +172,7 @@ public class CachedBundle { } } catch (DBException ignored) { } - if( bundle == null) { + if (bundle == null) { bundle = new Bundle(); } Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -283,7 +285,7 @@ public class CachedBundle { String dateStr = Helper.dateToString(date); try { db.delete(Sqlite.TABLE_INTENT, Sqlite.COL_CREATED_AT + " < ?", new String[]{dateStr}); - }catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/BlurHashDecoder.kt b/app/src/main/java/app/fedilab/android/mastodon/helper/BlurHashDecoder.kt index 9cc73818..e192239f 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/BlurHashDecoder.kt +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/BlurHashDecoder.kt @@ -69,20 +69,20 @@ class BlurHashDecoder { val g = (value / 19) % 19 val b = value % 19 return floatArrayOf( - signedPow2((r - 9) / 9.0f) * maxAc, - signedPow2((g - 9) / 9.0f) * maxAc, - signedPow2((b - 9) / 9.0f) * maxAc + signedPow2((r - 9) / 9.0f) * maxAc, + signedPow2((g - 9) / 9.0f) * maxAc, + signedPow2((b - 9) / 9.0f) * maxAc ) } private fun signedPow2(value: Float) = value.pow(2f).withSign(value) private fun composeBitmap( - width: Int, - height: Int, - numCompX: Int, - numCompY: Int, - colors: Array + width: Int, + height: Int, + numCompX: Int, + numCompY: Int, + colors: Array ): Bitmap { val imageArray = IntArray(width * height) for (y in 0 until height) { @@ -100,7 +100,7 @@ class BlurHashDecoder { } } imageArray[x + width * y] = - Color.rgb(linearToSrgb(r), linearToSrgb(g), linearToSrgb(b)) + Color.rgb(linearToSrgb(r), linearToSrgb(g), linearToSrgb(b)) } } return Bitmap.createBitmap(imageArray, width, height, Bitmap.Config.ARGB_8888) @@ -116,12 +116,12 @@ class BlurHashDecoder { } private val charMap = listOf( - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', - 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '#', '$', '%', '*', '+', ',', - '-', '.', ':', ';', '=', '?', '@', '[', ']', '^', '_', '{', '|', '}', '~' + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '#', '$', '%', '*', '+', ',', + '-', '.', ':', ';', '=', '?', '@', '[', ']', '^', '_', '{', '|', '}', '~' ) - .mapIndexed { i, c -> c to i } - .toMap() + .mapIndexed { i, c -> c to i } + .toMap() } \ No newline at end of file diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/CacheDataSourceFactory.java b/app/src/main/java/app/fedilab/android/mastodon/helper/CacheDataSourceFactory.java index ddfceadf..ed47b62a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/CacheDataSourceFactory.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/CacheDataSourceFactory.java @@ -19,9 +19,6 @@ import android.content.SharedPreferences; import androidx.annotation.NonNull; import androidx.media3.database.ExoDatabaseProvider; -import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter; -import androidx.preference.PreferenceManager; - import androidx.media3.datasource.DataSource; import androidx.media3.datasource.DefaultDataSourceFactory; import androidx.media3.datasource.DefaultHttpDataSource; @@ -30,6 +27,8 @@ import androidx.media3.datasource.cache.CacheDataSink; import androidx.media3.datasource.cache.CacheDataSource; import androidx.media3.datasource.cache.LeastRecentlyUsedCacheEvictor; import androidx.media3.datasource.cache.SimpleCache; +import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter; +import androidx.preference.PreferenceManager; import java.io.File; diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java index 76128f89..a489c611 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java @@ -909,7 +909,7 @@ public class Helper { if (args != null) fragment.setArguments(args); ft.add(containerViewId, fragment, tag); if (backStackName != null) ft.addToBackStack(backStackName); - if(!fragmentManager.isDestroyed()) { + if (!fragmentManager.isDestroyed()) { ft.commit(); } } diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java index f6228484..b5e9ee52 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java @@ -306,7 +306,7 @@ public class SpannableHelper { for (Mention mention : mentions) { if (word.compareToIgnoreCase("@" + mention.username) == 0) { - if(!checkRemotely) { + if (!checkRemotely) { targetedMention = mention; } else { acct = mention.acct; @@ -317,7 +317,7 @@ public class SpannableHelper { if (targetedMention != null) { args.putString(Helper.ARG_USER_ID, targetedMention.id); - } else if( acct != null){ + } else if (acct != null) { args.putString(Helper.ARG_MENTION, acct); } else { args.putString(Helper.ARG_MENTION, word); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java index 08541ce9..69520727 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java @@ -891,8 +891,8 @@ public class ComposeAdapter extends RecyclerView.Adapter implements Filterable { stat += Integer.parseInt(history.accounts); } } - if(stat > 0 ) { + if (stat > 0) { holder.binding.tagCount.setText("(" + context.getString(R.string.talking_about, stat) + ")"); holder.binding.tagCount.setVisibility(View.VISIBLE); } else { diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java index 82d98132..deeb0147 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java @@ -21,8 +21,6 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.os.Handler; -import android.os.Looper; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -97,7 +95,7 @@ public class FragmentMedia extends Fragment { @OptIn(markerClass = UnstableApi.class) public void toggleController(boolean display) { - if(display) { + if (display) { binding.controls.show(); } else { binding.controls.hide(); @@ -241,9 +239,7 @@ public class FragmentMedia extends Fragment { ); } switch (type.toLowerCase()) { - case "video": - case "audio": - case "gifv": + case "video", "audio", "gifv" -> { if (attachment.peertubeId != null) { //It's a peertube video, we are fetching data TimelinesVM timelinesVM = new ViewModelProvider(requireActivity()).get(TimelinesVM.class); @@ -258,7 +254,7 @@ public class FragmentMedia extends Fragment { } else { loadVideo(url, type); } - break; + } } } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java index c1fdd45b..197431cc 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java @@ -65,6 +65,7 @@ public class FragmentMediaProfile extends Fragment { private boolean checkRemotely; private String accountId; private Bundle arguments; + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -98,7 +99,6 @@ public class FragmentMediaProfile extends Fragment { } - private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { @@ -107,7 +107,7 @@ public class FragmentMediaProfile extends Fragment { } checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false); } - if(accountTimeline == null) { + if (accountTimeline == null) { return; } flagLoading = false; @@ -148,7 +148,6 @@ public class FragmentMediaProfile extends Fragment { } - /** * Intialize the common view for statuses on different timelines * diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java index fc4699a7..81f1c00a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java @@ -138,6 +138,7 @@ public class FragmentMastodonContext extends Fragment { private Status firstStatus; private boolean pullToRefresh; private String user_token, user_instance; + private Bundle arguments; /** * Return the position of the status in the ArrayList @@ -158,8 +159,6 @@ public class FragmentMastodonContext extends Fragment { return found ? position : -1; } - private Bundle arguments; - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java index 5177cc65..b2397dfd 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -91,7 +91,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. private StatusAdapter statusAdapter; private Timeline.TimeLineEnum timelineType; private List timelineStatuses; - private Bundle arguments; //Handle actions that can be done in other fragments private final BroadcastReceiver receive_action = new BroadcastReceiver() { @Override @@ -184,6 +183,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } } }; + private Bundle arguments; private boolean retry_for_home_done; private String lemmy_post_id; private boolean checkRemotely; @@ -351,7 +351,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } - @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -393,6 +392,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } } } + private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { timelineType = (Timeline.TimeLineEnum) bundle.get(Helper.ARG_TIMELINE_TYPE); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java index e0b5bc73..1169004f 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java @@ -48,12 +48,14 @@ public class FragmentProfileTimeline extends Fragment { private boolean checkRemotely; private boolean show_boosts = true, show_replies = true; private Bundle arguments; + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { binding = FragmentProfileTimelinesBinding.inflate(inflater, container, false); arguments = getArguments(); return binding.getRoot(); } + @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); @@ -169,5 +171,4 @@ public class FragmentProfileTimeline extends Fragment { } - } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/pageadapter/FedilabProfilePageAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/pageadapter/FedilabProfilePageAdapter.java index 22f55cd9..fa198615 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/pageadapter/FedilabProfilePageAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/pageadapter/FedilabProfilePageAdapter.java @@ -61,7 +61,7 @@ public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter { case 0 -> { fragmentMastodonTimeline = new FragmentMastodonTimeline(); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE); - if(account != null) { + if (account != null) { bundle.putSerializable(Helper.ARG_CACHED_ACCOUNT_ID, account.id); } bundle.putBoolean(Helper.ARG_SHOW_PINNED, true); @@ -74,7 +74,7 @@ public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter { case 1 -> { fragmentMastodonTimeline = new FragmentMastodonTimeline(); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE); - if(account != null) { + if (account != null) { bundle.putSerializable(Helper.ARG_CACHED_ACCOUNT_ID, account.id); } bundle.putBoolean(Helper.ARG_SHOW_PINNED, false); @@ -86,7 +86,7 @@ public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter { } case 2 -> { FragmentMediaProfile fragmentMediaProfile = new FragmentMediaProfile(); - if(account != null) { + if (account != null) { bundle.putSerializable(Helper.ARG_CACHED_ACCOUNT_ID, account.id); } bundle.putBoolean(Helper.ARG_CHECK_REMOTELY, checkRemotely); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java index ed91fe5d..f64c9217 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java @@ -32,7 +32,6 @@ import java.util.List; import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; -import app.fedilab.android.mastodon.activities.ProfileActivity; import app.fedilab.android.mastodon.client.endpoints.MastodonAccountsService; import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Accounts; @@ -1078,7 +1077,7 @@ public class AccountsVM extends AndroidViewModel { Response> searchResponse = searchCall.execute(); if (searchResponse.isSuccessful()) { accountList = searchResponse.body(); - if(accountList != null && accountList.size() > 0 ) { + if (accountList != null && accountList.size() > 0) { new CachedBundle(getApplication().getApplicationContext()).insertAccountBundle(accountList.get(0), currentAccount); } } diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java index 02b40f62..544892a5 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java @@ -105,10 +105,9 @@ import androidx.media3.exoplayer.source.SingleSampleMediaSource; import androidx.media3.exoplayer.trackselection.AdaptiveTrackSelection; import androidx.media3.exoplayer.trackselection.DefaultTrackSelector; import androidx.media3.exoplayer.trackselection.TrackSelector; -import androidx.media3.session.MediaSession; import androidx.media3.ui.AspectRatioFrameLayout; -import androidx.media3.ui.PlayerControlView; import androidx.media3.ui.DefaultTimeBar; +import androidx.media3.ui.PlayerControlView; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -209,6 +208,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis private Status status; private int flags; private boolean humanInteraction; + public static void hideKeyboard(Activity activity) { if (activity != null && activity.getWindow() != null) { activity.getWindow().getDecorView(); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java index 96c7a8d2..105114ae 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java @@ -40,7 +40,6 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -513,7 +512,8 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity { Intent notificationIntent = new Intent(this, RetrieveInfoService.class); try { startService(notificationIntent); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } @Override diff --git a/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java b/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java index cef50847..5fea73c9 100644 --- a/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java +++ b/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java @@ -18,7 +18,6 @@ import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN; -import static app.fedilab.android.peertube.helper.Helper.peertubeInformation; import android.app.Activity; import android.content.Context; diff --git a/app/src/main/java/app/fedilab/android/peertube/helper/TrackSelectionDialog.java b/app/src/main/java/app/fedilab/android/peertube/helper/TrackSelectionDialog.java index 6090d123..e2f0d2a7 100644 --- a/app/src/main/java/app/fedilab/android/peertube/helper/TrackSelectionDialog.java +++ b/app/src/main/java/app/fedilab/android/peertube/helper/TrackSelectionDialog.java @@ -31,7 +31,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import app.fedilab.android.R; import app.fedilab.android.databinding.TrackSelectionDialogBinding;