mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
v16.6-a4
This commit is contained in:
parent
06f39dacae
commit
07dd0e12a1
@ -10,7 +10,7 @@ android {
|
||||
targetSdkVersion 29
|
||||
|
||||
versionCode 27
|
||||
versionName '16.6-a3'
|
||||
versionName '16.6-a4'
|
||||
|
||||
multiDexEnabled true
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package awais.instagrabber.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@ -14,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
@ -30,6 +32,7 @@ import awais.instagrabber.models.direct_messages.DirectItemModel;
|
||||
import awais.instagrabber.models.direct_messages.DirectItemModel.DirectItemMediaModel;
|
||||
import awais.instagrabber.models.direct_messages.InboxThreadModel;
|
||||
import awais.instagrabber.models.enums.DirectItemType;
|
||||
import awais.instagrabber.models.enums.DownloadMethod;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.models.enums.UserInboxDirection;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
@ -48,7 +51,7 @@ public final class DirectMessagesUserInbox extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onResult(final InboxThreadModel result) {
|
||||
if (result == null && "MINCURSOR".equals(endCursor) || "MAXCURSOR".equals(endCursor) || Utils.isEmpty(endCursor))
|
||||
if (result == null && ("MINCURSOR".equals(endCursor) || "MAXCURSOR".equals(endCursor) || Utils.isEmpty(endCursor)))
|
||||
Toast.makeText(DirectMessagesUserInbox.this, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
|
||||
if (result != null) {
|
||||
@ -97,29 +100,41 @@ public final class DirectMessagesUserInbox extends AppCompatActivity {
|
||||
}
|
||||
}));
|
||||
|
||||
dmsBinding.rvDirectMessages.setAdapter(messageItemsAdapter = new MessageItemsAdapter(directItemModels, users, v -> {
|
||||
// todo do something with clicked message
|
||||
messageItemsAdapter = new MessageItemsAdapter(directItemModels, users, v -> {
|
||||
Object tag = v.getTag();
|
||||
if (tag instanceof DirectItemModel) {
|
||||
directItemModel = (DirectItemModel) tag;
|
||||
final String username = getUser(directItemModel.getUserId()).getUsername();
|
||||
final DirectItemType itemType = directItemModel.getItemType();
|
||||
switch(itemType) {
|
||||
switch (itemType) {
|
||||
case LINK:
|
||||
Intent linkIntent = new Intent(Intent.ACTION_VIEW);
|
||||
linkIntent.setData(Uri.parse(directItemModel.getLinkModel().getLinkContext().getLinkUrl()));
|
||||
startActivity(linkIntent);
|
||||
break;
|
||||
case MEDIA_SHARE:
|
||||
startActivity(new Intent(this, PostViewer.class)
|
||||
.putExtra(Constants.EXTRAS_POST, new PostModel(directItemModel.getMediaModel().getCode())));
|
||||
break;
|
||||
/*case STORY_SHARE:
|
||||
case MEDIA:
|
||||
Utils.dmDownload(this, username, DownloadMethod.DOWNLOAD_DIRECT, Collections.singletonList(directItemModel.getMediaModel()));
|
||||
Toast.makeText(v.getContext(), R.string.downloader_downloading_media, Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case REEL_SHARE:
|
||||
case STORY_SHARE:
|
||||
if (directItemModel.getReelShare() != null)
|
||||
startActivity(new Intent(this, StoryViewer.class)
|
||||
.putExtra(Constants.EXTRAS_USERNAME, directItemModel.getReelShare().getReelOwnerName())
|
||||
.putExtra(Constants.EXTRAS_STORIES, new StoryModel(
|
||||
/*.putExtra(Constants.EXTRAS_STORIES, new StoryModel(
|
||||
directItemModel.getReelShare().getReelId(),
|
||||
directItemModel.getReelShare().getMedia()
|
||||
))
|
||||
))*/
|
||||
);
|
||||
break;*/
|
||||
break;
|
||||
case TEXT:
|
||||
searchUsername(username);
|
||||
Utils.copyText(v.getContext(), directItemModel.getText());
|
||||
Toast.makeText(v.getContext(), R.string.clipboard_copied, Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -127,9 +142,13 @@ public final class DirectMessagesUserInbox extends AppCompatActivity {
|
||||
.putExtra(Constants.EXTRAS_POST, new PostModel(tag.toString())));
|
||||
*/
|
||||
}
|
||||
}, (view, text, isHashtag) -> {
|
||||
// todo mention click stuff
|
||||
}));
|
||||
},
|
||||
(view, text, isHashtag) -> {
|
||||
});
|
||||
|
||||
dmsBinding.rvDirectMessages.setAdapter(
|
||||
messageItemsAdapter
|
||||
);
|
||||
|
||||
new UserInboxFetcher(threadModel.getThreadId(), UserInboxDirection.OLDER, null, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
@ -168,10 +168,6 @@ public final class MessageItemsAdapter extends RecyclerView.Adapter<TextMessageV
|
||||
else holder.tvMessage.setText(text);
|
||||
|
||||
holder.tvMessage.setVisibility(View.VISIBLE);
|
||||
holder.tvMessage.setOnClickListener(v -> {
|
||||
Utils.copyText(v.getContext(), holder.tvMessage.getText());
|
||||
Toast.makeText(v.getContext(), R.string.clipboard_copied, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
break;
|
||||
|
||||
case LINK: {
|
||||
|
@ -872,6 +872,51 @@ public final class Utils {
|
||||
Toast.makeText(context, R.string.error_creating_folders, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static void dmDownload(@NonNull final Context context, @Nullable final String username, final DownloadMethod method,
|
||||
final List<? extends DirectItemMediaModel> itemsToDownload) {
|
||||
if (settingsHelper == null) settingsHelper = new SettingsHelper(context);
|
||||
|
||||
if (itemsToDownload == null || itemsToDownload.size() < 1) return;
|
||||
|
||||
if (ContextCompat.checkSelfPermission(context, Utils.PERMS[0]) == PackageManager.PERMISSION_GRANTED)
|
||||
dmDownloadImpl(context, username, method, itemsToDownload);
|
||||
else if (context instanceof Activity)
|
||||
ActivityCompat.requestPermissions((Activity) context, Utils.PERMS, 8020);
|
||||
}
|
||||
|
||||
private static void dmDownloadImpl(@NonNull final Context context, @Nullable final String username,
|
||||
final DownloadMethod method, final List<? extends DirectItemMediaModel> itemsToDownload) {
|
||||
File dir = new File(Environment.getExternalStorageDirectory(), "Download");
|
||||
|
||||
if (settingsHelper.getBoolean(FOLDER_SAVE_TO)) {
|
||||
final String customPath = settingsHelper.getString(FOLDER_PATH);
|
||||
if (!Utils.isEmpty(customPath)) dir = new File(customPath);
|
||||
}
|
||||
|
||||
if (settingsHelper.getBoolean(Constants.DOWNLOAD_USER_FOLDER) && !isEmpty(username))
|
||||
dir = new File(dir, username);
|
||||
|
||||
if (dir.exists() || dir.mkdirs()) {
|
||||
final Main main = method != DownloadMethod.DOWNLOAD_FEED && context instanceof Main ? (Main) context : null;
|
||||
|
||||
final int itemsToDownloadSize = itemsToDownload.size();
|
||||
|
||||
final File finalDir = dir;
|
||||
for (int i = itemsToDownloadSize - 1; i >= 0; i--) {
|
||||
final DirectItemMediaModel selectedItem = itemsToDownload.get(i);
|
||||
|
||||
if (main == null) {
|
||||
new DownloadAsync(context,
|
||||
selectedItem.getThumbUrl(),
|
||||
getDownloadSaveFileDm(finalDir, selectedItem, ""),
|
||||
null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
}
|
||||
}
|
||||
} else
|
||||
Toast.makeText(context, R.string.error_creating_folders, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static File getDownloadSaveFile(final File finalDir, @NonNull final BasePostModel model, final String sliderPrefix) {
|
||||
final String displayUrl = model.getDisplayUrl();
|
||||
@ -879,6 +924,13 @@ public final class Utils {
|
||||
getExtensionFromModel(displayUrl, model));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static File getDownloadSaveFileDm(final File finalDir, @NonNull final DirectItemMediaModel model, final String sliderPrefix) {
|
||||
final String displayUrl = model.getThumbUrl();
|
||||
return new File(finalDir, model.getId() + sliderPrefix +
|
||||
getExtensionFromModel(displayUrl, model));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getExtensionFromModel(@NonNull final String url, final Object model) {
|
||||
final String extension;
|
||||
|
@ -140,6 +140,7 @@
|
||||
<string name="downloader_started">Download started</string>
|
||||
<string name="downloader_complete">Download completed</string>
|
||||
<string name="downloader_downloading_post">Downloading post</string>
|
||||
<string name="downloader_downloading_media">Downloading media</string>
|
||||
<string name="downloader_downloading_pfp">Downloading profile picture</string>
|
||||
|
||||
<string name="downloader_downloaded_in_folder">File downloaded in Downloads folder!</string>
|
||||
|
Loading…
Reference in New Issue
Block a user