mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Some cleaning
This commit is contained in:
parent
2edfd8c945
commit
1ff15b0f93
58 changed files with 215 additions and 282 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -87,10 +86,10 @@ public class AboutActivity extends BaseBarActivity {
|
|||
|
||||
|
||||
String finalVersion = version;
|
||||
binding.aboutVersionCopy.setOnClickListener(v->{
|
||||
binding.aboutVersionCopy.setOnClickListener(v -> {
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
String content = "Fedilab v" + finalVersion + " for " + (BuildConfig.DONATIONS?"FDroid":"Google");
|
||||
String content = "Fedilab v" + finalVersion + " for " + (BuildConfig.DONATIONS ? "FDroid" : "Google");
|
||||
|
||||
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
|
||||
if (clipboard != null) {
|
||||
|
|
|
@ -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,9 +74,10 @@ public class AccountReportActivity extends BaseBarActivity {
|
|||
initializeAfterBundle(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeAfterBundle(Bundle bundle) {
|
||||
|
||||
if(bundle != null) {
|
||||
if (bundle != null) {
|
||||
account_id = bundle.getString(Helper.ARG_ACCOUNT_ID, null);
|
||||
targeted_account = (AdminAccount) bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
report = (AdminReport) bundle.getSerializable(Helper.ARG_REPORT);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -485,9 +484,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
binding.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
|
||||
statusList = new ArrayList<>();
|
||||
Bundle b = getIntent().getExtras();
|
||||
if(b != null) {
|
||||
if (b != null) {
|
||||
long bundleId = b.getLong(Helper.ARG_INTENT_ID, -1);
|
||||
if(bundleId != -1 ) {
|
||||
if (bundleId != -1) {
|
||||
new CachedBundle(ComposeActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||
} else {
|
||||
initializeAfterBundle(b);
|
||||
|
@ -497,7 +496,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
|
||||
private void initializeAfterBundle(Bundle b) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
new Thread(()->{
|
||||
new Thread(() -> {
|
||||
if (b != null) {
|
||||
statusReply = (Status) b.getSerializable(Helper.ARG_STATUS_REPLY);
|
||||
statusQuoted = (Status) b.getSerializable(Helper.ARG_QUOTED_MESSAGE);
|
||||
|
@ -802,7 +801,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
status.id = Helper.generateIdString();
|
||||
status.mentions = statusList.get(position - 1).mentions;
|
||||
status.visibility = statusList.get(position - 1).visibility;
|
||||
if(initialContent != null) {
|
||||
if (initialContent != null) {
|
||||
status.text = initialContent;
|
||||
}
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ComposeActivity.this);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -151,7 +150,7 @@ public class FollowedTagActivity extends BaseBarActivity implements FollowedTagA
|
|||
popupAddFollowedTagtBinding.addTag.setFilters(new InputFilter[]{new InputFilter.LengthFilter(255)});
|
||||
dialogBuilder.setPositiveButton(R.string.validate, (dialog, id) -> {
|
||||
String name = Objects.requireNonNull(popupAddFollowedTagtBinding.addTag.getText()).toString().trim();
|
||||
if(tagList.contains(new Tag(name))) {
|
||||
if (tagList.contains(new Tag(name))) {
|
||||
Toasty.error(FollowedTagActivity.this, getString(R.string.tag_already_followed), Toasty.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
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)
|
||||
.observe(this@InstanceHealthActivity) { instanceSocialList: InstanceSocial? ->
|
||||
val instance = instanceSocialList?.instances?.firstOrNull { instance ->
|
||||
instance.name.equals(
|
||||
BaseMainActivity.currentInstance.trim { it <= ' ' },
|
||||
ignoreCase = true
|
||||
)
|
||||
}
|
||||
binding.name.text = instance.name
|
||||
if (instance.up) {
|
||||
binding.up.setText(R.string.is_up)
|
||||
binding.up.setTextColor(
|
||||
ThemeHelper.getAttColor(
|
||||
requireContext(),
|
||||
R.attr.colorPrimary
|
||||
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
|
||||
)
|
||||
)
|
||||
} 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.up.setText(R.string.is_down)
|
||||
binding.up.setTextColor(
|
||||
ThemeHelper.getAttColor(
|
||||
requireContext(),
|
||||
R.attr.colorError
|
||||
)
|
||||
)
|
||||
binding.instanceData.isVisible = false
|
||||
binding.noInstance.isVisible = true
|
||||
}
|
||||
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
|
||||
}
|
||||
binding.loader.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -240,7 +240,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
|||
}
|
||||
|
||||
private Spannable linkify(Context context, String content) {
|
||||
if(content == null) {
|
||||
if (content == null) {
|
||||
return new SpannableString("");
|
||||
}
|
||||
Matcher matcher = WEB_URL.matcher(content);
|
||||
|
@ -263,7 +263,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
|||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
if(!underlineLinks) {
|
||||
if (!underlineLinks) {
|
||||
ds.setUnderlineText(status != null && status.underlined);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -136,7 +135,7 @@ public class ProfileActivity extends BaseActivity {
|
|||
Bundle args = intent.getExtras();
|
||||
if (args != null) {
|
||||
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||
if(bundleId != -1 ) {
|
||||
if (bundleId != -1) {
|
||||
new CachedBundle(ProfileActivity.this).getBundle(bundleId, currentAccount, bundle -> {
|
||||
Account accountReceived = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
if (bundle.getBoolean(Helper.RECEIVE_REDRAW_PROFILE, false) && accountReceived != null) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -74,9 +74,9 @@ public class ReportActivity extends BaseBarActivity {
|
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
Bundle args = getIntent().getExtras();
|
||||
if(args != null) {
|
||||
if (args != null) {
|
||||
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||
if(bundleId != -1 ) {
|
||||
if (bundleId != -1) {
|
||||
new CachedBundle(ReportActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||
} else {
|
||||
initializeAfterBundle(args);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public class AdminAccountActivity extends BaseActivity {
|
|||
|
||||
private void initializeAfterBundle(Bundle bundle) {
|
||||
|
||||
if(bundle !=null) {
|
||||
if (bundle != null) {
|
||||
adminAccount = (AdminAccount) bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
account_id = bundle.getString(Helper.ARG_ACCOUNT_ID, null);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -115,7 +114,7 @@ public class AdminReportActivity extends BaseBarActivity {
|
|||
|
||||
|
||||
private void initializeAfterBundle(Bundle bundle) {
|
||||
if(bundle != null) {
|
||||
if (bundle != null) {
|
||||
adminAccount = (AdminAccount) bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
if (adminAccount != null) {
|
||||
account = adminAccount.account;
|
||||
|
|
|
@ -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 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 {
|
||||
|
@ -248,12 +239,12 @@ public class EmojiInstance implements Serializable {
|
|||
throw new DBException("db is null. Wrong initialization.");
|
||||
}
|
||||
new Thread(() -> {
|
||||
List<Emoji> emojiArrayList= new ArrayList<>();
|
||||
List<Emoji> emojiFiltered= new ArrayList<>();
|
||||
List<Emoji> emojiArrayList = new ArrayList<>();
|
||||
List<Emoji> emojiFiltered = new ArrayList<>();
|
||||
if (emojis == null || !emojis.containsKey(BaseMainActivity.currentInstance) || emojis.get(BaseMainActivity.currentInstance) == null) {
|
||||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_EMOJI_INSTANCE, null, Sqlite.COL_INSTANCE + " = '" + instance + "'", null, null, null, null, "1");
|
||||
emojiArrayList = cursorToEmojiList(c);
|
||||
emojiArrayList = cursorToEmojiList(c);
|
||||
} catch (Exception e) {
|
||||
MastodonInstanceService mastodonInstanceService = init(instance);
|
||||
Call<List<Emoji>> emojiCall = mastodonInstanceService.customEmoji();
|
||||
|
@ -271,9 +262,9 @@ public class EmojiInstance implements Serializable {
|
|||
} else {
|
||||
emojiArrayList = emojis.get(instance);
|
||||
}
|
||||
if(emojiArrayList != null && emojiArrayList.size() > 0 ) {
|
||||
for(Emoji emoji: emojiArrayList) {
|
||||
if(emoji.shortcode.contains(filter)) {
|
||||
if (emojiArrayList != null && emojiArrayList.size() > 0) {
|
||||
for (Emoji emoji : emojiArrayList) {
|
||||
if (emoji.shortcode.contains(filter)) {
|
||||
emojiFiltered.add(emoji);
|
||||
}
|
||||
}
|
||||
|
@ -311,4 +302,8 @@ public class EmojiInstance implements Serializable {
|
|||
}
|
||||
return filteredEmojis;
|
||||
}
|
||||
|
||||
public interface EmojiFilteredCallBack {
|
||||
void get(List<Emoji> emojiList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -79,11 +81,11 @@ public class CachedBundle {
|
|||
values.put(Sqlite.COL_BUNDLE, serializeBundle(bundle));
|
||||
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(new Date()));
|
||||
values.put(Sqlite.COL_TYPE, CacheType.ARGS.getValue());
|
||||
if( bundle.containsKey(Helper.ARG_ACCOUNT) && currentUser != null) {
|
||||
if (bundle.containsKey(Helper.ARG_ACCOUNT) && currentUser != null) {
|
||||
ContentValues valuesAccount = new ContentValues();
|
||||
Bundle bundleAccount = new Bundle();
|
||||
Account account = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
if(account != null) {
|
||||
if (account != null) {
|
||||
bundleAccount.putSerializable(Helper.ARG_ACCOUNT, account);
|
||||
valuesAccount.put(Sqlite.COL_BUNDLE, serializeBundle(bundleAccount));
|
||||
valuesAccount.put(Sqlite.COL_CREATED_AT, Helper.dateToString(new Date()));
|
||||
|
@ -95,11 +97,11 @@ public class CachedBundle {
|
|||
db.insertOrThrow(Sqlite.TABLE_INTENT, null, valuesAccount);
|
||||
}
|
||||
}
|
||||
if( bundle.containsKey(Helper.ARG_STATUS) && currentUser != null) {
|
||||
if (bundle.containsKey(Helper.ARG_STATUS) && currentUser != null) {
|
||||
ContentValues valuesAccount = new ContentValues();
|
||||
Bundle bundleStatus = new Bundle();
|
||||
Status status = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||
if(status != null) {
|
||||
if (status != null) {
|
||||
bundleStatus.putSerializable(Helper.ARG_STATUS, status);
|
||||
valuesAccount.put(Sqlite.COL_BUNDLE, serializeBundle(bundleStatus));
|
||||
valuesAccount.put(Sqlite.COL_CREATED_AT, Helper.dateToString(new Date()));
|
||||
|
@ -119,36 +121,29 @@ 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(()->{
|
||||
new Thread(() -> {
|
||||
Bundle bundle = null;
|
||||
try {
|
||||
CachedBundle cachedBundle = getCachedBundle(String.valueOf(id));
|
||||
if (cachedBundle != null) {
|
||||
bundle = cachedBundle.bundle;
|
||||
if(bundle != null && bundle.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) {
|
||||
if (bundle != null && bundle.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) {
|
||||
Account cachedAccount = getCachedAccount(Account, bundle.getString(Helper.ARG_CACHED_ACCOUNT_ID));
|
||||
if(cachedAccount != null) {
|
||||
if (cachedAccount != null) {
|
||||
bundle.putSerializable(Helper.ARG_ACCOUNT, cachedAccount);
|
||||
}
|
||||
}
|
||||
if(bundle != null && bundle.containsKey(Helper.ARG_CACHED_STATUS_ID)) {
|
||||
if (bundle != null && bundle.containsKey(Helper.ARG_CACHED_STATUS_ID)) {
|
||||
Status cachedStatus = getCachedStatus(Account, bundle.getString(Helper.ARG_CACHED_STATUS_ID));
|
||||
if(cachedStatus != null) {
|
||||
if (cachedStatus != null) {
|
||||
bundle.putSerializable(Helper.ARG_STATUS, cachedStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
removeIntent(String.valueOf(id));
|
||||
} catch (DBException ignored) {}
|
||||
} catch (DBException ignored) {
|
||||
}
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Bundle finalBundle = bundle;
|
||||
Runnable myRunnable = () -> callback.get(finalBundle);
|
||||
|
@ -157,11 +152,12 @@ public class CachedBundle {
|
|||
}
|
||||
|
||||
public void insertBundle(Bundle bundle, BaseAccount Account, BundleInsertCallback callback) {
|
||||
new Thread(()->{
|
||||
new Thread(() -> {
|
||||
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
|
||||
*
|
||||
|
@ -181,17 +175,17 @@ public class CachedBundle {
|
|||
if (db == null) {
|
||||
throw new DBException("db is null. Wrong initialization.");
|
||||
}
|
||||
if(account == null || target_id == null) {
|
||||
if (account == null || target_id == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_INTENT, null, Sqlite.COL_USER_ID + " = '" + account.user_id + "' AND "
|
||||
+ Sqlite.COL_INSTANCE + " = '" + account.instance+ "' AND "
|
||||
+ Sqlite.COL_INSTANCE + " = '" + account.instance + "' AND "
|
||||
+ Sqlite.COL_TYPE + " = '" + CacheType.ACCOUNT.getValue() + "' AND "
|
||||
+ Sqlite.COL_TARGET_ID + " = '" + target_id + "'", null, null, null, null, "1");
|
||||
CachedBundle cachedBundle = cursorToCachedBundle(c);
|
||||
if(cachedBundle != null && cachedBundle.bundle.containsKey(Helper.ARG_ACCOUNT) ) {
|
||||
return (Account) cachedBundle.bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
if (cachedBundle != null && cachedBundle.bundle.containsKey(Helper.ARG_ACCOUNT)) {
|
||||
return (Account) cachedBundle.bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
|
@ -199,7 +193,6 @@ public class CachedBundle {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a bundle by targeted status id
|
||||
*
|
||||
|
@ -210,17 +203,17 @@ public class CachedBundle {
|
|||
if (db == null) {
|
||||
throw new DBException("db is null. Wrong initialization.");
|
||||
}
|
||||
if(account == null || target_id == null) {
|
||||
if (account == null || target_id == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_INTENT, null, Sqlite.COL_USER_ID + " = '" + account.user_id + "' AND "
|
||||
+ Sqlite.COL_INSTANCE + " = '" + account.instance+ "' AND "
|
||||
+ Sqlite.COL_INSTANCE + " = '" + account.instance + "' AND "
|
||||
+ Sqlite.COL_TYPE + " = '" + CacheType.STATUS.getValue() + "' AND "
|
||||
+ Sqlite.COL_TARGET_ID + " = '" + target_id + "'", null, null, null, null, "1");
|
||||
CachedBundle cachedBundle = cursorToCachedBundle(c);
|
||||
if(cachedBundle != null && cachedBundle.bundle.containsKey(Helper.ARG_STATUS) ) {
|
||||
return (Status) cachedBundle.bundle.getSerializable(Helper.ARG_STATUS);
|
||||
if (cachedBundle != null && cachedBundle.bundle.containsKey(Helper.ARG_STATUS)) {
|
||||
return (Status) cachedBundle.bundle.getSerializable(Helper.ARG_STATUS);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
|
@ -228,7 +221,6 @@ public class CachedBundle {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a bundle by its ID
|
||||
*
|
||||
|
@ -259,24 +251,21 @@ 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) {
|
||||
throw new DBException("db is null. Wrong initialization.");
|
||||
}
|
||||
if(account == null || target_id == null) {
|
||||
if (account == null || target_id == null) {
|
||||
return;
|
||||
}
|
||||
db.delete(Sqlite.TABLE_INTENT, Sqlite.COL_USER_ID + " = '" + account.user_id + "' AND "
|
||||
+ Sqlite.COL_INSTANCE + " = '" + account.instance+ "' AND "
|
||||
+ Sqlite.COL_INSTANCE + " = '" + account.instance + "' AND "
|
||||
+ Sqlite.COL_TARGET_ID + " = '" + target_id + "'", null);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* Method to hydrate an CachedBundle from database
|
||||
* @param c Cursor
|
||||
|
@ -325,7 +314,7 @@ public class CachedBundle {
|
|||
zos.write(parcel.marshall());
|
||||
zos.close();
|
||||
base64 = Base64.encodeToString(bos.toByteArray(), 0);
|
||||
} catch(IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
parcel.recycle();
|
||||
|
@ -350,13 +339,12 @@ public class CachedBundle {
|
|||
bundle = parcel.readBundle(getClass().getClassLoader());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
} finally {
|
||||
parcel.recycle();
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<FloatArray>
|
||||
width: Int,
|
||||
height: Int,
|
||||
numCompX: Int,
|
||||
numCompY: Int,
|
||||
colors: Array<FloatArray>
|
||||
): 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()
|
||||
}
|
|
@ -23,7 +23,6 @@ import java.util.ArrayList;
|
|||
import java.util.regex.Matcher;
|
||||
|
||||
|
||||
|
||||
public class ComposeHelper {
|
||||
|
||||
|
||||
|
@ -44,13 +43,13 @@ public class ComposeHelper {
|
|||
Matcher matcher = mentionPatternALL.matcher(content);
|
||||
while (matcher.find()) {
|
||||
String mentionLong = matcher.group(1);
|
||||
if(mentionLong != null) {
|
||||
if (mentionLong != null) {
|
||||
if (!mentions.contains(mentionLong)) {
|
||||
mentions.add(mentionLong);
|
||||
}
|
||||
}
|
||||
String mentionShort = matcher.group(2);
|
||||
if(mentionShort != null) {
|
||||
if (mentionShort != null) {
|
||||
if (!mentions.contains(mentionShort)) {
|
||||
mentions.add(mentionShort);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ public class SpannableHelper {
|
|||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
if(!underlineLinks) {
|
||||
if (!underlineLinks) {
|
||||
ds.setUnderlineText(status != null && status.underlined);
|
||||
}
|
||||
if (linkColor != -1) {
|
||||
|
@ -604,7 +604,7 @@ public class SpannableHelper {
|
|||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
if(!underlineLinks) {
|
||||
if (!underlineLinks) {
|
||||
ds.setUnderlineText(status != null && status.underlined);
|
||||
}
|
||||
if (linkColor != -1) {
|
||||
|
@ -763,7 +763,7 @@ public class SpannableHelper {
|
|||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
if(!underlineLinks) {
|
||||
if (!underlineLinks) {
|
||||
ds.setUnderlineText(status != null && status.underlined);
|
||||
}
|
||||
if (linkColor != -1) {
|
||||
|
@ -916,7 +916,7 @@ public class SpannableHelper {
|
|||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
if(!underlineLinks) {
|
||||
if (!underlineLinks) {
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
if (linkColor != -1) {
|
||||
|
|
|
@ -176,12 +176,10 @@ 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);
|
||||
}
|
||||
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();
|
||||
|
|
|
@ -81,7 +81,7 @@ public class TranslateHelper {
|
|||
String translate;
|
||||
if (translates == null || translates.size() <= 1) {
|
||||
translate = MyTransL.getLocale();
|
||||
if(translates != null && translates.size() == 1 ) {
|
||||
if (translates != null && translates.size() == 1) {
|
||||
for (String val : translates) {
|
||||
translate = val;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
isPermissionGranted(grantResults[0] == PackageManager.PERMISSION_GRANTED, permissions[0]);
|
||||
break;
|
||||
if (requestCode == READ_WRITE_STORAGE) {
|
||||
isPermissionGranted(grantResults[0] == PackageManager.PERMISSION_GRANTED, permissions[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -66,14 +66,14 @@ public class CustomReceiver extends MessagingReceiver {
|
|||
@Override
|
||||
public void onNewEndpoint(@Nullable Context context, @NotNull String endpoint, @NotNull String slug) {
|
||||
if (context != null) {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String storedEnpoint = sharedpreferences.getString(context.getString(R.string.SET_STORED_ENDPOINT)+slug, null);
|
||||
if(storedEnpoint == null || !storedEnpoint.equals(endpoint)) {
|
||||
String storedEnpoint = sharedpreferences.getString(context.getString(R.string.SET_STORED_ENDPOINT) + slug, null);
|
||||
if (storedEnpoint == null || !storedEnpoint.equals(endpoint)) {
|
||||
PushNotifications
|
||||
.registerPushNotifications(context, endpoint, slug);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(context.getString(R.string.SET_STORED_ENDPOINT)+slug, endpoint);
|
||||
editor.putString(context.getString(R.string.SET_STORED_ENDPOINT) + slug, endpoint);
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -549,7 +547,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String defaultFormat = sharedpreferences.getString(context.getString(R.string.SET_THREAD_MESSAGE), context.getString(R.string.DEFAULT_THREAD_VALUE));
|
||||
//User asked to be prompted for threading long messages
|
||||
if(defaultFormat.compareToIgnoreCase("ASK") == 0 && !splitChoiceDone) {
|
||||
if (defaultFormat.compareToIgnoreCase("ASK") == 0 && !splitChoiceDone) {
|
||||
splitChoiceDone = true;
|
||||
AlertDialog.Builder threadConfirm = new MaterialAlertDialogBuilder(context);
|
||||
threadConfirm.setTitle(context.getString(R.string.thread_long_this_message));
|
||||
|
@ -561,29 +559,29 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
holder.binding.content.setText(splitText.get(0));
|
||||
int statusListSize = statusList.size();
|
||||
int i = 0;
|
||||
for(String message: splitText) {
|
||||
if(i==0) {
|
||||
for (String message : splitText) {
|
||||
if (i == 0) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
manageDrafts.onItemDraftAdded(statusListSize+(i-1), message);
|
||||
manageDrafts.onItemDraftAdded(statusListSize + (i - 1), message);
|
||||
buttonVisibility(holder);
|
||||
i++;
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
threadConfirm.show();
|
||||
} else if(defaultFormat.compareToIgnoreCase("ENABLE") == 0) { //User wants to automatically thread long messages
|
||||
} else if (defaultFormat.compareToIgnoreCase("ENABLE") == 0) { //User wants to automatically thread long messages
|
||||
proceedToSplit = true;
|
||||
ArrayList<String> splitText = ComposeHelper.splitToots(s.toString(), max_car);
|
||||
int statusListSize = statusList.size();
|
||||
int i = 0;
|
||||
for(String message: splitText) {
|
||||
if(i==0) {
|
||||
for (String message : splitText) {
|
||||
if (i == 0) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
manageDrafts.onItemDraftAdded(statusListSize+(i-1), message);
|
||||
manageDrafts.onItemDraftAdded(statusListSize + (i - 1), message);
|
||||
buttonVisibility(holder);
|
||||
i++;
|
||||
}
|
||||
|
@ -594,7 +592,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
String contentString = s.toString();
|
||||
if(proceedToSplit) {
|
||||
if (proceedToSplit) {
|
||||
int max_car = MastodonHelper.getInstanceMaxChars(context);
|
||||
ArrayList<String> splitText = ComposeHelper.splitToots(contentString, max_car);
|
||||
contentString = splitText.get(0);
|
||||
|
@ -1352,21 +1350,21 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
if (getItemViewType(position) == TYPE_NORMAL) {
|
||||
Status status = statusList.get(position);
|
||||
StatusSimpleViewHolder holder = (StatusSimpleViewHolder) viewHolder;
|
||||
if(status.media_attachments != null && status.media_attachments.size() > 0 ) {
|
||||
if (status.media_attachments != null && status.media_attachments.size() > 0) {
|
||||
holder.binding.simpleMedia.removeAllViews();
|
||||
List<Attachment> attachmentList = statusList.get(position).media_attachments;
|
||||
for(Attachment attachment: attachmentList) {
|
||||
for (Attachment attachment : attachmentList) {
|
||||
DrawerMediaListBinding drawerMediaListBinding = DrawerMediaListBinding.inflate(LayoutInflater.from(context), holder.binding.simpleMedia, false);
|
||||
Glide.with(drawerMediaListBinding.media.getContext())
|
||||
.load(attachment.preview_url)
|
||||
.into(drawerMediaListBinding.media);
|
||||
|
||||
if(attachment.filename != null) {
|
||||
if (attachment.filename != null) {
|
||||
drawerMediaListBinding.mediaName.setText(attachment.filename);
|
||||
} else if (attachment.preview_url != null){
|
||||
} else if (attachment.preview_url != null) {
|
||||
drawerMediaListBinding.mediaName.setText(URLUtil.guessFileName(attachment.preview_url, null, null));
|
||||
}
|
||||
drawerMediaListBinding.getRoot().setOnClickListener(v->{
|
||||
drawerMediaListBinding.getRoot().setOnClickListener(v -> {
|
||||
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -935,7 +934,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_ACCOUNT, fetchedStatus.reblog != null ? fetchedStatus.reblog.account : fetchedStatus.account);
|
||||
new CachedBundle(context).insertBundle(args, currentAccount,bundleId -> {
|
||||
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
intent.putExtras(bundle);
|
||||
|
@ -1299,13 +1298,13 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
} else {
|
||||
holder.binding.replyCount.setVisibility(View.GONE);
|
||||
}
|
||||
if(statusToDeal.reblogs_count > 0) {
|
||||
if (statusToDeal.reblogs_count > 0) {
|
||||
holder.binding.boostCount.setText(String.valueOf(statusToDeal.reblogs_count));
|
||||
holder.binding.boostCount.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.binding.boostCount.setVisibility(View.GONE);
|
||||
}
|
||||
if(statusToDeal.favourites_count > 0) {
|
||||
if (statusToDeal.favourites_count > 0) {
|
||||
holder.binding.favoriteCount.setText(String.valueOf(statusToDeal.favourites_count));
|
||||
holder.binding.favoriteCount.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -1330,7 +1329,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
} else {
|
||||
holder.binding.dateShort.setCompoundDrawables(null, null, null, null);
|
||||
}
|
||||
if(relativeDate) {
|
||||
if (relativeDate) {
|
||||
if (originalDateForBoost || status.reblog == null) {
|
||||
holder.binding.dateShort.setText(Helper.dateDiff(context, statusToDeal.created_at));
|
||||
} else {
|
||||
|
@ -1795,7 +1794,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
|
||||
if (statusToDeal.poll != null && statusToDeal.poll.options != null) {
|
||||
int normalize;
|
||||
if(statusToDeal.poll.multiple && statusToDeal.poll.voters_count > 1) {
|
||||
if (statusToDeal.poll.multiple && statusToDeal.poll.voters_count > 1) {
|
||||
normalize = statusToDeal.poll.voters_count;
|
||||
} else {
|
||||
normalize = statusToDeal.poll.votes_count;
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class FragmentMediaProfile extends Fragment {
|
|||
if (getArguments() != null) {
|
||||
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
|
||||
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
|
||||
if(bundle != null) {
|
||||
if (bundle != null) {
|
||||
accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -98,7 +97,7 @@ public class FragmentMastodonAccount extends Fragment {
|
|||
}
|
||||
|
||||
private void initializeAfterBundle(Bundle bundle) {
|
||||
if(bundle != null) {
|
||||
if (bundle != null) {
|
||||
search = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null);
|
||||
accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
followType = (FedilabProfileTLPageAdapter.follow_type) bundle.getSerializable(Helper.ARG_FOLLOW_TYPE);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -385,7 +383,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
flagLoading = false;
|
||||
if (getArguments() != null) {
|
||||
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
|
||||
if(bundleId != -1 ) {
|
||||
if (bundleId != -1) {
|
||||
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||
} else {
|
||||
initializeAfterBundle(getArguments());
|
||||
|
@ -397,7 +395,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
}
|
||||
|
||||
private void initializeAfterBundle(Bundle bundle) {
|
||||
new Thread(()->{
|
||||
new Thread(() -> {
|
||||
if (bundle != null) {
|
||||
timelineType = (Timeline.TimeLineEnum) bundle.get(Helper.ARG_TIMELINE_TYPE);
|
||||
lemmy_post_id = bundle.getString(Helper.ARG_LEMMY_POST_ID, null);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class FragmentProfileTimeline extends Fragment {
|
|||
binding = FragmentProfileTimelinesBinding.inflate(inflater, container, false);
|
||||
if (getArguments() != null) {
|
||||
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
|
||||
if(bundleId != -1 ) {
|
||||
if (bundleId != -1) {
|
||||
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
|
||||
account = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
|
||||
checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
|
@ -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();
|
||||
|
|
|
@ -1591,7 +1591,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
}
|
||||
}
|
||||
};
|
||||
ContextCompat.registerReceiver(PeertubeActivity.this, mPowerKeyReceiver, theFilter, ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
ContextCompat.registerReceiver(PeertubeActivity.this, mPowerKeyReceiver, theFilter, ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
}
|
||||
|
||||
private void unregisterReceiver() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
//At the state the instance can be encoded
|
||||
instance = URLDecoder.decode(instance, StandardCharsets.UTF_8);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
account.token = token;
|
||||
account.client_id = client_id;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class RetrieveInfoService extends Service implements NetworkStateReceiver
|
|||
super.onCreate();
|
||||
networkStateReceiver = new NetworkStateReceiver();
|
||||
networkStateReceiver.addListener(this);
|
||||
ContextCompat.registerReceiver(RetrieveInfoService.this, networkStateReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION), ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
ContextCompat.registerReceiver(RetrieveInfoService.this, networkStateReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION), ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
|
||||
getString(R.string.notification_channel_name),
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue