mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-12-01 12:31:45 +00:00
Implemented PlaybackHistoryActivity
This commit is contained in:
@ -225,6 +225,7 @@
|
|||||||
android:screenOrientation="landscape"
|
android:screenOrientation="landscape"
|
||||||
android:theme="@style/VideoplayerTheme" >
|
android:theme="@style/VideoplayerTheme" >
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:label="@string/playback_history_label" android:name=".activity.PlaybackHistoryActivity"></activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
8
res/layout/playbackhistory_activity.xml
Normal file
8
res/layout/playbackhistory_activity.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/playbackhistory_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
<item android:id="@id/search_item" android:icon="@drawable/action_search" android:title="@string/search_label" android:showAsAction="ifRoom|collapseActionView"></item><item android:id="@+id/show_player" android:title="@string/show_player_label" android:icon="@drawable/av_play" android:showAsAction="collapseActionView"></item>
|
<item android:id="@id/search_item" android:icon="@drawable/action_search" android:title="@string/search_label" android:showAsAction="ifRoom|collapseActionView"></item><item android:id="@+id/show_player" android:title="@string/show_player_label" android:icon="@drawable/av_play" android:showAsAction="collapseActionView"></item>
|
||||||
<item android:id="@+id/opml_import" android:title="@string/opml_import_label" android:showAsAction="collapseActionView"></item>
|
<item android:id="@+id/opml_import" android:title="@string/opml_import_label" android:showAsAction="collapseActionView"></item>
|
||||||
<item android:id="@+id/opml_export" android:title="@string/opml_export_label"></item><item android:id="@+id/show_downloads" android:title="@string/downloads_label" android:icon="@drawable/av_download" android:showAsAction="collapseActionView">
|
<item android:id="@+id/opml_export" android:title="@string/opml_export_label"></item><item android:id="@+id/show_playback_history" android:title="@string/playback_history_label" android:showAsAction="collapseActionView"></item><item android:id="@+id/show_downloads" android:title="@string/downloads_label" android:icon="@drawable/av_download" android:showAsAction="collapseActionView">
|
||||||
</item><item android:id="@+id/show_preferences" android:title="@string/settings_label" android:icon="@drawable/action_settings" android:showAsAction="collapseActionView"></item>
|
</item><item android:id="@+id/show_preferences" android:title="@string/settings_label" android:icon="@drawable/action_settings" android:showAsAction="collapseActionView"></item>
|
||||||
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@ -10,5 +10,6 @@
|
|||||||
<item type="id" name="search_item"/>
|
<item type="id" name="search_item"/>
|
||||||
<item name="enqueue_all_item" type="id"/>
|
<item name="enqueue_all_item" type="id"/>
|
||||||
<item name="download_all_item" type="id"/>
|
<item name="download_all_item" type="id"/>
|
||||||
|
<item type="id" name="clear_history_item"/>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@ -10,6 +10,10 @@
|
|||||||
<string name="downloads_label">Downloads</string>
|
<string name="downloads_label">Downloads</string>
|
||||||
<string name="cancel_download_label">Cancel Download</string>
|
<string name="cancel_download_label">Cancel Download</string>
|
||||||
<string name="download_log_label">Download log</string>
|
<string name="download_log_label">Download log</string>
|
||||||
|
<string name="playback_history_label">Playback history</string>
|
||||||
|
|
||||||
|
<!-- Playback history -->
|
||||||
|
<string name="clear_history_label">Clear history</string>
|
||||||
|
|
||||||
<!-- Other -->
|
<!-- Other -->
|
||||||
<string name="confirm_label">Confirm</string>
|
<string name="confirm_label">Confirm</string>
|
||||||
|
|||||||
@ -127,6 +127,9 @@ public class MainActivity extends SherlockFragmentActivity {
|
|||||||
case R.id.search_item:
|
case R.id.search_item:
|
||||||
onSearchRequested();
|
onSearchRequested();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.show_playback_history:
|
||||||
|
startActivity(new Intent(this, PlaybackHistoryActivity.class));
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,57 @@
|
|||||||
|
package de.danoeh.antennapod.activity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
|
import com.actionbarsherlock.view.Menu;
|
||||||
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.AppConfig;
|
||||||
|
import de.danoeh.antennapod.R;
|
||||||
|
import de.danoeh.antennapod.feed.FeedManager;
|
||||||
|
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
|
||||||
|
|
||||||
|
public class PlaybackHistoryActivity extends SherlockFragmentActivity {
|
||||||
|
private static final String TAG = "PlaybackHistoryActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
menu.add(Menu.NONE, R.id.clear_history_item, Menu.NONE,
|
||||||
|
R.string.clear_history_label).setShowAsAction(
|
||||||
|
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
|
| Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
case R.id.clear_history_item:
|
||||||
|
FeedManager.getInstance().clearPlaybackHistory(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle arg0) {
|
||||||
|
super.onCreate(arg0);
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Activity created");
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
setContentView(R.layout.playbackhistory_activity);
|
||||||
|
|
||||||
|
FragmentTransaction fT = getSupportFragmentManager().beginTransaction();
|
||||||
|
fT.replace(R.id.playbackhistory_fragment, new PlaybackHistoryFragment());
|
||||||
|
fT.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -325,6 +325,33 @@ public class FeedManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearPlaybackHistory(final Context context) {
|
||||||
|
if (!playbackHistory.isEmpty()) {
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Clearing playback history.");
|
||||||
|
final FeedItem[] items = playbackHistory
|
||||||
|
.toArray(new FeedItem[playbackHistory.size()]);
|
||||||
|
playbackHistory.clear();
|
||||||
|
sendPlaybackHistoryUpdateBroadcast(context);
|
||||||
|
dbExec.execute(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||||
|
adapter.open();
|
||||||
|
for (FeedItem item : items) {
|
||||||
|
if (item.getMedia() != null
|
||||||
|
&& item.getMedia().getPlaybackCompletionDate() != null) {
|
||||||
|
item.getMedia().setPlaybackCompletionDate(null);
|
||||||
|
adapter.setMedia(item.getMedia());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
adapter.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addItemToPlaybackHistory(Context context, FeedItem item) {
|
public void addItemToPlaybackHistory(Context context, FeedItem item) {
|
||||||
if (item.getMedia() != null
|
if (item.getMedia() != null
|
||||||
&& item.getMedia().getPlaybackCompletionDate() != null) {
|
&& item.getMedia().getPlaybackCompletionDate() != null) {
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
package de.danoeh.antennapod.fragment;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import de.danoeh.antennapod.AppConfig;
|
||||||
|
import de.danoeh.antennapod.feed.FeedManager;
|
||||||
|
|
||||||
|
public class PlaybackHistoryFragment extends ItemlistFragment {
|
||||||
|
private static final String TAG = "PlaybackHistoryFragment";
|
||||||
|
|
||||||
|
public PlaybackHistoryFragment() {
|
||||||
|
super(FeedManager.getInstance().getPlaybackHistory(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
getActivity().registerReceiver(historyUpdate,
|
||||||
|
new IntentFilter(FeedManager.ACTION_PLAYBACK_HISTORY_UPDATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
try {
|
||||||
|
getActivity().unregisterReceiver(historyUpdate);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BroadcastReceiver historyUpdate = new BroadcastReceiver() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Received content update");
|
||||||
|
fila.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user