deep link bug fix
This commit is contained in:
parent
52a0a9b455
commit
51031dcd44
|
@ -67,7 +67,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
|
||||||
|
|
||||||
public static final String KEY_TWEET_ID = "tweetID";
|
public static final String KEY_TWEET_ID = "tweetID";
|
||||||
public static final String KEY_TWEET_NAME = "username";
|
public static final String KEY_TWEET_NAME = "username";
|
||||||
public static final Pattern linkPattern = Pattern.compile("https://twitter.com/\\w+/status/\\d+");
|
public static final Pattern LINK_PATTERN = Pattern.compile("https://twitter.com/\\w+/status/\\d+");
|
||||||
|
|
||||||
private TextView tweet_api, tweetDate, tweetText, scrName, usrName, tweetLocName;
|
private TextView tweet_api, tweetDate, tweetText, scrName, usrName, tweetLocName;
|
||||||
private Button rtwButton, favButton, replyName, tweetLocGPS;
|
private Button rtwButton, favButton, replyName, tweetLocGPS;
|
||||||
|
@ -315,17 +315,25 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLinkClick(String tag) {
|
public void onLinkClick(String tag) {
|
||||||
if (linkPattern.matcher(tag).matches()) {
|
String shortLink = tag;
|
||||||
String name = tag.substring(20, tag.indexOf('/', 20));
|
int cut = shortLink.indexOf('?');
|
||||||
long id = Long.parseLong(tag.substring(tag.lastIndexOf('/') + 1));
|
if (cut > 0) {
|
||||||
|
shortLink = shortLink.substring(0, cut);
|
||||||
|
}
|
||||||
|
if (LINK_PATTERN.matcher(shortLink).matches()) {
|
||||||
|
String name = shortLink.substring(20, shortLink.indexOf('/', 20));
|
||||||
|
long id = Long.parseLong(shortLink.substring(shortLink.lastIndexOf('/') + 1));
|
||||||
Intent intent = new Intent(this, TweetDetail.class);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
intent.putExtra(KEY_TWEET_ID, id);
|
intent.putExtra(KEY_TWEET_ID, id);
|
||||||
intent.putExtra(KEY_TWEET_NAME, name);
|
intent.putExtra(KEY_TWEET_NAME, name);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(tag));
|
Uri link = Uri.parse(tag);
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW, link);
|
||||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, R.string.error_connection_failed, LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,9 @@ import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_TYPE;
|
||||||
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_IMAGE;
|
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_IMAGE;
|
||||||
import static org.nuclearfog.twidda.activity.MessagePopup.KEY_DM_PREFIX;
|
import static org.nuclearfog.twidda.activity.MessagePopup.KEY_DM_PREFIX;
|
||||||
import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
|
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_PREFIX;
|
||||||
import static org.nuclearfog.twidda.activity.TwitterList.KEY_USERLIST_OWNER_ID;
|
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_ID;
|
||||||
|
@ -363,19 +366,29 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLinkClick(String link) {
|
public void onLinkClick(String tag) {
|
||||||
if (TweetDetail.linkPattern.matcher(link).matches()) {
|
String shortLink = tag;
|
||||||
|
int cut = shortLink.indexOf('?');
|
||||||
|
if (cut > 0) {
|
||||||
|
shortLink = shortLink.substring(0, cut);
|
||||||
|
}
|
||||||
|
if (LINK_PATTERN.matcher(shortLink).matches()) {
|
||||||
|
String name = shortLink.substring(20, shortLink.indexOf('/', 20));
|
||||||
|
long id = Long.parseLong(shortLink.substring(shortLink.lastIndexOf('/') + 1));
|
||||||
Intent intent = new Intent(this, TweetDetail.class);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
intent.setData(Uri.parse(link));
|
intent.putExtra(KEY_TWEET_ID, id);
|
||||||
|
intent.putExtra(KEY_TWEET_NAME, name);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
|
Uri link = Uri.parse(tag);
|
||||||
if (intent.resolveActivity(getPackageManager()) != null)
|
Intent intent = new Intent(Intent.ACTION_VIEW, link);
|
||||||
|
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
else
|
} else {
|
||||||
Toast.makeText(this, R.string.error_connection_failed, LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.error_connection_failed, LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,6 +40,9 @@ import static android.os.AsyncTask.Status.RUNNING;
|
||||||
import static android.widget.Toast.LENGTH_SHORT;
|
import static android.widget.Toast.LENGTH_SHORT;
|
||||||
import static org.nuclearfog.twidda.activity.MessagePopup.KEY_DM_PREFIX;
|
import static org.nuclearfog.twidda.activity.MessagePopup.KEY_DM_PREFIX;
|
||||||
import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
|
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.UserProfile.KEY_PROFILE_ID;
|
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_ID;
|
||||||
|
|
||||||
public class MessageFragment extends Fragment implements OnRefreshListener, OnItemSelected {
|
public class MessageFragment extends Fragment implements OnRefreshListener, OnItemSelected {
|
||||||
|
@ -104,14 +107,23 @@ public class MessageFragment extends Fragment implements OnRefreshListener, OnIt
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLinkClick(String link) {
|
public void onLinkClick(String tag) {
|
||||||
if (getContext() != null && !reload.isRefreshing()) {
|
if (getContext() != null) {
|
||||||
if (TweetDetail.linkPattern.matcher(link).matches()) {
|
String shortLink = tag;
|
||||||
|
int cut = shortLink.indexOf('?');
|
||||||
|
if (cut > 0) {
|
||||||
|
shortLink = shortLink.substring(0, cut);
|
||||||
|
}
|
||||||
|
if (LINK_PATTERN.matcher(shortLink).matches()) {
|
||||||
|
String name = shortLink.substring(20, shortLink.indexOf('/', 20));
|
||||||
|
long id = Long.parseLong(shortLink.substring(shortLink.lastIndexOf('/') + 1));
|
||||||
Intent intent = new Intent(getContext(), TweetDetail.class);
|
Intent intent = new Intent(getContext(), TweetDetail.class);
|
||||||
intent.setData(Uri.parse(link));
|
intent.putExtra(KEY_TWEET_ID, id);
|
||||||
|
intent.putExtra(KEY_TWEET_NAME, name);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
|
Uri link = Uri.parse(tag);
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW, link);
|
||||||
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
|
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue