mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-30 10:55:06 +01:00
added deep link for sharing tweets, layout fix
This commit is contained in:
parent
073a761309
commit
239b60ee81
@ -22,7 +22,7 @@ import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.adapter.FragmentAdapter;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
|
||||
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_PREFIX;
|
||||
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_TEXT;
|
||||
|
||||
/**
|
||||
* Twitter search Activity
|
||||
@ -98,7 +98,7 @@ public class SearchPage extends AppCompatActivity implements OnTabSelectedListen
|
||||
if (item.getItemId() == R.id.search_tweet) {
|
||||
Intent intent = new Intent(this, TweetPopup.class);
|
||||
if (search.startsWith("#"))
|
||||
intent.putExtra(KEY_TWEETPOPUP_PREFIX, search);
|
||||
intent.putExtra(KEY_TWEETPOPUP_TEXT, search + " ");
|
||||
startActivity(intent);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
@ -53,8 +53,8 @@ import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_ANGIF;
|
||||
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_IMAGE;
|
||||
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_VIDEO;
|
||||
import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
|
||||
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_PREFIX;
|
||||
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_REPLYID;
|
||||
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_TEXT;
|
||||
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_ID;
|
||||
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_MODE;
|
||||
import static org.nuclearfog.twidda.activity.UserDetail.USERLIST_RETWEETS;
|
||||
@ -218,9 +218,10 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
|
||||
if (statusAsync != null && tweet != null && statusAsync.getStatus() != RUNNING) {
|
||||
switch (v.getId()) {
|
||||
case R.id.tweet_answer:
|
||||
String tweetPrefix = tweet.getUser().getScreenname() + " ";
|
||||
Intent tweetPopup = new Intent(this, TweetPopup.class);
|
||||
tweetPopup.putExtra(KEY_TWEETPOPUP_REPLYID, tweet.getId());
|
||||
tweetPopup.putExtra(KEY_TWEETPOPUP_PREFIX, tweet.getUser().getScreenname());
|
||||
tweetPopup.putExtra(KEY_TWEETPOPUP_TEXT, tweetPrefix);
|
||||
startActivity(tweetPopup);
|
||||
break;
|
||||
|
||||
|
@ -55,7 +55,7 @@ import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_VIDEO;
|
||||
public class TweetPopup extends AppCompatActivity implements OnClickListener, LocationListener, OnDismissListener {
|
||||
|
||||
public static final String KEY_TWEETPOPUP_REPLYID = "tweet_replyID";
|
||||
public static final String KEY_TWEETPOPUP_PREFIX = "tweet_prefix";
|
||||
public static final String KEY_TWEETPOPUP_TEXT = "tweet_text";
|
||||
|
||||
private enum MediaType {
|
||||
NONE,
|
||||
@ -110,8 +110,8 @@ public class TweetPopup extends AppCompatActivity implements OnClickListener, Lo
|
||||
Bundle param = getIntent().getExtras();
|
||||
if (param != null) {
|
||||
inReplyId = param.getLong(KEY_TWEETPOPUP_REPLYID, 0);
|
||||
if (param.containsKey(KEY_TWEETPOPUP_PREFIX)) {
|
||||
String addition = param.getString(KEY_TWEETPOPUP_PREFIX) + " ";
|
||||
if (param.containsKey(KEY_TWEETPOPUP_TEXT)) {
|
||||
String addition = param.getString(KEY_TWEETPOPUP_TEXT);
|
||||
tweetText.append(addition);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
|
||||
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_ID;
|
||||
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_NAME;
|
||||
import static org.nuclearfog.twidda.activity.TweetDetail.LINK_PATTERN;
|
||||
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_PREFIX;
|
||||
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_TEXT;
|
||||
import static org.nuclearfog.twidda.activity.TwitterList.KEY_USERLIST_OWNER_ID;
|
||||
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_ID;
|
||||
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_MODE;
|
||||
@ -267,9 +267,10 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
if (user != null && properties != null) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.profile_tweet:
|
||||
String tweetPrefix = user.getScreenname() + " ";
|
||||
Intent tweet = new Intent(this, TweetPopup.class);
|
||||
if (user.getId() != settings.getUserId())
|
||||
tweet.putExtra(KEY_TWEETPOPUP_PREFIX, user.getScreenname());
|
||||
tweet.putExtra(KEY_TWEETPOPUP_TEXT, tweetPrefix);
|
||||
startActivity(tweet);
|
||||
break;
|
||||
|
||||
|
@ -12,6 +12,7 @@ import org.nuclearfog.twidda.activity.DirectMessage;
|
||||
import org.nuclearfog.twidda.activity.MainActivity;
|
||||
import org.nuclearfog.twidda.activity.SearchPage;
|
||||
import org.nuclearfog.twidda.activity.TweetDetail;
|
||||
import org.nuclearfog.twidda.activity.TweetPopup;
|
||||
import org.nuclearfog.twidda.activity.TwitterList;
|
||||
import org.nuclearfog.twidda.activity.UserProfile;
|
||||
|
||||
@ -21,6 +22,7 @@ import java.util.regex.Pattern;
|
||||
import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
|
||||
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_ID;
|
||||
import static org.nuclearfog.twidda.activity.TweetDetail.KEY_TWEET_NAME;
|
||||
import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_TEXT;
|
||||
import static org.nuclearfog.twidda.activity.TwitterList.KEY_USERLIST_OWNER_NAME;
|
||||
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_NAME;
|
||||
|
||||
@ -57,15 +59,15 @@ public class LinkContentLoader extends AsyncTask<Uri, Integer, LinkContentLoader
|
||||
String path = link.getPath();
|
||||
if (path != null && path.length() > 1) {
|
||||
path = path.substring(1);
|
||||
if (path.startsWith("home")) {
|
||||
if (path.equals("home")) {
|
||||
publishProgress(0);
|
||||
} else if (path.startsWith("i/trends")) {
|
||||
} else if (path.equals("i/trends") || path.equals("trends") || path.equals("explore")) {
|
||||
publishProgress(1);
|
||||
} else if (path.startsWith("notifications")) {
|
||||
} else if (path.equals("notifications")) {
|
||||
publishProgress(2);
|
||||
} else if (path.startsWith("messages")) {
|
||||
} else if (path.equals("messages")) {
|
||||
dataHolder = new DataHolder(null, DirectMessage.class);
|
||||
} else if (path.startsWith("search")) {
|
||||
} else if (path.equals("search")) {
|
||||
if (link.isHierarchical()) {
|
||||
String search = link.getQueryParameter("q");
|
||||
if (search != null) {
|
||||
@ -73,21 +75,24 @@ public class LinkContentLoader extends AsyncTask<Uri, Integer, LinkContentLoader
|
||||
dataHolder = new DataHolder(data, SearchPage.class);
|
||||
}
|
||||
}
|
||||
} else if (path.startsWith("hashtag")) {
|
||||
int cut = path.indexOf('/');
|
||||
if (cut > 0) {
|
||||
String search = '#' + path.substring(cut + 1);
|
||||
data.putString(KEY_SEARCH_QUERY, search);
|
||||
dataHolder = new DataHolder(data, SearchPage.class);
|
||||
} else if (path.equals("intent/tweet")) {
|
||||
if (link.isHierarchical()) {
|
||||
String tweet = link.getQueryParameter("text");
|
||||
if (tweet != null) {
|
||||
data.putString(KEY_TWEETPOPUP_TEXT, tweet);
|
||||
dataHolder = new DataHolder(data, TweetPopup.class);
|
||||
}
|
||||
}
|
||||
} else if (path.startsWith("hashtag/")) {
|
||||
String search = '#' + path.substring(8);
|
||||
data.putString(KEY_SEARCH_QUERY, search);
|
||||
dataHolder = new DataHolder(data, SearchPage.class);
|
||||
} else if (USER_PATH.matcher(path).matches()) {
|
||||
if (!path.equals("explore")) {
|
||||
int end = path.indexOf('/');
|
||||
if (end > 0)
|
||||
path = path.substring(0, end);
|
||||
data.putString(KEY_PROFILE_NAME, path);
|
||||
dataHolder = new DataHolder(data, UserProfile.class);
|
||||
}
|
||||
int end = path.indexOf('/');
|
||||
if (end > 0)
|
||||
path = path.substring(0, end);
|
||||
data.putString(KEY_PROFILE_NAME, path);
|
||||
dataHolder = new DataHolder(data, UserProfile.class);
|
||||
} else if (TWEET_PATH.matcher(path).matches()) {
|
||||
String username = '@' + path.substring(0, path.indexOf('/'));
|
||||
long tweetId = Long.parseLong(path.substring(path.lastIndexOf('/') + 1));
|
||||
|
@ -4,6 +4,6 @@
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M15.173,2H4C2.899,2 2,2.9 2,4v12c0,1.1 0.899,2 2,2h12c1.101,0 2,-0.9 2,-2V5.127L15.173,2zM14,8c0,0.549 -0.45,1 -1,1H7C6.45,9 6,8.549 6,8V3h8V8zM13,4h-2v4h2V4z" />
|
||||
</vector>
|
||||
|
Loading…
x
Reference in New Issue
Block a user