merge subscriptions view updates

This commit is contained in:
Tom Hennen 2016-03-25 12:53:26 -04:00
commit 7ed82bcac3
29 changed files with 408 additions and 6 deletions

View File

@ -19,7 +19,6 @@ dependencies {
compile("org.shredzone.flattr4j:flattr4j-core:$flattr4jVersion") {
exclude group: "org.json", module: "json"
}
compile "commons-io:commons-io:$commonsioVersion"
compile "org.jsoup:jsoup:$jsoupVersion"
compile "com.github.bumptech.glide:glide:$glideVersion"
@ -49,14 +48,14 @@ dependencies {
def getMyVersionName() {
def parsedManifestXml = (new XmlSlurper())
.parse("${projectDir}/src/main/AndroidManifest.xml")
.declareNamespace(android:"http://schemas.android.com/apk/res/android")
.declareNamespace(android: "http://schemas.android.com/apk/res/android")
return parsedManifestXml."@android:versionName"
}
def getMyVersionCode() {
def parsedManifestXml = (new XmlSlurper())
.parse("${projectDir}/src/main/AndroidManifest.xml")
.declareNamespace(android:"http://schemas.android.com/apk/res/android")
.declareNamespace(android: "http://schemas.android.com/apk/res/android")
return parsedManifestXml."@android:versionCode".toInteger()
}
@ -150,7 +149,7 @@ task filterAbout {
from "src/main/templates/about.html"
into "src/main/assets"
filter(ReplaceTokens, tokens: [versionname: android.defaultConfig.versionName,
commit: "git rev-parse --short HEAD".execute().text])
commit : "git rev-parse --short HEAD".execute().text])
}
}

View File

