Add CommentActivity for sending comments (not implemented yet). Minor UI tweaks.

This commit is contained in:
Alex Ning 2019-06-13 12:16:04 +08:00
parent ef8daed571
commit 42c7b316f3
17 changed files with 346 additions and 44 deletions

View File

@ -23,7 +23,7 @@
<PersistentState> <PersistentState>
<option name="values"> <option name="values">
<map> <map>
<entry key="url" value="jar:file:/home/alex/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_clear_black_24dp.xml" /> <entry key="url" value="jar:file:/home/alex/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_send_black_24dp.xml" />
</map> </map>
</option> </option>
</PersistentState> </PersistentState>
@ -34,7 +34,7 @@
<option name="values"> <option name="values">
<map> <map>
<entry key="color" value="ffffff" /> <entry key="color" value="ffffff" />
<entry key="outputName" value="ic_clear_white_24dp" /> <entry key="outputName" value="ic_send_white_24dp" />
<entry key="sourceFile" value="$USER_HOME$/Downloads/outline-search-24px.svg" /> <entry key="sourceFile" value="$USER_HOME$/Downloads/outline-search-24px.svg" />
</map> </map>
</option> </option>

Binary file not shown.

View File

@ -33,7 +33,7 @@ repositories {
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05' implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
implementation 'com.google.android.material:material:1.1.0-alpha07' implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
@ -75,4 +75,5 @@ dependencies {
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
implementation 'com.github.Ferfalk:SimpleSearchView:0.1.3' implementation 'com.github.Ferfalk:SimpleSearchView:0.1.3'
implementation 'org.greenrobot:eventbus:3.1.1' implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.github.chinalwb:are:0.1.5'
} }

View File

@ -19,17 +19,23 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<activity android:name=".SearchActivity" <activity
android:name=".CommentActivity"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.NoActionBar"
android:label="@string/comment_activity_label"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".SearchActivity"
android:label="@string/search_activity_label" android:label="@string/search_activity_label"
android:parentActivityName=".MainActivity"> android:parentActivityName=".MainActivity"
</activity> android:theme="@style/AppTheme.NoActionBar" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBarWithTransparentStatusBar"> android:theme="@style/AppTheme.NoActionBarWithTransparentStatusBar">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
@ -47,7 +53,8 @@
android:theme="@style/AppTheme.ActionBar.Transparent" /> android:theme="@style/AppTheme.ActionBar.Transparent" />
<activity <activity
android:name=".ViewPostDetailActivity" android:name=".ViewPostDetailActivity"
android:parentActivityName=".MainActivity" /> android:parentActivityName=".MainActivity"
android:theme="@style/AppTheme.NoActionBar"/>
<activity <activity
android:name=".ViewSubredditDetailActivity" android:name=".ViewSubredditDetailActivity"
android:parentActivityName=".MainActivity" android:parentActivityName=".MainActivity"

View File

@ -0,0 +1,127 @@
package ml.docilealligator.infinityforreddit;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.chinalwb.are.AREditText;
import com.chinalwb.are.styles.toolbar.IARE_Toolbar;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_AlignmentCenter;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_AlignmentLeft;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_AlignmentRight;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_At;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Bold;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Hr;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Image;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Italic;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Link;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_ListBullet;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_ListNumber;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Quote;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Strikethrough;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Subscript;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Superscript;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Underline;
import com.chinalwb.are.styles.toolitems.ARE_ToolItem_Video;
import com.chinalwb.are.styles.toolitems.IARE_ToolItem;
import butterknife.BindView;
import butterknife.ButterKnife;
public class CommentActivity extends AppCompatActivity {
static final String COMMENT_PARENT_TEXT = "CPT";
static final String EXTRA_COMMENT_DATA = "ECD";
static final int WRITE_COMMENT_REQUEST_CODE = 1;
@BindView(R.id.toolbar_comment_activity) Toolbar toolbar;
@BindView(R.id.comment_parent_text_view_comment_activity) TextView commentParentTextView;
@BindView(R.id.arEditText) AREditText commentEditor;
@BindView(R.id.areToolbar) IARE_Toolbar editorToolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comment);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
commentParentTextView.setText(getIntent().getExtras().getString(COMMENT_PARENT_TEXT));
commentEditor.setBackgroundColor(getResources().getColor(android.R.color.transparent));
initToolbar();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.comment_activity, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.action_send_comment_activity:
CommentData commentData = null;
Intent returnIntent = new Intent();
returnIntent.putExtra(EXTRA_COMMENT_DATA, commentData);
setResult(RESULT_OK, returnIntent);
}
return super.onOptionsItemSelected(item);
}
private void initToolbar() {
IARE_ToolItem bold = new ARE_ToolItem_Bold();
IARE_ToolItem italic = new ARE_ToolItem_Italic();
IARE_ToolItem underline = new ARE_ToolItem_Underline();
IARE_ToolItem strikethrough = new ARE_ToolItem_Strikethrough();
IARE_ToolItem quote = new ARE_ToolItem_Quote();
IARE_ToolItem listNumber = new ARE_ToolItem_ListNumber();
IARE_ToolItem listBullet = new ARE_ToolItem_ListBullet();
IARE_ToolItem hr = new ARE_ToolItem_Hr();
IARE_ToolItem link = new ARE_ToolItem_Link();
IARE_ToolItem subscript = new ARE_ToolItem_Subscript();
IARE_ToolItem superscript = new ARE_ToolItem_Superscript();
IARE_ToolItem left = new ARE_ToolItem_AlignmentLeft();
IARE_ToolItem center = new ARE_ToolItem_AlignmentCenter();
IARE_ToolItem right = new ARE_ToolItem_AlignmentRight();
IARE_ToolItem image = new ARE_ToolItem_Image();
IARE_ToolItem video = new ARE_ToolItem_Video();
IARE_ToolItem at = new ARE_ToolItem_At();
editorToolbar.addToolbarItem(bold);
editorToolbar.addToolbarItem(italic);
editorToolbar.addToolbarItem(underline);
editorToolbar.addToolbarItem(strikethrough);
editorToolbar.addToolbarItem(quote);
editorToolbar.addToolbarItem(listNumber);
editorToolbar.addToolbarItem(listBullet);
editorToolbar.addToolbarItem(hr);
editorToolbar.addToolbarItem(link);
editorToolbar.addToolbarItem(subscript);
editorToolbar.addToolbarItem(superscript);
editorToolbar.addToolbarItem(left);
editorToolbar.addToolbarItem(center);
editorToolbar.addToolbarItem(right);
editorToolbar.addToolbarItem(image);
editorToolbar.addToolbarItem(video);
editorToolbar.addToolbarItem(at);
commentEditor.setToolbar(editorToolbar);
/*setHtml();
initToolbarArrow();*/
}
}

View File

