mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Apply for status
This commit is contained in:
parent
1ff15b0f93
commit
85e462e276
14 changed files with 422 additions and 181 deletions
|
@ -304,9 +304,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
Snackbar.make(binding.displaySnackBar, getString(R.string.message_has_been_sent), Snackbar.LENGTH_LONG)
|
Snackbar.make(binding.displaySnackBar, getString(R.string.message_has_been_sent), Snackbar.LENGTH_LONG)
|
||||||
.setAction(getString(R.string.display), view -> {
|
.setAction(getString(R.string.display), view -> {
|
||||||
Intent intentContext = new Intent(BaseMainActivity.this, ContextActivity.class);
|
Intent intentContext = new Intent(BaseMainActivity.this, ContextActivity.class);
|
||||||
intentContext.putExtra(Helper.ARG_STATUS, statusSent);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, statusSent);
|
||||||
|
new CachedBundle(BaseMainActivity.this).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intentContext.putExtras(bundle);
|
||||||
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intentContext);
|
startActivity(intentContext);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
//The message was edited, we need to update the timeline
|
//The message was edited, we need to update the timeline
|
||||||
|
@ -782,9 +788,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
public void federatedStatus(Status status) {
|
public void federatedStatus(Status status) {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
Intent intent = new Intent(activity, ContextActivity.class);
|
Intent intent = new Intent(activity, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, status);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
|
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,9 +1033,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
public void federatedStatus(Status status) {
|
public void federatedStatus(Status status) {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
Intent intent = new Intent(activity, ContextActivity.class);
|
Intent intent = new Intent(activity, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, status);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
|
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Toasty.error(activity, activity.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
|
Toasty.error(activity, activity.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ import app.fedilab.android.R;
|
||||||
import app.fedilab.android.activities.MainActivity;
|
import app.fedilab.android.activities.MainActivity;
|
||||||
import app.fedilab.android.databinding.ActivityConversationBinding;
|
import app.fedilab.android.databinding.ActivityConversationBinding;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.client.entities.app.StatusCache;
|
import app.fedilab.android.mastodon.client.entities.app.StatusCache;
|
||||||
import app.fedilab.android.mastodon.exception.DBException;
|
import app.fedilab.android.mastodon.exception.DBException;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
|
@ -86,14 +87,24 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||||
}
|
}
|
||||||
Bundle b = getIntent().getExtras();
|
|
||||||
displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false);
|
displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false);
|
||||||
focusedStatus = null; // or other values
|
focusedStatus = null; // or other values
|
||||||
if (b != null) {
|
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
|
||||||
focusedStatus = (Status) b.getSerializable(Helper.ARG_STATUS);
|
|
||||||
remote_instance = b.getString(Helper.ARG_REMOTE_INSTANCE, null);
|
|
||||||
focusedStatusURI = b.getString(Helper.ARG_FOCUSED_STATUS_URI, null);
|
|
||||||
|
|
||||||
|
Bundle args = getIntent().getExtras();
|
||||||
|
if (args != null) {
|
||||||
|
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||||
|
new CachedBundle(ContextActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||||
|
} else {
|
||||||
|
initializeAfterBundle(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeAfterBundle(Bundle bundle) {
|
||||||
|
if (bundle != null) {
|
||||||
|
focusedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||||
|
remote_instance = bundle.getString(Helper.ARG_REMOTE_INSTANCE, null);
|
||||||
|
focusedStatusURI = bundle.getString(Helper.ARG_FOCUSED_STATUS_URI, null);
|
||||||
}
|
}
|
||||||
if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) {
|
if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) {
|
||||||
finish();
|
finish();
|
||||||
|
@ -102,7 +113,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
||||||
if (focusedStatusURI == null && remote_instance == null) {
|
if (focusedStatusURI == null && remote_instance == null) {
|
||||||
focusedStatusURI = focusedStatus.uri;
|
focusedStatusURI = focusedStatus.uri;
|
||||||
}
|
}
|
||||||
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
checkRemotely = sharedpreferences.getBoolean(getString(R.string.SET_CONVERSATION_REMOTELY), false);
|
checkRemotely = sharedpreferences.getBoolean(getString(R.string.SET_CONVERSATION_REMOTELY), false);
|
||||||
if (!checkRemotely) {
|
if (!checkRemotely) {
|
||||||
|
@ -113,6 +124,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
@ -120,9 +132,12 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadLocalConversation() {
|
private void loadLocalConversation() {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, focusedStatus);
|
||||||
|
args.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance);
|
||||||
|
new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable(Helper.ARG_STATUS, focusedStatus);
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
bundle.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance);
|
|
||||||
FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext();
|
FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext();
|
||||||
fragmentMastodonContext.firstMessage = this;
|
fragmentMastodonContext.firstMessage = this;
|
||||||
currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, null);
|
currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, null);
|
||||||
|
@ -151,6 +166,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -245,13 +261,17 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
||||||
String finalInstance = instance;
|
String finalInstance = instance;
|
||||||
statusesVM.getStatus(instance, null, remoteId).observe(ContextActivity.this, status -> {
|
statusesVM.getStatus(instance, null, remoteId).observe(ContextActivity.this, status -> {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
|
args.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance);
|
||||||
|
args.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI);
|
||||||
|
new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable(Helper.ARG_STATUS, status);
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
bundle.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance);
|
|
||||||
bundle.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI);
|
|
||||||
FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext();
|
FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext();
|
||||||
fragmentMastodonContext.firstMessage = ContextActivity.this;
|
fragmentMastodonContext.firstMessage = ContextActivity.this;
|
||||||
currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, null);
|
currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, null);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
loadLocalConversation();
|
loadLocalConversation();
|
||||||
}
|
}
|
||||||
|
@ -293,11 +313,17 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
||||||
statusesVM.getStatus(instance, null, remoteId).observe(ContextActivity.this, status -> {
|
statusesVM.getStatus(instance, null, remoteId).observe(ContextActivity.this, status -> {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
Intent intentContext = new Intent(ContextActivity.this, ContextActivity.class);
|
Intent intentContext = new Intent(ContextActivity.this, ContextActivity.class);
|
||||||
intentContext.putExtra(Helper.ARG_STATUS, status);
|
Bundle args = new Bundle();
|
||||||
intentContext.putExtra(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI);
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
intentContext.putExtra(Helper.ARG_REMOTE_INSTANCE, finalInstance);
|
args.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI);
|
||||||
|
args.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance);
|
||||||
|
new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intentContext.putExtras(bundle);
|
||||||
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intentContext);
|
startActivity(intentContext);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Toasty.warning(ContextActivity.this, getString(R.string.toast_error_fetch_message), Toasty.LENGTH_SHORT).show();
|
Toasty.warning(ContextActivity.this, getString(R.string.toast_error_fetch_message), Toasty.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import app.fedilab.android.mastodon.client.entities.api.Attachment;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Emoji;
|
import app.fedilab.android.mastodon.client.entities.api.Emoji;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Tag;
|
import app.fedilab.android.mastodon.client.entities.api.Tag;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
import app.fedilab.android.mastodon.helper.customsharing.CustomSharingAsyncTask;
|
import app.fedilab.android.mastodon.helper.customsharing.CustomSharingAsyncTask;
|
||||||
import app.fedilab.android.mastodon.helper.customsharing.CustomSharingResponse;
|
import app.fedilab.android.mastodon.helper.customsharing.CustomSharingResponse;
|
||||||
|
@ -65,23 +66,34 @@ public class CustomSharingActivity extends BaseBarActivity implements OnCustomSh
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(CustomSharingActivity.this);
|
|
||||||
binding = ActivityCustomSharingBinding.inflate(getLayoutInflater());
|
binding = ActivityCustomSharingBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
if (getSupportActionBar() != null) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||||
}
|
}
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle args = getIntent().getExtras();
|
||||||
status = null;
|
status = null;
|
||||||
if (b != null) {
|
if (args != null) {
|
||||||
status = (Status) b.getSerializable(Helper.ARG_STATUS);
|
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||||
|
new CachedBundle(CustomSharingActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||||
|
} else {
|
||||||
|
initializeAfterBundle(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeAfterBundle(Bundle bundle) {
|
||||||
|
|
||||||
|
if (bundle != null) {
|
||||||
|
status = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||||
}
|
}
|
||||||
if (status == null) {
|
if (status == null) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(CustomSharingActivity.this);
|
||||||
bundle_creator = status.account.acct;
|
bundle_creator = status.account.acct;
|
||||||
bundle_url = status.url;
|
bundle_url = status.url;
|
||||||
bundle_id = status.uri;
|
bundle_id = status.uri;
|
||||||
|
|
|
@ -39,6 +39,7 @@ import app.fedilab.android.BaseMainActivity;
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
import app.fedilab.android.databinding.ActivityDirectMessageBinding;
|
import app.fedilab.android.databinding.ActivityDirectMessageBinding;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.client.entities.app.StatusCache;
|
import app.fedilab.android.mastodon.client.entities.app.StatusCache;
|
||||||
import app.fedilab.android.mastodon.exception.DBException;
|
import app.fedilab.android.mastodon.exception.DBException;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
|
@ -71,31 +72,48 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
|
float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
|
||||||
binding.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
|
binding.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
|
||||||
|
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
|
||||||
if (getSupportActionBar() != null) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||||
}
|
}
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle args = getIntent().getExtras();
|
||||||
displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false);
|
displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false);
|
||||||
Status focusedStatus = null; // or other values
|
|
||||||
if (b != null) {
|
if (args != null) {
|
||||||
focusedStatus = (Status) b.getSerializable(Helper.ARG_STATUS);
|
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||||
remote_instance = b.getString(Helper.ARG_REMOTE_INSTANCE, null);
|
new CachedBundle(DirectMessageActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||||
|
} else {
|
||||||
|
initializeAfterBundle(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeAfterBundle(Bundle bundle) {
|
||||||
|
Status focusedStatus = null; // or other values
|
||||||
|
if (bundle != null) {
|
||||||
|
focusedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||||
|
remote_instance = bundle.getString(Helper.ARG_REMOTE_INSTANCE, null);
|
||||||
|
}
|
||||||
|
|
||||||
if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) {
|
if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle args = new Bundle();
|
||||||
bundle.putSerializable(Helper.ARG_STATUS, focusedStatus);
|
args.putSerializable(Helper.ARG_STATUS, focusedStatus);
|
||||||
bundle.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance);
|
args.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance);
|
||||||
|
Status finalFocusedStatus = focusedStatus;
|
||||||
|
new CachedBundle(DirectMessageActivity.this).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle args2 = new Bundle();
|
||||||
|
args2.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
FragmentMastodonDirectMessage FragmentMastodonDirectMessage = new FragmentMastodonDirectMessage();
|
FragmentMastodonDirectMessage FragmentMastodonDirectMessage = new FragmentMastodonDirectMessage();
|
||||||
FragmentMastodonDirectMessage.firstMessage = this;
|
FragmentMastodonDirectMessage.firstMessage = this;
|
||||||
currentFragment = (FragmentMastodonDirectMessage) Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, FragmentMastodonDirectMessage, bundle, null, null);
|
currentFragment = (FragmentMastodonDirectMessage) Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, FragmentMastodonDirectMessage, args2, null, null);
|
||||||
StatusesVM timelinesVM = new ViewModelProvider(DirectMessageActivity.this).get(StatusesVM.class);
|
StatusesVM timelinesVM = new ViewModelProvider(DirectMessageActivity.this).get(StatusesVM.class);
|
||||||
timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(DirectMessageActivity.this, status -> {
|
timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, finalFocusedStatus.id).observe(DirectMessageActivity.this, status -> {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
StatusCache statusCache = new StatusCache();
|
StatusCache statusCache = new StatusCache();
|
||||||
statusCache.instance = BaseMainActivity.currentInstance;
|
statusCache.instance = BaseMainActivity.currentInstance;
|
||||||
|
@ -116,8 +134,9 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.activities;
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
import static android.util.Patterns.WEB_URL;
|
import static android.util.Patterns.WEB_URL;
|
||||||
|
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
|
@ -63,6 +64,7 @@ import app.fedilab.android.R;
|
||||||
import app.fedilab.android.databinding.ActivityMediaPagerBinding;
|
import app.fedilab.android.databinding.ActivityMediaPagerBinding;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Attachment;
|
import app.fedilab.android.mastodon.client.entities.api.Attachment;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
import app.fedilab.android.mastodon.helper.MediaHelper;
|
import app.fedilab.android.mastodon.helper.MediaHelper;
|
||||||
import app.fedilab.android.mastodon.helper.TranslateHelper;
|
import app.fedilab.android.mastodon.helper.TranslateHelper;
|
||||||
|
@ -124,13 +126,26 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
|
|
||||||
fullscreen = false;
|
fullscreen = false;
|
||||||
flags = getWindow().getDecorView().getSystemUiVisibility();
|
flags = getWindow().getDecorView().getSystemUiVisibility();
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle args = getIntent().getExtras();
|
||||||
if (b != null) {
|
if (args != null) {
|
||||||
mediaPosition = b.getInt(Helper.ARG_MEDIA_POSITION, 1);
|
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||||
attachments = (ArrayList<Attachment>) b.getSerializable(Helper.ARG_MEDIA_ARRAY);
|
new CachedBundle(MediaActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||||
mediaFromProfile = b.getBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, false);
|
} else {
|
||||||
status = (Status) b.getSerializable(Helper.ARG_STATUS);
|
initializeAfterBundle(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeAfterBundle(Bundle bundle) {
|
||||||
|
|
||||||
|
if (bundle != null) {
|
||||||
|
mediaPosition = bundle.getInt(Helper.ARG_MEDIA_POSITION, 1);
|
||||||
|
attachments = (ArrayList<Attachment>) bundle.getSerializable(Helper.ARG_MEDIA_ARRAY);
|
||||||
|
mediaFromProfile = bundle.getBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, false);
|
||||||
|
status = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||||
|
}
|
||||||
|
|
||||||
if (mediaFromProfile && FragmentMediaProfile.mediaAttachmentProfile != null) {
|
if (mediaFromProfile && FragmentMediaProfile.mediaAttachmentProfile != null) {
|
||||||
attachments = new ArrayList<>();
|
attachments = new ArrayList<>();
|
||||||
attachments.addAll(FragmentMediaProfile.mediaAttachmentProfile);
|
attachments.addAll(FragmentMediaProfile.mediaAttachmentProfile);
|
||||||
|
@ -146,7 +161,6 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle("");
|
setTitle("");
|
||||||
|
|
||||||
ScreenSlidePagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
ScreenSlidePagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||||
binding.mediaViewpager.setAdapter(mPagerAdapter);
|
binding.mediaViewpager.setAdapter(mPagerAdapter);
|
||||||
binding.mediaViewpager.setSaveEnabled(false);
|
binding.mediaViewpager.setSaveEnabled(false);
|
||||||
|
@ -239,6 +253,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
setFullscreen(true);
|
setFullscreen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Spannable linkify(Context context, String content) {
|
private Spannable linkify(Context context, String content) {
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
return new SpannableString("");
|
return new SpannableString("");
|
||||||
|
|
|
@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.activities;
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
|
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||||
import static app.fedilab.android.BaseMainActivity.currentInstance;
|
import static app.fedilab.android.BaseMainActivity.currentInstance;
|
||||||
import static app.fedilab.android.BaseMainActivity.currentToken;
|
import static app.fedilab.android.BaseMainActivity.currentToken;
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ import app.fedilab.android.mastodon.client.entities.api.Account;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Accounts;
|
import app.fedilab.android.mastodon.client.entities.api.Accounts;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.RelationShip;
|
import app.fedilab.android.mastodon.client.entities.api.RelationShip;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
import app.fedilab.android.mastodon.ui.drawer.AccountAdapter;
|
import app.fedilab.android.mastodon.ui.drawer.AccountAdapter;
|
||||||
import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM;
|
import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM;
|
||||||
|
@ -70,12 +72,23 @@ public class StatusInfoActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
accountList = new ArrayList<>();
|
accountList = new ArrayList<>();
|
||||||
checkRemotely = false;
|
checkRemotely = false;
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle args = getIntent().getExtras();
|
||||||
if (b != null) {
|
if (args != null) {
|
||||||
type = (typeOfInfo) b.getSerializable(Helper.ARG_TYPE_OF_INFO);
|
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||||
status = (Status) b.getSerializable(Helper.ARG_STATUS);
|
new CachedBundle(StatusInfoActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||||
checkRemotely = b.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
} else {
|
||||||
|
initializeAfterBundle(null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeAfterBundle(Bundle bundle) {
|
||||||
|
|
||||||
|
if (bundle != null) {
|
||||||
|
type = (typeOfInfo) bundle.getSerializable(Helper.ARG_TYPE_OF_INFO);
|
||||||
|
status = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||||
|
checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (type == null || status == null) {
|
if (type == null || status == null) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
@ -138,6 +151,7 @@ public class StatusInfoActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void manageView(Accounts accounts) {
|
private void manageView(Accounts accounts) {
|
||||||
binding.loadingNextAccounts.setVisibility(View.GONE);
|
binding.loadingNextAccounts.setVisibility(View.GONE);
|
||||||
if (accountList != null && accounts != null && accounts.accounts != null) {
|
if (accountList != null && accounts != null && accounts.accounts != null) {
|
||||||
|
|
|
@ -45,16 +45,25 @@ public class TimelineActivity extends BaseBarActivity {
|
||||||
if (getSupportActionBar() != null) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle args = getIntent().getExtras();
|
||||||
|
if (args != null) {
|
||||||
|
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||||
|
new CachedBundle(TimelineActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||||
|
} else {
|
||||||
|
initializeAfterBundle(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeAfterBundle(Bundle bundle) {
|
||||||
Timeline.TimeLineEnum timelineType = null;
|
Timeline.TimeLineEnum timelineType = null;
|
||||||
String lemmy_post_id = null;
|
String lemmy_post_id = null;
|
||||||
PinnedTimeline pinnedTimeline = null;
|
PinnedTimeline pinnedTimeline = null;
|
||||||
Status status = null;
|
Status status = null;
|
||||||
if (b != null) {
|
if (bundle != null) {
|
||||||
timelineType = (Timeline.TimeLineEnum) b.get(Helper.ARG_TIMELINE_TYPE);
|
timelineType = (Timeline.TimeLineEnum) bundle.get(Helper.ARG_TIMELINE_TYPE);
|
||||||
lemmy_post_id = b.getString(Helper.ARG_LEMMY_POST_ID, null);
|
lemmy_post_id = bundle.getString(Helper.ARG_LEMMY_POST_ID, null);
|
||||||
pinnedTimeline = (PinnedTimeline) b.getSerializable(Helper.ARG_REMOTE_INSTANCE);
|
pinnedTimeline = (PinnedTimeline) bundle.getSerializable(Helper.ARG_REMOTE_INSTANCE);
|
||||||
status = (Status) b.getSerializable(Helper.ARG_STATUS);
|
status = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||||
}
|
}
|
||||||
if (pinnedTimeline != null && pinnedTimeline.remoteInstance != null) {
|
if (pinnedTimeline != null && pinnedTimeline.remoteInstance != null) {
|
||||||
setTitle(pinnedTimeline.remoteInstance.host);
|
setTitle(pinnedTimeline.remoteInstance.host);
|
||||||
|
@ -68,13 +77,12 @@ public class TimelineActivity extends BaseBarActivity {
|
||||||
args.putSerializable(Helper.ARG_STATUS, status);
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
}
|
}
|
||||||
new CachedBundle(TimelineActivity.this).insertBundle(args, currentAccount, bundleId -> {
|
new CachedBundle(TimelineActivity.this).insertBundle(args, currentAccount, bundleId -> {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle1 = new Bundle();
|
||||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
bundle1.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
fragmentMastodonTimeline.setArguments(bundle);
|
fragmentMastodonTimeline.setArguments(bundle1);
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.fragment_container_view, fragmentMastodonTimeline).commit();
|
.add(R.id.fragment_container_view, fragmentMastodonTimeline).commit();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -627,9 +627,15 @@ public class SpannableHelper {
|
||||||
@Override
|
@Override
|
||||||
public void federatedStatus(Status status) {
|
public void federatedStatus(Status status) {
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, status);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -663,9 +669,15 @@ public class SpannableHelper {
|
||||||
@Override
|
@Override
|
||||||
public void federatedStatus(Status status) {
|
public void federatedStatus(Status status) {
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, status);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -699,9 +711,15 @@ public class SpannableHelper {
|
||||||
@Override
|
@Override
|
||||||
public void federatedStatus(Status status) {
|
public void federatedStatus(Status status) {
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, status);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.ui.drawer;
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
|
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||||
import static app.fedilab.android.BaseMainActivity.currentNightMode;
|
import static app.fedilab.android.BaseMainActivity.currentNightMode;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
@ -22,6 +23,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -49,13 +51,14 @@ import app.fedilab.android.R;
|
||||||
import app.fedilab.android.databinding.DrawerConversationBinding;
|
import app.fedilab.android.databinding.DrawerConversationBinding;
|
||||||
import app.fedilab.android.databinding.ThumbnailBinding;
|
import app.fedilab.android.databinding.ThumbnailBinding;
|
||||||
import app.fedilab.android.mastodon.activities.ContextActivity;
|
import app.fedilab.android.mastodon.activities.ContextActivity;
|
||||||
import app.fedilab.android.mastodon.activities.DirectMessageActivity;
|
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Account;
|
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.Attachment;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Conversation;
|
import app.fedilab.android.mastodon.client.entities.api.Conversation;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
||||||
|
import app.fedilab.android.mastodon.activities.DirectMessageActivity;
|
||||||
|
|
||||||
|
|
||||||
public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
@ -220,9 +223,15 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
} else {
|
} else {
|
||||||
intent = new Intent(context, ContextActivity.class);
|
intent = new Intent(context, ContextActivity.class);
|
||||||
}
|
}
|
||||||
intent.putExtra(Helper.ARG_STATUS, conversation.last_status);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, conversation.last_status);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
holder.binding.attachmentsListContainer.setOnTouchListener((v, event) -> {
|
holder.binding.attachmentsListContainer.setOnTouchListener((v, event) -> {
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||||
|
@ -232,8 +241,14 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
} else {
|
} else {
|
||||||
intent = new Intent(context, ContextActivity.class);
|
intent = new Intent(context, ContextActivity.class);
|
||||||
}
|
}
|
||||||
intent.putExtra(Helper.ARG_STATUS, conversation.last_status);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, conversation.last_status);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.ui.drawer;
|
||||||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -31,6 +33,7 @@ import app.fedilab.android.databinding.DrawerMediaBinding;
|
||||||
import app.fedilab.android.mastodon.activities.ContextActivity;
|
import app.fedilab.android.mastodon.activities.ContextActivity;
|
||||||
import app.fedilab.android.mastodon.activities.MediaActivity;
|
import app.fedilab.android.mastodon.activities.MediaActivity;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Attachment;
|
import app.fedilab.android.mastodon.client.entities.api.Attachment;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
import app.fedilab.android.mastodon.ui.fragment.media.FragmentMediaProfile;
|
import app.fedilab.android.mastodon.ui.fragment.media.FragmentMediaProfile;
|
||||||
|
|
||||||
|
@ -89,13 +92,19 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
|
|
||||||
holder.binding.media.setOnLongClickListener(v -> {
|
holder.binding.media.setOnLongClickListener(v -> {
|
||||||
Intent intentContext = new Intent(context, ContextActivity.class);
|
Intent intentContext = new Intent(context, ContextActivity.class);
|
||||||
|
Bundle args = new Bundle();
|
||||||
if (attachment != null) {
|
if (attachment != null) {
|
||||||
intentContext.putExtra(Helper.ARG_STATUS, attachment.status);
|
args.putSerializable(Helper.ARG_STATUS, attachment.status);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intentContext.putExtras(bundle);
|
||||||
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(intentContext);
|
context.startActivity(intentContext);
|
||||||
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -503,9 +503,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal.quote);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, statusToDeal.quote);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
holder.binding.quotedMessage.cardviewContainer.setStrokeColor(ThemeHelper.getAttColor(context, R.attr.colorPrimary));
|
holder.binding.quotedMessage.cardviewContainer.setStrokeColor(ThemeHelper.getAttColor(context, R.attr.colorPrimary));
|
||||||
holder.binding.quotedMessage.statusContent.setText(
|
holder.binding.quotedMessage.statusContent.setText(
|
||||||
statusToDeal.quote.getSpanContent(context,
|
statusToDeal.quote.getSpanContent(context,
|
||||||
|
@ -1773,20 +1779,32 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
holder.binding.reblogInfo.setOnClickListener(v -> {
|
holder.binding.reblogInfo.setOnClickListener(v -> {
|
||||||
if (statusToDeal.reblogs_count > 0) {
|
if (statusToDeal.reblogs_count > 0) {
|
||||||
Intent intent = new Intent(context, StatusInfoActivity.class);
|
Intent intent = new Intent(context, StatusInfoActivity.class);
|
||||||
intent.putExtra(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.BOOSTED_BY);
|
Bundle args = new Bundle();
|
||||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||||
intent.putExtra(Helper.ARG_CHECK_REMOTELY, remote);
|
args.putSerializable(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.BOOSTED_BY);
|
||||||
|
args.putBoolean(Helper.ARG_CHECK_REMOTELY, remote);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
holder.binding.favouriteInfo.setOnClickListener(v -> {
|
holder.binding.favouriteInfo.setOnClickListener(v -> {
|
||||||
if (statusToDeal.favourites_count > 0) {
|
if (statusToDeal.favourites_count > 0) {
|
||||||
Intent intent = new Intent(context, StatusInfoActivity.class);
|
Intent intent = new Intent(context, StatusInfoActivity.class);
|
||||||
intent.putExtra(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.LIKED_BY);
|
Bundle args = new Bundle();
|
||||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||||
intent.putExtra(Helper.ARG_CHECK_REMOTELY, remote);
|
args.putSerializable(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.LIKED_BY);
|
||||||
|
args.putBoolean(Helper.ARG_CHECK_REMOTELY, remote);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2002,22 +2020,31 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (context instanceof ContextActivity && !remote) {
|
if (context instanceof ContextActivity && !remote) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
Fragment fragment = Helper.addFragment(((AppCompatActivity) context).getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, FragmentMastodonContext.class.getName());
|
Fragment fragment = Helper.addFragment(((AppCompatActivity) context).getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, FragmentMastodonContext.class.getName());
|
||||||
((ContextActivity) context).setCurrentFragment((FragmentMastodonContext) fragment);
|
((ContextActivity) context).setCurrentFragment((FragmentMastodonContext) fragment);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (remote) {
|
if (remote) {
|
||||||
//Lemmy main post that should open Lemmy threads
|
//Lemmy main post that should open Lemmy threads
|
||||||
if (adapter instanceof StatusAdapter && ((StatusAdapter) adapter).type == RemoteInstance.InstanceType.LEMMY && status.lemmy_post_id != null) {
|
if (adapter instanceof StatusAdapter && ((StatusAdapter) adapter).type == RemoteInstance.InstanceType.LEMMY && status.lemmy_post_id != null) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle args = new Bundle();
|
||||||
bundle.putSerializable(Helper.ARG_REMOTE_INSTANCE, ((StatusAdapter) adapter).pinnedTimeline);
|
args.putSerializable(Helper.ARG_REMOTE_INSTANCE, ((StatusAdapter) adapter).pinnedTimeline);
|
||||||
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
|
args.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
|
||||||
bundle.putString(Helper.ARG_LEMMY_POST_ID, status.lemmy_post_id);
|
args.putString(Helper.ARG_LEMMY_POST_ID, status.lemmy_post_id);
|
||||||
bundle.putSerializable(Helper.ARG_STATUS, status);
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
Intent intent = new Intent(context, TimelineActivity.class);
|
Intent intent = new Intent(context, TimelineActivity.class);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
|
|
||||||
} //Classic other cases for remote instances that will search the remote context
|
} //Classic other cases for remote instances that will search the remote context
|
||||||
else if (!(context instanceof ContextActivity)) { //We are not already checking a remote conversation
|
else if (!(context instanceof ContextActivity)) { //We are not already checking a remote conversation
|
||||||
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
||||||
|
@ -2026,8 +2053,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
||||||
Status fetchedStatus = results.statuses.get(0);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, fetchedStatus);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, fetchedStatus);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
@ -2047,8 +2080,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2262,8 +2301,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_report) {
|
} else if (itemId == R.id.action_report) {
|
||||||
Intent intent = new Intent(context, ReportActivity.class);
|
Intent intent = new Intent(context, ReportActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
} else if (itemId == R.id.action_copy) {
|
} else if (itemId == R.id.action_copy) {
|
||||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
String content;
|
String content;
|
||||||
|
@ -2317,8 +2362,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
||||||
} else if (itemId == R.id.action_custom_sharing) {
|
} else if (itemId == R.id.action_custom_sharing) {
|
||||||
Intent intent = new Intent(context, CustomSharingActivity.class);
|
Intent intent = new Intent(context, CustomSharingActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
} else if (itemId == R.id.action_mention) {
|
} else if (itemId == R.id.action_mention) {
|
||||||
Intent intent = new Intent(context, ComposeActivity.class);
|
Intent intent = new Intent(context, ComposeActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
|
@ -3183,9 +3234,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
});
|
});
|
||||||
holder.bindingArt.bottomBanner.setOnClickListener(v -> {
|
holder.bindingArt.bottomBanner.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, status);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, status);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} else if (viewHolder.getItemViewType() == STATUS_PIXELFED) {
|
} else if (viewHolder.getItemViewType() == STATUS_PIXELFED) {
|
||||||
Status statusToDeal = status.reblog != null ? status.reblog : status;
|
Status statusToDeal = status.reblog != null ? status.reblog : status;
|
||||||
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
||||||
|
@ -3223,9 +3280,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
});
|
});
|
||||||
holder.bindingPixelfed.bottomBanner.setOnClickListener(v -> {
|
holder.bindingPixelfed.bottomBanner.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||||
|
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
|
||||||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||||
import static app.fedilab.android.mastodon.activities.ContextActivity.displayCW;
|
import static app.fedilab.android.mastodon.activities.ContextActivity.displayCW;
|
||||||
import static app.fedilab.android.mastodon.activities.ContextActivity.expand;
|
import static app.fedilab.android.mastodon.activities.ContextActivity.expand;
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ import app.fedilab.android.databinding.FragmentPaginationBinding;
|
||||||
import app.fedilab.android.mastodon.activities.ContextActivity;
|
import app.fedilab.android.mastodon.activities.ContextActivity;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Context;
|
import app.fedilab.android.mastodon.client.entities.api.Context;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.client.entities.app.Timeline;
|
import app.fedilab.android.mastodon.client.entities.app.Timeline;
|
||||||
import app.fedilab.android.mastodon.helper.DividerDecoration;
|
import app.fedilab.android.mastodon.helper.DividerDecoration;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
|
@ -158,10 +160,21 @@ public class FragmentMastodonContext extends Fragment {
|
||||||
pullToRefresh = false;
|
pullToRefresh = false;
|
||||||
focusedStatusURI = null;
|
focusedStatusURI = null;
|
||||||
refresh = true;
|
refresh = true;
|
||||||
|
binding = FragmentPaginationBinding.inflate(inflater, container, false);
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
focusedStatus = (Status) getArguments().getSerializable(Helper.ARG_STATUS);
|
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
|
||||||
remote_instance = getArguments().getString(Helper.ARG_REMOTE_INSTANCE, null);
|
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||||
focusedStatusURI = getArguments().getString(Helper.ARG_FOCUSED_STATUS_URI, null);
|
} else {
|
||||||
|
initializeAfterBundle(null);
|
||||||
|
}
|
||||||
|
return binding.getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeAfterBundle(Bundle bundle) {
|
||||||
|
if (bundle != null) {
|
||||||
|
focusedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||||
|
remote_instance = bundle.getString(Helper.ARG_REMOTE_INSTANCE, null);
|
||||||
|
focusedStatusURI = bundle.getString(Helper.ARG_FOCUSED_STATUS_URI, null);
|
||||||
}
|
}
|
||||||
if (remote_instance != null) {
|
if (remote_instance != null) {
|
||||||
user_instance = remote_instance;
|
user_instance = remote_instance;
|
||||||
|
@ -174,7 +187,7 @@ public class FragmentMastodonContext extends Fragment {
|
||||||
getChildFragmentManager().beginTransaction().remove(this).commit();
|
getChildFragmentManager().beginTransaction().remove(this).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
binding = FragmentPaginationBinding.inflate(inflater, container, false);
|
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||||
boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false);
|
boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false);
|
||||||
binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar);
|
binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar);
|
||||||
|
@ -202,9 +215,9 @@ public class FragmentMastodonContext extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextCompat.registerReceiver(requireActivity(), receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION), ContextCompat.RECEIVER_NOT_EXPORTED);
|
ContextCompat.registerReceiver(requireActivity(), receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION), ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||||
return binding.getRoot();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
if (statuses != null) {
|
if (statuses != null) {
|
||||||
for (Status status : statuses) {
|
for (Status status : statuses) {
|
||||||
|
|
|
@ -82,6 +82,7 @@ import app.fedilab.android.mastodon.client.entities.api.Context;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Mention;
|
import app.fedilab.android.mastodon.client.entities.api.Mention;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Poll;
|
import app.fedilab.android.mastodon.client.entities.api.Poll;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
|
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
|
||||||
import app.fedilab.android.mastodon.exception.DBException;
|
import app.fedilab.android.mastodon.exception.DBException;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
|
@ -131,8 +132,21 @@ public class FragmentMastodonDirectMessage extends Fragment {
|
||||||
|
|
||||||
focusedStatus = null;
|
focusedStatus = null;
|
||||||
pullToRefresh = false;
|
pullToRefresh = false;
|
||||||
|
binding = FragmentDirectMessageBinding.inflate(inflater, container, false);
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
focusedStatus = (Status) getArguments().getSerializable(Helper.ARG_STATUS);
|
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
|
||||||
|
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||||
|
} else {
|
||||||
|
initializeAfterBundle(null);
|
||||||
|
}
|
||||||
|
return binding.getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void initializeAfterBundle(Bundle bundle) {
|
||||||
|
|
||||||
|
if (bundle != null) {
|
||||||
|
focusedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||||
}
|
}
|
||||||
user_instance = MainActivity.currentInstance;
|
user_instance = MainActivity.currentInstance;
|
||||||
user_token = MainActivity.currentToken;
|
user_token = MainActivity.currentToken;
|
||||||
|
@ -140,7 +154,7 @@ public class FragmentMastodonDirectMessage extends Fragment {
|
||||||
if (focusedStatus == null) {
|
if (focusedStatus == null) {
|
||||||
getChildFragmentManager().beginTransaction().remove(this).commit();
|
getChildFragmentManager().beginTransaction().remove(this).commit();
|
||||||
}
|
}
|
||||||
binding = FragmentDirectMessageBinding.inflate(inflater, container, false);
|
|
||||||
statusesVM = new ViewModelProvider(FragmentMastodonDirectMessage.this).get(StatusesVM.class);
|
statusesVM = new ViewModelProvider(FragmentMastodonDirectMessage.this).get(StatusesVM.class);
|
||||||
binding.recyclerView.setNestedScrollingEnabled(true);
|
binding.recyclerView.setNestedScrollingEnabled(true);
|
||||||
this.statuses = new ArrayList<>();
|
this.statuses = new ArrayList<>();
|
||||||
|
@ -216,10 +230,8 @@ public class FragmentMastodonDirectMessage extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return binding.getRoot();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void onSubmit(StatusDraft statusDraft) {
|
private void onSubmit(StatusDraft statusDraft) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
if (statusDraft.instance == null) {
|
if (statusDraft.instance == null) {
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.json.JSONObject;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.IDN;
|
import java.net.IDN;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
|
Loading…
Reference in a new issue