@ -43,13 +43,17 @@ import de.danoeh.antennapod.core.event.ProgressEvent;
import de.danoeh.antennapod.core.event.QueueEvent;
import de.danoeh.antennapod.core.feed.EventDistributor;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.core.util.StorageUtils;
import de.danoeh.antennapod.core.util.playback.Playable;
import de.danoeh.antennapod.core.util.playback.PlaybackController;
import de.danoeh.antennapod.dialog.RatingDialog;
import de.danoeh.antennapod.fragment.AddFeedFragment;
import de.danoeh.antennapod.fragment.DownloadsFragment;
@ -58,6 +62,7 @@ import de.danoeh.antennapod.fragment.ExternalPlayerFragment;
import de.danoeh.antennapod.fragment.ItemlistFragment;
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
import de.danoeh.antennapod.fragment.QueueFragment;
import de.danoeh.antennapod.fragment.SubscriptionFragment;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.preferences.PreferenceController;
import de.greenrobot.event.EventBus;
@ -94,6 +99,7 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
EpisodesFragment.TAG,
DownloadsFragment.TAG,
PlaybackHistoryFragment.TAG,
SubscriptionFragment.TAG,
AddFeedFragment.TAG
};
@ -269,7 +275,7 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
}
public void loadFragment(int index, Bundle args) {
Log.d(TAG, "loadFragment(index: " + index + ", args: " + args +")");
Log.d(TAG, "loadFragment(index: " + index + ", args: " + args + ")");
if (index < navAdapter.getSubscriptionOffset()) {
String tag = navAdapter.getTags().get(index);
loadFragment(tag, args);
@ -298,6 +304,11 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
case AddFeedFragment.TAG:
fragment = new AddFeedFragment();
break;
case SubscriptionFragment.TAG:
SubscriptionFragment subscriptionFragment = new SubscriptionFragment();
subscriptionFragment.setItemAccess(itemAccess);
fragment = subscriptionFragment;
break;
default:
// default to the queue
tag = QueueFragment.TAG;
@ -646,6 +657,7 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
public int getFeedCounter(long feedId) {
return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0;
}
};
private void loadData() {
@ -671,6 +683,10 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
loadData();
}
public void onEvent(SubscriptionFragment.SubscriptionEvent event) {
loadFeedFragmentById(event.feed.getId(), null);
}
public void onEventMainThread(ProgressEvent event) {
Log.d(TAG, "onEvent(" + event + ")");
switch(event.action) {

View File

@ -19,6 +19,7 @@ import com.bumptech.glide.Glide;
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.widget.IconTextView;
import de.danoeh.antennapod.fragment.SubscriptionFragment;
import org.apache.commons.lang3.ArrayUtils;
import java.util.ArrayList;
@ -108,6 +109,9 @@ public class NavListAdapter extends BaseAdapter
case PlaybackHistoryFragment.TAG:
icon = R.attr.ic_history;
break;
case SubscriptionFragment.TAG:
icon = R.attr.ic_folder;
break;
case AddFeedFragment.TAG:
icon = R.attr.content_new;
break;
@ -127,7 +131,11 @@ public class NavListAdapter extends BaseAdapter
@Override
public int getCount() {
return getSubscriptionOffset() + itemAccess.getCount();
int baseCount = getSubscriptionOffset();
if (UserPreferences.showSubscriptionsInDrawer()) {
baseCount += itemAccess.getCount();
}
return baseCount;
}
@Override

View File

@ -0,0 +1,70 @@
package de.danoeh.antennapod.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.view.SubscriptionViewItem;
/**
* Adapter for subscriptions
*/
public class SubscriptionsAdapter extends BaseAdapter {
private NavListAdapter.ItemAccess mItemAccess;
private Context mContext;
public SubscriptionsAdapter(Context context, NavListAdapter.ItemAccess itemAccess) {
mItemAccess = itemAccess;
mContext = context;
}
public void setItemAccess(NavListAdapter.ItemAccess itemAccess) {
mItemAccess = itemAccess;
}
@Override
public int getCount() {
return mItemAccess.getCount();
}
@Override
public Object getItem(int position) {
return mItemAccess.getItem(position);
}
@Override
public long getItemId(int position) {
return mItemAccess.getItem(position).getId();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder;
final Feed item = (Feed) getItem(position);
if (item == null) return null;
if (convertView == null) {
holder = new Holder();
LayoutInflater inflater =
(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.subscription_item, parent, false);
holder.itemView = (SubscriptionViewItem) convertView.findViewById(R.id.subscription_item);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
holder.itemView.setFeed(item);
return convertView;
}
static class Holder {
SubscriptionViewItem itemView;
}
}

View File

@ -0,0 +1,113 @@
package de.danoeh.antennapod.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import java.util.ArrayList;
import java.util.List;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.adapter.NavListAdapter;
import de.danoeh.antennapod.adapter.SubscriptionsAdapter;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.storage.DBReader;
import de.greenrobot.event.EventBus;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* Fragment for displaying feed subscriptions
*/
public class SubscriptionFragment extends Fragment {
public static final String TAG = "SubscriptionFragment";
private GridView mSubscriptionGridLayout;
private DBReader.NavDrawerData mDrawerData;
private SubscriptionsAdapter mSubscriptionAdapter;
private NavListAdapter.ItemAccess mItemAccess;
private List<Feed> mSubscriptionList = new ArrayList<>();
public SubscriptionFragment() {
}
public void setItemAccess(NavListAdapter.ItemAccess itemAccess) {
mItemAccess = itemAccess;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_subscriptions, container, false);
mSubscriptionGridLayout = (GridView) root.findViewById(R.id.subscriptions_grid);
return root;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mSubscriptionAdapter = new SubscriptionsAdapter(getActivity(), mItemAccess);
mSubscriptionGridLayout.setAdapter(mSubscriptionAdapter);
Observable.fromCallable(() -> loadData())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
mDrawerData = result;
mSubscriptionList = mDrawerData.feeds;
mSubscriptionAdapter.setItemAccess(mItemAccess);
mSubscriptionAdapter.notifyDataSetChanged();
}, error -> {
Log.e(TAG, Log.getStackTraceString(error));
});
mSubscriptionGridLayout.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
EventBus.getDefault().post(new SubscriptionEvent(mSubscriptionList.get(position)));
}
});
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.my_subscriptions);
}
}
@Override
public void onResume() {
super.onResume();
}
public class SubscriptionEvent {
public final Feed feed;
SubscriptionEvent(Feed f) {
feed = f;
}
}
private DBReader.NavDrawerData loadData() {
return DBReader.getNavDrawerData();
}
}

View File

