Flair, spoiler and nsfw support for submitting posts.

This commit is contained in:
Alex Ning 2019-07-17 09:31:49 +08:00
parent 116ce0bb24
commit ebf542161e
27 changed files with 893 additions and 41 deletions

Binary file not shown.

Binary file not shown.

View File

@ -74,4 +74,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.libRG:customtextview:2.2'
} }

View File

@ -22,4 +22,5 @@ interface AppComponent {
void inject(PostLinkActivity postLinkActivity); void inject(PostLinkActivity postLinkActivity);
void inject(PostImageActivity postImageActivity); void inject(PostImageActivity postImageActivity);
void inject(PostVideoActivity postVideoActivity); void inject(PostVideoActivity postVideoActivity);
void inject(FlairBottomSheetFragment flairBottomSheetFragment);
} }

View File

@ -0,0 +1,97 @@
package ml.docilealligator.infinityforreddit;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import androidx.annotation.NonNull;
import org.json.JSONArray;
import org.json.JSONException;
import java.util.ArrayList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
class FetchFlairsInSubreddit {
interface FetchFlairsInSubredditListener {
void fetchSuccessful(ArrayList<String> flairs);
void fetchFailed();
}
static void fetchFlairs(Retrofit oauthRetrofit, SharedPreferences authInfoSharedPreferences, String subredditName, FetchFlairsInSubredditListener fetchFlairsInSubredditListener) {
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
String accessToken = authInfoSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, "");
Call<String> flairsCall = api.getFlairs(RedditUtils.getOAuthHeader(accessToken), subredditName);
flairsCall.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
new ParseFlairsAsyncTask(response.body(), new ParseFlairsAsyncTask.ParseFlairsAsyncTaskListener() {
@Override
public void parseSuccessful(ArrayList<String> flairs) {
fetchFlairsInSubredditListener.fetchSuccessful(flairs);
}
@Override
public void parseFailed() {
fetchFlairsInSubredditListener.fetchFailed();
}
}).execute();
} else if(response.code() == 403) {
//No flairs
fetchFlairsInSubredditListener.fetchSuccessful(null);
} else {
fetchFlairsInSubredditListener.fetchFailed();
}
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
fetchFlairsInSubredditListener.fetchFailed();
}
});
}
private static class ParseFlairsAsyncTask extends AsyncTask<Void, ArrayList<String>, ArrayList<String>> {
interface ParseFlairsAsyncTaskListener {
void parseSuccessful(ArrayList<String> flairs);
void parseFailed();
}
private String response;
private ParseFlairsAsyncTaskListener parseFlairsAsyncTaskListener;
ParseFlairsAsyncTask(String response, ParseFlairsAsyncTaskListener parseFlairsAsyncTaskListener) {
this.response = response;
this.parseFlairsAsyncTaskListener = parseFlairsAsyncTaskListener;
}
@Override
protected ArrayList<String> doInBackground(Void... voids) {
try {
JSONArray jsonArray = new JSONArray(response);
ArrayList<String> flairs = new ArrayList<>();
for(int i = 0; i < jsonArray.length(); i++) {
flairs.add(jsonArray.getJSONObject(i).getString(JSONUtils.TEXT_KEY));
}
return flairs;
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(ArrayList<String> strings) {
if(strings != null) {
parseFlairsAsyncTaskListener.parseSuccessful(strings);
} else {
parseFlairsAsyncTaskListener.parseFailed();
}
}
}
}

View File

@ -0,0 +1,106 @@
package ml.docilealligator.infinityforreddit;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import java.util.ArrayList;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Retrofit;
/**
* A simple {@link Fragment} subclass.
*/
public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
interface FlairSelectionCallback {
void flairSelected(String flair);
}
static final String EXTRA_SUBREDDIT_NAME = "ESN";
@BindView(R.id.progress_bar_flair_bottom_sheet_fragment) ProgressBar progressBar;
@BindView(R.id.error_text_view_flair_bottom_sheet_fragment) TextView errorTextView;
@BindView(R.id.recycler_view_bottom_sheet_fragment) RecyclerView recyclerView;
private Activity mAcitivity;
private FlairBottomSheetRecyclerViewAdapter mAdapter;
@Inject
@Named("auth_info")
SharedPreferences mAuthInfoSharedPreferences;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
public FlairBottomSheetFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_flair_bottom_sheet, container, false);
ButterKnife.bind(this, rootView);
mAcitivity = getActivity();
((Infinity) mAcitivity.getApplication()).getmAppComponent().inject(this);
mAdapter = new FlairBottomSheetRecyclerViewAdapter(flair -> ((FlairSelectionCallback) mAcitivity).flairSelected(flair));
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(mAdapter);
String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
fetchFlairs(subredditName);
return rootView;
}
private void fetchFlairs(String subredditName) {
FetchFlairsInSubreddit.fetchFlairs(mOauthRetrofit, mAuthInfoSharedPreferences,
subredditName, new FetchFlairsInSubreddit.FetchFlairsInSubredditListener() {
@Override
public void fetchSuccessful(ArrayList<String> flairs) {
progressBar.setVisibility(View.GONE);
if(flairs == null || flairs.size() == 0) {
errorTextView.setVisibility(View.VISIBLE);
errorTextView.setText(R.string.no_flair);
} else {
errorTextView.setVisibility(View.GONE);
mAdapter.changeDataset(flairs);
}
}
@Override
public void fetchFailed() {
progressBar.setVisibility(View.GONE);
errorTextView.setVisibility(View.VISIBLE);
errorTextView.setText(R.string.error_loading_flairs);
errorTextView.setOnClickListener(view -> fetchFlairs(subredditName));
}
});
}
}

View File

@ -0,0 +1,59 @@
package ml.docilealligator.infinityforreddit;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<FlairBottomSheetRecyclerViewAdapter.FlairViewHolder> {
interface ItemClickListener {
void onClick(String flair);
}
private ArrayList<String> flairs;
private ItemClickListener itemClickListener;
FlairBottomSheetRecyclerViewAdapter(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
@NonNull
@Override
public FlairViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new FlairViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_flair, null, false));
}
@Override
public void onBindViewHolder(@NonNull FlairViewHolder holder, int position) {
holder.flairTextView.setText(flairs.get(holder.getAdapterPosition()));
}
@Override
public int getItemCount() {
return flairs == null ? 0 : flairs.size();
}
void changeDataset(ArrayList<String> flairs) {
this.flairs = flairs;
notifyDataSetChanged();
}
class FlairViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.flair_text_view_item_flair) TextView flairTextView;
FlairViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
flairTextView.setOnClickListener(view -> itemClickListener.onClick(flairs.get(getAdapterPosition())));
}
}
}

View File

@ -74,4 +74,5 @@ public class JSONUtils {
static final String ARGS_KEY = "args"; static final String ARGS_KEY = "args";
static final String FIELDS_KEY = "fields"; static final String FIELDS_KEY = "fields";
static final String VALUE_KEY = "value"; static final String VALUE_KEY = "value";
static final String TEXT_KEY = "text";
} }

View File

@ -42,7 +42,6 @@ public class MainActivity extends AppCompatActivity {
private static final String FRAGMENT_OUT_STATE = "FOS"; private static final String FRAGMENT_OUT_STATE = "FOS";
private static final String FETCH_USER_INFO_STATE = "FUIS"; private static final String FETCH_USER_INFO_STATE = "FUIS";
private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS";
private static final String IS_IN_LAZY_MODE_STATE = "IILMS"; private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final int LOGIN_ACTIVITY_REQUEST_CODE = 0; private static final int LOGIN_ACTIVITY_REQUEST_CODE = 0;

View File

@ -28,6 +28,7 @@ import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
@ -44,7 +45,7 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class PostImageActivity extends AppCompatActivity { public class PostImageActivity extends AppCompatActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -54,6 +55,9 @@ public class PostImageActivity extends AppCompatActivity {
private static final String SUBREDDIT_IS_USER_STATE = "SIUS"; private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
private static final String IMAGE_URI_STATE = "IUS"; private static final String IMAGE_URI_STATE = "IUS";
private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS"; private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS";
private static final String FLAIR_STATE = "FS";
private static final String IS_SPOILER_STATE = "ISS";
private static final String IS_NSFW_STATE = "INS";
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0; private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
private static final int PICK_IMAGE_REQUEST_CODE = 1; private static final int PICK_IMAGE_REQUEST_CODE = 1;
@ -62,6 +66,9 @@ public class PostImageActivity extends AppCompatActivity {
@BindView(R.id.subreddit_icon_gif_image_view_post_image_activity) GifImageView iconGifImageView; @BindView(R.id.subreddit_icon_gif_image_view_post_image_activity) GifImageView iconGifImageView;
@BindView(R.id.subreddit_name_text_view_post_image_activity) TextView subreditNameTextView; @BindView(R.id.subreddit_name_text_view_post_image_activity) TextView subreditNameTextView;
@BindView(R.id.rules_button_post_image_activity) Button rulesButton; @BindView(R.id.rules_button_post_image_activity) Button rulesButton;
@BindView(R.id.flair_custom_text_view_post_image_activity) CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_image_activity) CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_image_activity) CustomTextView nsfwTextView;
@BindView(R.id.post_title_edit_text_post_image_activity) EditText titleEditText; @BindView(R.id.post_title_edit_text_post_image_activity) EditText titleEditText;
@BindView(R.id.select_image_constraint_layout_post_image_activity) ConstraintLayout constraintLayout; @BindView(R.id.select_image_constraint_layout_post_image_activity) ConstraintLayout constraintLayout;
@BindView(R.id.capture_fab_post_image_activity) FloatingActionButton captureFab; @BindView(R.id.capture_fab_post_image_activity) FloatingActionButton captureFab;
@ -76,8 +83,13 @@ public class PostImageActivity extends AppCompatActivity {
private boolean loadSubredditIconSuccessful = true; private boolean loadSubredditIconSuccessful = true;
private Uri imageUri; private Uri imageUri;
private String flair = null;
private boolean isSpoiler = false;
private boolean isNSFW = false;
private RequestManager mGlide; private RequestManager mGlide;
private Locale mLocale; private Locale mLocale;
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
@Inject @Inject
@Named("oauth") @Named("oauth")
@ -117,6 +129,9 @@ public class PostImageActivity extends AppCompatActivity {
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE); subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE); subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE); loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE);
flair = savedInstanceState.getString(FLAIR_STATE);
isSpoiler = savedInstanceState.getBoolean(IS_SPOILER_STATE);
isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE);
if(savedInstanceState.getString(IMAGE_URI_STATE) != null) { if(savedInstanceState.getString(IMAGE_URI_STATE) != null) {
imageUri = Uri.parse(savedInstanceState.getString(IMAGE_URI_STATE)); imageUri = Uri.parse(savedInstanceState.getString(IMAGE_URI_STATE));
@ -125,11 +140,23 @@ public class PostImageActivity extends AppCompatActivity {
if(subredditName != null) { if(subredditName != null) {
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE);
if(!loadSubredditIconSuccessful) { if(!loadSubredditIconSuccessful) {
loadSubredditIcon(); loadSubredditIcon();
} }
} }
displaySubredditIcon(); displaySubredditIcon();
if(flair != null) {
flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
}
if(isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
}
if(isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
}
} else { } else {
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) { if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME); subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
@ -152,6 +179,40 @@ public class PostImageActivity extends AppCompatActivity {
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
}); });
flairTextView.setOnClickListener(view -> {
if(flair == null) {
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
flairSelectionBottomSheetFragment.setArguments(bundle);
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
} else {
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair));
flair = null;
}
});
spoilerTextView.setOnClickListener(view -> {
if(!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
isSpoiler = true;
} else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
isSpoiler = false;
}
});
nsfwTextView.setOnClickListener(view -> {
if(!isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
isNSFW = true;
} else {
nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
isNSFW = false;
}
});
captureFab.setOnClickListener(view -> { captureFab.setOnClickListener(view -> {
}); });
@ -245,7 +306,7 @@ public class PostImageActivity extends AppCompatActivity {
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
SubmitPost.submitImagePost(mOauthRetrofit, mUploadMediaRetrofit, sharedPreferences, SubmitPost.submitImagePost(mOauthRetrofit, mUploadMediaRetrofit, sharedPreferences,
mLocale, subredditName, titleEditText.getText().toString(), resource, mLocale, subredditName, titleEditText.getText().toString(), resource,
false, new SubmitPost.SubmitPostListener() { flair, isSpoiler, isNSFW, new SubmitPost.SubmitPostListener() {
@Override @Override
public void submitSuccessful(Post post) { public void submitSuccessful(Post post) {
RedditAPI api = mOauthRetrofit.create(RedditAPI.class); RedditAPI api = mOauthRetrofit.create(RedditAPI.class);
@ -326,6 +387,9 @@ public class PostImageActivity extends AppCompatActivity {
outState.putString(IMAGE_URI_STATE, imageUri.toString()); outState.putString(IMAGE_URI_STATE, imageUri.toString());
} }
outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful); outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful);
outState.putString(FLAIR_STATE, flair);
outState.putBoolean(IS_SPOILER_STATE, isSpoiler);
outState.putBoolean(IS_NSFW_STATE, isNSFW);
} }
@Override @Override
@ -341,6 +405,11 @@ public class PostImageActivity extends AppCompatActivity {
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
displaySubredditIcon(); displaySubredditIcon();
flairTextView.setVisibility(View.VISIBLE);
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair));
flair = null;
} }
} else if(requestCode == PICK_IMAGE_REQUEST_CODE) { } else if(requestCode == PICK_IMAGE_REQUEST_CODE) {
if(resultCode == RESULT_OK) { if(resultCode == RESULT_OK) {
@ -354,4 +423,12 @@ public class PostImageActivity extends AppCompatActivity {
} }
} }
} }
@Override
public void flairSelected(String flair) {
this.flair = flair;
flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
flairSelectionBottomSheetFragment.dismiss();
}
} }

