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

View File

@ -95,6 +95,7 @@ public final class Main extends BaseLanguageActivity {
private ArrayAdapter<String> profileDialogAdapter; private ArrayAdapter<String> profileDialogAdapter;
private DialogInterface.OnClickListener profileDialogListener; private DialogInterface.OnClickListener profileDialogListener;
private Stack<String> queriesStack; private Stack<String> queriesStack;
private DataBox.CookieModel cookieModel;
public Main() { public Main() {
super(); super();
@ -152,13 +153,13 @@ public final class Main extends BaseLanguageActivity {
if (mainHelper != null && !mainBinding.swipeRefreshLayout.isRefreshing()) mainHelper.onRefresh(); if (mainHelper != null && !mainBinding.swipeRefreshLayout.isRefreshing()) mainHelper.onRefresh();
} }
// adds cookies to database for quick access // 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())) if (Utils.dataBox.getCookieCount() == 0 || cookieModel == null || Utils.isEmpty(cookieModel.getUsername()))
Utils.dataBox.addUserCookie(new DataBox.CookieModel(uid, username, cookie)); Utils.dataBox.addUserCookie(new DataBox.CookieModel(uid, username, cookie));
} }
}; };
boolean found = false; boolean found = false;
final DataBox.CookieModel cookieModel = Utils.dataBox.getCookie(uid); cookieModel = Utils.dataBox.getCookie(uid);
if (cookieModel != null) { if (cookieModel != null) {
final String username = cookieModel.getUsername(); final String username = cookieModel.getUsername();
if (username != null) { if (username != null) {
@ -316,8 +317,7 @@ public final class Main extends BaseLanguageActivity {
searchView.setQueryHint(getResources().getString(R.string.action_search)); searchView.setQueryHint(getResources().getString(R.string.action_search));
searchView.setSuggestionsAdapter(suggestionAdapter); searchView.setSuggestionsAdapter(suggestionAdapter);
searchView.setOnSearchClickListener(v -> { searchView.setOnSearchClickListener(v -> {
searchView.setQuery((profileModel != null && profileModel.getId().equals( searchView.setQuery(userQuery.equals(cookieModel.getUsername()) ? "" : userQuery, false);
Utils.getUserIdFromCookie(Utils.settingsHelper.getString(Constants.COOKIE))) ? "" : userQuery), false);
menu.findItem(R.id.action_about).setVisible(false); menu.findItem(R.id.action_about).setVisible(false);
menu.findItem(R.id.action_settings).setVisible(false); menu.findItem(R.id.action_settings).setVisible(false);
menu.findItem(R.id.action_dms).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.commentsCount.setText(String.valueOf(commentsCount));
viewerBinding.bottomPanel.btnComments.setVisibility(View.VISIBLE); viewerBinding.bottomPanel.btnComments.setVisibility(View.VISIBLE);
if (commentsCount > 0) { viewerBinding.bottomPanel.btnComments.setOnClickListener(v ->
viewerBinding.bottomPanel.btnComments.setOnClickListener(v -> startActivityForResult(new Intent(this, CommentsViewer.class)
startActivityForResult(new Intent(this, CommentsViewer.class) .putExtra(Constants.EXTRAS_END_CURSOR, commentsEndCursor)
.putExtra(Constants.EXTRAS_END_CURSOR, commentsEndCursor) .putExtra(Constants.EXTRAS_SHORTCODE, postShortCode)
.putExtra(Constants.EXTRAS_SHORTCODE, postShortCode) .putExtra(Constants.EXTRAS_POST, viewerPostModel.getPostId())
.putExtra(Constants.EXTRAS_POST, viewerPostModel.getPostId()) .putExtra(Constants.EXTRAS_USER, postUserId), 6969));
.putExtra(Constants.EXTRAS_USER, postUserId), 6969)); viewerBinding.bottomPanel.btnComments.setClickable(true);
viewerBinding.bottomPanel.btnComments.setClickable(true); viewerBinding.bottomPanel.btnComments.setEnabled(true);
viewerBinding.bottomPanel.btnComments.setEnabled(true);
} else {
viewerBinding.bottomPanel.btnComments.setOnClickListener(null);
viewerBinding.bottomPanel.btnComments.setClickable(false);
viewerBinding.bottomPanel.btnComments.setEnabled(false);
}
if (postModel instanceof PostModel) { if (postModel instanceof PostModel) {
final PostModel postModel = (PostModel) this.postModel; final PostModel postModel = (PostModel) this.postModel;

View File

@ -147,7 +147,10 @@ public final class QuickAccessDialog extends BottomSheetDialogFragment implement
if (cookieModel.isSelected()) if (cookieModel.isSelected())
Toast.makeText(v.getContext(), R.string.quick_access_cannot_delete_curr, Toast.LENGTH_SHORT).show(); Toast.makeText(v.getContext(), R.string.quick_access_cannot_delete_curr, Toast.LENGTH_SHORT).show();
else 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, .setNegativeButton(R.string.no, null).setMessage(getString(R.string.quick_access_confirm_delete,
cookieModel.getUsername())).show(); 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