@ -0,0 +1,83 @@
package de.danoeh.antennapod.view;
import android.content.Context;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.Feed;
/**
* Custom view for handling feed item.
*/
public class SubscriptionViewItem extends RelativeLayout {
private ImageView mImageView;
private TextView mTextTime;
private TextView mFeedTitle;
private Context mContext;
public SubscriptionViewItem(Context context) {
super(context);
init(context);
}
public SubscriptionViewItem(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public SubscriptionViewItem(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
private void init(Context context) {
mContext = context;
LayoutInflater mLayoutInflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = mLayoutInflater.inflate(R.layout.subscription_view, this);
mTextTime = (TextView) view.findViewById(R.id.txtvTime);
mFeedTitle = (TextView) view.findViewById(R.id.txtvTitle);
mImageView = (ImageView) view.findViewById(R.id.imgvCover);
}
public void setFeed(Feed feed) {
mFeedTitle.setVisibility(VISIBLE);
mFeedTitle.setText(feed.getTitle());
Glide.with(mContext)
.load(feed.getImageUri())
.listener(new RequestListener<Uri, GlideDrawable>() {
@Override
public boolean onException(Exception e, Uri model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, Uri model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
mFeedTitle.setVisibility(INVISIBLE);
return false;
}
})
.centerCrop()
.into(mImageView);
mTextTime.setVisibility(GONE);
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="1dp"
android:color="@color/white"/>
</shape>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/subscriptions_grid"
android:layout_width="match_parent"
android:numColumns="3"
android:horizontalSpacing="2dp"
android:verticalSpacing="2dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
</GridView>
</LinearLayout>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<de.danoeh.antennapod.view.SubscriptionViewItem
android:layout_width="match_parent"
android:id="@+id/subscription_item"
android:layout_height="match_parent"/>
</RelativeLayout>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imgvCover"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
tools:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/txtvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="@dimen/widget_margin"
android:ellipsize="end"
android:padding="@dimen/widget_margin"
style="@style/AntennaPod.TextView.Heading"
android:textSize="15sp"
android:textStyle="bold"
tools:text="@string/app_name" />
<TextView
android:id="@+id/txtvTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/widget_margin"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/white"
android:textSize="12sp"
tools:text="@string/app_name" />
</RelativeLayout>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="time_just_now">just now</string>
<string name="time_a_min_ago">a min ago</string>
<string name="time_an_hour_ago">an hour ago</string>
<string name="time_min_ago">" min ago"</string>
<string name="time_yesterday">yesterday</string>
<string name="time_hours_ago">" hours ago"</string>
<string name="time_days_ago">" days ago"</string>
</resources>

View File

@ -36,6 +36,12 @@
android:summary="@string/pref_nav_drawer_feed_counter_sum"
android:defaultValue="0"
app:useStockLayout="true"/>
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:defaultValue="true"
android:enabled="true"
android:key="prefShowSubscriptionsInDrawer"
android:summary="@string/pref_show_subscriptions_in_drawer_sum"
android:title="@string/pref_show_subscriptions_in_drawer_title"/>
</PreferenceScreen>
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:defaultValue="false"

View File

@ -112,6 +112,7 @@ public class UserPreferences {
public static final int EPISODE_CLEANUP_QUEUE = -1;
public static final int EPISODE_CLEANUP_NULL = -2;
public static final int EPISODE_CLEANUP_DEFAULT = 0;
private static final String PREF_SHOW_SUBSCRIPTIONS_IN_DRAWER = "prefShowSubscriptionsInDrawer";
// Constants
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
@ -174,6 +175,10 @@ public class UserPreferences {
return Integer.parseInt(value);
}
public static boolean showSubscriptionsInDrawer() {
return prefs.getBoolean(PREF_SHOW_SUBSCRIPTIONS_IN_DRAWER, true);
}
/**
* Returns notification priority.
*

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

View File

@ -148,6 +148,7 @@
<item>@string/episodes_label</item>
<item>@string/downloads_label</item>
<item>@string/playback_history_label</item>
<item>@string/my_subscriptions</item>
<item>@string/add_feed_label</item>
</string-array>

View File

@ -21,6 +21,7 @@
<attr name="navigation_up" format="reference"/>
<attr name="social_share" format="reference"/>
<attr name="stat_playlist" format="reference"/>
<attr name="ic_folder" format="reference"/>
<attr name="type_audio" format="reference"/>
<attr name="type_video" format="reference"/>
<attr name="borderless_button" format="reference"/>

View File

@ -30,6 +30,7 @@
<dimen name="listitem_threeline_horizontalpadding">16dp</dimen>
<dimen name="list_vertical_padding">8dp</dimen>
<dimen name="minimum_text_margin">8dp</dimen>
<dimen name="listitem_icon_leftpadding">16dp</dimen>
<dimen name="listitem_icon_rightpadding">16dp</dimen>

View File

@ -22,6 +22,7 @@
<string name="downloads_running_label">Running</string>
<string name="downloads_completed_label">Completed</string>
<string name="downloads_log_label">Log</string>
<string name="my_subscriptions">Subscriptions</string>
<string name="cancel_download_label">Cancel\nDownload</string>
<string name="playback_history_label">Playback History</string>
<string name="gpodnet_main_label">gpodder.net</string>
@ -383,6 +384,8 @@
<string name="pref_expandNotify_sum">Always expand the notification to show playback buttons.</string>
<string name="pref_persistNotify_title">Persistent Playback Controls</string>
<string name="pref_persistNotify_sum">Keep notification and lockscreen controls when playback is paused.</string>
<string name="pref_show_subscriptions_in_drawer_title">Show subscriptions</string>
<string name="pref_show_subscriptions_in_drawer_sum">Show subscription list directly in navigation drawer</string>
<string name="pref_lockscreen_background_title">Set Lockscreen Background</string>
<string name="pref_lockscreen_background_sum">Set the lockscreen background to the current episode\'s image. As a side effect, this will also show the image in third party apps.</string>
<string name="pref_showDownloadReport_title">Show Download Report</string>

View File

@ -37,6 +37,7 @@
<item name="attr/nav_drawer_background">@color/white</item>
<item name="attr/ic_new">@drawable/ic_new_releases_grey600_24dp</item>
<item name="attr/ic_history">@drawable/ic_history_grey600_24dp</item>
<item name="attr/ic_folder">@drawable/ic_folder_grey600_24dp</item>
<item name="attr/av_play_big">@drawable/ic_play_arrow_grey600_36dp</item>
<item name="attr/av_pause_big">@drawable/ic_pause_grey600_36dp</item>
<item name="attr/av_ff_big">@drawable/ic_fast_forward_grey600_36dp</item>
@ -94,6 +95,7 @@
<item name="attr/nav_drawer_background">#3B3B3B</item>
<item name="attr/ic_new">@drawable/ic_new_releases_white_24dp</item>
<item name="attr/ic_history">@drawable/ic_history_white_24dp</item>
<item name="attr/ic_folder">@drawable/ic_folder_white_24dp</item>
<item name="attr/av_play_big">@drawable/ic_play_arrow_white_36dp</item>
<item name="attr/av_pause_big">@drawable/ic_pause_white_36dp</item>
<item name="attr/av_ff_big">@drawable/ic_fast_forward_white_36dp</item>
@ -152,6 +154,7 @@
<item name="attr/nav_drawer_background">@color/white</item>
<item name="attr/ic_new">@drawable/ic_new_releases_grey600_24dp</item>
<item name="attr/ic_history">@drawable/ic_history_grey600_24dp</item>
<item name="attr/ic_folder">@drawable/ic_folder_grey600_24dp</item>
<item name="attr/av_play_big">@drawable/ic_play_arrow_grey600_36dp</item>
<item name="attr/av_pause_big">@drawable/ic_pause_grey600_36dp</item>
<item name="attr/av_ff_big">@drawable/ic_fast_forward_grey600_36dp</item>
@ -210,6 +213,7 @@
<item name="attr/nav_drawer_background">#3B3B3B</item>
<item name="attr/ic_new">@drawable/ic_new_releases_white_24dp</item>
<item name="attr/ic_history">@drawable/ic_history_white_24dp</item>
<item name="attr/ic_folder">@drawable/ic_folder_white_24dp</item>
<item name="attr/av_play_big">@drawable/ic_play_arrow_white_36dp</item>
<item name="attr/av_pause_big">@drawable/ic_pause_white_36dp</item>
<item name="attr/av_ff_big">@drawable/ic_fast_forward_white_36dp</item>

1
submodules/dslv Submodule

@ -0,0 +1 @@
Subproject commit 5f58dff340f705b4dc7f920f81c33d382919c3ad