View File

@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
@ -20,6 +21,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
import java.util.Locale; import java.util.Locale;
@ -33,7 +35,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class PostLinkActivity extends AppCompatActivity { public class PostLinkActivity extends AppCompatActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -42,6 +44,9 @@ public class PostLinkActivity extends AppCompatActivity {
private static final String SUBREDDIT_SELECTED_STATE = "SSS"; private static final String SUBREDDIT_SELECTED_STATE = "SSS";
private static final String SUBREDDIT_IS_USER_STATE = "SIUS"; private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS"; private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS";
private static final String FLAIR_STATE = "FS";
private static final String IS_SPOILER_STATE = "ISS";
private static final String IS_NSFW_STATE = "INS";
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0; private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
@ -49,6 +54,9 @@ public class PostLinkActivity extends AppCompatActivity {
@BindView(R.id.subreddit_icon_gif_image_view_post_link_activity) GifImageView iconGifImageView; @BindView(R.id.subreddit_icon_gif_image_view_post_link_activity) GifImageView iconGifImageView;
@BindView(R.id.subreddit_name_text_view_post_link_activity) TextView subreditNameTextView; @BindView(R.id.subreddit_name_text_view_post_link_activity) TextView subreditNameTextView;
@BindView(R.id.rules_button_post_link_activity) Button rulesButton; @BindView(R.id.rules_button_post_link_activity) Button rulesButton;
@BindView(R.id.flair_custom_text_view_post_link_activity) CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_link_activity) CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_link_activity) CustomTextView nsfwTextView;
@BindView(R.id.post_title_edit_text_post_link_activity) EditText titleEditText; @BindView(R.id.post_title_edit_text_post_link_activity) EditText titleEditText;
@BindView(R.id.post_link_edit_text_post_link_activity) EditText contentEditText; @BindView(R.id.post_link_edit_text_post_link_activity) EditText contentEditText;
@ -58,8 +66,13 @@ public class PostLinkActivity extends AppCompatActivity {
private boolean subredditIsUser; private boolean subredditIsUser;
private boolean loadSubredditIconSuccessful = true; private boolean loadSubredditIconSuccessful = true;
private String flair = null;
private boolean isSpoiler = false;
private boolean isNSFW = false;
private RequestManager mGlide; private RequestManager mGlide;
private Locale mLocale; private Locale mLocale;
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
@Inject @Inject
@Named("oauth") @Named("oauth")
@ -91,18 +104,34 @@ public class PostLinkActivity extends AppCompatActivity {
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE); subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE); subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE); loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE);
flair = savedInstanceState.getString(FLAIR_STATE);
isSpoiler = savedInstanceState.getBoolean(IS_SPOILER_STATE);
isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE);
if(subredditName != null) { if(subredditName != null) {
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE);
if(!loadSubredditIconSuccessful) { if(!loadSubredditIconSuccessful) {
loadSubredditIcon(); loadSubredditIcon();
} }
} }
displaySubredditIcon(); displaySubredditIcon();
if(flair != null) {
flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
}
if(isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
}
if(isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
}
} else { } else {
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) { if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME); subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE);
loadSubredditIcon(); loadSubredditIcon();
} else { } else {
mGlide.load(R.drawable.subreddit_default_icon) mGlide.load(R.drawable.subreddit_default_icon)
@ -120,6 +149,40 @@ public class PostLinkActivity extends AppCompatActivity {
Intent intent = new Intent(this, SubredditSelectionActivity.class); Intent intent = new Intent(this, SubredditSelectionActivity.class);
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
}); });
flairTextView.setOnClickListener(view -> {
if(flair == null) {
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
flairSelectionBottomSheetFragment.setArguments(bundle);
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
} else {
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair));
flair = null;
}
});
spoilerTextView.setOnClickListener(view -> {
if(!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
isSpoiler = true;
} else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
isSpoiler = false;
}
});
nsfwTextView.setOnClickListener(view -> {
if(!isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
isNSFW = true;
} else {
nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
isNSFW = false;
}
});
} }
private void displaySubredditIcon() { private void displaySubredditIcon() {
@ -177,7 +240,7 @@ public class PostLinkActivity extends AppCompatActivity {
SubmitPost.submitTextOrLinkPost(mOauthRetrofit, sharedPreferences, mLocale, subredditName, SubmitPost.submitTextOrLinkPost(mOauthRetrofit, sharedPreferences, mLocale, subredditName,
titleEditText.getText().toString(), contentEditText.getText().toString(), titleEditText.getText().toString(), contentEditText.getText().toString(),
false, RedditUtils.KIND_LINK, new SubmitPost.SubmitPostListener() { flair, isSpoiler, isNSFW, RedditUtils.KIND_LINK, new SubmitPost.SubmitPostListener() {
@Override @Override
public void submitSuccessful(Post post) { public void submitSuccessful(Post post) {
Intent intent = new Intent(PostLinkActivity.this, ViewPostDetailActivity.class); Intent intent = new Intent(PostLinkActivity.this, ViewPostDetailActivity.class);
@ -212,6 +275,9 @@ public class PostLinkActivity extends AppCompatActivity {
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected); outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
outState.putBoolean(SUBREDDIT_IS_USER_STATE, subredditIsUser); outState.putBoolean(SUBREDDIT_IS_USER_STATE, subredditIsUser);
outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful); outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful);
outState.putString(FLAIR_STATE, flair);
outState.putBoolean(IS_SPOILER_STATE, isSpoiler);
outState.putBoolean(IS_NSFW_STATE, isNSFW);
} }
@Override @Override
@ -227,7 +293,20 @@ public class PostLinkActivity extends AppCompatActivity {
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
displaySubredditIcon(); displaySubredditIcon();
flairTextView.setVisibility(View.VISIBLE);
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair));
flair = null;
} }
} }
} }
@Override
public void flairSelected(String flair) {
this.flair = flair;
flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
flairSelectionBottomSheetFragment.dismiss();
}
} }

View File

@ -91,7 +91,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
} }
} }
static final DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() { private static final DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() {
@Override @Override
public boolean areItemsTheSame(@NonNull Post post, @NonNull Post t1) { public boolean areItemsTheSame(@NonNull Post post, @NonNull Post t1) {
return post.getId().equals(t1.getId()); return post.getId().equals(t1.getId());

View File

@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
@ -20,6 +21,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
import java.util.Locale; import java.util.Locale;
@ -33,7 +35,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class PostTextActivity extends AppCompatActivity { public class PostTextActivity extends AppCompatActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -42,6 +44,9 @@ public class PostTextActivity extends AppCompatActivity {
private static final String SUBREDDIT_SELECTED_STATE = "SSS"; private static final String SUBREDDIT_SELECTED_STATE = "SSS";
private static final String SUBREDDIT_IS_USER_STATE = "SIUS"; private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS"; private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS";
private static final String FLAIR_STATE = "FS";
private static final String IS_SPOILER_STATE = "ISS";
private static final String IS_NSFW_STATE = "INS";
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0; private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
@ -49,6 +54,9 @@ public class PostTextActivity extends AppCompatActivity {
@BindView(R.id.subreddit_icon_gif_image_view_post_text_activity) GifImageView iconGifImageView; @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.subreddit_name_text_view_post_text_activity) TextView subreditNameTextView;
@BindView(R.id.rules_button_post_text_activity) Button rulesButton; @BindView(R.id.rules_button_post_text_activity) Button rulesButton;
@BindView(R.id.flair_custom_text_view_post_text_activity) CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_text_activity) CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_text_activity) CustomTextView nsfwTextView;
@BindView(R.id.post_title_edit_text_post_text_activity) EditText titleEditText; @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; @BindView(R.id.post_text_content_edit_text_post_text_activity) EditText contentEditText;
@ -58,8 +66,13 @@ public class PostTextActivity extends AppCompatActivity {
private boolean subredditIsUser; private boolean subredditIsUser;
private boolean loadSubredditIconSuccessful = true; private boolean loadSubredditIconSuccessful = true;
private String flair = null;
private boolean isSpoiler = false;
private boolean isNSFW = false;
private RequestManager mGlide; private RequestManager mGlide;
private Locale mLocale; private Locale mLocale;
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
@Inject @Inject
@Named("oauth") @Named("oauth")
@ -91,19 +104,35 @@ public class PostTextActivity extends AppCompatActivity {
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE); subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE); subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE); loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE);
flair = savedInstanceState.getString(FLAIR_STATE);
isSpoiler = savedInstanceState.getBoolean(IS_SPOILER_STATE);
isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE);
if(subredditName != null) { if(subredditName != null) {
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE);
if(!loadSubredditIconSuccessful) { if(!loadSubredditIconSuccessful) {
loadSubredditIcon(); loadSubredditIcon();
} }
} }
displaySubredditIcon(); displaySubredditIcon();
if(flair != null) {
flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
}
if(isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
}
if(isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
}
} else { } else {
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) { if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
loadSubredditIconSuccessful = false; loadSubredditIconSuccessful = false;
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME); subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE);
loadSubredditIcon(); loadSubredditIcon();
} else { } else {
mGlide.load(R.drawable.subreddit_default_icon) mGlide.load(R.drawable.subreddit_default_icon)
@ -121,6 +150,44 @@ public class PostTextActivity extends AppCompatActivity {
Intent intent = new Intent(this, SubredditSelectionActivity.class); Intent intent = new Intent(this, SubredditSelectionActivity.class);
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
}); });
flairTextView.setOnClickListener(view -> {
if(flair == null) {
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
Bundle bundle = new Bundle();
if(subredditIsUser) {
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
} else {
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
}
flairSelectionBottomSheetFragment.setArguments(bundle);
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
} else {
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair));
flair = null;
}
});
spoilerTextView.setOnClickListener(view -> {
if(!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
isSpoiler = true;
} else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
isSpoiler = false;
}
});
nsfwTextView.setOnClickListener(view -> {
if(!isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
isNSFW = true;
} else {
nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
isNSFW = false;
}
});
} }
private void displaySubredditIcon() { private void displaySubredditIcon() {
@ -178,7 +245,7 @@ public class PostTextActivity extends AppCompatActivity {
SubmitPost.submitTextOrLinkPost(mOauthRetrofit, sharedPreferences, mLocale, subredditName, SubmitPost.submitTextOrLinkPost(mOauthRetrofit, sharedPreferences, mLocale, subredditName,
titleEditText.getText().toString(), contentEditText.getText().toString(), titleEditText.getText().toString(), contentEditText.getText().toString(),
false, RedditUtils.KIND_SELF, new SubmitPost.SubmitPostListener() { flair, isSpoiler, isNSFW, RedditUtils.KIND_SELF, new SubmitPost.SubmitPostListener() {
@Override @Override
public void submitSuccessful(Post post) { public void submitSuccessful(Post post) {
Intent intent = new Intent(PostTextActivity.this, ViewPostDetailActivity.class); Intent intent = new Intent(PostTextActivity.this, ViewPostDetailActivity.class);
@ -213,6 +280,9 @@ public class PostTextActivity extends AppCompatActivity {
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected); outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
outState.putBoolean(SUBREDDIT_IS_USER_STATE, subredditIsUser); outState.putBoolean(SUBREDDIT_IS_USER_STATE, subredditIsUser);
outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful); outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful);
outState.putString(FLAIR_STATE, flair);
outState.putBoolean(IS_SPOILER_STATE, isSpoiler);
outState.putBoolean(IS_NSFW_STATE, isNSFW);
} }
@Override @Override
@ -228,7 +298,20 @@ public class PostTextActivity extends AppCompatActivity {
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
displaySubredditIcon(); displaySubredditIcon();
flairTextView.setVisibility(View.VISIBLE);
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair));
flair = null;
} }
} }
} }
@Override
public void flairSelected(String flair) {
this.flair = flair;
flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
flairSelectionBottomSheetFragment.dismiss();
}
} }

