Browse Source
Convert comment viewer activity to fragment and update layouts
renovate/org.robolectric-robolectric-4.x
Convert comment viewer activity to fragment and update layouts
renovate/org.robolectric-robolectric-4.x
Ammar Githam
4 years ago
37 changed files with 951 additions and 688 deletions
-
14app/src/main/AndroidManifest.xml
-
4app/src/main/java/awais/instagrabber/MainHelper.java
-
302app/src/main/java/awais/instagrabber/activities/CommentsViewer.java
-
370app/src/main/java/awais/instagrabber/activities/CommentsViewerFragment.java
-
1app/src/main/java/awais/instagrabber/activities/DirectMessagesActivity.java
-
27app/src/main/java/awais/instagrabber/activities/MainActivity.java
-
2app/src/main/java/awais/instagrabber/activities/PostViewer.java
-
1app/src/main/java/awais/instagrabber/activities/ProfileViewer.java
-
167app/src/main/java/awais/instagrabber/activities/StoryViewer.java
-
40app/src/main/java/awais/instagrabber/adapters/CommentsAdapter.java
-
20app/src/main/java/awais/instagrabber/adapters/viewholder/CommentViewHolder.java
-
3app/src/main/java/awais/instagrabber/asyncs/ImageUploader.java
-
2app/src/main/java/awais/instagrabber/asyncs/i/iPostFetcher.java
-
20app/src/main/java/awais/instagrabber/fragments/PostViewFragment.java
-
19app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java
-
12app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java
-
26app/src/main/java/awais/instagrabber/repositories/MediaRepository.java
-
26app/src/main/java/awais/instagrabber/services/BaseService.java
-
4app/src/main/java/awais/instagrabber/services/LoggingInterceptor.java
-
196app/src/main/java/awais/instagrabber/services/MediaService.java
-
1app/src/main/java/awais/instagrabber/utils/Constants.java
-
32app/src/main/java/awais/instagrabber/utils/Utils.java
-
10app/src/main/res/drawable/ic_search_24.xml
-
70app/src/main/res/layout/activity_comments.xml
-
1app/src/main/res/layout/activity_main.xml
-
48app/src/main/res/layout/fragment_comments.xml
-
8app/src/main/res/layout/item_comment.xml
-
15app/src/main/res/layout/item_comment_small.xml
-
2app/src/main/res/layout/item_post.xml
-
5app/src/main/res/layout/layout_dm_inbox_item.xml
-
4app/src/main/res/menu/follow.xml
-
2app/src/main/res/menu/menu.xml
-
65app/src/main/res/navigation/comments_nav_graph.xml
-
1app/src/main/res/navigation/discover_nav_graph.xml
-
19app/src/main/res/navigation/feed_nav_graph.xml
-
18app/src/main/res/navigation/post_view_nav_graph.xml
-
2app/src/main/res/navigation/profile_nav_graph.xml
@ -1,302 +0,0 @@ |
|||
package awais.instagrabber.activities; |
|||
|
|||
import android.content.DialogInterface; |
|||
import android.content.Intent; |
|||
import android.content.res.Resources; |
|||
import android.os.AsyncTask; |
|||
import android.os.Bundle; |
|||
import android.text.SpannableString; |
|||
import android.text.Spanned; |
|||
import android.text.style.RelativeSizeSpan; |
|||
import android.util.Log; |
|||
import android.view.Menu; |
|||
import android.view.MenuItem; |
|||
import android.view.View; |
|||
import android.view.inputmethod.InputMethodManager; |
|||
import android.widget.ArrayAdapter; |
|||
import android.widget.Toast; |
|||
|
|||
import androidx.annotation.Nullable; |
|||
import androidx.appcompat.app.AlertDialog; |
|||
import androidx.appcompat.widget.SearchView; |
|||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
|||
|
|||
import java.io.DataOutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLEncoder; |
|||
|
|||
import awais.instagrabber.R; |
|||
import awais.instagrabber.adapters.CommentsAdapter; |
|||
import awais.instagrabber.asyncs.CommentsFetcher; |
|||
import awais.instagrabber.databinding.ActivityCommentsBinding; |
|||
import awais.instagrabber.interfaces.FetchListener; |
|||
import awais.instagrabber.interfaces.MentionClickListener; |
|||
import awais.instagrabber.models.CommentModel; |
|||
import awais.instagrabber.models.ProfileModel; |
|||
import awais.instagrabber.utils.Constants; |
|||
import awais.instagrabber.utils.Utils; |
|||
|
|||
public final class CommentsViewer extends BaseLanguageActivity implements SwipeRefreshLayout.OnRefreshListener { |
|||
private CommentsAdapter commentsAdapter; |
|||
private CommentModel commentModel; |
|||
private ActivityCommentsBinding commentsBinding; |
|||
private ArrayAdapter<String> commmentDialogAdapter; |
|||
private String shortCode, postId, userId; |
|||
private final String cookie = Utils.settingsHelper.getString(Constants.COOKIE); |
|||
private Resources resources; |
|||
private InputMethodManager imm; |
|||
private View focus; |
|||
|
|||
@Override |
|||
protected void onCreate(@Nullable final Bundle savedInstanceState) { |
|||
super.onCreate(savedInstanceState); |
|||
commentsBinding = ActivityCommentsBinding.inflate(getLayoutInflater()); |
|||
setContentView(commentsBinding.getRoot()); |
|||
commentsBinding.swipeRefreshLayout.setOnRefreshListener(this); |
|||
|
|||
final Intent intent = getIntent(); |
|||
if (intent == null || !intent.hasExtra(Constants.EXTRAS_SHORTCODE) |
|||
|| Utils.isEmpty((shortCode = intent.getStringExtra(Constants.EXTRAS_SHORTCODE))) |
|||
|| !intent.hasExtra(Constants.EXTRAS_POST) |
|||
|| Utils.isEmpty((postId = intent.getStringExtra(Constants.EXTRAS_POST))) |
|||
|| !intent.hasExtra(Constants.EXTRAS_USER) |
|||
|| Utils.isEmpty((userId = intent.getStringExtra(Constants.EXTRAS_USER)))) { |
|||
Utils.errorFinish(this); |
|||
return; |
|||
} |
|||
|
|||
commentsBinding.swipeRefreshLayout.setRefreshing(true); |
|||
setSupportActionBar(commentsBinding.toolbar.toolbar); |
|||
commentsBinding.toolbar.toolbar.setTitle(R.string.title_comments); |
|||
commentsBinding.toolbar.toolbar.setSubtitle(shortCode); |
|||
|
|||
resources = getResources(); |
|||
|
|||
if (!Utils.isEmpty(cookie)) { |
|||
commentsBinding.commentText.setVisibility(View.VISIBLE); |
|||
commentsBinding.commentSend.setVisibility(View.VISIBLE); |
|||
|
|||
commentsBinding.commentSend.setOnClickListener(newCommentListener); |
|||
commentsBinding.commentCancelParent.setOnClickListener(newCommentListener); |
|||
} |
|||
|
|||
new CommentsFetcher(shortCode, new FetchListener<CommentModel[]>() { |
|||
@Override |
|||
public void onResult(final CommentModel[] commentModels) { |
|||
commentsAdapter = new CommentsAdapter(commentModels, true, clickListener, mentionClickListener); |
|||
|
|||
commentsBinding.rvComments.setAdapter(commentsAdapter); |
|||
commentsBinding.swipeRefreshLayout.setRefreshing(false); |
|||
} |
|||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
|||
} |
|||
|
|||
@Override |
|||
public void onRefresh() { |
|||
commentsBinding.swipeRefreshLayout.setRefreshing(true); |
|||
new CommentsFetcher(shortCode, new FetchListener<CommentModel[]>() { |
|||
@Override |
|||
public void onResult(final CommentModel[] commentModels) { |
|||
commentsBinding.swipeRefreshLayout.setRefreshing(false); |
|||
|
|||
commentsAdapter = new CommentsAdapter(commentModels, true, clickListener, mentionClickListener); |
|||
|
|||
commentsBinding.rvComments.setAdapter(commentsAdapter); |
|||
} |
|||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
|||
} |
|||
|
|||
final DialogInterface.OnClickListener profileDialogListener = (dialog, which) -> { |
|||
final ProfileModel profileModel = commentModel.getProfileModel(); |
|||
|
|||
if (which == 0) { |
|||
searchUsername(profileModel.getUsername()); |
|||
} else if (which == 1) { |
|||
startActivity(new Intent(this, ProfilePicViewer.class).putExtra(Constants.EXTRAS_PROFILE, profileModel)); |
|||
} else if (which == 2) { |
|||
Utils.copyText(this, profileModel.getUsername()); |
|||
} else if (which == 3) { |
|||
Utils.copyText(this, commentModel.getText().toString()); |
|||
} else if (which == 4) { |
|||
if (commentModel == null) { |
|||
Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|||
} |
|||
else { |
|||
focus = commentsBinding.rvComments.findViewWithTag(commentModel); |
|||
focus.setBackgroundColor(0x80888888); |
|||
commentsBinding.commentCancelParent.setVisibility(View.VISIBLE); |
|||
String mention = "@" + profileModel.getUsername() + " "; |
|||
commentsBinding.commentText.setText(mention); |
|||
commentsBinding.commentText.requestFocus(); |
|||
commentsBinding.commentText.setSelection(mention.length()); |
|||
commentsBinding.commentText.postDelayed(new Runnable() { |
|||
@Override |
|||
public void run() { |
|||
imm = (InputMethodManager) getSystemService(getApplicationContext().INPUT_METHOD_SERVICE); |
|||
imm.showSoftInput(commentsBinding.commentText, 0); |
|||
} |
|||
}, 200); |
|||
} |
|||
} else if (which == 5) { |
|||
new CommentAction().execute((commentModel.getLiked() ? "unlike/" : "like/")+commentModel.getId()); |
|||
} else if (which == 6) { |
|||
new CommentAction().execute("delete/"+commentModel.getId()); |
|||
} |
|||
}; |
|||
|
|||
private final View.OnClickListener clickListener = v -> { |
|||
final Object tag = v.getTag(); |
|||
if (tag instanceof CommentModel) { |
|||
commentModel = (CommentModel) tag; |
|||
|
|||
final String username = commentModel.getProfileModel().getUsername(); |
|||
final SpannableString title = new SpannableString(username + ":\n" + commentModel.getText()); |
|||
title.setSpan(new RelativeSizeSpan(1.23f), 0, username.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); |
|||
|
|||
String[] commentDialogList; |
|||
|
|||
if (!Utils.isEmpty(cookie) && |
|||
(Utils.getUserIdFromCookie(cookie).equals(commentModel.getProfileModel().getId()) || |
|||
Utils.getUserIdFromCookie(cookie).equals(userId))) commentDialogList = new String[]{ |
|||
resources.getString(R.string.open_profile), |
|||
resources.getString(R.string.view_pfp), |
|||
resources.getString(R.string.comment_viewer_copy_user), |
|||
resources.getString(R.string.comment_viewer_copy_comment), |
|||
resources.getString(R.string.comment_viewer_reply_comment), |
|||
commentModel.getLiked() ? resources.getString(R.string.comment_viewer_unlike_comment) : resources.getString(R.string.comment_viewer_like_comment), |
|||
resources.getString(R.string.comment_viewer_delete_comment) |
|||
}; |
|||
else if (!Utils.isEmpty(cookie)) commentDialogList = new String[]{ |
|||
resources.getString(R.string.open_profile), |
|||
resources.getString(R.string.view_pfp), |
|||
resources.getString(R.string.comment_viewer_copy_user), |
|||
resources.getString(R.string.comment_viewer_copy_comment), |
|||
resources.getString(R.string.comment_viewer_reply_comment), |
|||
commentModel.getLiked() ? resources.getString(R.string.comment_viewer_unlike_comment) : resources.getString(R.string.comment_viewer_like_comment), |
|||
}; |
|||
else commentDialogList = new String[]{ |
|||
resources.getString(R.string.open_profile), |
|||
resources.getString(R.string.view_pfp), |
|||
resources.getString(R.string.comment_viewer_copy_user), |
|||
resources.getString(R.string.comment_viewer_copy_comment) |
|||
}; |
|||
|
|||
commmentDialogAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, commentDialogList); |
|||
|
|||
new AlertDialog.Builder(this).setTitle(title) |
|||
.setAdapter(commmentDialogAdapter, profileDialogListener) |
|||
.setNeutralButton(R.string.cancel, null) |
|||
.show(); |
|||
} |
|||
}; |
|||
|
|||
private final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) -> |
|||
new AlertDialog.Builder(this).setTitle(text) |
|||
.setMessage(isHashtag ? R.string.comment_view_mention_hash_search : R.string.comment_view_mention_user_search) |
|||
.setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.ok, |
|||
(dialog, which) -> searchUsername(text)).show(); |
|||
|
|||
private final View.OnClickListener newCommentListener = v -> { |
|||
if (Utils.isEmpty(commentsBinding.commentText.getText().toString()) && v == commentsBinding.commentSend) |
|||
Toast.makeText(getApplicationContext(), R.string.comment_send_empty_comment, Toast.LENGTH_SHORT).show(); |
|||
else if (v == commentsBinding.commentSend) new CommentAction().execute("add"); |
|||
else if (v == commentsBinding.commentCancelParent) { |
|||
focus.setBackgroundColor(commentModel.getLiked() ? 0x40FF69B4 : 0x00000000); |
|||
commentsBinding.commentCancelParent.setVisibility(View.GONE); |
|||
commentsBinding.commentText.setText(""); |
|||
commentModel = null; |
|||
focus = null; |
|||
} |
|||
}; |
|||
|
|||
private void searchUsername(final String text) { |
|||
startActivity( |
|||
new Intent(getApplicationContext(), ProfileViewer.class) |
|||
.putExtra(Constants.EXTRAS_USERNAME, text) |
|||
); |
|||
} |
|||
|
|||
@Override |
|||
public boolean onCreateOptionsMenu(final Menu menu) { |
|||
getMenuInflater().inflate(R.menu.follow, menu); |
|||
|
|||
final MenuItem menuSearch = menu.findItem(R.id.action_search); |
|||
final SearchView searchView = (SearchView) menuSearch.getActionView(); |
|||
searchView.setQueryHint(getResources().getString(R.string.action_search)); |
|||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { |
|||
@Override |
|||
public boolean onQueryTextSubmit(final String query) { |
|||
return false; |
|||
} |
|||
|
|||
@Override |
|||
public boolean onQueryTextChange(final String query) { |
|||
if (commentsAdapter != null) commentsAdapter.getFilter().filter(query); |
|||
return true; |
|||
} |
|||
}); |
|||
|
|||
menu.findItem(R.id.action_compare).setVisible(false); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
class CommentAction extends AsyncTask<String, Void, Void> { |
|||
boolean ok = false; |
|||
|
|||
protected Void doInBackground(String... rawAction) { |
|||
final String action = rawAction[0]; |
|||
final String url = "https://www.instagram.com/web/comments/"+postId+"/"+action+"/"; |
|||
try { |
|||
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); |
|||
urlConnection.setRequestMethod("POST"); |
|||
urlConnection.setUseCaches(false); |
|||
urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT); |
|||
urlConnection.setRequestProperty("x-csrftoken", cookie.split("csrftoken=")[1].split(";")[0]); |
|||
if (action == "add") { |
|||
// https://stackoverflow.com/questions/14321873/java-url-encoding-urlencoder-vs-uri |
|||
final String commentText = URLEncoder.encode(commentsBinding.commentText.getText().toString(), "UTF-8") |
|||
.replaceAll("\\+", "%20").replaceAll("\\%21", "!").replaceAll("\\%27", "'") |
|||
.replaceAll("\\%28", "(").replaceAll("\\%29", ")").replaceAll("\\%7E", "~"); |
|||
final String urlParameters = "comment_text="+commentText+"&replied_to_comment_id="+ |
|||
(commentModel == null ? "" : commentModel.getId()); |
|||
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
|||
urlConnection.setRequestProperty("Content-Length", "" + |
|||
urlParameters.getBytes().length); |
|||
urlConnection.setDoOutput(true); |
|||
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream()); |
|||
wr.writeBytes(urlParameters); |
|||
wr.flush(); |
|||
wr.close(); |
|||
} |
|||
urlConnection.connect(); |
|||
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|||
ok = true; |
|||
if (action == "add") { |
|||
commentsBinding.commentText.setText(""); |
|||
commentsBinding.commentText.clearFocus(); |
|||
} |
|||
} |
|||
urlConnection.disconnect(); |
|||
} catch (Throwable ex) { |
|||
Log.e("austin_debug", action+": " + ex); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
protected void onPostExecute(Void result) { |
|||
if (ok == true) { |
|||
if (focus != null) { |
|||
focus.setBackgroundColor(commentModel.getLiked() ? 0x40FF69B4 : 0x00000000); |
|||
commentsBinding.commentCancelParent.setVisibility(View.GONE); |
|||
commentModel = null; |
|||
focus = null; |
|||
} |
|||
onRefresh(); |
|||
} |
|||
else Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,370 @@ |
|||
package awais.instagrabber.activities; |
|||
|
|||
import android.content.DialogInterface; |
|||
import android.content.Intent; |
|||
import android.content.res.Resources; |
|||
import android.os.AsyncTask; |
|||
import android.os.Bundle; |
|||
import android.text.Editable; |
|||
import android.text.SpannableString; |
|||
import android.text.Spanned; |
|||
import android.text.TextWatcher; |
|||
import android.text.style.RelativeSizeSpan; |
|||
import android.util.Log; |
|||
import android.view.LayoutInflater; |
|||
import android.view.Menu; |
|||
import android.view.MenuInflater; |
|||
import android.view.MenuItem; |
|||
import android.view.View; |
|||
import android.view.ViewGroup; |
|||
import android.view.inputmethod.InputMethodManager; |
|||
import android.widget.LinearLayout; |
|||
import android.widget.Toast; |
|||
|
|||
import androidx.annotation.NonNull; |
|||
import androidx.annotation.Nullable; |
|||
import androidx.appcompat.app.ActionBar; |
|||
import androidx.appcompat.app.AlertDialog; |
|||
import androidx.appcompat.app.AppCompatActivity; |
|||
import androidx.appcompat.widget.SearchView; |
|||
import androidx.fragment.app.Fragment; |
|||
import androidx.navigation.NavDirections; |
|||
import androidx.navigation.fragment.NavHostFragment; |
|||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
|||
|
|||
import awais.instagrabber.R; |
|||
import awais.instagrabber.adapters.CommentsAdapter; |
|||
import awais.instagrabber.asyncs.CommentsFetcher; |
|||
import awais.instagrabber.databinding.FragmentCommentsBinding; |
|||
import awais.instagrabber.interfaces.MentionClickListener; |
|||
import awais.instagrabber.models.CommentModel; |
|||
import awais.instagrabber.models.ProfileModel; |
|||
import awais.instagrabber.services.MediaService; |
|||
import awais.instagrabber.services.ServiceCallback; |
|||
import awais.instagrabber.utils.Constants; |
|||
import awais.instagrabber.utils.Utils; |
|||
|
|||
import static android.content.Context.INPUT_METHOD_SERVICE; |
|||
|
|||
public final class CommentsViewerFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { |
|||
private static final String TAG = "CommentsViewerFragment"; |
|||
|
|||
private final String cookie = Utils.settingsHelper.getString(Constants.COOKIE); |
|||
|
|||
private CommentsAdapter commentsAdapter; |
|||
private CommentModel commentModel; |
|||
private FragmentCommentsBinding binding; |
|||
private String shortCode; |
|||
private String userId; |
|||
private Resources resources; |
|||
private InputMethodManager imm; |
|||
private AppCompatActivity fragmentActivity; |
|||
private LinearLayout root; |
|||
private boolean shouldRefresh = true; |
|||
private MediaService mediaService; |
|||
private String postId; |
|||
|
|||
@Override |
|||
public void onCreate(@Nullable final Bundle savedInstanceState) { |
|||
super.onCreate(savedInstanceState); |
|||
fragmentActivity = (AppCompatActivity) getActivity(); |
|||
mediaService = MediaService.getInstance(); |
|||
setHasOptionsMenu(true); |
|||
} |
|||
|
|||
@NonNull |
|||
@Override |
|||
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { |
|||
if (root != null) { |
|||
shouldRefresh = false; |
|||
return root; |
|||
} |
|||
binding = FragmentCommentsBinding.inflate(getLayoutInflater()); |
|||
root = binding.getRoot(); |
|||
return root; |
|||
} |
|||
|
|||
@Override |
|||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) { |
|||
if (!shouldRefresh) return; |
|||
init(); |
|||
shouldRefresh = false; |
|||
} |
|||
|
|||
@Override |
|||
public void onCreateOptionsMenu(@NonNull final Menu menu, @NonNull final MenuInflater inflater) { |
|||
inflater.inflate(R.menu.follow, menu); |
|||
final MenuItem favItem = menu.findItem(R.id.favourites); |
|||
if (favItem != null) favItem.setVisible(false); |
|||
menu.findItem(R.id.action_compare).setVisible(false); |
|||
final MenuItem menuSearch = menu.findItem(R.id.action_search); |
|||
final SearchView searchView = (SearchView) menuSearch.getActionView(); |
|||
searchView.setQueryHint(getResources().getString(R.string.action_search)); |
|||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { |
|||
@Override |
|||
public boolean onQueryTextSubmit(final String query) { |
|||
return false; |
|||
} |
|||
|
|||
@Override |
|||
public boolean onQueryTextChange(final String query) { |
|||
if (commentsAdapter != null) commentsAdapter.getFilter().filter(query); |
|||
return true; |
|||
} |
|||
}); |
|||
} |
|||
|
|||
@Override |
|||
public void onRefresh() { |
|||
binding.swipeRefreshLayout.setRefreshing(true); |
|||
new CommentsFetcher(shortCode, commentModels -> { |
|||
binding.swipeRefreshLayout.setRefreshing(false); |
|||
commentsAdapter = new CommentsAdapter(commentModels, true, clickListener, mentionClickListener); |
|||
binding.rvComments.setAdapter(commentsAdapter); |
|||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
|||
} |
|||
|
|||
private void init() { |
|||
if (getArguments() == null) return; |
|||
final CommentsViewerFragmentArgs fragmentArgs = CommentsViewerFragmentArgs.fromBundle(getArguments()); |
|||
shortCode = fragmentArgs.getShortCode(); |
|||
postId = fragmentArgs.getPostId(); |
|||
userId = fragmentArgs.getPostUserId(); |
|||
setTitle(); |
|||
binding.swipeRefreshLayout.setOnRefreshListener(this); |
|||
binding.swipeRefreshLayout.setRefreshing(true); |
|||
resources = getResources(); |
|||
if (!Utils.isEmpty(cookie)) { |
|||
binding.commentField.setStartIconVisible(false); |
|||
binding.commentField.setEndIconVisible(false); |
|||
binding.commentField.setVisibility(View.VISIBLE); |
|||
binding.commentText.addTextChangedListener(new TextWatcher() { |
|||
@Override |
|||
public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {} |
|||
|
|||
@Override |
|||
public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { |
|||
binding.commentField.setStartIconVisible(s.length() > 0); |
|||
binding.commentField.setEndIconVisible(s.length() > 0); |
|||
} |
|||
|
|||
@Override |
|||
public void afterTextChanged(final Editable s) {} |
|||
}); |
|||
binding.commentField.setStartIconOnClickListener(v -> { |
|||
commentModel = null; |
|||
binding.commentText.setText(""); |
|||
}); |
|||
binding.commentField.setEndIconOnClickListener(newCommentListener); |
|||
} |
|||
new CommentsFetcher(this.shortCode, commentModels -> { |
|||
commentsAdapter = new CommentsAdapter(commentModels, true, clickListener, mentionClickListener); |
|||
binding.rvComments.setAdapter(commentsAdapter); |
|||
binding.swipeRefreshLayout.setRefreshing(false); |
|||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
|||
} |
|||
|
|||
private void setTitle() { |
|||
final ActionBar actionBar = fragmentActivity.getSupportActionBar(); |
|||
if (actionBar == null) return; |
|||
actionBar.setTitle(R.string.title_comments); |
|||
// actionBar.setSubtitle(shortCode); |
|||
} |
|||
|
|||
final DialogInterface.OnClickListener profileDialogListener = (dialog, which) -> { |
|||
if (commentModel == null) { |
|||
Toast.makeText(requireContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
final ProfileModel profileModel = commentModel.getProfileModel(); |
|||
switch (which) { |
|||
case 0: // open profile |
|||
openProfile(profileModel.getUsername()); |
|||
break; |
|||
case 1: // view profile pic |
|||
startActivity(new Intent(requireContext(), ProfilePicViewer.class).putExtra(Constants.EXTRAS_PROFILE, profileModel)); |
|||
break; |
|||
case 2: // copy username |
|||
Utils.copyText(requireContext(), profileModel.getUsername()); |
|||
break; |
|||
case 3: // copy comment |
|||
Utils.copyText(requireContext(), commentModel.getText().toString()); |
|||
break; |
|||
case 4: // reply to comment |
|||
final View focus = binding.rvComments.findViewWithTag(commentModel); |
|||
focus.setBackgroundColor(0x80888888); |
|||
String mention = "@" + profileModel.getUsername() + " "; |
|||
binding.commentText.setText(mention); |
|||
binding.commentText.requestFocus(); |
|||
binding.commentText.setSelection(mention.length()); |
|||
binding.commentText.postDelayed(new Runnable() { |
|||
@Override |
|||
public void run() { |
|||
imm = (InputMethodManager) requireContext().getSystemService(INPUT_METHOD_SERVICE); |
|||
if (imm == null) return; |
|||
imm.showSoftInput(binding.commentText, 0); |
|||
} |
|||
}, 200); |
|||
break; |
|||
case 5: // like/unlike comment |
|||
if (!commentModel.getLiked()) { |
|||
mediaService.commentLike(commentModel.getId(), Utils.getCsrfTokenFromCookie(cookie), new ServiceCallback<Boolean>() { |
|||
@Override |
|||
public void onSuccess(final Boolean result) { |
|||
commentModel = null; |
|||
if (!result) { |
|||
Toast.makeText(requireContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
onRefresh(); |
|||
} |
|||
|
|||
@Override |
|||
public void onFailure(final Throwable t) { |
|||
Log.e(TAG, "Error liking comment", t); |
|||
Toast.makeText(requireContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); |
|||
} |
|||
}); |
|||
return; |
|||
} |
|||
mediaService.commentUnlike(commentModel.getId(), Utils.getCsrfTokenFromCookie(cookie), new ServiceCallback<Boolean>() { |
|||
@Override |
|||
public void onSuccess(final Boolean result) { |
|||
commentModel = null; |
|||
if (!result) { |
|||
Toast.makeText(requireContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
onRefresh(); |
|||
} |
|||
|
|||
@Override |
|||
public void onFailure(final Throwable t) { |
|||
Log.e(TAG, "Error unliking comment", t); |
|||
Toast.makeText(requireContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); |
|||
} |
|||
}); |
|||
break; |
|||
case 6: // delete comment |
|||
final String userId = Utils.getUserIdFromCookie(cookie); |
|||
if (userId == null) return; |
|||
mediaService.deleteComment( |
|||
postId, userId, commentModel.getId(), Utils.getCsrfTokenFromCookie(cookie), |
|||
new ServiceCallback<Boolean>() { |
|||
@Override |
|||
public void onSuccess(final Boolean result) { |
|||
commentModel = null; |
|||
if (!result) { |
|||
Toast.makeText(requireContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
onRefresh(); |
|||
} |
|||
|
|||
@Override |
|||
public void onFailure(final Throwable t) { |
|||
Log.e(TAG, "Error deleting comment", t); |
|||
Toast.makeText(requireContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); |
|||
} |
|||
}); |
|||
break; |
|||
} |
|||
}; |
|||
|
|||
private final View.OnClickListener clickListener = v -> { |
|||
final Object tag = v.getTag(); |
|||
if (tag instanceof CommentModel) { |
|||
commentModel = (CommentModel) tag; |
|||
|
|||
final String username = commentModel.getProfileModel().getUsername(); |
|||
final SpannableString title = new SpannableString(username + ":\n" + commentModel.getText()); |
|||
title.setSpan(new RelativeSizeSpan(1.23f), 0, username.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); |
|||
|
|||
String[] commentDialogList; |
|||
|
|||
final String userIdFromCookie = Utils.getUserIdFromCookie(cookie); |
|||
if (!Utils.isEmpty(cookie) |
|||
&& userIdFromCookie != null |
|||
&& (userIdFromCookie.equals(commentModel.getProfileModel().getId()) || userIdFromCookie.equals(userId))) { |
|||
commentDialogList = new String[]{ |
|||
resources.getString(R.string.open_profile), |
|||
resources.getString(R.string.view_pfp), |
|||
resources.getString(R.string.comment_viewer_copy_user), |
|||
resources.getString(R.string.comment_viewer_copy_comment), |
|||
resources.getString(R.string.comment_viewer_reply_comment), |
|||
commentModel.getLiked() ? resources.getString(R.string.comment_viewer_unlike_comment) |
|||
: resources.getString(R.string.comment_viewer_like_comment), |
|||
resources.getString(R.string.comment_viewer_delete_comment) |
|||
}; |
|||
} else if (!Utils.isEmpty(cookie)) { |
|||
commentDialogList = new String[]{ |
|||
resources.getString(R.string.open_profile), |
|||
resources.getString(R.string.view_pfp), |
|||
resources.getString(R.string.comment_viewer_copy_user), |
|||
resources.getString(R.string.comment_viewer_copy_comment), |
|||
resources.getString(R.string.comment_viewer_reply_comment), |
|||
commentModel.getLiked() ? resources.getString(R.string.comment_viewer_unlike_comment) |
|||
: resources.getString(R.string.comment_viewer_like_comment), |
|||
}; |
|||
} else { |
|||
commentDialogList = new String[]{ |
|||
resources.getString(R.string.open_profile), |
|||
resources.getString(R.string.view_pfp), |
|||
resources.getString(R.string.comment_viewer_copy_user), |
|||
resources.getString(R.string.comment_viewer_copy_comment) |
|||
}; |
|||
} |
|||
new AlertDialog.Builder(requireContext()) |
|||
.setTitle(title) |
|||
.setItems(commentDialogList, profileDialogListener) |
|||
.setNegativeButton(R.string.cancel, null) |
|||
.show(); |
|||
} |
|||
}; |
|||
|
|||
private final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) -> { |
|||
if (isHashtag) { |
|||
final NavDirections action = CommentsViewerFragmentDirections.actionGlobalHashTagFragment(text); |
|||
NavHostFragment.findNavController(this).navigate(action); |
|||
return; |
|||
} |
|||
openProfile(text); |
|||
}; |
|||
|
|||
private final View.OnClickListener newCommentListener = v -> { |
|||
final Editable text = binding.commentText.getText(); |
|||
if (text == null || Utils.isEmpty(text.toString())) { |
|||
Toast.makeText(requireContext(), R.string.comment_send_empty_comment, Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
final String userId = Utils.getUserIdFromCookie(cookie); |
|||
if (userId == null) return; |
|||
String replyToId = null; |
|||
if (commentModel != null) { |
|||
replyToId = commentModel.getId(); |
|||
} |
|||
mediaService.comment(postId, text.toString(), userId, replyToId, Utils.getCsrfTokenFromCookie(cookie), new ServiceCallback<Boolean>() { |
|||
@Override |
|||
public void onSuccess(final Boolean result) { |
|||
commentModel = null; |
|||
binding.commentText.setText(""); |
|||
if (!result) { |
|||
Toast.makeText(requireContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
onRefresh(); |
|||
} |
|||
|
|||
@Override |
|||
public void onFailure(final Throwable t) { |
|||
Log.e(TAG, "Error during comment", t); |
|||
Toast.makeText(requireContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); |
|||
} |
|||
}); |
|||
}; |
|||
|
|||
private void openProfile(final String username) { |
|||
final NavDirections action = CommentsViewerFragmentDirections.actionGlobalProfileFragment("@" + username); |
|||
NavHostFragment.findNavController(this).navigate(action); |
|||
} |
|||
} |
@ -1,167 +0,0 @@ |
|||
// package awais.instagrabber.activities; |
|||
// |
|||
// import android.content.Intent; |
|||
// import android.os.AsyncTask; |
|||
// import android.os.Bundle; |
|||
// import android.view.MenuItem; |
|||
// import android.view.View; |
|||
// import android.widget.Toast; |
|||
// |
|||
// import androidx.annotation.Nullable; |
|||
// import androidx.core.view.GestureDetectorCompat; |
|||
// import androidx.recyclerview.widget.LinearLayoutManager; |
|||
// |
|||
// import awais.instagrabber.R; |
|||
// import awais.instagrabber.adapters.StoriesAdapter; |
|||
// import awais.instagrabber.asyncs.SeenAction; |
|||
// import awais.instagrabber.asyncs.i.iStoryStatusFetcher; |
|||
// import awais.instagrabber.customviews.helpers.SwipeGestureListener; |
|||
// import awais.instagrabber.databinding.ActivityStoryViewerBinding; |
|||
// import awais.instagrabber.interfaces.SwipeEvent; |
|||
// import awais.instagrabber.models.FeedStoryModel; |
|||
// import awais.instagrabber.models.StoryModel; |
|||
// import awais.instagrabber.models.stickers.PollModel; |
|||
// import awais.instagrabber.models.stickers.QuestionModel; |
|||
// import awais.instagrabber.models.stickers.QuizModel; |
|||
// import awais.instagrabber.utils.Constants; |
|||
// import awais.instagrabber.utils.Utils; |
|||
// |
|||
// import static awais.instagrabber.utils.Constants.MARK_AS_SEEN; |
|||
// import static awais.instagrabber.utils.Utils.settingsHelper; |
|||
// |
|||
// public final class StoryViewer extends BaseLanguageActivity { |
|||
// private final StoriesAdapter storiesAdapter = new StoriesAdapter(null, new View.OnClickListener() { |
|||
// @Override |
|||
// public void onClick(final View v) { |
|||
// final Object tag = v.getTag(); |
|||
// if (tag instanceof StoryModel) { |
|||
// currentStory = (StoryModel) tag; |
|||
// slidePos = currentStory.getPosition(); |
|||
// refreshStory(); |
|||
// } |
|||
// } |
|||
// }); |
|||
// private ActivityStoryViewerBinding storyViewerBinding; |
|||
// private StoryModel[] storyModels; |
|||
// private GestureDetectorCompat gestureDetector; |
|||
// |
|||
// private SwipeEvent swipeEvent; |
|||
// private MenuItem menuDownload, menuDm; |
|||
// private PollModel poll; |
|||
// private QuestionModel question; |
|||
// private String[] mentions; |
|||
// private QuizModel quiz; |
|||
// private StoryModel currentStory; |
|||
// private String url, username; |
|||
// private int slidePos = 0, lastSlidePos = 0; |
|||
// private final String cookie = settingsHelper.getString(Constants.COOKIE); |
|||
// private boolean fetching = false; |
|||
// |
|||
// @Override |
|||
// protected void onCreate(@Nullable final Bundle savedInstanceState) { |
|||
// super.onCreate(savedInstanceState); |
|||
// storyViewerBinding = ActivityStoryViewerBinding.inflate(getLayoutInflater()); |
|||
// setContentView(storyViewerBinding.getRoot()); |
|||
// |
|||
// setSupportActionBar(storyViewerBinding.toolbar.toolbar); |
|||
// |
|||
// final Intent intent = getIntent(); |
|||
// if (intent == null || !intent.hasExtra(Constants.EXTRAS_STORIES) |
|||
// || (storyModels = (StoryModel[]) intent.getSerializableExtra(Constants.EXTRAS_STORIES)) == null) { |
|||
// Utils.errorFinish(this); |
|||
// return; |
|||
// } |
|||
// |
|||
// username = intent.getStringExtra(Constants.EXTRAS_USERNAME); |
|||
// final String highlight = intent.getStringExtra(Constants.EXTRAS_HIGHLIGHT); |
|||
// final boolean hasUsername = !Utils.isEmpty(username); |
|||
// final boolean hasHighlight = !Utils.isEmpty(highlight); |
|||
// |
|||
// if (hasUsername) { |
|||
// username = username.replace("@", ""); |
|||
// storyViewerBinding.toolbar.toolbar.setTitle(username); |
|||
// storyViewerBinding.toolbar.toolbar.setOnClickListener(v -> { |
|||
// searchUsername(username); |
|||
// }); |
|||
// if (hasHighlight) storyViewerBinding.toolbar.toolbar.setSubtitle(getString(R.string.title_highlight, highlight)); |
|||
// else storyViewerBinding.toolbar.toolbar.setSubtitle(R.string.title_user_story); |
|||
// } |
|||
// |
|||
// storyViewerBinding.storiesList.setVisibility(View.GONE); |
|||
// storyViewerBinding.storiesList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); |
|||
// storyViewerBinding.storiesList.setAdapter(storiesAdapter); |
|||
// |
|||
// swipeEvent = new SwipeEvent() { |
|||
// private final int storiesLen = storyModels != null ? storyModels.length : 0; |
|||
// |
|||
// @Override |
|||
// public void onSwipe(final boolean isRightSwipe) { |
|||
// if (storyModels != null && storiesLen > 0) { |
|||
// if (((slidePos + 1 >= storiesLen && isRightSwipe == false) || (slidePos == 0 && isRightSwipe == true)) |
|||
// && intent.hasExtra(Constants.FEED)) { |
|||
// final FeedStoryModel[] storyFeed = (FeedStoryModel[]) intent.getSerializableExtra(Constants.FEED); |
|||
// final int index = intent.getIntExtra(Constants.FEED_ORDER, 1738); |
|||
// if (settingsHelper.getBoolean(MARK_AS_SEEN)) new SeenAction(cookie, storyModel).execute(); |
|||
// if ((isRightSwipe == true && index == 0) || (isRightSwipe == false && index == storyFeed.length - 1)) |
|||
// Toast.makeText(getApplicationContext(), R.string.no_more_stories, Toast.LENGTH_SHORT).show(); |
|||
// else { |
|||
// final FeedStoryModel feedStoryModel = isRightSwipe ? |
|||
// (index == 0 ? null : storyFeed[index - 1]) : |
|||
// (storyFeed.length == index + 1 ? null : storyFeed[index + 1]); |
|||
// if (feedStoryModel != null) { |
|||
// if (fetching) { |
|||
// Toast.makeText(getApplicationContext(), R.string.be_patient, Toast.LENGTH_SHORT).show(); |
|||
// } else { |
|||
// fetching = true; |
|||
// new iStoryStatusFetcher(feedStoryModel.getStoryMediaId(), null, false, false, false, false, result -> { |
|||
// if (result != null && result.length > 0) { |
|||
// final Intent newIntent = new Intent(getApplicationContext(), StoryViewer.class) |
|||
// .putExtra(Constants.EXTRAS_STORIES, result) |
|||
// .putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername()) |
|||
// .putExtra(Constants.FEED, storyFeed) |
|||
// .putExtra(Constants.FEED_ORDER, isRightSwipe ? (index - 1) : (index + 1)); |
|||
// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
|||
// startActivity(newIntent); |
|||
// } else |
|||
// Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|||
// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
|||
// } |
|||
// } |
|||
// } |
|||
// } |
|||
// else { |
|||
// if (isRightSwipe) { |
|||
// if (--slidePos <= 0) slidePos = 0; |
|||
// } else if (++slidePos >= storiesLen) slidePos = storiesLen - 1; |
|||
// currentStory = storyModels[slidePos]; |
|||
// refreshStory(); |
|||
// } |
|||
// } |
|||
// } |
|||
// }; |
|||
// gestureDetector = new GestureDetectorCompat(this, new SwipeGestureListener(swipeEvent)); |
|||
// |
|||
// viewPost(); |
|||
// } |
|||
// |
|||
// private void searchUsername(final String text) { |
|||
// startActivity( |
|||
// new Intent(getApplicationContext(), ProfileViewer.class) |
|||
// .putExtra(Constants.EXTRAS_USERNAME, text) |
|||
// ); |
|||
// } |
|||
// |
|||
// |
|||
// |
|||
// public static int indexOfIntArray(Object[] array, Object key) { |
|||
// int returnvalue = -1; |
|||
// for (int i = 0; i < array.length; ++i) { |
|||
// if (key == array[i]) { |
|||
// returnvalue = i; |
|||
// break; |
|||
// } |
|||
// } |
|||
// return returnvalue; |
|||
// } |
|||
// |
|||
// } |
@ -0,0 +1,10 @@ |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="24dp" |
|||
android:height="24dp" |
|||
android:viewportWidth="24" |
|||
android:viewportHeight="24" |
|||
android:tint="?attr/colorControlNormal"> |
|||
<path |
|||
android:fillColor="@android:color/white" |
|||
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/> |
|||
</vector> |
@ -1,70 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<LinearLayout 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" |
|||
android:orientation="vertical" |
|||
tools:context=".activities.CommentsViewer"> |
|||
|
|||
<include |
|||
android:id="@+id/toolbar" |
|||
android:layout_weight="1" |
|||
layout="@layout/layout_include_toolbar" /> |
|||
|
|||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout |
|||
android:id="@+id/swipeRefreshLayout" |
|||
android:layout_weight="8" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent"> |
|||
<androidx.recyclerview.widget.RecyclerView |
|||
android:id="@+id/rvComments" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:clipToPadding="false" |
|||
android:paddingStart="8dp" |
|||
android:paddingLeft="8dp" |
|||
android:paddingEnd="8dp" |
|||
android:paddingRight="8dp" |
|||
app:layoutManager="LinearLayoutManager" |
|||
tools:listitem="@layout/item_comment" /> |
|||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |
|||
|
|||
<LinearLayout android:layout_width="match_parent" |
|||
android:layout_height="wrap_content"> |
|||
|
|||
<androidx.appcompat.widget.AppCompatImageView |
|||
android:id="@+id/commentCancelParent" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:background="?selectableItemBackgroundBorderless" |
|||
android:clickable="true" |
|||
android:paddingRight="8dp" |
|||
android:visibility="gone" |
|||
app:srcCompat="@android:drawable/ic_menu_revert" /> |
|||
<EditText |
|||
android:id="@+id/commentText" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="2" |
|||
android:paddingLeft="8dp" |
|||
android:gravity="bottom" |
|||
android:hint="@string/comment_hint" |
|||
android:inputType="textMultiLine" |
|||
android:maxLength="2200" |
|||
android:maxLines="10" |
|||
android:visibility="gone" |
|||
android:scrollHorizontally="false" /> |
|||
|
|||
<androidx.appcompat.widget.AppCompatImageView |
|||
android:id="@+id/commentSend" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:background="?selectableItemBackgroundBorderless" |
|||
android:clickable="true" |
|||
android:paddingRight="8dp" |
|||
android:visibility="gone" |
|||
app:srcCompat="@android:drawable/ic_menu_send" /> |
|||
|
|||
</LinearLayout> |
|||
</LinearLayout> |
@ -0,0 +1,48 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<LinearLayout 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" |
|||
android:orientation="vertical"> |
|||
|
|||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout |
|||
android:id="@+id/swipeRefreshLayout" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="0dp" |
|||
android:layout_weight="1"> |
|||
|
|||
<androidx.recyclerview.widget.RecyclerView |
|||
android:id="@+id/rvComments" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:clipToPadding="false" |
|||
app:layoutManager="LinearLayoutManager" |
|||
tools:listitem="@layout/item_comment" /> |
|||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |
|||
|
|||
<com.google.android.material.textfield.TextInputLayout |
|||
android:id="@+id/commentField" |
|||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_margin="4dp" |
|||
android:hint="@string/comment_hint" |
|||
app:counterEnabled="true" |
|||
app:counterMaxLength="2200" |
|||
app:endIconDrawable="@drawable/ic_send_24" |
|||
app:endIconMode="custom" |
|||
app:startIconDrawable="@drawable/ic_close_24"> |
|||
|
|||
<com.google.android.material.textfield.TextInputEditText |
|||
android:id="@+id/commentText" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:autofillHints="no" |
|||
android:inputType="textMultiLine" |
|||
android:maxLength="2200" |
|||
android:maxLines="10" |
|||
android:scrollHorizontally="false" /> |
|||
|
|||
</com.google.android.material.textfield.TextInputLayout> |
|||
</LinearLayout> |
@ -0,0 +1,65 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<navigation 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:id="@+id/comments_nav_graph" |
|||
app:startDestination="@id/commentsViewerFragment"> |
|||
|
|||
<include app:graph="@navigation/hashtag_nav_graph" /> |
|||
|
|||
<action |
|||
android:id="@+id/action_global_hashTagFragment" |
|||
app:destination="@id/hashtag_nav_graph"> |
|||
<argument |
|||
android:name="hashtag" |
|||
app:argType="string" |
|||
app:nullable="false" /> |
|||
</action> |
|||
|
|||
<!--<include app:graph="@navigation/profile_nav_graph" />--> |
|||
|
|||
<action |
|||
android:id="@+id/action_global_profileFragment" |
|||
app:destination="@id/profile_nav_graph"> |
|||
<argument |
|||
android:name="username" |
|||
app:argType="string" |
|||
app:nullable="true" /> |
|||
</action> |
|||
|
|||
<fragment |
|||
android:id="@+id/commentsViewerFragment" |
|||
android:name="awais.instagrabber.activities.CommentsViewerFragment" |
|||
android:label="Comments" |
|||
tools:layout="@layout/fragment_comments"> |
|||
<argument |
|||
android:name="shortCode" |
|||
app:argType="string" |
|||
app:nullable="false" /> |
|||
<argument |
|||
android:name="postId" |
|||
app:argType="string" |
|||
app:nullable="false" /> |
|||
<argument |
|||
android:name="postUserId" |
|||
app:argType="string" |
|||
app:nullable="false" /> |
|||
</fragment> |
|||
|
|||
<action |
|||
android:id="@+id/action_global_commentsViewerFragment" |
|||
app:destination="@id/commentsViewerFragment"> |
|||
<argument |
|||
android:name="shortCode" |
|||
app:argType="string" |
|||
app:nullable="false" /> |
|||
<argument |
|||
android:name="postId" |
|||
app:argType="string" |
|||
app:nullable="false" /> |
|||
<argument |
|||
android:name="postUserId" |
|||
app:argType="string" |
|||
app:nullable="false" /> |
|||
</action> |
|||
</navigation> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue