From 117a33be3b3c112bcde45fce3974851a8ae58c47 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 9 Jul 2019 17:47:40 +0800 Subject: Minor UI tweaks. Preparing for submitting text posts. --- .../CommentRecyclerViewAdapter.java | 2 +- .../infinityforreddit/MainActivity.java | 7 +++ .../infinityforreddit/PostTextActivity.java | 54 ++++++++++++++++++++++ .../infinityforreddit/ViewImageActivity.java | 12 +---- .../infinityforreddit/ViewVideoActivity.java | 16 ++----- 5 files changed, 66 insertions(+), 25 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java index b7ebf9c1..8cc218b5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java @@ -632,7 +632,7 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter { + Intent intent = new Intent(this, PostTextActivity.class); + this.startActivity(intent); + }); } private void loadUserData() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java new file mode 100644 index 00000000..d7aa6e1d --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java @@ -0,0 +1,54 @@ +package ml.docilealligator.infinityforreddit; + +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.view.MenuItem; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; + +import butterknife.BindView; +import butterknife.ButterKnife; +import pl.droidsonroids.gif.GifImageView; + +public class PostTextActivity extends AppCompatActivity { + + static final String EXTRA_SUBREDDIT_NAME = "ESN"; + + @BindView(R.id.subreddit_icon_gif_image_view_post_text_activity) GifImageView iconGifImageView; + @BindView(R.id.subreddit_name_text_view_post_text_activity) TextView subreditNameTextView; + @BindView(R.id.rules_button_post_text_activity) Button rulesButton; + @BindView(R.id.post_title_edit_text_post_text_activity) EditText titleEditText; + @BindView(R.id.post_text_content_edit_text_post_text_activity) EditText contentEditText; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_post_text); + + ButterKnife.bind(this); + + ActionBar actionBar = getSupportActionBar(); + Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); + actionBar.setHomeAsUpIndicator(upArrow); + + if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) { + subreditNameTextView.setText(getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME)); + } + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + return true; + } + + return false; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java index 08dc356c..1dcba0c1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java @@ -8,7 +8,6 @@ import android.annotation.SuppressLint; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; -import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -16,9 +15,6 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Environment; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.style.ForegroundColorSpan; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; @@ -95,16 +91,12 @@ public class ViewImageActivity extends AppCompatActivity { Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); actionBar.setHomeAsUpIndicator(upArrow); actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarColor))); + setTitle(""); Intent intent = getIntent(); mImageUrl = intent.getExtras().getString(IMAGE_URL_KEY); mImageFileName = intent.getExtras().getString(FILE_NAME_KEY); - String title = intent.getExtras().getString(TITLE_KEY); - Spannable text = new SpannableString(title); - text.setSpan(new ForegroundColorSpan(Color.WHITE), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - setTitle(text); - mLoadErrorLinearLayout.setOnClickListener(view -> { if(!isSwiping) { mProgressBar.setVisibility(View.VISIBLE); @@ -133,8 +125,6 @@ public class ViewImageActivity extends AppCompatActivity { actionBarColorAnimation.addUpdateListener(valueAnimator -> actionBar.setBackgroundDrawable(new ColorDrawable((int) valueAnimator.getAnimatedValue()))); actionBarElementColorAnimation.addUpdateListener(valueAnimator -> { - text.setSpan(new ForegroundColorSpan((int) valueAnimator.getAnimatedValue()), 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); - actionBar.setTitle(text); upArrow.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); if(mMenu != null) { Drawable drawable = mMenu.getItem(0).getIcon(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java index 1d164bb3..976ff8c5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java @@ -8,7 +8,6 @@ import android.app.DownloadManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; -import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -17,9 +16,6 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.style.ForegroundColorSpan; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; @@ -94,9 +90,10 @@ public class ViewVideoActivity extends AppCompatActivity { setVolumeControlStream(AudioManager.STREAM_MUSIC); ActionBar actionBar = getSupportActionBar(); - actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarColor))); Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); - getSupportActionBar().setHomeAsUpIndicator(upArrow); + actionBar.setHomeAsUpIndicator(upArrow); + actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarColor))); + setTitle(""); //Set player controller margin bottom in order to display it above the navbar int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android"); @@ -108,11 +105,6 @@ public class ViewVideoActivity extends AppCompatActivity { mVideoUri = intent.getData(); mIsDashVideo = intent.getExtras().getBoolean(IS_DASH_VIDEO_KEY); - String title = intent.getExtras().getString(TITLE_KEY); - Spannable text = new SpannableString(title); - text.setSpan(new ForegroundColorSpan(Color.WHITE), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - setTitle(text); - if(intent.getExtras().getBoolean(IS_DOWNLOADABLE_KEY)) { mGifOrVideoFileName = intent.getExtras().getString(SUBREDDIT_KEY).substring(2) + "-" + intent.getExtras().getString(ID_KEY).substring(3) + ".gif"; @@ -139,8 +131,6 @@ public class ViewVideoActivity extends AppCompatActivity { actionBarColorAnimation.addUpdateListener(valueAnimator -> actionBar.setBackgroundDrawable(new ColorDrawable((int) valueAnimator.getAnimatedValue()))); actionBarElementColorAnimation.addUpdateListener(valueAnimator -> { - text.setSpan(new ForegroundColorSpan((int) valueAnimator.getAnimatedValue()), 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); - actionBar.setTitle(text); upArrow.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); if(mMenu != null) { Drawable drawable = mMenu.getItem(0).getIcon(); -- cgit v1.2.3