@ -1,8 +1,11 @@
package ml.docilealligator.infinityforreddit; package ml.docilealligator.infinityforreddit;
import android.os.Parcel;
import android.os.Parcelable;
import com.multilevelview.models.RecyclerViewItem; import com.multilevelview.models.RecyclerViewItem;
class CommentData extends RecyclerViewItem { class CommentData extends RecyclerViewItem implements Parcelable {
private String id; private String id;
private String fullName; private String fullName;
private String author; private String author;
@ -35,6 +38,36 @@ class CommentData extends RecyclerViewItem {
this.scoreHidden = scoreHidden; this.scoreHidden = scoreHidden;
} }
protected CommentData(Parcel in) {
super(0);
id = in.readString();
fullName = in.readString();
author = in.readString();
commentTime = in.readString();
commentContent = in.readString();
score = in.readInt();
voteType = in.readInt();
isSubmitter = in.readByte() != 0;
permalink = in.readString();
depth = in.readInt();
collapsed = in.readByte() != 0;
hasReply = in.readByte() != 0;
scoreHidden = in.readByte() != 0;
super.setLevel(depth);
}
public static final Creator<CommentData> CREATOR = new Creator<CommentData>() {
@Override
public CommentData createFromParcel(Parcel in) {
return new CommentData(in);
}
@Override
public CommentData[] newArray(int size) {
return new CommentData[size];
}
};
public String getId() { public String getId() {
return id; return id;
} }
@ -98,4 +131,26 @@ class CommentData extends RecyclerViewItem {
public void setVoteType(int voteType) { public void setVoteType(int voteType) {
this.voteType = voteType; this.voteType = voteType;
} }
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(id);
parcel.writeString(fullName);
parcel.writeString(author);
parcel.writeString(commentTime);
parcel.writeString(commentContent);
parcel.writeInt(score);
parcel.writeInt(voteType);
parcel.writeByte((byte) (isSubmitter ? 1 : 0));
parcel.writeString(permalink);
parcel.writeInt(depth);
parcel.writeByte((byte) (collapsed ? 1 : 0));
parcel.writeByte((byte) (hasReply ? 1 : 0));
parcel.writeByte((byte) (scoreHidden ? 1 : 0));
}
} }

View File

@ -258,6 +258,11 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
notifyItemRangeInserted(sizeBefore, mCommentData.size() - sizeBefore); notifyItemRangeInserted(sizeBefore, mCommentData.size() - sizeBefore);
} }
void addComment(CommentData comment) {
mCommentData.add(0, comment);
notifyItemInserted(0);
}
private void setExpandButton(ImageView expandButton, boolean isExpanded) { private void setExpandButton(ImageView expandButton, boolean isExpanded) {
// set the icon based on the current state // set the icon based on the current state
expandButton.setVisibility(View.VISIBLE); expandButton.setVisibility(View.VISIBLE);
@ -265,26 +270,16 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
} }
class CommentViewHolder extends RecyclerView.ViewHolder { class CommentViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.author_text_view_item_post_comment) @BindView(R.id.author_text_view_item_post_comment) TextView authorTextView;
TextView authorTextView; @BindView(R.id.comment_time_text_view_item_post_comment) TextView commentTimeTextView;
@BindView(R.id.comment_time_text_view_item_post_comment) @BindView(R.id.comment_markdown_view_item_post_comment) MarkwonView commentMarkdownView;
TextView commentTimeTextView; @BindView(R.id.plus_button_item_post_comment) ImageView upvoteButton;
@BindView(R.id.comment_markdown_view_item_post_comment) @BindView(R.id.score_text_view_item_post_comment) TextView scoreTextView;
MarkwonView commentMarkdownView; @BindView(R.id.minus_button_item_post_comment) ImageView downvoteButton;
@BindView(R.id.plus_button_item_post_comment) @BindView(R.id.expand_button_item_post_comment) ImageView expandButton;
ImageView upvoteButton; @BindView(R.id.load_more_comments_progress_bar) ProgressBar loadMoreCommentsProgressBar;
@BindView(R.id.score_text_view_item_post_comment) @BindView(R.id.reply_button_item_post_comment) ImageView replyButton;
TextView scoreTextView; @BindView(R.id.vertical_block_item_post_comment) View verticalBlock;
@BindView(R.id.minus_button_item_post_comment)
ImageView downvoteButton;
@BindView(R.id.expand_button_item_post_comment)
ImageView expandButton;
@BindView(R.id.load_more_comments_progress_bar)
ProgressBar loadMoreCommentsProgressBar;
@BindView(R.id.reply_button_item_post_comment)
ImageView replyButton;
@BindView(R.id.vertical_block_item_post_comment)
View verticalBlock;
CommentViewHolder(View itemView) { CommentViewHolder(View itemView) {
super(itemView); super(itemView);

View File

@ -382,10 +382,13 @@ public class MainActivity extends AppCompatActivity {
if (mFragment instanceof FragmentCommunicator) { if (mFragment instanceof FragmentCommunicator) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_refresh_main_activity: case R.id.action_refresh_main_activity:
((FragmentCommunicator) mFragment).refresh(); /*((FragmentCommunicator) mFragment).refresh();
mFetchUserInfoSuccess = false; mFetchUserInfoSuccess = false;
mInsertSuccess = false; mInsertSuccess = false;
loadUserData(); loadUserData();*/
Intent intent = new Intent(this, CommentActivity.class);
intent.putExtra(CommentActivity.EXTRA_COMMENT_DATA, "asdfasdfas");
startActivity(intent);
return true; return true;
case R.id.action_lazy_mode_main_activity: case R.id.action_lazy_mode_main_activity:
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity); MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity);

View File

@ -5,7 +5,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -19,9 +18,10 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.browser.customtabs.CustomTabsIntent; import androidx.browser.customtabs.CustomTabsIntent;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
@ -64,6 +64,9 @@ import retrofit2.Retrofit;
import ru.noties.markwon.SpannableConfiguration; import ru.noties.markwon.SpannableConfiguration;
import ru.noties.markwon.view.MarkwonView; import ru.noties.markwon.view.MarkwonView;
import static ml.docilealligator.infinityforreddit.CommentActivity.EXTRA_COMMENT_DATA;
import static ml.docilealligator.infinityforreddit.CommentActivity.WRITE_COMMENT_REQUEST_CODE;
public class ViewPostDetailActivity extends AppCompatActivity { public class ViewPostDetailActivity extends AppCompatActivity {
static final String EXTRA_TITLE = "ET"; static final String EXTRA_TITLE = "ET";
@ -91,6 +94,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
private LoadSubredditIconAsyncTask mLoadSubredditIconAsyncTask; private LoadSubredditIconAsyncTask mLoadSubredditIconAsyncTask;
@BindView(R.id.coordinator_layout_view_post_detail) CoordinatorLayout mCoordinatorLayout; @BindView(R.id.coordinator_layout_view_post_detail) CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.toolbar_view_post_detail_activity) Toolbar toolbar;
@BindView(R.id.nested_scroll_view_view_post_detail_activity) NestedScrollView mNestedScrollView; @BindView(R.id.nested_scroll_view_view_post_detail_activity) NestedScrollView mNestedScrollView;
@BindView(R.id.subreddit_icon_name_linear_layout_view_post_detail) LinearLayout mSubredditIconNameLinearLayout; @BindView(R.id.subreddit_icon_name_linear_layout_view_post_detail) LinearLayout mSubredditIconNameLinearLayout;
@BindView(R.id.subreddit_icon_circle_image_view_view_post_detail) AspectRatioGifImageView mSubredditIconGifImageView; @BindView(R.id.subreddit_icon_circle_image_view_view_post_detail) AspectRatioGifImageView mSubredditIconGifImageView;
@ -105,22 +109,18 @@ public class ViewPostDetailActivity extends AppCompatActivity {
@BindView(R.id.nsfw_text_view_view_post_detail) Chip mNSFWChip; @BindView(R.id.nsfw_text_view_view_post_detail) Chip mNSFWChip;
@BindView(R.id.link_text_view_view_post_detail) TextView linkTextView; @BindView(R.id.link_text_view_view_post_detail) TextView linkTextView;
@BindView(R.id.image_view_wrapper_view_post_detail) RelativeLayout mRelativeLayout; @BindView(R.id.image_view_wrapper_view_post_detail) RelativeLayout mRelativeLayout;
@BindView(R.id.load_wrapper_view_post_detail) RelativeLayout mLoadWrapper; @BindView(R.id.load_wrapper_view_post_detail) RelativeLayout mLoadWrapper;
@BindView(R.id.progress_bar_view_post_detail) ProgressBar mLoadImageProgressBar; @BindView(R.id.progress_bar_view_post_detail) ProgressBar mLoadImageProgressBar;
@BindView(R.id.load_image_error_text_view_view_post_detail) TextView mLoadImageErrorTextView; @BindView(R.id.load_image_error_text_view_view_post_detail) TextView mLoadImageErrorTextView;
@BindView(R.id.image_view_view_post_detail) AspectRatioImageView mImageView; @BindView(R.id.image_view_view_post_detail) AspectRatioImageView mImageView;
@BindView(R.id.image_view_no_preview_link_view_post_detail) ImageView mNoPreviewLinkImageView; @BindView(R.id.image_view_no_preview_link_view_post_detail) ImageView mNoPreviewLinkImageView;
@BindView(R.id.plus_button_view_post_detail) ImageView mUpvoteButton; @BindView(R.id.plus_button_view_post_detail) ImageView mUpvoteButton;
@BindView(R.id.score_text_view_view_post_detail) TextView mScoreTextView; @BindView(R.id.score_text_view_view_post_detail) TextView mScoreTextView;
@BindView(R.id.minus_button_view_post_detail) ImageView mDownvoteButton; @BindView(R.id.minus_button_view_post_detail) ImageView mDownvoteButton;
@BindView(R.id.share_button_view_post_detail) ImageView mShareButton; @BindView(R.id.share_button_view_post_detail) ImageView mShareButton;
@BindView(R.id.comment_progress_bar_view_post_detail) CircleProgressBar mCommentProgressbar; @BindView(R.id.comment_progress_bar_view_post_detail) CircleProgressBar mCommentProgressbar;
@BindView(R.id.comment_card_view_view_post_detail) MaterialCardView mCommentCardView; @BindView(R.id.comment_card_view_view_post_detail) MaterialCardView mCommentCardView;
@BindView(R.id.recycler_view_view_post_detail) MultiLevelRecyclerView mRecyclerView; @BindView(R.id.recycler_view_view_post_detail) MultiLevelRecyclerView mRecyclerView;
@BindView(R.id.no_comment_wrapper_linear_layout_view_post_detail) LinearLayout mNoCommentWrapperLinearLayout; @BindView(R.id.no_comment_wrapper_linear_layout_view_post_detail) LinearLayout mNoCommentWrapperLinearLayout;
@BindView(R.id.no_comment_image_view_view_post_detail) ImageView mNoCommentImageView; @BindView(R.id.no_comment_image_view_view_post_detail) ImageView mNoCommentImageView;
@ -144,9 +144,8 @@ public class ViewPostDetailActivity extends AppCompatActivity {
((Infinity) getApplication()).getmAppComponent().inject(this); ((Infinity) getApplication()).getmAppComponent().inject(this);
ActionBar actionBar = getSupportActionBar(); toolbar.setTitle("");
actionBar.setDisplayHomeAsUpEnabled(true); setSupportActionBar(toolbar);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));
mGlide = Glide.with(this); mGlide = Glide.with(this);
mLocale = getResources().getConfiguration().locale; mLocale = getResources().getConfiguration().locale;
@ -684,6 +683,11 @@ public class ViewPostDetailActivity extends AppCompatActivity {
case R.id.action_refresh_view_post_detail_activity: case R.id.action_refresh_view_post_detail_activity:
refresh(); refresh();
return true; return true;
case R.id.action_comment_view_post_detail_activity:
Intent intent = new Intent(this, CommentActivity.class);
intent.putExtra(CommentActivity.COMMENT_PARENT_TEXT, mPost.getTitle());
startActivityForResult(intent, WRITE_COMMENT_REQUEST_CODE);
return true;
case android.R.id.home: case android.R.id.home:
onBackPressed(); onBackPressed();
return true; return true;
@ -692,7 +696,16 @@ public class ViewPostDetailActivity extends AppCompatActivity {
} }
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK && requestCode == WRITE_COMMENT_REQUEST_CODE) {
CommentData comment = data.getExtras().getParcelable(EXTRA_COMMENT_DATA);
mAdapter.addComment(comment);
}
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putInt(ORIENTATION_STATE, orientation); outState.putInt(ORIENTATION_STATE, orientation);
outState.putParcelable(POST_STATE, mPost); outState.putParcelable(POST_STATE, mPost);

View File

@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FFFFFF" 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="M20,2L4,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h14l4,4L22,4c0,-1.1 -0.9,-2 -2,-2zM18,14L6,14v-2h12v2zM18,11L6,11L6,9h12v2zM18,8L6,8L6,6h12v2z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
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="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CommentActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_comment_activity"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:navigationIcon="?attr/homeAsUpIndicator"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:id="@+id/comment_parent_text_view_comment_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="16sp" />
<com.chinalwb.are.AREditText
android:id="@+id/arEditText"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="8dp"
android:layout_weight="1"
android:gravity="top"
android:hint="@string/write_comment_hint"
android:inputType="textMultiLine|textCapSentences"
android:textSize="18sp"
android:textColor="@color/primaryTextColor"/>
<com.chinalwb.are.styles.toolbar.ARE_ToolbarDefault
android:id="@+id/areToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -7,10 +7,25 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ViewPostDetailActivity"> tools:context=".ViewPostDetailActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_view_post_detail_activity"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:navigationIcon="?attr/homeAsUpIndicator" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/nested_scroll_view_view_post_detail_activity" android:id="@+id/nested_scroll_view_view_post_detail_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -339,7 +354,6 @@
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_send_comment_activity"
android:orderInCategory="1"
android:title="@string/action_send"
android:icon="@drawable/ic_send_white_24dp"
app:showAsAction="ifRoom" />
</menu>

View File

@ -1,10 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_comment_view_post_detail_activity"
android:orderInCategory="1"
android:title="@string/action_add_comment"
android:icon="@drawable/ic_insert_comment_white_24dp"
app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_refresh_view_post_detail_activity" android:id="@+id/action_refresh_view_post_detail_activity"
android:orderInCategory="2" android:orderInCategory="2"
android:title="@string/action_refresh" android:title="@string/action_refresh"
android:icon="@drawable/ic_refresh_white_24dp" app:showAsAction="never" />
app:showAsAction="always" />
</menu> </menu>

View File

@ -2,6 +2,7 @@
<string name="app_name">Infinity</string> <string name="app_name">Infinity</string>
<string name="login_activity_label">Login</string> <string name="login_activity_label">Login</string>
<string name="search_activity_label">Search</string> <string name="search_activity_label">Search</string>
<string name="comment_activity_label">Add Comment</string>
<string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string>
@ -9,9 +10,11 @@
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="action_download">Download</string> <string name="action_download">Download</string>
<string name="action_refresh">Refresh</string> <string name="action_refresh">Refresh</string>
<string name="action_add_comment">Add a comment</string>
<string name="action_search">Search</string> <string name="action_search">Search</string>
<string name="action_start_lazy_mode">Start Lazy Mode</string> <string name="action_start_lazy_mode">Start Lazy Mode</string>
<string name="action_stop_lazy_mode">Stop Lazy Mode</string> <string name="action_stop_lazy_mode">Stop Lazy Mode</string>
<string name="action_send">Send</string>
<string name="tap_to_retry">Error loading image. Tap to retry.</string> <string name="tap_to_retry">Error loading image. Tap to retry.</string>
<string name="load_posts_error">Error loading posts.\nTap to retry.</string> <string name="load_posts_error">Error loading posts.\nTap to retry.</string>
@ -68,4 +71,6 @@
<string name="lazy_mode_start">Lazy Mode starts in %1$.1fs</string> <string name="lazy_mode_start">Lazy Mode starts in %1$.1fs</string>
<string name="lazy_mode_stop">Lazy Mode stopped</string> <string name="lazy_mode_stop">Lazy Mode stopped</string>
<string name="write_comment_hint">Your interesting thoughts here</string>
</resources> </resources>