|
|
@ -1328,95 +1328,6 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// private void sendText(final String text, final String itemId, final boolean delete) { |
|
|
|
// DirectThreadBroadcaster.TextBroadcastOptions textOptions = null; |
|
|
|
// DirectThreadBroadcaster.ReactionBroadcastOptions reactionOptions = null; |
|
|
|
// if (text != null) { |
|
|
|
// try { |
|
|
|
// textOptions = new DirectThreadBroadcaster.TextBroadcastOptions(text); |
|
|
|
// } catch (UnsupportedEncodingException e) { |
|
|
|
// Log.e(TAG, "Error", e); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// reactionOptions = new DirectThreadBroadcaster.ReactionBroadcastOptions(itemId, delete); |
|
|
|
// } |
|
|
|
// broadcast(text != null ? textOptions : reactionOptions, result -> { |
|
|
|
// final Context context = getContext(); |
|
|
|
// if (context == null) return; |
|
|
|
// if (result == null || result.getResponseCode() != HttpURLConnection.HTTP_OK) { |
|
|
|
// Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// if (text != null) { |
|
|
|
// // binding.commentText.setText(""); |
|
|
|
// } else { |
|
|
|
// // final View viewWithTag = binding.messageList.findViewWithTag(directItemModel); |
|
|
|
// // if (viewWithTag != null) { |
|
|
|
// // final ViewParent dim = viewWithTag.getParent(); |
|
|
|
// // if (dim instanceof View) { |
|
|
|
// // final View dimView = (View) dim; |
|
|
|
// // final View likedContainer = dimView.findViewById(R.id.liked_container); |
|
|
|
// // if (likedContainer != null) { |
|
|
|
// // likedContainer.setVisibility(delete ? View.GONE : View.VISIBLE); |
|
|
|
// // } |
|
|
|
// // } |
|
|
|
// // } |
|
|
|
// // directItemModel.setLiked(); |
|
|
|
// } |
|
|
|
// context.sendBroadcast(new Intent(DMRefreshBroadcastReceiver.ACTION_REFRESH_DM)); |
|
|
|
// hasSentSomething = true; |
|
|
|
// // new DirectMessageInboxThreadFetcher(threadId, UserInboxDirection.OLDER, null, fetchListener) |
|
|
|
// // .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
|
|
|
// }); |
|
|
|
// } |
|
|
|
|
|
|
|
// private void sendImage(final Uri imageUri) { |
|
|
|
// final Context context = getContext(); |
|
|
|
// if (context == null) return; |
|
|
|
// try (InputStream inputStream = context.getContentResolver().openInputStream(imageUri)) { |
|
|
|
// final Bitmap bitmap = BitmapFactory.decodeStream(inputStream); |
|
|
|
// Toast.makeText(context, R.string.uploading, Toast.LENGTH_SHORT).show(); |
|
|
|
// // Upload Image |
|
|
|
// final ImageUploader imageUploader = new ImageUploader(); |
|
|
|
// imageUploader.setOnTaskCompleteListener(response -> { |
|
|
|
// if (response == null || response.getResponseCode() != HttpURLConnection.HTTP_OK) { |
|
|
|
// Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|
|
|
// if (response != null && response.getResponse() != null) { |
|
|
|
// Log.e(TAG, response.getResponse().toString()); |
|
|
|
// } |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// final JSONObject responseJson = response.getResponse(); |
|
|
|
// try { |
|
|
|
// final String uploadId = responseJson.getString("upload_id"); |
|
|
|
// // Broadcast |
|
|
|
// final DirectThreadBroadcaster.ImageBroadcastOptions options = new DirectThreadBroadcaster.ImageBroadcastOptions(true, uploadId); |
|
|
|
// hasSentSomething = true; |
|
|
|
// broadcast(options, |
|
|
|
// broadcastResponse -> { |
|
|
|
// // new DirectMessageInboxThreadFetcher(threadId, UserInboxDirection.OLDER, null, fetchListener) |
|
|
|
// // .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
|
|
|
// }); |
|
|
|
// } catch (JSONException e) { |
|
|
|
// Log.e(TAG, "Error parsing json response", e); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// final ImageUploadOptions options = ImageUploadOptions.builder(bitmap).build(); |
|
|
|
// imageUploader.execute(options); |
|
|
|
// } catch (IOException e) { |
|
|
|
// Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); |
|
|
|
// Log.e(TAG, "Error opening file", e); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
// private void broadcast(final DirectThreadBroadcaster.BroadcastOptions broadcastOptions, |
|
|
|
// final DirectThreadBroadcaster.OnBroadcastCompleteListener listener) { |
|
|
|
// final DirectThreadBroadcaster broadcaster = new DirectThreadBroadcaster(threadId); |
|
|
|
// broadcaster.setOnTaskCompleteListener(listener); |
|
|
|
// broadcaster.execute(broadcastOptions); |
|
|
|
// } |
|
|
|
|
|
|
|
@NonNull |
|
|
|
private User getUser(final long userId) { |
|
|
|
for (final User user : users) { |
|
|
@ -1426,58 +1337,6 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
// private void searchUsername(final String text) { |
|
|
|
// final Bundle bundle = new Bundle(); |
|
|
|
// bundle.putString("username", "@" + text); |
|
|
|
// NavHostFragment.findNavController(this).navigate(R.id.action_global_profileFragment, bundle); |
|
|
|
// } |
|
|
|
|
|
|
|
// class ThreadAction extends AsyncTask<String, Void, Void> { |
|
|
|
// String action, argument; |
|
|
|
// |
|
|
|
// protected Void doInBackground(String... rawAction) { |
|
|
|
// action = rawAction[0]; |
|
|
|
// argument = rawAction[1]; |
|
|
|
// final String url = "https://i.instagram.com/api/v1/direct_v2/threads/" + threadId + "/items/" + argument + "/" + action + "/"; |
|
|
|
// try { |
|
|
|
// String urlParameters = "_csrftoken=" + COOKIE.split("csrftoken=")[1].split(";")[0] |
|
|
|
// + "&_uuid=" + Utils.settingsHelper.getString(Constants.DEVICE_UUID); |
|
|
|
// final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); |
|
|
|
// urlConnection.setRequestMethod("POST"); |
|
|
|
// urlConnection.setUseCaches(false); |
|
|
|
// urlConnection.setRequestProperty("User-Agent", Constants.I_USER_AGENT); |
|
|
|
// urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
|
|
|
// urlConnection.setRequestProperty("Content-Length", Integer.toString(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) { |
|
|
|
// if (action.equals("delete")) { |
|
|
|
// hasDeletedSomething = true; |
|
|
|
// } else if (action.equals("seen")) { |
|
|
|
// // context.sendBroadcast(new Intent(DMRefreshBroadcastReceiver.ACTION_REFRESH_DM)); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// urlConnection.disconnect(); |
|
|
|
// } catch (Throwable ex) { |
|
|
|
// Log.e("austin_debug", action + ": " + ex); |
|
|
|
// } |
|
|
|
// return null; |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// protected void onPostExecute(Void result) { |
|
|
|
// if (hasDeletedSomething) { |
|
|
|
// // directItemModel = null; |
|
|
|
// // new DirectMessageInboxThreadFetcher(threadId, UserInboxDirection.OLDER, null, fetchListener) |
|
|
|
// // .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
private void setupKbHeightProvider() { |
|
|
|
if (heightProvider != null) return; |
|
|
|
heightProvider = new HeightProvider(fragmentActivity).init().setHeightListener(height -> { |
|
|
|