This commit is contained in:
Austin Huang 2020-07-26 21:14:02 -04:00
parent 8787b05ef9
commit 1585cabba5
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
5 changed files with 33 additions and 21 deletions

View File

@ -49,6 +49,7 @@ public final class CommentsViewer extends BaseLanguageActivity implements SwipeR
private String shortCode, postId, userId;
private final String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
private Resources resources;
private InputMethodManager imm;
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
@ -68,6 +69,8 @@ public final class CommentsViewer extends BaseLanguageActivity implements SwipeR
return;
}
Log.d("austin_debug", "f:"+postId);
commentsBinding.swipeRefreshLayout.setRefreshing(true);
setSupportActionBar(commentsBinding.toolbar.toolbar);
commentsBinding.toolbar.toolbar.setTitle(R.string.title_comments);
@ -134,7 +137,7 @@ public final class CommentsViewer extends BaseLanguageActivity implements SwipeR
commentsBinding.commentText.postDelayed(new Runnable(){
@Override
public void run(){
final InputMethodManager imm = (InputMethodManager) getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
imm = (InputMethodManager) getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
imm.showSoftInput(commentsBinding.commentText, 0);
}
}
@ -250,6 +253,7 @@ public final class CommentsViewer extends BaseLanguageActivity implements SwipeR
final String action = rawAction[0];
final String url = "https://www.instagram.com/web/comments/"+postId+"/"+action+"/";
try {
Log.d("austin_debug", url);
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setUseCaches(false);
@ -274,7 +278,10 @@ public final class CommentsViewer extends BaseLanguageActivity implements SwipeR
urlConnection.connect();
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
ok = true;
if (action == "add") commentsBinding.commentText.setText("");
if (action == "add") {
commentsBinding.commentText.setText("");
commentsBinding.commentText.clearFocus();
}
}
else Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
urlConnection.disconnect();
@ -291,6 +298,8 @@ public final class CommentsViewer extends BaseLanguageActivity implements SwipeR
commentsBinding.rvComments.findViewWithTag(commentModel).setBackgroundColor(commentModel.getLiked() ? 0x40FF69B4 : 0x00000000);
commentsBinding.commentCancelParent.setVisibility(View.GONE);
}
//imm.hideSoftInputFromWindow(commentsBinding.getView().getRootView().getWindowToken(), 0);
onRefresh();
}
}

View File

@ -95,6 +95,7 @@ public final class Main extends BaseLanguageActivity {
private ArrayAdapter<String> profileDialogAdapter;
private DialogInterface.OnClickListener profileDialogListener;
private Stack<String> queriesStack;
private DataBox.CookieModel cookieModel;
public Main() {
super();
@ -152,13 +153,13 @@ public final class Main extends BaseLanguageActivity {
if (mainHelper != null && !mainBinding.swipeRefreshLayout.isRefreshing()) mainHelper.onRefresh();
}
// adds cookies to database for quick access
final DataBox.CookieModel cookieModel = Utils.dataBox.getCookie(uid);
cookieModel = Utils.dataBox.getCookie(uid);
if (Utils.dataBox.getCookieCount() == 0 || cookieModel == null || Utils.isEmpty(cookieModel.getUsername()))
Utils.dataBox.addUserCookie(new DataBox.CookieModel(uid, username, cookie));
}
};
boolean found = false;
final DataBox.CookieModel cookieModel = Utils.dataBox.getCookie(uid);
cookieModel = Utils.dataBox.getCookie(uid);
if (cookieModel != null) {
final String username = cookieModel.getUsername();
if (username != null) {
@ -316,8 +317,7 @@ public final class Main extends BaseLanguageActivity {
searchView.setQueryHint(getResources().getString(R.string.action_search));
searchView.setSuggestionsAdapter(suggestionAdapter);
searchView.setOnSearchClickListener(v -> {
searchView.setQuery((profileModel != null && profileModel.getId().equals(
Utils.getUserIdFromCookie(Utils.settingsHelper.getString(Constants.COOKIE))) ? "" : userQuery), false);
searchView.setQuery(userQuery.equals(cookieModel.getUsername()) ? "" : userQuery, false);
menu.findItem(R.id.action_about).setVisible(false);
menu.findItem(R.id.action_settings).setVisible(false);
menu.findItem(R.id.action_dms).setVisible(false);

View File

@ -355,20 +355,14 @@ public final class PostViewer extends BaseLanguageActivity {
viewerBinding.bottomPanel.commentsCount.setText(String.valueOf(commentsCount));
viewerBinding.bottomPanel.btnComments.setVisibility(View.VISIBLE);
if (commentsCount > 0) {
viewerBinding.bottomPanel.btnComments.setOnClickListener(v ->
startActivityForResult(new Intent(this, CommentsViewer.class)
.putExtra(Constants.EXTRAS_END_CURSOR, commentsEndCursor)
.putExtra(Constants.EXTRAS_SHORTCODE, postShortCode)
.putExtra(Constants.EXTRAS_POST, viewerPostModel.getPostId())
.putExtra(Constants.EXTRAS_USER, postUserId), 6969));
viewerBinding.bottomPanel.btnComments.setClickable(true);
viewerBinding.bottomPanel.btnComments.setEnabled(true);
} else {
viewerBinding.bottomPanel.btnComments.setOnClickListener(null);
viewerBinding.bottomPanel.btnComments.setClickable(false);
viewerBinding.bottomPanel.btnComments.setEnabled(false);
}
viewerBinding.bottomPanel.btnComments.setOnClickListener(v ->
startActivityForResult(new Intent(this, CommentsViewer.class)
.putExtra(Constants.EXTRAS_END_CURSOR, commentsEndCursor)
.putExtra(Constants.EXTRAS_SHORTCODE, postShortCode)
.putExtra(Constants.EXTRAS_POST, viewerPostModel.getPostId())
.putExtra(Constants.EXTRAS_USER, postUserId), 6969));
viewerBinding.bottomPanel.btnComments.setClickable(true);
viewerBinding.bottomPanel.btnComments.setEnabled(true);
if (postModel instanceof PostModel) {
final PostModel postModel = (PostModel) this.postModel;

View File

@ -147,7 +147,10 @@ public final class QuickAccessDialog extends BottomSheetDialogFragment implement
if (cookieModel.isSelected())
Toast.makeText(v.getContext(), R.string.quick_access_cannot_delete_curr, Toast.LENGTH_SHORT).show();
else
new AlertDialog.Builder(activity).setPositiveButton(R.string.yes, (d, which) -> Utils.dataBox.delUserCookie(cookieModel))
new AlertDialog.Builder(activity).setPositiveButton(R.string.yes, (d, which) -> {
Utils.dataBox.delUserCookie(cookieModel);
rvQuickAccess.findViewWithTag(cookieModel).setVisibility(View.GONE);
})
.setNegativeButton(R.string.no, null).setMessage(getString(R.string.quick_access_confirm_delete,
cookieModel.getUsername())).show();
}

View File

@ -0,0 +1,6 @@
* You can now write comments, and reply/like/delete comments through the menu (by clicking the comment)
* You're actually
* Liked comments are shown with a pink background
* Post like counts are now displayed (The button texts are slightly reduced to accomodate @world_record_egg)
* Mute buttons are changed to display the current status (i.e. muted icon when muted, sound icon when not muted)
* Fixed a bug relating to viewing feed stories