View File

@ -30,6 +30,7 @@ import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@ -45,7 +46,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class PostVideoActivity extends AppCompatActivity { public class PostVideoActivity extends AppCompatActivity implements FlairBottomSheetFragment.FlairSelectionCallback {
static final String EXTRA_SUBREDDIT_NAME = "ESN"; static final String EXTRA_SUBREDDIT_NAME = "ESN";
@ -55,6 +56,9 @@ public class PostVideoActivity extends AppCompatActivity {
private static final String SUBREDDIT_IS_USER_STATE = "SIUS"; private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
private static final String VIDEO_URI_STATE = "IUS"; private static final String VIDEO_URI_STATE = "IUS";
private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS"; private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS";
private static final String FLAIR_STATE = "FS";
private static final String IS_SPOILER_STATE = "ISS";
private static final String IS_NSFW_STATE = "INS";
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0; private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
private static final int PICK_VIDEO_REQUEST_CODE = 1; private static final int PICK_VIDEO_REQUEST_CODE = 1;
@ -63,6 +67,9 @@ public class PostVideoActivity extends AppCompatActivity {
@BindView(R.id.subreddit_icon_gif_image_view_post_video_activity) GifImageView iconGifImageView; @BindView(R.id.subreddit_icon_gif_image_view_post_video_activity) GifImageView iconGifImageView;
@BindView(R.id.subreddit_name_text_view_post_video_activity) TextView subreditNameTextView; @BindView(R.id.subreddit_name_text_view_post_video_activity) TextView subreditNameTextView;
@BindView(R.id.rules_button_post_video_activity) Button rulesButton; @BindView(R.id.rules_button_post_video_activity) Button rulesButton;
@BindView(R.id.flair_custom_text_view_post_video_activity) CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_video_activity) CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_video_activity) CustomTextView nsfwTextView;
@BindView(R.id.post_title_edit_text_post_video_activity) EditText titleEditText; @BindView(R.id.post_title_edit_text_post_video_activity) EditText titleEditText;
@BindView(R.id.select_video_constraint_layout_post_video_activity) ConstraintLayout constraintLayout; @BindView(R.id.select_video_constraint_layout_post_video_activity) ConstraintLayout constraintLayout;
@BindView(R.id.capture_fab_post_video_activity) FloatingActionButton captureFab; @BindView(R.id.capture_fab_post_video_activity) FloatingActionButton captureFab;
@ -77,8 +84,13 @@ public class PostVideoActivity extends AppCompatActivity {
private Uri videoUri; private Uri videoUri;
private boolean loadSubredditIconSuccessful = true; private boolean loadSubredditIconSuccessful = true;
private String flair = null;
private boolean isSpoiler = false;
private boolean isNSFW = false;
private RequestManager mGlide; private RequestManager mGlide;
private Locale mLocale; private Locale mLocale;
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
@Inject @Inject
@Named("oauth") @Named("oauth")
@ -122,6 +134,9 @@ public class PostVideoActivity extends AppCompatActivity {
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE); subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE); subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE); loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE);
flair = savedInstanceState.getString(FLAIR_STATE);
isSpoiler = savedInstanceState.getBoolean(IS_SPOILER_STATE);
isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE);
if(savedInstanceState.getString(VIDEO_URI_STATE) != null) { if(savedInstanceState.getString(VIDEO_URI_STATE) != null) {
videoUri = Uri.parse(savedInstanceState.getString(VIDEO_URI_STATE)); videoUri = Uri.parse(savedInstanceState.getString(VIDEO_URI_STATE));
@ -130,11 +145,23 @@ public class PostVideoActivity extends AppCompatActivity {
if(subredditName != null) { if(subredditName != null) {
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE);
if(!loadSubredditIconSuccessful) { if(!loadSubredditIconSuccessful) {
loadSubredditIcon(); loadSubredditIcon();
} }
} }
displaySubredditIcon(); displaySubredditIcon();
if(flair != null) {
flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
}
if(isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
}
if(isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
}
} else { } else {
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) { if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME); subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
@ -157,6 +184,40 @@ public class PostVideoActivity extends AppCompatActivity {
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
}); });
flairTextView.setOnClickListener(view -> {
if(flair == null) {
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
flairSelectionBottomSheetFragment.setArguments(bundle);
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
} else {
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair));
flair = null;
}
});
spoilerTextView.setOnClickListener(view -> {
if(!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
isSpoiler = true;
} else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
isSpoiler = false;
}
});
nsfwTextView.setOnClickListener(view -> {
if(!isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
isNSFW = true;
} else {
nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
isNSFW = false;
}
});
captureFab.setOnClickListener(view -> { captureFab.setOnClickListener(view -> {
}); });
@ -255,7 +316,7 @@ public class PostVideoActivity extends AppCompatActivity {
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
SubmitPost.submitVideoPost(mOauthRetrofit, mUploadMediaRetrofit, mUploadVideoRetrofit, SubmitPost.submitVideoPost(mOauthRetrofit, mUploadMediaRetrofit, mUploadVideoRetrofit,
sharedPreferences, mLocale, subredditName, titleEditText.getText().toString(), sharedPreferences, mLocale, subredditName, titleEditText.getText().toString(),
buffer, getContentResolver().getType(videoUri), resource, false, buffer, getContentResolver().getType(videoUri), resource, flair, isSpoiler, isNSFW,
new SubmitPost.SubmitPostListener() { new SubmitPost.SubmitPostListener() {
@Override @Override
public void submitSuccessful(Post post) { public void submitSuccessful(Post post) {
@ -307,6 +368,9 @@ public class PostVideoActivity extends AppCompatActivity {
outState.putString(VIDEO_URI_STATE, videoUri.toString()); outState.putString(VIDEO_URI_STATE, videoUri.toString());
} }
outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful); outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful);
outState.putString(FLAIR_STATE, flair);
outState.putBoolean(IS_SPOILER_STATE, isSpoiler);
outState.putBoolean(IS_NSFW_STATE, isNSFW);
} }
@Override @Override
@ -322,6 +386,11 @@ public class PostVideoActivity extends AppCompatActivity {
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
subreditNameTextView.setText(subredditName); subreditNameTextView.setText(subredditName);
displaySubredditIcon(); displaySubredditIcon();
flairTextView.setVisibility(View.VISIBLE);
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair));
flair = null;
} }
} else if(requestCode == PICK_VIDEO_REQUEST_CODE) { } else if(requestCode == PICK_VIDEO_REQUEST_CODE) {
if(resultCode == RESULT_OK) { if(resultCode == RESULT_OK) {
@ -335,4 +404,12 @@ public class PostVideoActivity extends AppCompatActivity {
} }
} }
} }
@Override
public void flairSelected(String flair) {
this.flair = flair;
flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark));
flairSelectionBottomSheetFragment.dismiss();
}
} }

