mirror of https://github.com/readrops/Readrops.git
Modify edit feed dialog opening way and add feed website link opening on long click
This commit is contained in:
parent
f8054d14a9
commit
54b4aa15a7
|
@ -5,6 +5,7 @@
|
|||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -16,7 +17,7 @@
|
|||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity android:name=".activities.ManageFeedsActivity"
|
||||
android:parentActivityName=".activities.MainActivitys">
|
||||
android:parentActivityName=".activities.MainActivity">
|
||||
|
||||
</activity>
|
||||
<activity
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.readrops.app.activities;
|
||||
|
||||
import android.arch.lifecycle.ViewModelProvider;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Vibrator;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
@ -56,6 +59,15 @@ public class ManageFeedsActivity extends AppCompatActivity {
|
|||
public void onDelete(FeedWithFolder feedWithFolder) {
|
||||
deleteFolder(feedWithFolder.getFeed().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenLink(FeedWithFolder feedWithFolder) {
|
||||
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
|
||||
vibrator.vibrate(50);
|
||||
|
||||
Intent urlIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(feedWithFolder.getFeed().getSiteUrl()));
|
||||
startActivity(urlIntent);
|
||||
}
|
||||
});
|
||||
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
|
|
@ -44,7 +44,7 @@ public interface FeedDao {
|
|||
|
||||
@Query("Select Feed.name as feed_name, Feed.id as feed_id, Folder.name as folder_name, Folder.id as folder_id," +
|
||||
"Feed.description as feed_description, Feed.icon_url as feed_icon_url, Feed.url as feed_url, Feed.folder_id as feed_folder_id" +
|
||||
" from Feed Inner Join Folder on Feed.folder_id = Folder.id Order by Feed.name")
|
||||
", Feed.siteUrl as feed_siteUrl from Feed Inner Join Folder on Feed.folder_id = Folder.id Order by Feed.name")
|
||||
LiveData<List<FeedWithFolder>> getAllFeedsWithFolder();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ public class FeedsAdapter extends ListAdapter<FeedWithFolder, FeedsAdapter.ViewH
|
|||
private static final DiffUtil.ItemCallback<FeedWithFolder> DIFF_CALLBACK = new DiffUtil.ItemCallback<FeedWithFolder>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull FeedWithFolder feedWithFolder, @NonNull FeedWithFolder t1) {
|
||||
Log.d("", "areItemsTheSame: ");
|
||||
return feedWithFolder.getFeed().getId() == t1.getFeed().getId();
|
||||
}
|
||||
|
||||
|
@ -67,6 +66,8 @@ public class FeedsAdapter extends ListAdapter<FeedWithFolder, FeedsAdapter.ViewH
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||
|
@ -100,7 +101,11 @@ public class FeedsAdapter extends ListAdapter<FeedWithFolder, FeedsAdapter.ViewH
|
|||
else
|
||||
viewHolder.folderName.setText(viewHolder.itemView.getResources().getString(R.string.no_folder));
|
||||
|
||||
viewHolder.editFeed.setOnClickListener(v -> listener.onEdit(getItem(i)));
|
||||
viewHolder.itemView.setOnClickListener(v -> listener.onEdit(getItem(i)));
|
||||
viewHolder.itemView.setOnLongClickListener(v -> {
|
||||
listener.onOpenLink(getItem(i));
|
||||
return true;
|
||||
});
|
||||
viewHolder.deleteFeed.setOnClickListener(v -> listener.onDelete(getItem(i)));
|
||||
}
|
||||
|
||||
|
@ -122,20 +127,20 @@ public class FeedsAdapter extends ListAdapter<FeedWithFolder, FeedsAdapter.ViewH
|
|||
}
|
||||
|
||||
public interface ManageFeedsListener {
|
||||
void onOpenLink(FeedWithFolder feedWithFolder);
|
||||
void onEdit(FeedWithFolder feedWithFolder);
|
||||
void onDelete(FeedWithFolder feedWithFolder);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView feedIcon;
|
||||
private TextView feedName;
|
||||
private TextView feedDescription;
|
||||
private TextView folderName;
|
||||
|
||||
private ImageView editFeed;
|
||||
private ImageView deleteFeed;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
|
@ -145,7 +150,6 @@ public class FeedsAdapter extends ListAdapter<FeedWithFolder, FeedsAdapter.ViewH
|
|||
feedName = itemView.findViewById(R.id.feed_layout_name);
|
||||
feedDescription = itemView.findViewById(R.id.feed_layout_description);
|
||||
folderName = itemView.findViewById(R.id.feed_layout_folder);
|
||||
editFeed = itemView.findViewById(R.id.feed_layout_edit);
|
||||
deleteFeed = itemView.findViewById(R.id.feed_layout_delete);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#727272"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z"/>
|
||||
</vector>
|
|
@ -14,8 +14,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="6dp">
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -74,26 +72,26 @@
|
|||
android:layout_below="@id/feed_layout_first_part"
|
||||
android:layout_marginTop="6dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/feed_layout_folder_icon"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:src="@drawable/ic_folder_grey" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/feed_layout_folder"
|
||||
style="@style/Base.TextAppearance.AppCompat.Body1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toStartOf="@id/feed_layout_edit"
|
||||
android:layout_toEndOf="@id/feed_layout_folder_icon"
|
||||
android:layout_toRightOf="@id/feed_layout_folder_icon"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
tools:text="Folder 1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/feed_layout_edit"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="8dp"
|
||||
android:src="@drawable/ic_edit_grey" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue