Added long-press menu for timecode links
This commit is contained in:
parent
6b5d269185
commit
d6e0104337
|
@ -12,6 +12,7 @@
|
||||||
<item name="open_in_browser_item" type="id"/>
|
<item name="open_in_browser_item" type="id"/>
|
||||||
<item name="copy_url_item" type="id"/>
|
<item name="copy_url_item" type="id"/>
|
||||||
<item name="share_url_item" type="id"/>
|
<item name="share_url_item" type="id"/>
|
||||||
|
<item name="go_to_position_item" type="id"/>
|
||||||
<item name="organize_queue_item" type="id"/>
|
<item name="organize_queue_item" type="id"/>
|
||||||
<item name="drag_handle" type="id"/>
|
<item name="drag_handle" type="id"/>
|
||||||
<item name="skip_episode_item" type="id"/>
|
<item name="skip_episode_item" type="id"/>
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<string name="copy_url_label">Copy URL</string>
|
<string name="copy_url_label">Copy URL</string>
|
||||||
<string name="share_url_label">Share URL</string>
|
<string name="share_url_label">Share URL</string>
|
||||||
<string name="copied_url_msg">Copied URL to clipboard.</string>
|
<string name="copied_url_msg">Copied URL to clipboard.</string>
|
||||||
|
<string name="go_to_position_label">Go to this position</string>
|
||||||
|
|
||||||
<!-- Playback history -->
|
<!-- Playback history -->
|
||||||
<string name="clear_history_label">Clear history</string>
|
<string name="clear_history_label">Clear history</string>
|
||||||
|
|
|
@ -14,7 +14,6 @@ import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -32,6 +31,7 @@ import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.feed.FeedItem;
|
import de.danoeh.antennapod.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||||
import de.danoeh.antennapod.storage.DBReader;
|
import de.danoeh.antennapod.storage.DBReader;
|
||||||
|
import de.danoeh.antennapod.util.Converter;
|
||||||
import de.danoeh.antennapod.util.ShareUtils;
|
import de.danoeh.antennapod.util.ShareUtils;
|
||||||
import de.danoeh.antennapod.util.ShownotesProvider;
|
import de.danoeh.antennapod.util.ShownotesProvider;
|
||||||
import de.danoeh.antennapod.util.playback.Playable;
|
import de.danoeh.antennapod.util.playback.Playable;
|
||||||
|
@ -126,13 +126,7 @@ public class ItemDescriptionFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
if (Timeline.isTimecodeLink(url)) {
|
if (Timeline.isTimecodeLink(url)) {
|
||||||
int time = Timeline.getTimecodeLinkTime(url);
|
onTimecodeLinkSelected(url);
|
||||||
if (getActivity() != null && getActivity() instanceof ItemDescriptionFragmentCallback) {
|
|
||||||
PlaybackController pc = ((ItemDescriptionFragmentCallback) getActivity()).getPlaybackController();
|
|
||||||
if (pc != null) {
|
|
||||||
pc.seekTo(time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||||
try {
|
try {
|
||||||
|
@ -272,11 +266,9 @@ public class ItemDescriptionFragment extends Fragment {
|
||||||
+ r.getExtra()
|
+ r.getExtra()
|
||||||
);
|
);
|
||||||
selectedURL = r.getExtra();
|
selectedURL = r.getExtra();
|
||||||
if (!Timeline.isTimecodeLink(selectedURL)) {
|
|
||||||
webvDescription.showContextMenu();
|
webvDescription.showContextMenu();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
selectedURL = null;
|
selectedURL = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -313,6 +305,13 @@ public class ItemDescriptionFragment extends Fragment {
|
||||||
R.string.copied_url_msg, Toast.LENGTH_SHORT);
|
R.string.copied_url_msg, Toast.LENGTH_SHORT);
|
||||||
t.show();
|
t.show();
|
||||||
break;
|
break;
|
||||||
|
case R.id.go_to_position_item:
|
||||||
|
if (Timeline.isTimecodeLink(selectedURL)) {
|
||||||
|
onTimecodeLinkSelected(selectedURL);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Selected go_to_position_item, but URL was no timecode link: " + selectedURL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
handled = false;
|
handled = false;
|
||||||
break;
|
break;
|
||||||
|
@ -329,6 +328,11 @@ public class ItemDescriptionFragment extends Fragment {
|
||||||
ContextMenuInfo menuInfo) {
|
ContextMenuInfo menuInfo) {
|
||||||
if (selectedURL != null) {
|
if (selectedURL != null) {
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
|
if (Timeline.isTimecodeLink(selectedURL)) {
|
||||||
|
menu.add(Menu.NONE, R.id.go_to_position_item, Menu.NONE,
|
||||||
|
R.string.go_to_position_label);
|
||||||
|
menu.setHeaderTitle(Converter.getDurationStringLong(Timeline.getTimecodeLinkTime(selectedURL)));
|
||||||
|
} else {
|
||||||
menu.add(Menu.NONE, R.id.open_in_browser_item, Menu.NONE,
|
menu.add(Menu.NONE, R.id.open_in_browser_item, Menu.NONE,
|
||||||
R.string.open_in_browser_label);
|
R.string.open_in_browser_label);
|
||||||
menu.add(Menu.NONE, R.id.copy_url_item, Menu.NONE,
|
menu.add(Menu.NONE, R.id.copy_url_item, Menu.NONE,
|
||||||
|
@ -338,6 +342,7 @@ public class ItemDescriptionFragment extends Fragment {
|
||||||
menu.setHeaderTitle(selectedURL);
|
menu.setHeaderTitle(selectedURL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private AsyncTask<Void, Void, Void> createLoader() {
|
private AsyncTask<Void, Void, Void> createLoader() {
|
||||||
return new AsyncTask<Void, Void, Void>() {
|
return new AsyncTask<Void, Void, Void>() {
|
||||||
|
@ -455,6 +460,16 @@ public class ItemDescriptionFragment extends Fragment {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onTimecodeLinkSelected(String link) {
|
||||||
|
int time = Timeline.getTimecodeLinkTime(link);
|
||||||
|
if (getActivity() != null && getActivity() instanceof ItemDescriptionFragmentCallback) {
|
||||||
|
PlaybackController pc = ((ItemDescriptionFragmentCallback) getActivity()).getPlaybackController();
|
||||||
|
if (pc != null) {
|
||||||
|
pc.seekTo(time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public interface ItemDescriptionFragmentCallback {
|
public interface ItemDescriptionFragmentCallback {
|
||||||
public PlaybackController getPlaybackController();
|
public PlaybackController getPlaybackController();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue