Added export menu item

This commit is contained in:
daniel oeh 2012-07-26 19:36:38 +02:00
parent cbb1bed530
commit fab2110715
3 changed files with 10 additions and 2 deletions

View File

@ -16,6 +16,7 @@
<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/show_downloads" android:title="Downloads" 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_downloads" android:title="Downloads" 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>

View File

@ -18,6 +18,7 @@ import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window; import com.actionbarsherlock.view.Window;
import com.viewpagerindicator.TabPageIndicator; import com.viewpagerindicator.TabPageIndicator;
import de.danoeh.antennapod.asynctask.OpmlExportWorker;
import de.danoeh.antennapod.feed.FeedManager; import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.fragment.FeedlistFragment; import de.danoeh.antennapod.fragment.FeedlistFragment;
import de.danoeh.antennapod.fragment.QueueFragment; import de.danoeh.antennapod.fragment.QueueFragment;
@ -108,6 +109,9 @@ public class MainActivity extends SherlockFragmentActivity {
case R.id.opml_import: case R.id.opml_import:
startActivity(new Intent(this, OpmlImportActivity.class)); startActivity(new Intent(this, OpmlImportActivity.class));
return true; return true;
case R.id.opml_export:
new OpmlExportWorker(this).executeAsync();
return false;
case R.id.search_item: case R.id.search_item:
onSearchRequested(); onSearchRequested();
return true; return true;
@ -125,6 +129,9 @@ public class MainActivity extends SherlockFragmentActivity {
} else { } else {
refreshAll.setVisible(true); refreshAll.setVisible(true);
} }
boolean hasFeeds = !manager.getFeeds().isEmpty();
menu.findItem(R.id.opml_export).setVisible(hasFeeds);
return true; return true;
} }

View File

@ -19,7 +19,7 @@ import de.danoeh.antennapod.opml.OpmlWriter;
/** Writes an OPML file into the export directory in the background. */ /** Writes an OPML file into the export directory in the background. */
public class OpmlExportWorker extends AsyncTask<Void, Void, Void> { public class OpmlExportWorker extends AsyncTask<Void, Void, Void> {
private static final String TAG = "OpmlExportWorker"; private static final String TAG = "OpmlExportWorker";
private static final String DEFAULT_OUTPUT_NAME = "AntennaPod-Feeds.opml"; private static final String DEFAULT_OUTPUT_NAME = "antennapod-feeds.opml";
private Context context; private Context context;
private File output; private File output;