mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-08 07:57:28 +00:00
Merge branch 'master' into pr/753
This commit is contained in:
commit
0b8545c0e1
@ -540,7 +540,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
public void onSuccess(final Void result) {
|
||||
hashtagDetailsBinding.favChip.setText(R.string.favorite_short);
|
||||
hashtagDetailsBinding.favChip.setChipIconResource(R.drawable.ic_star_check_24);
|
||||
showSnackbar(getString(R.string.added_to_favs_short));
|
||||
showSnackbar(getString(R.string.added_to_favs));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -528,7 +528,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
public void onSuccess(final Void result) {
|
||||
locationDetailsBinding.favChip.setText(R.string.favorite_short);
|
||||
locationDetailsBinding.favChip.setChipIconResource(R.drawable.ic_star_check_24);
|
||||
showSnackbar(getString(R.string.added_to_favs_short));
|
||||
showSnackbar(getString(R.string.added_to_favs));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -122,9 +122,8 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
private boolean hasStories = false;
|
||||
private HighlightsAdapter highlightsAdapter;
|
||||
private HighlightsViewModel highlightsViewModel;
|
||||
private MenuItem blockMenuItem;
|
||||
private MenuItem restrictMenuItem;
|
||||
private MenuItem chainingMenuItem;
|
||||
private MenuItem blockMenuItem, restrictMenuItem, chainingMenuItem;
|
||||
private MenuItem muteStoriesMenuItem, mutePostsMenuItem;
|
||||
private boolean highlightsFetching;
|
||||
private boolean postsSetupDone = false;
|
||||
private Set<Media> selectedFeedModels;
|
||||
@ -381,6 +380,25 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
restrictMenuItem.setVisible(false);
|
||||
}
|
||||
}
|
||||
muteStoriesMenuItem = menu.findItem(R.id.mute_stories);
|
||||
if (muteStoriesMenuItem != null) {
|
||||
if (profileModel != null) {
|
||||
muteStoriesMenuItem.setVisible(!Objects.equals(profileModel.getPk(), CookieUtils.getUserIdFromCookie(cookie)));
|
||||
muteStoriesMenuItem.setTitle(profileModel.getFriendshipStatus().isMutingReel() ? R.string.mute_stories : R.string.unmute_stories);
|
||||
} else {
|
||||
muteStoriesMenuItem.setVisible(false);
|
||||
}
|
||||
}
|
||||
mutePostsMenuItem = menu.findItem(R.id.mute_posts);
|
||||
if (mutePostsMenuItem != null) {
|
||||
if (profileModel != null) {
|
||||
mutePostsMenuItem.setVisible(!Objects.equals(profileModel.getPk(), CookieUtils.getUserIdFromCookie(cookie)));
|
||||
mutePostsMenuItem.setTitle(profileModel.getFriendshipStatus().isMuting() ? R.string.mute_posts : R.string.unmute_posts);
|
||||
}
|
||||
else {
|
||||
mutePostsMenuItem.setVisible(false);
|
||||
}
|
||||
}
|
||||
chainingMenuItem = menu.findItem(R.id.chaining);
|
||||
if (chainingMenuItem != null) {
|
||||
if (profileModel != null) {
|
||||
@ -459,6 +477,48 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
NavHostFragment.findNavController(this).navigate(navDirections);
|
||||
return true;
|
||||
}
|
||||
if (item.getItemId() == R.id.mute_stories) {
|
||||
if (!isLoggedIn) return false;
|
||||
final String action = profileModel.getFriendshipStatus().isMutingReel() ? "Unmute stories" : "Mute stories";
|
||||
friendshipService.changeMute(
|
||||
profileModel.getFriendshipStatus().isMutingReel(),
|
||||
profileModel.getPk(),
|
||||
true,
|
||||
new ServiceCallback<FriendshipChangeResponse>() {
|
||||
@Override
|
||||
public void onSuccess(final FriendshipChangeResponse result) {
|
||||
Log.d(TAG, action + " success: " + result);
|
||||
fetchProfileDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
Log.e(TAG, "Error while performing " + action, t);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (item.getItemId() == R.id.mute_posts) {
|
||||
if (!isLoggedIn) return false;
|
||||
final String action = profileModel.getFriendshipStatus().isMuting() ? "Unmute stories" : "Mute stories";
|
||||
friendshipService.changeMute(
|
||||
profileModel.getFriendshipStatus().isMuting(),
|
||||
profileModel.getPk(),
|
||||
false,
|
||||
new ServiceCallback<FriendshipChangeResponse>() {
|
||||
@Override
|
||||
public void onSuccess(final FriendshipChangeResponse result) {
|
||||
Log.d(TAG, action + " success: " + result);
|
||||
fetchProfileDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
Log.e(TAG, "Error while performing " + action, t);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@ -617,7 +677,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
@Override
|
||||
public void onSuccess(final Favorite result) {
|
||||
profileDetailsBinding.favChip.setChipIconResource(R.drawable.ic_star_check_24);
|
||||
profileDetailsBinding.favChip.setText(R.string.added_to_favs_short);
|
||||
profileDetailsBinding.favChip.setText(R.string.favorite_short);
|
||||
favoriteRepository.insertOrUpdateFavorite(new Favorite(
|
||||
result.getId(),
|
||||
profileModel.getUsername(),
|
||||
@ -669,9 +729,9 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
), new RepositoryCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(final Void result) {
|
||||
profileDetailsBinding.favChip.setText(R.string.added_to_favs_short);
|
||||
profileDetailsBinding.favChip.setText(R.string.favorite_short);
|
||||
profileDetailsBinding.favChip.setChipIconResource(R.drawable.ic_star_check_24);
|
||||
showSnackbar(getString(R.string.added_to_favs_short));
|
||||
showSnackbar(getString(R.string.added_to_favs));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -689,7 +749,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
|
||||
final String postCount = String.valueOf(profileModel.getMediaCount());
|
||||
|
||||
SpannableStringBuilder span = new SpannableStringBuilder(getResources().getQuantityString(R.plurals.main_posts_count_inline,
|
||||
SpannableStringBuilder span = new SpannableStringBuilder(getResources().getQuantityString(R.plurals.main_posts_count,
|
||||
profileModel.getMediaCount() > 2000000000L
|
||||
? 2000000000
|
||||
: (int) profileModel.getMediaCount(),
|
||||
@ -896,21 +956,21 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
}
|
||||
if (restrictMenuItem != null) {
|
||||
restrictMenuItem.setVisible(true);
|
||||
if (profileModel.getFriendshipStatus().isRestricted()) {
|
||||
restrictMenuItem.setTitle(R.string.unrestrict);
|
||||
} else {
|
||||
restrictMenuItem.setTitle(R.string.restrict);
|
||||
}
|
||||
restrictMenuItem.setTitle(profileModel.getFriendshipStatus().isRestricted() ? R.string.unrestrict : R.string.restrict);
|
||||
}
|
||||
if (blockMenuItem != null) {
|
||||
blockMenuItem.setVisible(true);
|
||||
if (profileModel.getFriendshipStatus().isBlocking()) {
|
||||
blockMenuItem.setTitle(R.string.unblock);
|
||||
} else {
|
||||
blockMenuItem.setTitle(R.string.block);
|
||||
}
|
||||
blockMenuItem.setTitle(profileModel.getFriendshipStatus().isBlocking() ? R.string.unblock : R.string.block);
|
||||
}
|
||||
if (chainingMenuItem != null && !Objects.equals(profileId, myId)) {
|
||||
if (muteStoriesMenuItem != null) {
|
||||
muteStoriesMenuItem.setVisible(true);
|
||||
muteStoriesMenuItem.setTitle(profileModel.getFriendshipStatus().isMutingReel() ? R.string.unmute_stories : R.string.mute_stories);
|
||||
}
|
||||
if (mutePostsMenuItem != null) {
|
||||
mutePostsMenuItem.setVisible(true);
|
||||
mutePostsMenuItem.setTitle(profileModel.getFriendshipStatus().isMuting() ? R.string.unmute_posts : R.string.mute_posts);
|
||||
}
|
||||
if (chainingMenuItem != null) {
|
||||
chainingMenuItem.setVisible(true);
|
||||
}
|
||||
return;
|
||||
|
@ -45,10 +45,9 @@ import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
public class MorePreferencesFragment extends BasePreferencesFragment {
|
||||
private static final String TAG = "MorePreferencesFragment";
|
||||
|
||||
private final AccountRepository accountRepository;
|
||||
private AccountRepository accountRepository;
|
||||
|
||||
public MorePreferencesFragment() {
|
||||
accountRepository = AccountRepository.getInstance(AccountDataSource.getInstance(getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,6 +57,7 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
|
||||
// screen.addPreference(new MoreHeaderPreference(getContext()));
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
accountRepository = AccountRepository.getInstance(AccountDataSource.getInstance(context));
|
||||
final PreferenceCategory accountCategory = new PreferenceCategory(context);
|
||||
accountCategory.setTitle(R.string.account);
|
||||
accountCategory.setIconSpaceReserved(false);
|
||||
|
@ -29,4 +29,9 @@ public interface FriendshipRepository {
|
||||
Call<String> getList(@Path("userId") long userId,
|
||||
@Path("type") String type, // following or followers
|
||||
@QueryMap(encoded = true) Map<String, String> queryParams);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("/api/v1/friendships/{action}/")
|
||||
Call<FriendshipChangeResponse> changeMute(@Path("action") String action,
|
||||
@FieldMap Map<String, String> form);
|
||||
}
|
||||
|
@ -158,6 +158,38 @@ public class FriendshipService extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
public void changeMute(final boolean unmute,
|
||||
final long targetUserId,
|
||||
final boolean story, // true for story, false for posts
|
||||
final ServiceCallback<FriendshipChangeResponse> callback) {
|
||||
final Map<String, String> form = new HashMap<>(4);
|
||||
form.put("_csrftoken", csrfToken);
|
||||
form.put("_uid", String.valueOf(userId));
|
||||
form.put("_uuid", deviceUuid);
|
||||
form.put(story ? "target_reel_author_id" : "target_posts_author_id", String.valueOf(targetUserId));
|
||||
final Call<FriendshipChangeResponse> request = repository.changeMute(unmute ?
|
||||
"unmute_posts_or_story_from_follow" :
|
||||
"mute_posts_or_story_from_follow",
|
||||
form);
|
||||
request.enqueue(new Callback<FriendshipChangeResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<FriendshipChangeResponse> call,
|
||||
@NonNull final Response<FriendshipChangeResponse> response) {
|
||||
if (callback != null) {
|
||||
callback.onSuccess(response.body());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull final Call<FriendshipChangeResponse> call,
|
||||
@NonNull final Throwable t) {
|
||||
if (callback != null) {
|
||||
callback.onFailure(t);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getList(final boolean follower,
|
||||
final long targetUserId,
|
||||
final String maxId,
|
||||
|
@ -137,6 +137,7 @@ public class StoriesService extends BaseService {
|
||||
final JSONArray feedStoriesReel = new JSONObject(body).getJSONArray("tray");
|
||||
for (int i = 0; i < feedStoriesReel.length(); ++i) {
|
||||
final JSONObject node = feedStoriesReel.getJSONObject(i);
|
||||
if (node.optBoolean("hide_from_feed_unit")) continue;
|
||||
final JSONObject userJson = node.getJSONObject(node.has("user") ? "user" : "owner");
|
||||
try {
|
||||
final User user = new User(userJson.getLong("pk"),
|
||||
|
@ -26,4 +26,18 @@
|
||||
android:title="@string/action_ayml"
|
||||
android:visible="false"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/mute_stories"
|
||||
android:icon="@drawable/ic_highlight_off_24"
|
||||
android:title="@string/mute_stories"
|
||||
android:visible="false"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/mute_posts"
|
||||
android:icon="@drawable/ic_highlight_off_24"
|
||||
android:title="@string/mute_posts"
|
||||
android:visible="false"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
@ -48,10 +48,14 @@
|
||||
<string name="instadp_settings">Use Instadp for high definition profile pictures</string>
|
||||
<string name="import_export">Import/Export</string>
|
||||
<string name="select_language">Language</string>
|
||||
<plurals name="main_posts_count_inline">
|
||||
<plurals name="main_posts_count">
|
||||
<item quantity="one">%s\nPost</item>
|
||||
<item quantity="other">%s\nPosts</item>
|
||||
</plurals>
|
||||
<plurals name="main_posts_count_inline">
|
||||
<item quantity="one">%s Post</item>
|
||||
<item quantity="other">%s Posts</item>
|
||||
</plurals>
|
||||
<plurals name="main_posts_followers">
|
||||
<item quantity="one">%s\nFollower</item>
|
||||
<item quantity="other">%s\nFollowers</item>
|
||||
@ -117,12 +121,15 @@
|
||||
<string name="unbookmark">Unbookmark</string>
|
||||
<string name="follow">Follow</string>
|
||||
<string name="unfollow">Unfollow</string>
|
||||
<string name="favorite_short">Favorite</string>
|
||||
<string name="unfavorite_short">Unfavorite</string>
|
||||
<string name="favorite_short" comment="Adjective, not verb">Favorite</string>
|
||||
<string name="block">Block</string>
|
||||
<string name="unblock">Unblock</string>
|
||||
<string name="restrict">Restrict</string>
|
||||
<string name="unrestrict">Unrestrict</string>
|
||||
<string name="mute_stories">Mute stories</string>
|
||||
<string name="mute_posts">Mute posts</string>
|
||||
<string name="unmute_stories">Unmute stories</string>
|
||||
<string name="unmute_posts">Unmute posts</string>
|
||||
<string name="bio_copy">Copy bio</string>
|
||||
<string name="bio_translate">Translate bio</string>
|
||||
<string name="status_mutual">Mutual</string>
|
||||
@ -310,14 +317,13 @@
|
||||
<string name="light_barinsta_theme" comment="Yes, this one is Barista (the theme), you can also substitute it with other coffee-related words">Barista</string>
|
||||
<string name="light_bibliogram_theme" translatable="false">Bibliogram</string>
|
||||
<string name="dark_material_dark_theme">Material Dark</string>
|
||||
<string name="added_to_favs">Added to Favorites</string>
|
||||
<string name="added_to_favs_short" comment="Here it's an adjective (equivalent to verb past tense), used for the favorite chip on profile/hashtag/location fragments, so be short">Favorited</string>
|
||||
<string name="add_to_favorites" comment="Here it's a verb, used for the favorite chip on profile/hashtag/location fragments, so be short">Favorite</string>
|
||||
<string name="added_to_favs">Added to Favorites!</string>
|
||||
<string name="add_to_favorites">Add to Favorites</string>
|
||||
<string name="accounts">Accounts</string>
|
||||
<string name="hashtags">Hashtags</string>
|
||||
<string name="locations">Locations</string>
|
||||
<string name="unknown">Unknown</string>
|
||||
<string name="removed_from_favs">Removed from Favourites</string>
|
||||
<string name="removed_from_favs">Removed from Favourites!</string>
|
||||
<string name="backup_and_restore">Backup & Restore</string>
|
||||
<string name="backup_summary">Backup Barinsta app settings, account login data, and/or favorites to a plain text or encrypted backup file for later restoration.</string>
|
||||
<string name="backup_warning">If you\'re backing up account login data, treat the file as confidential and keep it somewhere safe!</string>
|
||||
|
Loading…
Reference in New Issue
Block a user