added long click to share link to other instances

This commit is contained in:
Mariotaku Lee 2017-05-17 14:59:50 +08:00
parent f431d67a10
commit 0fb832776e
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
3 changed files with 21 additions and 6 deletions

View File

@ -225,6 +225,7 @@ public interface IntentConstants {
String EXTRA_PLACE_NAME = "place_name";
String EXTRA_SCHEDULE_INFO = "schedule_info";
String EXTRA_VISIBILITY = "visibility";
String EXTRA_SELECTION = "selection";
String EXTRA_SAVE_DRAFT = "save_draft";
String EXTRA_HOST = "host";
String EXTRA_LOCAL = "local";

View File

@ -1117,8 +1117,12 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
else -> extraText
}
val selectionEnd = editText.length()
editText.setSelection(selectionEnd)
val selection = intent.getIntExtra(EXTRA_SELECTION, -1)
if (selection < 0) {
editText.setSelection(editText.length())
} else {
editText.setSelection(selection.coerceIn(0..editText.length()))
}
return true
}

View File

@ -42,6 +42,7 @@ import org.mariotaku.ktextension.*
import org.mariotaku.sqliteqb.library.Expression
import org.mariotaku.twidere.R
import org.mariotaku.twidere.activity.AccountSelectorActivity
import org.mariotaku.twidere.activity.ComposeActivity
import org.mariotaku.twidere.adapter.ParcelableStatusesAdapter
import org.mariotaku.twidere.adapter.decorator.ExtendedDividerItemDecoration
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter
@ -621,7 +622,7 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
return true
}
R.id.retweet -> {
val intent = selectAccountIntent(fragment.context, status, itemId)
val intent = selectAccountIntent(fragment.context, status, itemId, false)
fragment.startActivityForResult(intent, REQUEST_RETWEET_SELECT_ACCOUNT)
return true
}
@ -650,7 +651,13 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
val accountKey = data.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY)
val extras = data.getBundleExtra(EXTRA_EXTRAS)
val status = extras.getParcelable<ParcelableStatus>(EXTRA_STATUS)
fragment.executeAfterFragmentResumed {
if (status.account_key.host != accountKey.host) {
val composeIntent = Intent(fragment.context, ComposeActivity::class.java)
composeIntent.putExtra(Intent.EXTRA_TEXT, " ${LinkCreator.getStatusWebLink(status)}")
composeIntent.putExtra(EXTRA_ACCOUNT_KEY, accountKey)
composeIntent.putExtra(EXTRA_SELECTION, 0)
fragment.startActivity(composeIntent)
} else fragment.executeAfterFragmentResumed {
RetweetQuoteDialogFragment.show(it.childFragmentManager, accountKey,
status.id, status)
}
@ -658,10 +665,13 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
}
}
fun selectAccountIntent(context: Context, status: ParcelableStatus, itemId: Long): Intent {
fun selectAccountIntent(context: Context, status: ParcelableStatus, itemId: Long,
sameHostOnly: Boolean = true): Intent {
val intent = Intent(context, AccountSelectorActivity::class.java)
intent.putExtra(EXTRA_SELECT_ONLY_ITEM_AUTOMATICALLY, true)
intent.putExtra(EXTRA_ACCOUNT_HOST, status.account_key.host)
if (sameHostOnly) {
intent.putExtra(EXTRA_ACCOUNT_HOST, status.account_key.host)
}
intent.putExtra(EXTRA_SINGLE_SELECTION, true)
intent.putExtra(EXTRA_EXTRAS, Bundle {
this[EXTRA_STATUS] = status