View File

@ -77,21 +77,24 @@ public interface RedditAPI {
@HeaderMap Map<String, String> headers); @HeaderMap Map<String, String> headers);
@FormUrlEncoded @FormUrlEncoded
@POST("/api/comment") @POST("api/comment")
Call<String> sendComment(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); Call<String> sendComment(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@FormUrlEncoded @FormUrlEncoded
@POST("/api/del") @POST("api/del")
Call<String> delete(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); Call<String> delete(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@FormUrlEncoded @FormUrlEncoded
@POST("/api/submit") @POST("api/submit")
Call<String> submit(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); Call<String> submit(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@FormUrlEncoded @FormUrlEncoded
@POST("/api/media/asset.json?raw_json=1&gilding_detail=1") @POST("api/media/asset.json?raw_json=1&gilding_detail=1")
Call<String> uploadImage(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); Call<String> uploadImage(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@GET("r/{subredditName}/api/link_flair.json?raw_json=1")
Call<String> getFlairs(@HeaderMap Map<String, String> headers, @Path("subredditName") String subredditName);
@Multipart @Multipart
@POST(".") @POST(".")
Call<String> uploadMediaToAWS(@PartMap()Map<String, RequestBody> params, @Part() MultipartBody.Part file); Call<String> uploadMediaToAWS(@PartMap()Map<String, RequestBody> params, @Part() MultipartBody.Part file);

View File

@ -63,9 +63,10 @@ public class RedditUtils {
static final String SR_KEY = "sr"; static final String SR_KEY = "sr";
static final String TITLE_KEY = "title"; static final String TITLE_KEY = "title";
static final String FLAIR_TEXT_KEY = "flair_text";
static final String SPOILER_KEY = "spoiler";
static final String NSFW_KEY = "nsfw"; static final String NSFW_KEY = "nsfw";
static final String KIND_KEY = "kind"; static final String KIND_KEY = "kind";
static final String KIND_TEXT = "text";
static final String KIND_SELF = "self"; static final String KIND_SELF = "self";
static final String KIND_LINK = "link"; static final String KIND_LINK = "link";
static final String KIND_IMAGE = "image"; static final String KIND_IMAGE = "image";

View File

@ -42,23 +42,24 @@ class SubmitPost {
} }
static void submitTextOrLinkPost(Retrofit oauthRetrofit, SharedPreferences authInfoSharedPreferences, static void submitTextOrLinkPost(Retrofit oauthRetrofit, SharedPreferences authInfoSharedPreferences,
Locale locale, String subredditName, String title, String content, boolean isNSFW, Locale locale, String subredditName, String title, String content,
String kind, SubmitPostListener submitPostListener) { String flair, boolean isSpoiler, boolean isNSFW, String kind,
SubmitPostListener submitPostListener) {
submitPost(oauthRetrofit, authInfoSharedPreferences, locale, subredditName, title, content, submitPost(oauthRetrofit, authInfoSharedPreferences, locale, subredditName, title, content,
isNSFW, kind, null, submitPostListener); flair, isSpoiler, isNSFW, kind, null, submitPostListener);
} }
static void submitImagePost(Retrofit oauthRetrofit, Retrofit uploadMediaRetrofit, static void submitImagePost(Retrofit oauthRetrofit, Retrofit uploadMediaRetrofit,
SharedPreferences authInfoSharedPreferences, Locale locale, SharedPreferences authInfoSharedPreferences, Locale locale,
String subredditName, String title, Bitmap image, boolean isNSFW, String subredditName, String title, Bitmap image, String flair,
SubmitPostListener submitPostListener) { boolean isSpoiler, boolean isNSFW, SubmitPostListener submitPostListener) {
uploadImage(oauthRetrofit, uploadMediaRetrofit, authInfoSharedPreferences, image, uploadImage(oauthRetrofit, uploadMediaRetrofit, authInfoSharedPreferences, image,
new UploadImageListener() { new UploadImageListener() {
@Override @Override
public void uploaded(String imageUrl) { public void uploaded(String imageUrl) {
submitPost(oauthRetrofit, authInfoSharedPreferences, locale, submitPost(oauthRetrofit, authInfoSharedPreferences, locale,
subredditName, title, imageUrl, isNSFW, RedditUtils.KIND_IMAGE, subredditName, title, imageUrl, flair, isSpoiler, isNSFW,
null, submitPostListener); RedditUtils.KIND_IMAGE, null, submitPostListener);
} }
@Override @Override
@ -71,7 +72,8 @@ class SubmitPost {
static void submitVideoPost(Retrofit oauthRetrofit, Retrofit uploadMediaRetrofit, static void submitVideoPost(Retrofit oauthRetrofit, Retrofit uploadMediaRetrofit,
Retrofit uploadVideoRetrofit, SharedPreferences authInfoSharedPreferences, Retrofit uploadVideoRetrofit, SharedPreferences authInfoSharedPreferences,
Locale locale, String subredditName, String title, byte[] buffer, String mimeType, Locale locale, String subredditName, String title, byte[] buffer, String mimeType,
Bitmap posterBitmap, boolean isNSFW, SubmitPostListener submitPostListener) { Bitmap posterBitmap, String flair, boolean isSpoiler, boolean isNSFW,
SubmitPostListener submitPostListener) {
RedditAPI api = oauthRetrofit.create(RedditAPI.class); RedditAPI api = oauthRetrofit.create(RedditAPI.class);
String accessToken = authInfoSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, ""); String accessToken = authInfoSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, "");
@ -115,12 +117,12 @@ class SubmitPost {
public void uploaded(String imageUrl) { public void uploaded(String imageUrl) {
if(fileType.equals("gif")) { if(fileType.equals("gif")) {
submitPost(oauthRetrofit, authInfoSharedPreferences, locale, submitPost(oauthRetrofit, authInfoSharedPreferences, locale,
subredditName, title, url, isNSFW, RedditUtils.KIND_VIDEOGIF, subredditName, title, url, flair, isSpoiler, isNSFW,
imageUrl, submitPostListener); RedditUtils.KIND_VIDEOGIF, imageUrl, submitPostListener);
} else { } else {
submitPost(oauthRetrofit, authInfoSharedPreferences, locale, submitPost(oauthRetrofit, authInfoSharedPreferences, locale,
subredditName, title, url, isNSFW, RedditUtils.KIND_VIDEO, subredditName, title, url, flair, isSpoiler, isNSFW,
imageUrl, submitPostListener); RedditUtils.KIND_VIDEO, imageUrl, submitPostListener);
} }
} }
@ -168,8 +170,9 @@ class SubmitPost {
} }
private static void submitPost(Retrofit oauthRetrofit, SharedPreferences authInfoSharedPreferences, private static void submitPost(Retrofit oauthRetrofit, SharedPreferences authInfoSharedPreferences,
Locale locale, String subredditName, String title, String content, boolean isNSFW, Locale locale, String subredditName, String title, String content,
String kind, @Nullable String posterUrl, SubmitPostListener submitPostListener) { String flair, boolean isSpoiler, boolean isNSFW, String kind,
@Nullable String posterUrl, SubmitPostListener submitPostListener) {
RedditAPI api = oauthRetrofit.create(RedditAPI.class); RedditAPI api = oauthRetrofit.create(RedditAPI.class);
String accessToken = authInfoSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, ""); String accessToken = authInfoSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, "");
@ -196,6 +199,8 @@ class SubmitPost {
params.put(RedditUtils.VIDEO_POSTER_URL_KEY, posterUrl); params.put(RedditUtils.VIDEO_POSTER_URL_KEY, posterUrl);
break; break;
} }
params.put(RedditUtils.FLAIR_TEXT_KEY, flair);
params.put(RedditUtils.SPOILER_KEY, Boolean.toString(isSpoiler));
params.put(RedditUtils.NSFW_KEY, Boolean.toString(isNSFW)); params.put(RedditUtils.NSFW_KEY, Boolean.toString(isNSFW));
Call<String> submitPostCall = api.submit(RedditUtils.getOAuthHeader(accessToken), params); Call<String> submitPostCall = api.submit(RedditUtils.getOAuthHeader(accessToken), params);

View File

@ -64,7 +64,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
glide = Glide.with(context.getApplicationContext()); glide = Glide.with(context.getApplicationContext());
} }
static final DiffUtil.ItemCallback<SubredditData> DIFF_CALLBACK = new DiffUtil.ItemCallback<SubredditData>() { private static final DiffUtil.ItemCallback<SubredditData> DIFF_CALLBACK = new DiffUtil.ItemCallback<SubredditData>() {
@Override @Override
public boolean areItemsTheSame(@NonNull SubredditData oldItem, @NonNull SubredditData newItem) { public boolean areItemsTheSame(@NonNull SubredditData oldItem, @NonNull SubredditData newItem) {
return oldItem.getId().equals(newItem.getId()); return oldItem.getId().equals(newItem.getId());

View File

@ -64,7 +64,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
glide = Glide.with(context.getApplicationContext()); glide = Glide.with(context.getApplicationContext());
} }
static final DiffUtil.ItemCallback<UserData> DIFF_CALLBACK = new DiffUtil.ItemCallback<UserData>() { private static final DiffUtil.ItemCallback<UserData> DIFF_CALLBACK = new DiffUtil.ItemCallback<UserData>() {
@Override @Override
public boolean areItemsTheSame(@NonNull UserData oldItem, @NonNull UserData newItem) { public boolean areItemsTheSame(@NonNull UserData oldItem, @NonNull UserData newItem) {
return oldItem.getName().equals(newItem.getName()); return oldItem.getName().equals(newItem.getName());

View File

@ -54,6 +54,57 @@
</RelativeLayout> </RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dividerColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.libRG.CustomTextView
android:id="@+id/flair_custom_text_view_post_image_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/flair"
android:textColor="@color/primaryTextColor"
android:visibility="gone"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/spoiler_custom_text_view_post_image_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/spoiler"
android:textColor="@color/primaryTextColor"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/nsfw_custom_text_view_post_image_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/nsfw"
android:textColor="@color/primaryTextColor"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorAccent"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"

View File

@ -54,6 +54,57 @@
</RelativeLayout> </RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dividerColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.libRG.CustomTextView
android:id="@+id/flair_custom_text_view_post_link_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/flair"
android:textColor="@color/primaryTextColor"
android:visibility="gone"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/spoiler_custom_text_view_post_link_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/spoiler"
android:textColor="@color/primaryTextColor"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/nsfw_custom_text_view_post_link_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/nsfw"
android:textColor="@color/primaryTextColor"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorAccent"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"

View File

@ -54,6 +54,57 @@
</RelativeLayout> </RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dividerColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.libRG.CustomTextView
android:id="@+id/flair_custom_text_view_post_text_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/flair"
android:textColor="@color/primaryTextColor"
android:visibility="gone"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/spoiler_custom_text_view_post_text_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/spoiler"
android:textColor="@color/primaryTextColor"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/nsfw_custom_text_view_post_text_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/nsfw"
android:textColor="@color/primaryTextColor"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorAccent"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"

View File

@ -54,6 +54,57 @@
</RelativeLayout> </RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dividerColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.libRG.CustomTextView
android:id="@+id/flair_custom_text_view_post_video_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/flair"
android:textColor="@color/primaryTextColor"
android:visibility="gone"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/spoiler_custom_text_view_post_video_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/spoiler"
android:textColor="@color/primaryTextColor"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/nsfw_custom_text_view_post_video_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:padding="4dp"
android:text="@string/nsfw"
android:textColor="@color/primaryTextColor"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorAccent"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".FlairBottomSheetFragment">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/flair"
android:textSize="18sp" />
<ProgressBar
android:id="@+id/progress_bar_flair_bottom_sheet_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="36dp"
android:layout_gravity="center" />
<TextView
android:id="@+id/error_text_view_flair_bottom_sheet_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:padding="48dp"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/flair_text_view_item_flair"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textColor="@color/primaryTextColor"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
</LinearLayout>

View File

@ -7,7 +7,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:padding="16dp"
android:text="@string/dialog_post_type" android:text="@string/bottom_sheet_post_type"
android:textSize="18sp" /> android:textSize="18sp" />
<LinearLayout <LinearLayout
@ -31,7 +31,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/dialog_post_text" android:text="@string/bottom_sheet_post_text"
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textSize="18sp" /> android:textSize="18sp" />
@ -58,7 +58,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/dialog_post_link" android:text="@string/bottom_sheet_post_link"
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textSize="18sp" /> android:textSize="18sp" />
@ -85,7 +85,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/dialog_post_image" android:text="@string/bottom_sheet_post_image"
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textSize="18sp" /> android:textSize="18sp" />
@ -113,7 +113,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/dialog_post_video" android:text="@string/bottom_sheet_post_video"
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textSize="18sp" /> android:textSize="18sp" />

View File

@ -107,15 +107,21 @@
<string name="subreddits">Subreddits</string> <string name="subreddits">Subreddits</string>
<string name="users">Users</string> <string name="users">Users</string>
<string name="dialog_post_type">Post</string> <string name="bottom_sheet_post_type">Post</string>
<string name="dialog_post_text">Text</string> <string name="bottom_sheet_post_text">Text</string>
<string name="dialog_post_link">Link</string> <string name="bottom_sheet_post_link">Link</string>
<string name="dialog_post_image">Image</string> <string name="bottom_sheet_post_image">Image</string>
<string name="dialog_post_video">Video</string> <string name="bottom_sheet_post_video">Video</string>
<string name="select_from_gallery">Select a picture</string> <string name="select_from_gallery">Select a picture</string>
<string name="select_again">Select again</string> <string name="select_again">Select again</string>
<string name="error_getting_image">Error getting the image</string> <string name="error_getting_image">Error getting the image</string>
<string name="video_is_processing">Video is processing. Please wait.</string> <string name="video_is_processing">Video is processing. Please wait.</string>
<string name="flair">Flair</string>
<string name="spoiler">Spoiler</string>
<string name="no_flair">No flair</string>
<string name="error_loading_flairs">Error loading flairs.\nTap to retry.</string>
</resources> </resources>