mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding close functionality for share dialog.
This commit is contained in:
parent
d0a3cb10d4
commit
7be202ac1e
9 changed files with 89 additions and 37 deletions
|
@ -39,7 +39,7 @@
|
|||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@id/dialog_share_comment"
|
||||
android:padding="10dp"
|
||||
android:text="@string/alert_dialog_cancel"
|
||||
android:text="@string/alert_dialog_close"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_marginRight="10dp"
|
||||
android:contentDescription="@string/description_comment_user"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/comment_sharesource_image"
|
||||
android:layout_width="25dp"
|
||||
|
@ -30,10 +30,10 @@
|
|||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="35dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:visibility="invisible"
|
||||
android:contentDescription="@string/description_comment_user"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/comment_user_reshare_image"
|
||||
android:layout_width="35dp"
|
||||
|
@ -42,10 +42,10 @@
|
|||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:visibility="invisible"
|
||||
android:contentDescription="@string/description_comment_user"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/comment_user_reshare_image"
|
||||
android:layout_width="50dp"
|
||||
|
@ -58,8 +58,8 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/comment_reply_icon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:scaleType="fitCenter"
|
||||
|
@ -69,16 +69,17 @@
|
|||
android:id="@+id/comment_shareddate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/comment_reply_icon"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_toLeftOf="@id/comment_reply_icon"
|
||||
android:paddingBottom="3dp"
|
||||
android:textColor="@color/lightgray"
|
||||
android:textSize="11dp" />
|
||||
android:textSize="12sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/comment_favourite_icon"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_alignBottom="@id/comment_shareddate"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_toLeftOf="@id/comment_shareddate"
|
||||
android:scaleType="fitCenter"
|
||||
|
@ -97,9 +98,11 @@
|
|||
android:id="@+id/comment_username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/comment_shareddate"
|
||||
android:layout_toRightOf="@id/comment_user_image"
|
||||
android:paddingBottom="3dp"
|
||||
android:textColor="@color/newsblur_blue"
|
||||
android:textSize="11dp" />
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_text"
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
android:paddingRight="10dp"
|
||||
android:paddingTop="12dp" >
|
||||
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reply_user_image"
|
||||
android:layout_width="30dp"
|
||||
|
@ -29,7 +27,7 @@
|
|||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="26dp"
|
||||
android:textColor="@color/lightgray"
|
||||
android:textSize="11dp" />
|
||||
android:textSize="12sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reply_username"
|
||||
|
@ -37,7 +35,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/newsblur_blue"
|
||||
android:layout_toRightOf="@id/reply_user_image"
|
||||
android:textSize="11dp" />
|
||||
android:layout_alignBottom="@id/reply_shareddate"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reply_text"
|
||||
|
@ -47,6 +46,7 @@
|
|||
android:layout_marginRight="10dp"
|
||||
android:layout_toRightOf="@id/reply_user_image"
|
||||
android:textColor="@color/darkgray"
|
||||
android:layout_marginTop="5dp"
|
||||
android:textSize="14dp" />
|
||||
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
<string name="alert_dialog_ok">Okay</string>
|
||||
<string name="alert_dialog_cancel">Cancel</string>
|
||||
<string name="alert_dialog_close">Close</string>
|
||||
|
||||
<string name="profile">Profile</string>
|
||||
<string name="profile_location_icon">Location icon</string>
|
||||
|
@ -130,5 +131,7 @@
|
|||
<string name="addfollow_add_newsblur">Follow NewsBlur</string>
|
||||
<string name="addfollow_add_popular">Follow Popular</string>
|
||||
<string name="add_follow">All Done!</string>
|
||||
<string name="share_with_comments">Share with comments</string>
|
||||
<string name="share_this_story">Share this story</string>
|
||||
|
||||
</resources>
|
|
@ -121,7 +121,8 @@ public abstract class Reading extends SherlockFragmentActivity implements OnPage
|
|||
return true;
|
||||
case R.id.menu_reading_sharenewsblur:
|
||||
if (story != null) {
|
||||
DialogFragment newFragment = ShareDialogFragment.newInstance(((ReadingItemFragment) readingAdapter.getItem(currentItem)), story);
|
||||
ReadingItemFragment currentFragment = (ReadingItemFragment) readingAdapter.instantiateItem(pager, currentItem);
|
||||
DialogFragment newFragment = ShareDialogFragment.newInstance(currentFragment, story, currentFragment.previouslySavedShareText);
|
||||
newFragment.show(getSupportFragmentManager(), "dialog");
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -59,6 +59,7 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
|
|||
private GridView tagContainer;
|
||||
private View view;
|
||||
private UserProfile user;
|
||||
public String previouslySavedShareText;
|
||||
|
||||
public static ReadingItemFragment newInstance(Story story, String feedTitle, String feedFaviconColor, String feedFaviconFade, Classifier classifier) {
|
||||
ReadingItemFragment readingFragment = new ReadingItemFragment();
|
||||
|
@ -136,7 +137,7 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
|
|||
shareButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DialogFragment newFragment = ShareDialogFragment.newInstance(ReadingItemFragment.this, story);
|
||||
DialogFragment newFragment = ShareDialogFragment.newInstance(ReadingItemFragment.this, story, previouslySavedShareText);
|
||||
newFragment.show(getFragmentManager(), "dialog");
|
||||
}
|
||||
});
|
||||
|
@ -338,4 +339,10 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPreviouslySavedShareText(String previouslySavedShareText) {
|
||||
this.previouslySavedShareText = previouslySavedShareText;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,25 +13,25 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.network.APIManager;
|
||||
|
||||
public class ReplyDialogFragment extends DialogFragment {
|
||||
|
||||
private static final String STORY_ID = "story_id";
|
||||
private static final String STORY_FEED_ID = "feed_id";
|
||||
private static final String STORY = "story";
|
||||
private static final String COMMENT_USER_ID = "comment_user_id";
|
||||
private static final String COMMENT_USERNAME = "comment_username";
|
||||
|
||||
String storyId, storyFeedId, commentUserId, commentUsername;
|
||||
private String commentUserId, commentUsername;
|
||||
private Story story;
|
||||
|
||||
private APIManager apiManager;
|
||||
|
||||
|
||||
public static ReplyDialogFragment newInstance(final String storyId, final String storyFeedId, final String commentUserId, final String commentUsername) {
|
||||
public static ReplyDialogFragment newInstance(final Story story, final String commentUserId, final String commentUsername) {
|
||||
ReplyDialogFragment frag = new ReplyDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(STORY_ID, storyId);
|
||||
args.putString(STORY_FEED_ID, storyFeedId);
|
||||
args.putSerializable(STORY, story);
|
||||
args.putString(COMMENT_USER_ID, commentUserId);
|
||||
args.putString(COMMENT_USERNAME, commentUsername);
|
||||
frag.setArguments(args);
|
||||
|
@ -42,8 +42,8 @@ public class ReplyDialogFragment extends DialogFragment {
|
|||
public void onCreate(Bundle savedInstanceState) {
|
||||
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog);
|
||||
|
||||
storyId = getArguments().getString(STORY_ID);
|
||||
storyFeedId = getArguments().getString(STORY_FEED_ID);
|
||||
story = (Story) getArguments().getSerializable(STORY);
|
||||
|
||||
commentUserId = getArguments().getString(COMMENT_USER_ID);
|
||||
commentUsername = getArguments().getString(COMMENT_USERNAME);
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class ReplyDialogFragment extends DialogFragment {
|
|||
new AsyncTask<Void, Void, Boolean>() {
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... arg) {
|
||||
return apiManager.replyToComment(storyId, storyFeedId, commentUserId, reply.getText().toString());
|
||||
return apiManager.replyToComment(story.id, story.feedId, commentUserId, reply.getText().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,10 @@ import android.database.Cursor;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -29,6 +32,7 @@ public class ShareDialogFragment extends DialogFragment {
|
|||
|
||||
private static final String STORY = "story";
|
||||
private static final String CALLBACK= "callback";
|
||||
private static final String PREVIOUSLY_SAVED_SHARE_TEXT = "previouslySavedComment";
|
||||
private APIManager apiManager;
|
||||
private SharedCallbackDialog callback;
|
||||
private Story story;
|
||||
|
@ -37,11 +41,15 @@ public class ShareDialogFragment extends DialogFragment {
|
|||
private boolean hasBeenShared = false;
|
||||
private Cursor commentCursor;
|
||||
private Comment previousComment;
|
||||
private String previouslySavedShareText;
|
||||
private boolean hasShared = false;
|
||||
private EditText commentEditText;
|
||||
|
||||
public static ShareDialogFragment newInstance(final SharedCallbackDialog sharedCallback, final Story story) {
|
||||
public static ShareDialogFragment newInstance(final SharedCallbackDialog sharedCallback, final Story story, final String previouslySavedShareText) {
|
||||
ShareDialogFragment frag = new ShareDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(STORY, story);
|
||||
args.putString(PREVIOUSLY_SAVED_SHARE_TEXT, previouslySavedShareText);
|
||||
args.putSerializable(CALLBACK, sharedCallback);
|
||||
frag.setArguments(args);
|
||||
return frag;
|
||||
|
@ -54,7 +62,8 @@ public class ShareDialogFragment extends DialogFragment {
|
|||
story = (Story) getArguments().getSerializable(STORY);
|
||||
callback = (SharedCallbackDialog) getArguments().getSerializable(CALLBACK);
|
||||
user = PrefsUtil.getUserDetails(getActivity());
|
||||
|
||||
previouslySavedShareText = getArguments().getString(PREVIOUSLY_SAVED_SHARE_TEXT);
|
||||
|
||||
apiManager = new APIManager(getActivity());
|
||||
resolver = getActivity().getContentResolver();
|
||||
|
||||
|
@ -78,13 +87,34 @@ public class ShareDialogFragment extends DialogFragment {
|
|||
|
||||
View v = inflater.inflate(R.layout.fragment_dialog, container, false);
|
||||
final TextView message = (TextView) v.findViewById(R.id.dialog_message);
|
||||
final EditText commentEditText = (EditText) v.findViewById(R.id.dialog_share_comment);
|
||||
commentEditText = (EditText) v.findViewById(R.id.dialog_share_comment);
|
||||
final Button shareButton = (Button) v.findViewById(R.id.dialog_button_okay);
|
||||
shareButton.setText(R.string.share_this_story);
|
||||
|
||||
commentEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (editable.length() > 0) {
|
||||
shareButton.setText(R.string.share_with_comments);
|
||||
} else {
|
||||
shareButton.setText(R.string.share_this_story);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) { }
|
||||
});
|
||||
|
||||
message.setText(String.format(shareString, story.title));
|
||||
|
||||
if (hasBeenShared) {
|
||||
Button shareButton = (Button) v.findViewById(R.id.dialog_button_okay);
|
||||
shareButton.setText(R.string.edit);
|
||||
commentEditText.setText(previousComment.commentText);
|
||||
} else if (!TextUtils.isEmpty(previouslySavedShareText)) {
|
||||
commentEditText.setText(previouslySavedShareText);
|
||||
}
|
||||
|
||||
Button okayButton = (Button) v.findViewById(R.id.dialog_button_okay);
|
||||
|
@ -102,6 +132,7 @@ public class ShareDialogFragment extends DialogFragment {
|
|||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (result) {
|
||||
hasShared = true;
|
||||
callback.sharedCallback(shareComment, hasBeenShared);
|
||||
Toast.makeText(getActivity(), R.string.shared, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
|
@ -123,16 +154,23 @@ public class ShareDialogFragment extends DialogFragment {
|
|||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (commentCursor != null && !commentCursor.isClosed()) {
|
||||
commentCursor.close();
|
||||
}
|
||||
|
||||
if (!hasShared && commentEditText.length() > 0) {
|
||||
Log.d("ShareDialog", "settingPreviouslySharedText");
|
||||
previouslySavedShareText = commentEditText.getText().toString();
|
||||
callback.setPreviouslySavedShareText(previouslySavedShareText);
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public interface SharedCallbackDialog extends Serializable{
|
||||
public interface SharedCallbackDialog extends Serializable{
|
||||
public void setPreviouslySavedShareText(String previouslySavedShareText);
|
||||
public void sharedCallback(String sharedText, boolean alreadyShared);
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (story != null) {
|
||||
DialogFragment newFragment = ReplyDialogFragment.newInstance(story.id, story.feedId, comment.userId, publicUserMap.get(comment.userId).username);
|
||||
DialogFragment newFragment = ReplyDialogFragment.newInstance(story, comment.userId, publicUserMap.get(comment.userId).username);
|
||||
newFragment.show(manager, "dialog");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue