implemented all functions for removing and renaming feeds.
This commit is contained in:
parent
ce6540acaf
commit
1fdccd1137
8 changed files with 538 additions and 66 deletions
|
@ -61,6 +61,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -372,6 +373,9 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
drawerToggle.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
public void switchToAllUnreadItems() {
|
||||
StartDetailFragment(SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS.getValue(), true, null, true);
|
||||
}
|
||||
public void reloadCountNumbersOfSlidingPaneAdapter() {
|
||||
NewsReaderListFragment nlf = getSlidingListFragment();
|
||||
if (nlf != null) {
|
||||
|
@ -379,7 +383,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
}
|
||||
}
|
||||
|
||||
private void updateCurrentRssView() {
|
||||
public void updateCurrentRssView() {
|
||||
NewsReaderDetailFragment ndf = getNewsReaderDetailFragment();
|
||||
if (ndf != null) {
|
||||
//ndf.reloadAdapterFromScratch();
|
||||
|
@ -615,8 +619,8 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
String iconurl = dbConn.getFeedById(idFeed).getFaviconUrl();
|
||||
String feedurl = dbConn.getFeedById(idFeed).getLink();
|
||||
|
||||
System.out.println("***********************: " + dbConn.getFeedById(idFeed).getLink());
|
||||
DialogFragment fragment = NewsReaderListDialogFragment.newInstance(titel, iconurl, feedurl);
|
||||
NewsReaderListDialogFragment fragment = NewsReaderListDialogFragment.newInstance(idFeed, titel, iconurl, feedurl);
|
||||
fragment.setActivity(this);
|
||||
fragment.show(ft, "news_reader_list_dialog");
|
||||
}
|
||||
}
|
||||
|
@ -855,8 +859,9 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if(resultCode == RESULT_OK){
|
||||
UpdateListView();
|
||||
if(resultCode == RESULT_OK){
|
||||
|
||||
UpdateListView();
|
||||
|
||||
getSlidingListFragment().ListViewNotifyDataSetChanged();
|
||||
}
|
||||
|
@ -884,11 +889,11 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
}
|
||||
}
|
||||
|
||||
private NewsReaderListFragment getSlidingListFragment() {
|
||||
public /*private*/ NewsReaderListFragment getSlidingListFragment() {
|
||||
return ((NewsReaderListFragment) getSupportFragmentManager().findFragmentById(R.id.left_drawer));
|
||||
}
|
||||
|
||||
private NewsReaderDetailFragment getNewsReaderDetailFragment() {
|
||||
public NewsReaderDetailFragment getNewsReaderDetailFragment() {
|
||||
return (NewsReaderDetailFragment) getSupportFragmentManager().findFragmentById(R.id.content_frame);
|
||||
}
|
||||
|
||||
|
@ -897,18 +902,18 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
LoginDialogFragment dialog = LoginDialogFragment.getInstance();
|
||||
dialog.setActivity(activity);
|
||||
dialog.setListener(new LoginSuccessfullListener() {
|
||||
@Override
|
||||
public void LoginSucceeded() {
|
||||
((NewsReaderListActivity) activity).getSlidingListFragment().ReloadAdapter();
|
||||
((NewsReaderListActivity) activity).updateCurrentRssView();
|
||||
((NewsReaderListActivity) activity).startSync();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void LoginSucceeded() {
|
||||
((NewsReaderListActivity) activity).getSlidingListFragment().ReloadAdapter();
|
||||
((NewsReaderListActivity) activity).updateCurrentRssView();
|
||||
((NewsReaderListActivity) activity).startSync();
|
||||
}
|
||||
});
|
||||
dialog.show(activity.getSupportFragmentManager(), "NoticeDialogFragment");
|
||||
}
|
||||
|
||||
|
||||
private void UpdateListView()
|
||||
public /*private*/ void UpdateListView()
|
||||
{
|
||||
getNewsReaderDetailFragment().notifyDataSetChangedOnAdapter();
|
||||
}
|
||||
|
@ -1041,7 +1046,8 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
}
|
||||
}
|
||||
|
||||
private class UserInfo implements Serializable {
|
||||
|
||||
private class UserInfo implements Serializable {
|
||||
private String mUserId;
|
||||
private String mDisplayName;
|
||||
private Bitmap mAvatar;
|
||||
|
|
|
@ -1,27 +1,38 @@
|
|||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nostra13.universalimageloader.cache.disc.DiskCache;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
|
||||
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
||||
import de.luhmer.owncloudnewsreader.reader.HttpJsonRequest;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.API;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -29,10 +40,11 @@ import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
|||
*/
|
||||
public class NewsReaderListDialogFragment extends DialogFragment{
|
||||
|
||||
static NewsReaderListDialogFragment newInstance(String dialogTitle, String iconurl, String feedurl) {
|
||||
static NewsReaderListDialogFragment newInstance(long feedId, String dialogTitle, String iconurl, String feedurl) {
|
||||
NewsReaderListDialogFragment f = new NewsReaderListDialogFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("feedid", feedId);
|
||||
args.putString("title", dialogTitle);
|
||||
args.putString("iconurl", iconurl);
|
||||
args.putString("feedurl", feedurl);
|
||||
|
@ -42,40 +54,52 @@ public class NewsReaderListDialogFragment extends DialogFragment{
|
|||
}
|
||||
|
||||
|
||||
private long mFeedId;
|
||||
private String mDialogTitle;
|
||||
private String mDialogText;
|
||||
private String mDialogIconUrl;
|
||||
private URL mImageUrl;
|
||||
|
||||
private FavIconHandler favIconHandler;
|
||||
private RemoveFeedTask mRemoveFeedTask = null;
|
||||
private RenameFeedTask mRenameFeedTask = null;
|
||||
private LinkedHashMap<String, MenuAction> mMenuItems;
|
||||
|
||||
private NewsReaderListActivity parentActivity;
|
||||
|
||||
private RelativeLayout mRemoveFeedDialogView, mRenameFeedDialogView, mProgressView;
|
||||
private Button mButtonRemoveConfirm, mButtonRemoveCancel, mButtonRenameConfirm, mButtonRenameCancel;
|
||||
private ListView mListView;
|
||||
private EditText mFeedName;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mFeedId = getArguments().getLong("feedid");
|
||||
mDialogTitle = getArguments().getString("title");
|
||||
mDialogIconUrl = getArguments().getString("iconurl");
|
||||
mDialogText = getArguments().getString("feedurl");
|
||||
mMenuItems = new LinkedHashMap<>();
|
||||
|
||||
mMenuItems.put("Rename feed"/*getString(R.string.action_img_download)*/, new MenuAction() {
|
||||
mMenuItems.put(getString(R.string.action_feed_rename), new MenuAction() {
|
||||
@Override
|
||||
public void execute() {
|
||||
renameFeed();
|
||||
attemptRenameFeed(mFeedId, mDialogTitle);
|
||||
}
|
||||
});
|
||||
|
||||
mMenuItems.put("Remove feed"/*getString(R.string.action_img_download)*/, new MenuAction() {
|
||||
mMenuItems.put(getString(R.string.action_feed_remove), new MenuAction() {
|
||||
@Override
|
||||
public void execute() {
|
||||
removeFeed();
|
||||
attemptRemoveFeed(mFeedId);
|
||||
}
|
||||
});
|
||||
|
||||
int style = DialogFragment.STYLE_NO_TITLE;
|
||||
int theme = ThemeChooser.isDarkTheme(getActivity())
|
||||
? R.style.Theme_Material_Dialog_Floating
|
||||
: R.style.Theme_Material_Light_Dialog_Floating;
|
||||
? R.style.FloatingDialog
|
||||
: R.style.FloatingDialogLight;
|
||||
setStyle(style, theme);
|
||||
}
|
||||
|
||||
|
@ -84,36 +108,39 @@ public class NewsReaderListDialogFragment extends DialogFragment{
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_dialog_image, container, false);
|
||||
View v = inflater.inflate(R.layout.fragment_dialog_feedoptions, container, false);
|
||||
|
||||
TextView tvTitle = (TextView) v.findViewById(R.id.ic_menu_title);
|
||||
TextView tvText = (TextView) v.findViewById(R.id.ic_menu_item_text);
|
||||
ImageView imgTitle = (ImageView) v.findViewById(R.id.ic_menu_gallery);
|
||||
ImageView imgTitle = (ImageView) v.findViewById(R.id.ic_menu_feedicon);
|
||||
|
||||
mRemoveFeedDialogView = (RelativeLayout) v.findViewById(R.id.remove_feed_dialog);
|
||||
mRenameFeedDialogView = (RelativeLayout) v.findViewById(R.id.rename_feed_dialog);
|
||||
mProgressView = (RelativeLayout) v.findViewById(R.id.progressView);
|
||||
mButtonRemoveConfirm = (Button) v.findViewById(R.id.button_remove_confirm);
|
||||
mButtonRemoveCancel = (Button) v.findViewById(R.id.button_remove_cancel);
|
||||
mButtonRenameConfirm = (Button) v.findViewById(R.id.button_rename_confirm);
|
||||
mButtonRenameCancel = (Button) v.findViewById(R.id.button_rename_cancel);
|
||||
mFeedName = (EditText) v.findViewById(R.id.renamefeed_feedname);
|
||||
|
||||
tvTitle.setText(mDialogTitle);
|
||||
tvText.setText(mDialogText);
|
||||
|
||||
|
||||
ViewGroup.LayoutParams params=((View)imgTitle).getLayoutParams();
|
||||
params.width=80;
|
||||
params.height=80;
|
||||
imgTitle.setLayoutParams(params);
|
||||
|
||||
if(mDialogIconUrl != null) {
|
||||
DiskCache diskCache = ImageLoader.getInstance().getDiskCache();
|
||||
File file = diskCache.get(mDialogIconUrl);
|
||||
if (file != null) {
|
||||
mDialogIconUrl = file.getAbsolutePath();
|
||||
imgTitle.setImageDrawable(new BitmapDrawable(mDialogIconUrl));
|
||||
} else {
|
||||
imgTitle.setImageResource(R.drawable.default_feed_icon_light);
|
||||
tvText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(mDialogText != null) {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(mDialogText));
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
imgTitle.setImageResource(R.drawable.default_feed_icon_light);
|
||||
}
|
||||
});
|
||||
|
||||
ListView mListView = (ListView) v.findViewById(R.id.ic_menu_item_list);
|
||||
favIconHandler = new FavIconHandler(getContext());
|
||||
favIconHandler.loadFavIconForFeed(mDialogIconUrl, imgTitle);
|
||||
|
||||
mListView = (ListView) v.findViewById(R.id.xx_menu_item_list);
|
||||
List<String> menuItemsList = new ArrayList<>(mMenuItems.keySet());
|
||||
|
||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(
|
||||
|
@ -132,21 +159,212 @@ public class NewsReaderListDialogFragment extends DialogFragment{
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
public void setActivity(Activity parentActivity) {
|
||||
this.parentActivity = (NewsReaderListActivity)parentActivity;
|
||||
|
||||
|
||||
private void renameFeed() {
|
||||
System.out.println("************** renameFeed");
|
||||
}
|
||||
|
||||
private void removeFeed() {
|
||||
System.out.println("************** removeFeed");
|
||||
|
||||
public void showProgress(final boolean show) {
|
||||
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
|
||||
|
||||
mRenameFeedDialogView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
mRemoveFeedDialogView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mProgressView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void attemptRenameFeed(final long feedId, final String feedName) {
|
||||
|
||||
mFeedName.setText(feedName);
|
||||
mButtonRenameConfirm.setEnabled(false);
|
||||
|
||||
mListView.setVisibility(View.GONE);
|
||||
mRenameFeedDialogView.setVisibility(View.VISIBLE);
|
||||
|
||||
mFeedName.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
if (s.toString().equals(feedName) || s.length() == 0) {
|
||||
mButtonRenameConfirm.setEnabled(false);
|
||||
} else {
|
||||
mButtonRenameConfirm.setEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mButtonRenameCancel.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
mButtonRenameConfirm.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
showProgress(true);
|
||||
setCancelable(false);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
mRenameFeedTask = new RenameFeedTask(feedId, mFeedName.getText().toString() ); //TODO needs testing!
|
||||
mRenameFeedTask.execute((Void) null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void attemptRemoveFeed(final long feedId) {
|
||||
|
||||
mListView.setVisibility(View.GONE);
|
||||
mRemoveFeedDialogView.setVisibility(View.VISIBLE);
|
||||
|
||||
mButtonRemoveCancel.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
mButtonRemoveConfirm.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
showProgress(true);
|
||||
setCancelable(false);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
mRemoveFeedTask = new RemoveFeedTask(feedId); //TODO needs testing!
|
||||
mRemoveFeedTask.execute((Void) null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
interface MenuAction {
|
||||
void execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class RemoveFeedTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
private final long mFeedId;
|
||||
|
||||
RemoveFeedTask(long feedId) {
|
||||
this.mFeedId = feedId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
API api = new APIv2(HttpJsonRequest.getInstance().getRootUrl());
|
||||
|
||||
try {
|
||||
int status = HttpJsonRequest.getInstance().performRemoveFeedRequest(api.getFeedUrl(),
|
||||
mFeedId);
|
||||
if(status == 200) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Log.d("NewFeedActivity", "Status: " + status);
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Boolean success) {
|
||||
mRemoveFeedTask = null;
|
||||
|
||||
if (success) {
|
||||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(getContext());
|
||||
dbConn.removeFeedById(mFeedId);
|
||||
|
||||
Long currentFeedId = parentActivity.getNewsReaderDetailFragment().getIdFeed();
|
||||
if(currentFeedId != null && currentFeedId == mFeedId) {
|
||||
parentActivity.switchToAllUnreadItems();
|
||||
}
|
||||
parentActivity.getSlidingListFragment().ReloadAdapter();
|
||||
parentActivity.updateCurrentRssView();
|
||||
|
||||
//parentActivity.UpdateItemList();
|
||||
//parentActivity.UpdateListView();
|
||||
//parentActivity.getSlidingListFragment().ListViewNotifyDataSetChanged();
|
||||
//parentActivity.startSync();
|
||||
} else {
|
||||
Toast.makeText(getContext().getApplicationContext(), getString(R.string.login_dialog_text_something_went_wrong), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
mRemoveFeedTask = null;
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class RenameFeedTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
private final long mFeedId;
|
||||
private final String mFeedName;
|
||||
|
||||
RenameFeedTask(long feedId, String newName) {
|
||||
mFeedId = feedId;
|
||||
mFeedName = newName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
API api = new APIv2(HttpJsonRequest.getInstance().getRootUrl());
|
||||
|
||||
try {
|
||||
int status = HttpJsonRequest.getInstance().performRenameFeedRequest(api.getFeedUrl(),
|
||||
mFeedId, mFeedName);
|
||||
if(status == 200) {
|
||||
return true;
|
||||
}
|
||||
Log.d("NewFeedActivity", "Status: " + status);
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Boolean success) {
|
||||
mRenameFeedTask = null;
|
||||
|
||||
if (success) {
|
||||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(getContext());
|
||||
dbConn.renameFeedById(mFeedId, mFeedName);
|
||||
|
||||
parentActivity.getSlidingListFragment().ReloadAdapter();
|
||||
//parentActivity.updateCurrentRssView();
|
||||
parentActivity.startSync();
|
||||
} else {
|
||||
Toast.makeText(getContext().getApplicationContext(), getString(R.string.login_dialog_text_something_went_wrong), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
mRenameFeedTask = null;
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,16 +218,8 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
|
|||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
|
||||
|
||||
int groupPosition = ExpandableListView.getPackedPositionGroup(id);
|
||||
int childPosition = ExpandableListView.getPackedPositionChild(id);
|
||||
|
||||
Long optional_id_folder = null;
|
||||
FolderSubscribtionItem groupItem = (FolderSubscribtionItem) lvAdapter.getGroup(groupPosition);
|
||||
if(groupItem != null)
|
||||
optional_id_folder = groupItem.id_database;
|
||||
|
||||
mCallbacks.onChildItemLongClicked(childPosition, optional_id_folder);
|
||||
mCallbacks.onChildItemLongClicked(childPosition, null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -330,10 +330,26 @@ public class DatabaseConnectionOrm {
|
|||
|
||||
public void removeFeedById(long feedId) {
|
||||
daoSession.getFeedDao().deleteByKey(feedId);
|
||||
|
||||
List<RssItem> list = daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.FeedId.eq(feedId)).list();
|
||||
for (RssItem rssItem : list) {
|
||||
//if(!rssItem.getStarred() && !rssItem.getStarred_temp()) {
|
||||
daoSession.getRssItemDao().delete(rssItem);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void renameFeedById(long feedId, String newTitle) {
|
||||
Feed feed = daoSession.getFeedDao().queryBuilder().where(FeedDao.Properties.Id.eq(feedId)).unique();
|
||||
feed.setFeedTitle(newTitle);
|
||||
/*
|
||||
List<RssItem> list = daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.FeedId.eq(feedId)).list();
|
||||
for (RssItem rssItem : list) {
|
||||
rssItem.setFeed(feed);
|
||||
}
|
||||
*/
|
||||
daoSession.getFeedDao().update(feed);
|
||||
}
|
||||
|
||||
public SparseArray<String> getUrlsToFavIcons() {
|
||||
SparseArray<String> favIconUrls = new SparseArray<>();
|
||||
|
|
|
@ -34,6 +34,8 @@ import com.squareup.okhttp.Request;
|
|||
import com.squareup.okhttp.RequestBody;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.KeyManagementException;
|
||||
|
@ -187,6 +189,41 @@ public class HttpJsonRequest {
|
|||
return response.code();
|
||||
}
|
||||
|
||||
|
||||
public int performRemoveFeedRequest(HttpUrl url, long feedId) throws Exception {
|
||||
HttpUrl feedUrl = url.newBuilder()
|
||||
.addPathSegment(String.valueOf(feedId))
|
||||
.build();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(feedUrl)
|
||||
.delete()
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
return response.code();
|
||||
}
|
||||
|
||||
|
||||
public int performRenameFeedRequest(HttpUrl url, long feedId, String newFeedName) throws Exception {
|
||||
HttpUrl feedUrl = url.newBuilder()
|
||||
.addPathSegment(String.valueOf(feedId))
|
||||
.addPathSegment("rename")
|
||||
.build();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(feedUrl)
|
||||
.put(RequestBody.create(JSON, new JSONObject().put("feedTitle", newFeedName).toString()))
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
return response.code();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int performTagChangeRequest(HttpUrl url, String content) throws Exception
|
||||
{
|
||||
Request request = new Request.Builder()
|
||||
|
|
|
@ -50,6 +50,8 @@ public class InsertFeedIntoDatabase implements IHandleJsonObject{
|
|||
feed.setFeedTitle(e.optString("title"));
|
||||
feed.setFolderId(e.optLong("folderId"));
|
||||
feed.setFaviconUrl(faviconLink);
|
||||
//feed.setLink(e.optString("link"));
|
||||
feed.setLink(e.optString("url"));
|
||||
|
||||
return feed;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,196 @@
|
|||
<?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:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:id="@+id/title_wrapper">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/ic_menu_feedicon"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:id="@+id/ic_menu_title"
|
||||
tools:text="Sample1"
|
||||
android:layout_centerVertical="true"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_toRightOf="@+id/ic_menu_feedicon"
|
||||
android:layout_toEndOf="@+id/ic_menu_feedicon"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="6dp"
|
||||
android:id="@+id/ic_menu_item_text"
|
||||
tools:text="Sample1"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_below="@+id/title_wrapper"
|
||||
android:textStyle="normal"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:background="#c8ababab"
|
||||
android:layout_below="@+id/ic_menu_item_text"/>
|
||||
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="13dp"
|
||||
android:divider="@null"
|
||||
android:id="@+id/xx_menu_item_list"
|
||||
android:layout_below="@+id/ic_menu_item_text">
|
||||
</ListView>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/remove_feed_dialog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/ic_menu_item_text"
|
||||
android:layout_marginTop="13dp"
|
||||
android:visibility="gone">
|
||||
<TextView
|
||||
android:layout_marginTop="13dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="6dp"
|
||||
android:paddingLeft="6dp"
|
||||
android:textSize="18sp"
|
||||
android:id="@+id/textView"
|
||||
android:layout_alignParentEnd="false"
|
||||
android:layout_alignParentStart="true"
|
||||
android:text="Do you really want to remove this Feed?
|
||||
This cannot be undone!"
|
||||
android:layout_marginBottom="13dp"></TextView>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/textView"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginRight="0dp">
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Cancel"
|
||||
android:id="@+id/button_remove_cancel"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginLeft="0dp" />
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Remove"
|
||||
android:id="@+id/button_remove_confirm"
|
||||
android:layout_toEndOf="@id/button_remove_confirm"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginRight="0dp" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rename_feed_dialog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/ic_menu_item_text"
|
||||
android:layout_marginTop="13dp"
|
||||
android:visibility="gone">
|
||||
<EditText
|
||||
android:layout_marginTop="13dp"
|
||||
android:paddingRight="6dp"
|
||||
android:paddingLeft="6dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/renamefeed_feedname"
|
||||
android:layout_alignParentEnd="false"
|
||||
android:layout_alignParentStart="true"
|
||||
android:textSize="18sp"
|
||||
android:text="Do you really want to remove this Feed? This cannot be undone!"
|
||||
android:layout_marginBottom="13dp"
|
||||
android:singleLine="true"
|
||||
android:lines="1"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textVisiblePassword"></EditText>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/renamefeed_feedname"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginRight="0dp">
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Cancel"
|
||||
android:id="@+id/button_rename_cancel"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginLeft="0dp" />
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Rename"
|
||||
android:id="@+id/button_rename_confirm"
|
||||
android:layout_toEndOf="@id/button_rename_cancel"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginRight="0dp" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/progressView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/ic_menu_item_text"
|
||||
android:layout_marginTop="13dp"
|
||||
android:visibility="gone">
|
||||
<ProgressBar
|
||||
android:id="@+id/alter_feedSource_progress"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginTop="12dp"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -70,6 +70,11 @@
|
|||
<string name="intent_title_share">Share via</string>
|
||||
|
||||
|
||||
<!-- Strings related to NewsReaderListDialogFragment (Rename/Remove Feed) -->
|
||||
<string name="action_feed_remove">Remove Feed</string>
|
||||
<string name="action_feed_rename">Rename Feed</string>
|
||||
|
||||
|
||||
<!-- Strings related to login -->
|
||||
<string name="pref_title_username">Username</string>
|
||||
<string name="pref_title_password">Password</string>
|
||||
|
|
Loading…
Reference in a new issue