Some cleaning

This commit is contained in:
Thomas 2024-01-09 16:00:35 +01:00
parent 2edfd8c945
commit 1ff15b0f93
58 changed files with 215 additions and 282 deletions

View file

@ -36,7 +36,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.database.MatrixCursor;
import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
@ -73,7 +72,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SearchView;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.cursoradapter.widget.CursorAdapter;
@ -81,7 +79,6 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
@ -1625,8 +1622,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
if (binding.viewPager.getAdapter() != null) {
int tabPosition = binding.tabLayout.getSelectedTabPosition();
Fragment fragment = (Fragment) binding.viewPager.getAdapter().instantiateItem(binding.viewPager, Math.max(tabPosition, 0));
if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) {
FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
if (fragment instanceof FragmentMastodonTimeline fragmentMastodonTimeline && fragment.isVisible()) {
fragmentMastodonTimeline.refreshAllAdapters();
}
}
@ -1921,14 +1917,11 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
int position = binding.tabLayout.getSelectedTabPosition();
if (binding.viewPager.getAdapter() != null) {
Fragment fragment = (Fragment) binding.viewPager.getAdapter().instantiateItem(binding.viewPager, Math.max(position, 0));
if (fragment instanceof FragmentMastodonTimeline) {
FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
if (fragment instanceof FragmentMastodonTimeline fragmentMastodonTimeline) {
fragmentMastodonTimeline.scrollToTop();
} else if (fragment instanceof FragmentMastodonConversation) {
FragmentMastodonConversation fragmentMastodonConversation = ((FragmentMastodonConversation) fragment);
} else if (fragment instanceof FragmentMastodonConversation fragmentMastodonConversation) {
fragmentMastodonConversation.scrollToTop();
} else if (fragment instanceof FragmentNotificationContainer) {
FragmentNotificationContainer fragmentNotificationContainer = ((FragmentNotificationContainer) fragment);
} else if (fragment instanceof FragmentNotificationContainer fragmentNotificationContainer) {
fragmentNotificationContainer.scrollToTop();
}
}

View file

@ -28,7 +28,6 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import androidx.core.app.ActivityOptionsCompat;
import androidx.lifecycle.ViewModelProvider;
import java.util.ArrayList;

View file

@ -52,6 +52,7 @@ public class AccountReportActivity extends BaseBarActivity {
private ActivityAdminReportBinding binding;
private AdminVM adminVM;
private AdminAccount targeted_account;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -73,6 +74,7 @@ public class AccountReportActivity extends BaseBarActivity {
initializeAfterBundle(null);
}
}
private void initializeAfterBundle(Bundle bundle) {
if (bundle != null) {

View file

@ -39,7 +39,6 @@ import org.conscrypt.Conscrypt;
import java.security.Security;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.ThemeHelper;

View file

@ -50,7 +50,6 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.work.Data;

View file

@ -33,7 +33,6 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.ViewModelProvider;
import com.bumptech.glide.Glide;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.TextInputEditText;

View file

@ -40,7 +40,6 @@ import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
import app.fedilab.android.databinding.ActivityFollowedTagsBinding;
import app.fedilab.android.databinding.PopupAddFollowedTagtBinding;
import app.fedilab.android.mastodon.client.entities.api.MastodonList;
import app.fedilab.android.mastodon.client.entities.api.Tag;
import app.fedilab.android.mastodon.client.entities.app.Timeline;
import app.fedilab.android.mastodon.helper.Helper;

View file

@ -29,7 +29,6 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.ViewModelProvider;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.ArrayList;

View file

@ -32,7 +32,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

View file

@ -300,7 +300,8 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
finish();
try {
ActivityCompat.finishAfterTransition(MediaActivity.this);
}catch (Exception ignored){}
} catch (Exception ignored) {
}
return true;
} else if (item.getItemId() == R.id.action_save) {
int position = binding.mediaViewpager.getCurrentItem();

View file

@ -25,7 +25,6 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import androidx.core.app.ActivityOptionsCompat;
import androidx.lifecycle.ViewModelProvider;
import java.util.ArrayList;

View file

@ -54,7 +54,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

View file

@ -31,7 +31,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;

View file

@ -114,14 +114,11 @@ public class SearchResultTabActivity extends BaseBarActivity {
Fragment fragment;
if (binding.searchViewpager.getAdapter() != null) {
fragment = (Fragment) binding.searchViewpager.getAdapter().instantiateItem(binding.searchViewpager, tab.getPosition());
if (fragment instanceof FragmentMastodonAccount) {
FragmentMastodonAccount fragmentMastodonAccount = ((FragmentMastodonAccount) fragment);
if (fragment instanceof FragmentMastodonAccount fragmentMastodonAccount) {
fragmentMastodonAccount.scrollToTop();
} else if (fragment instanceof FragmentMastodonTimeline) {
FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
} else if (fragment instanceof FragmentMastodonTimeline fragmentMastodonTimeline) {
fragmentMastodonTimeline.scrollToTop();
} else if (fragment instanceof FragmentMastodonTag) {
FragmentMastodonTag fragmentMastodonTag = ((FragmentMastodonTag) fragment);
} else if (fragment instanceof FragmentMastodonTag fragmentMastodonTag) {
fragmentMastodonTag.scrollToTop();
}
}

View file

@ -27,7 +27,6 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.ViewModelProvider;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.Objects;

View file

@ -48,7 +48,6 @@ import com.bumptech.glide.request.transition.Transition;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

View file

@ -19,16 +19,13 @@ import static app.fedilab.android.BaseMainActivity.emojis;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteBlobTooBigException;
import android.database.sqlite.SQLiteDatabase;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModelProvider;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
@ -41,7 +38,6 @@ import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.mastodon.client.endpoints.MastodonInstanceService;
import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.viewmodel.mastodon.InstancesVM;
import app.fedilab.android.sqlite.Sqlite;
import okhttp3.OkHttpClient;
import retrofit2.Call;
@ -230,17 +226,12 @@ public class EmojiInstance implements Serializable {
}
}
public interface EmojiFilteredCallBack{
void get(List<Emoji> emojiList);
}
/**
* Returns the emojis for an instance
*
* @param instance String
* @param filter String
* @param callBack EmojiFilteredCallBack - Get filtered emojis
*
* @return List<Emoji> - List of {@link Emoji}
*/
public void getEmojiListFiltered(@NonNull String instance, @NonNull String filter, EmojiFilteredCallBack callBack) throws DBException {
@ -311,4 +302,8 @@ public class EmojiInstance implements Serializable {
}
return filteredEmojis;
}
public interface EmojiFilteredCallBack {
void get(List<Emoji> emojiList);
}
}

View file

@ -32,7 +32,8 @@ public class Tag implements Serializable {
@SerializedName("following")
public boolean following = false;
public Tag() {}
public Tag() {
}
public Tag(String name) {
this.name = name;

View file

@ -56,7 +56,9 @@ public class CachedBundle {
private transient Context context;
public CachedBundle() {}
public CachedBundle() {
}
public CachedBundle(Context context) {
//Creation of the DB with tables
this.context = context;
@ -119,14 +121,6 @@ public class CachedBundle {
}
}
public interface BundleCallback{
void get(Bundle bundle);
}
public interface BundleInsertCallback{
void inserted(long bundleId);
}
public void getBundle(long id, BaseAccount Account, BundleCallback callback) {
new Thread(() -> {
Bundle bundle = null;
@ -148,7 +142,8 @@ public class CachedBundle {
}
}
removeIntent(String.valueOf(id));
} catch (DBException ignored) {}
} catch (DBException ignored) {
}
Handler mainHandler = new Handler(Looper.getMainLooper());
Bundle finalBundle = bundle;
Runnable myRunnable = () -> callback.get(finalBundle);
@ -161,7 +156,8 @@ public class CachedBundle {
long dbBundleId = -1;
try {
dbBundleId = insertIntent(bundle, Account);
} catch (DBException ignored) {}
} catch (DBException ignored) {
}
Handler mainHandler = new Handler(Looper.getMainLooper());
long finalDbBundleId = dbBundleId;
Runnable myRunnable = () -> callback.inserted(finalDbBundleId);
@ -169,8 +165,6 @@ public class CachedBundle {
}).start();
}
/**
* Returns a bundle by targeted account id
*
@ -199,7 +193,6 @@ public class CachedBundle {
return null;
}
/**
* Returns a bundle by targeted status id
*
@ -228,7 +221,6 @@ public class CachedBundle {
return null;
}
/**
* Returns a bundle by its ID
*
@ -259,10 +251,8 @@ public class CachedBundle {
db.delete(Sqlite.TABLE_INTENT, Sqlite.COL_ID + " = '" + id + "'", null);
}
/**
* Remove a bundle from db
*
*/
private void removeIntent(BaseAccount account, String target_id) throws DBException {
if (db == null) {
@ -276,7 +266,6 @@ public class CachedBundle {
+ Sqlite.COL_TARGET_ID + " = '" + target_id + "'", null);
}
/***
* Method to hydrate an CachedBundle from database
* @param c Cursor
@ -356,7 +345,6 @@ public class CachedBundle {
return bundle;
}
public enum CacheType {
@SerializedName("ARGS")
ARGS("ARGS"),
@ -370,9 +358,19 @@ public class CachedBundle {
CacheType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
public interface BundleCallback {
void get(Bundle bundle);
}
public interface BundleInsertCallback {
void inserted(long bundleId);
}
}

View file

@ -23,7 +23,6 @@ import java.util.ArrayList;
import java.util.regex.Matcher;
public class ComposeHelper {

View file

@ -78,7 +78,6 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.browser.customtabs.CustomTabColorSchemeParams;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.content.ContextCompat;
@ -89,7 +88,6 @@ import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -848,7 +846,7 @@ public class Helper {
@SuppressLint("DefaultLocale")
public static String withSuffix(long count) {
if (count < 1000) return "" + count;
if (count < 1000) return String.valueOf(count);
int exp = (int) (Math.log(count) / Math.log(1000));
Locale locale = null;
try {
@ -1000,8 +998,7 @@ public class Helper {
if (context == null) {
return false;
}
if (context instanceof Activity) {
final Activity activity = (Activity) context;
if (context instanceof Activity activity) {
return !activity.isDestroyed() && !activity.isFinishing();
}
return true;
@ -1611,7 +1608,7 @@ public class Helper {
message = message.substring(0, 499) + "";
}
}*/
notificationBuilder.setGroup(account.mastodon_account != null ? account.mastodon_account.username + "@" + account.instance : "" + "@" + account.instance)
notificationBuilder.setGroup(account.mastodon_account != null ? account.mastodon_account.username + "@" + account.instance : "@" + account.instance)
.setContentIntent(pIntent)
.setContentText(message);
int ledColour = Color.BLUE;
@ -1673,7 +1670,7 @@ public class Helper {
.setLargeIcon(icon)
.setSmallIcon(getNotificationIcon(context))
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setGroup(account.mastodon_account != null ? account.mastodon_account.username + "@" + account.instance : "" + "@" + account.instance)
.setGroup(account.mastodon_account != null ? account.mastodon_account.username + "@" + account.instance : "@" + account.instance)
.setGroupSummary(true)
.build();

View file

@ -679,8 +679,7 @@ public class PinnedTimelineHelper {
popup.setOnDismissListener(menu1 -> {
if (activityMainBinding.viewPager.getAdapter() != null && activityMainBinding.tabLayout.getSelectedTabPosition() != -1) {
Fragment fragment = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) {
FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
if (fragment instanceof FragmentMastodonTimeline fragmentMastodonTimeline && fragment.isVisible()) {
fragmentMastodonTimeline.refreshAllAdapters();
}
}

View file

@ -176,13 +176,11 @@ public class ThemeHelper {
String[] list;
try {
list = context.getAssets().list("themes/contributors");
if (list.length > 0) {
for (String file : list) {
InputStream is = context.getAssets().open("themes/contributors/" + file);
LinkedHashMap<String, String> data = readCSVFile(is);
linkedHashMaps.add(data);
}
}
} catch (IOException e) {
e.printStackTrace();
}

View file

@ -102,9 +102,8 @@ public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
// We only want the active item to change
if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
if (viewHolder instanceof ItemTouchHelperViewHolder) {
if (viewHolder instanceof ItemTouchHelperViewHolder itemViewHolder) {
// Let the view holder know that this item is being moved or dragged
ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder;
itemViewHolder.onItemSelected();
}
}
@ -118,9 +117,8 @@ public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
viewHolder.itemView.setAlpha(ALPHA_FULL);
if (viewHolder instanceof ItemTouchHelperViewHolder) {
if (viewHolder instanceof ItemTouchHelperViewHolder itemViewHolder) {
// Tell the view holder it's time to restore the idle state
ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder;
itemViewHolder.onItemClear();
}
}

View file

@ -73,8 +73,7 @@ public class TimePreferenceDialogFragment extends PreferenceDialogFragmentCompat
// Generate value to save
String time = hour + ":" + minute;
DialogPreference preference = getPreference();
if (preference instanceof TimePreference) {
TimePreference timePreference = ((TimePreference) preference);
if (preference instanceof TimePreference timePreference) {
if (timePreference.callChangeListener(time)) {
timePreference.setTime(time);
}

View file

@ -22,7 +22,6 @@ import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.exifinterface.media.ExifInterface;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.transition.ChangeBounds;
import androidx.transition.TransitionManager;

View file

@ -47,10 +47,8 @@ public class BaseActivity extends AppCompatActivity {
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case READ_WRITE_STORAGE:
if (requestCode == READ_WRITE_STORAGE) {
isPermissionGranted(grantResults[0] == PackageManager.PERMISSION_GRANTED, permissions[0]);
break;
}
}

View file

@ -32,7 +32,6 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.preference.PreferenceManager;
import androidx.work.Data;
import androidx.work.ForegroundInfo;

View file

@ -17,7 +17,6 @@ package app.fedilab.android.mastodon.ui.drawer;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -31,7 +30,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityOptionsCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;

View file

@ -16,7 +16,6 @@ package app.fedilab.android.mastodon.ui.drawer;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -26,7 +25,6 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityOptionsCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;

View file

@ -51,7 +51,6 @@ import android.view.inputmethod.InputMethodManager;
import android.webkit.URLUtil;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -110,7 +109,6 @@ import app.fedilab.android.databinding.DrawerStatusComposeBinding;
import app.fedilab.android.databinding.DrawerStatusSimpleBinding;
import app.fedilab.android.mastodon.activities.ComposeActivity;
import app.fedilab.android.mastodon.activities.MediaActivity;
import app.fedilab.android.mastodon.activities.SearchResultTabActivity;
import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.Attachment;
import app.fedilab.android.mastodon.client.entities.api.Emoji;

View file

@ -19,7 +19,6 @@ import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentNightMode;
import static app.fedilab.android.mastodon.ui.drawer.StatusAdapter.statusManagement;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -31,7 +30,6 @@ import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityOptionsCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;

View file

@ -88,7 +88,6 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -3238,8 +3237,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder viewHolder) {
super.onViewRecycled(viewHolder);
if (viewHolder instanceof StatusViewHolder) {
StatusViewHolder holder = (StatusViewHolder) viewHolder;
if (viewHolder instanceof StatusViewHolder holder) {
if (holder.binding != null) {
PlayerView doubleTapPlayerView = holder.binding.media.getRoot().findViewById(R.id.media_video);
if (doubleTapPlayerView != null && doubleTapPlayerView.getPlayer() != null) {

View file

@ -17,7 +17,6 @@ package app.fedilab.android.mastodon.ui.drawer;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -28,7 +27,6 @@ import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityOptionsCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;
import androidx.preference.PreferenceManager;

View file

@ -111,11 +111,15 @@ public class FragmentMedia extends Fragment {
}
});
binding.mediaPicture.setOnClickListener(v -> {
if(isAdded()){((MediaActivity) requireActivity()).toogleFullScreen();}
if (isAdded()) {
((MediaActivity) requireActivity()).toogleFullScreen();
}
});
binding.mediaVideo.setOnClickListener(v -> {
if(isAdded()) {((MediaActivity) requireActivity()).toogleFullScreen();}
if (isAdded()) {
((MediaActivity) requireActivity()).toogleFullScreen();
}
});
String type = attachment.type;
@ -367,7 +371,8 @@ public class FragmentMedia extends Fragment {
binding.videoLayout.setVisibility(View.GONE);
try {
ActivityCompat.finishAfterTransition(requireActivity());
}catch (Exception ignored){}
} catch (Exception ignored) {
}
}
}

View file

@ -31,6 +31,7 @@ import app.fedilab.android.mastodon.helper.Helper;
public class FragmentTimelinesSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
boolean recreate;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.pref_timelines);

View file

@ -39,7 +39,6 @@ import java.util.List;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.databinding.FragmentPaginationBinding;
import app.fedilab.android.mastodon.activities.SearchResultTabActivity;
import app.fedilab.android.mastodon.client.entities.api.Account;

View file

@ -21,7 +21,6 @@ import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -31,7 +30,6 @@ import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -59,7 +57,6 @@ public class FragmentMastodonContext extends Fragment {
private StatusesVM statusesVM;
private List<Status> statuses;
private StatusAdapter statusAdapter;
private boolean refresh;
//Handle actions that can be done in other fragments
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
@Override
@ -128,6 +125,7 @@ public class FragmentMastodonContext extends Fragment {
}
}
};
private boolean refresh;
private Status focusedStatus;
private String remote_instance, focusedStatusURI;
private Status firstStatus;

View file

@ -50,7 +50,6 @@ import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.work.Data;

View file

@ -19,7 +19,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
@ -31,7 +30,6 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

View file

@ -36,7 +36,6 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -63,7 +62,6 @@ import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
import app.fedilab.android.mastodon.client.entities.app.RemoteInstance;
import app.fedilab.android.mastodon.client.entities.app.TagTimeline;
import app.fedilab.android.mastodon.client.entities.app.Timeline;
import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.CrossActionHelper;
import app.fedilab.android.mastodon.helper.GlideApp;
import app.fedilab.android.mastodon.helper.Helper;

View file

@ -224,8 +224,7 @@ public class FragmentNotificationContainer extends Fragment {
Fragment fragment;
if (binding.viewpagerNotificationContainer.getAdapter() != null) {
fragment = (Fragment) binding.viewpagerNotificationContainer.getAdapter().instantiateItem(binding.viewpagerNotificationContainer, tab.getPosition());
if (fragment instanceof FragmentMastodonNotification) {
FragmentMastodonNotification fragmentMastodonNotification = ((FragmentMastodonNotification) fragment);
if (fragment instanceof FragmentMastodonNotification fragmentMastodonNotification) {
fragmentMastodonNotification.scrollToTop();
}
}

View file

@ -91,10 +91,7 @@ public class FragmentProfileTimeline extends Fragment {
public void onTabReselected(TabLayout.Tab tab) {
if (binding.viewpager.getAdapter() != null && binding.viewpager
.getAdapter()
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem()) instanceof FragmentMastodonTimeline) {
FragmentMastodonTimeline fragmentMastodonTimeline = (FragmentMastodonTimeline) binding.viewpager
.getAdapter()
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem());
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem()) instanceof FragmentMastodonTimeline fragmentMastodonTimeline) {
fragmentMastodonTimeline.goTop();
}
}
@ -116,10 +113,7 @@ public class FragmentProfileTimeline extends Fragment {
popup.setOnDismissListener(menu1 -> {
if (binding.viewpager.getAdapter() != null && binding.viewpager
.getAdapter()
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem()) instanceof FragmentMastodonTimeline) {
FragmentMastodonTimeline fragmentMastodonTimeline = (FragmentMastodonTimeline) binding.viewpager
.getAdapter()
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem());
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem()) instanceof FragmentMastodonTimeline fragmentMastodonTimeline) {
FragmentTransaction fragTransaction = getChildFragmentManager().beginTransaction();
fragTransaction.detach(fragmentMastodonTimeline).commit();
Bundle args = new Bundle();

View file

@ -61,7 +61,6 @@ import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.preference.PreferenceManager;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

View file

@ -47,6 +47,7 @@ import java.io.UnsupportedEncodingException;
import java.net.IDN;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
@ -178,11 +179,8 @@ public class RetrofitPeertubeAPI {
error.printStackTrace();
return;
}
try {
//At the state the instance can be encoded
instance = URLDecoder.decode(instance, "utf-8");
} catch (UnsupportedEncodingException ignored) {
}
instance = URLDecoder.decode(instance, StandardCharsets.UTF_8);
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
account.token = token;
account.client_id = client_id;

View file

@ -17,7 +17,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.ListPreference;
import androidx.preference.MultiSelectListPreference;
import androidx.preference.Preference;

View file

@ -57,7 +57,6 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
import com.avatarfirst.avatargenlib.AvatarGenerator;
@ -276,7 +275,7 @@ public class Helper {
* @return String rounded value to be displayed
*/
public static String withSuffix(long count) {
if (count < 1000) return "" + count;
if (count < 1000) return String.valueOf(count);
int exp = (int) (Math.log(count) / Math.log(1000));
Locale locale = null;
try {

View file

@ -109,11 +109,10 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
if (view instanceof FrameLayout) {
if (view instanceof FrameLayout frameLayout) {
if (((AppCompatActivity) activity).getSupportActionBar() != null)
((AppCompatActivity) activity).getSupportActionBar().hide();
// A video wants to be shown
FrameLayout frameLayout = (FrameLayout) view;
View focusedChild = frameLayout.getFocusedChild();
// Save video related variables
@ -125,9 +124,8 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
activityNonVideoView.setVisibility(View.INVISIBLE);
activityVideoView.addView(videoViewContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
activityVideoView.setVisibility(View.VISIBLE);
if (focusedChild instanceof android.widget.VideoView) {
if (focusedChild instanceof android.widget.VideoView videoView) {
// android.widget.VideoView (typically API level <11)
android.widget.VideoView videoView = (android.widget.VideoView) focusedChild;
// Handle all the required events
videoView.setOnCompletionListener(this);
videoView.setOnErrorListener(this);