Merge pull request #273 from ammargitham/master

Setting top views to collapsing toolbar layout in MainActivity
This commit is contained in:
Austin Huang 2020-11-30 12:30:15 -05:00 committed by GitHub
commit 32595dab64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 1250 additions and 1265 deletions

View File

@ -21,6 +21,7 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -40,7 +41,6 @@ import androidx.navigation.ui.NavigationUI;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -53,7 +53,6 @@ import awais.instagrabber.R;
import awais.instagrabber.adapters.SuggestionsAdapter; import awais.instagrabber.adapters.SuggestionsAdapter;
import awais.instagrabber.asyncs.PostFetcher; import awais.instagrabber.asyncs.PostFetcher;
import awais.instagrabber.asyncs.SuggestionsFetcher; import awais.instagrabber.asyncs.SuggestionsFetcher;
import awais.instagrabber.customviews.helpers.CustomHideBottomViewOnScrollBehavior;
import awais.instagrabber.databinding.ActivityMainBinding; import awais.instagrabber.databinding.ActivityMainBinding;
import awais.instagrabber.fragments.PostViewV2Fragment; import awais.instagrabber.fragments.PostViewV2Fragment;
import awais.instagrabber.fragments.main.FeedFragment; import awais.instagrabber.fragments.main.FeedFragment;
@ -80,29 +79,7 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
R.id.profileFragment, R.id.profileFragment,
R.id.discoverFragment, R.id.discoverFragment,
R.id.morePreferencesFragment); R.id.morePreferencesFragment);
private static final List<Integer> KEEP_SCROLL_BEHAVIOUR_DESTINATIONS = Arrays.asList(
R.id.directMessagesInboxFragment,
R.id.feedFragment,
R.id.profileFragment,
R.id.discoverFragment,
R.id.morePreferencesFragment,
R.id.settingsPreferencesFragment,
R.id.aboutFragment,
R.id.hashTagFragment,
R.id.locationFragment,
R.id.savedViewerFragment,
R.id.commentsViewerFragment,
R.id.followViewerFragment,
R.id.directMessagesSettingsFragment,
R.id.notificationsViewer,
R.id.themePreferencesFragment,
R.id.favoritesFragment,
R.id.backupPreferencesFragment,
R.id.directMessagesThreadFragment
);
private static final Map<Integer, Integer> NAV_TO_MENU_ID_MAP = new HashMap<>(); private static final Map<Integer, Integer> NAV_TO_MENU_ID_MAP = new HashMap<>();
private static final List<Integer> REMOVE_COLLAPSING_TOOLBAR_SCROLL_DESTINATIONS = ImmutableList.of(R.id.commentsViewerFragment,
R.id.directMessagesThreadFragment);
private static final String FIRST_FRAGMENT_GRAPH_INDEX_KEY = "firstFragmentGraphIndex"; private static final String FIRST_FRAGMENT_GRAPH_INDEX_KEY = "firstFragmentGraphIndex";
private ActivityMainBinding binding; private ActivityMainBinding binding;
@ -152,7 +129,6 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
if (savedInstanceState == null) { if (savedInstanceState == null) {
setupBottomNavigationBar(true); setupBottomNavigationBar(true);
} }
setupScrollingListener();
setupSuggestions(); setupSuggestions();
final boolean checkUpdates = settingsHelper.getBoolean(Constants.CHECK_UPDATES); final boolean checkUpdates = settingsHelper.getBoolean(Constants.CHECK_UPDATES);
if (checkUpdates) FlavorTown.updateCheck(this); if (checkUpdates) FlavorTown.updateCheck(this);
@ -233,7 +209,9 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
if (isTaskRoot() && isBackStackEmpty) { if (isTaskRoot() && isBackStackEmpty) {
finishAfterTransition(); finishAfterTransition();
} else { } else {
super.onBackPressed(); try {
super.onBackPressed();
} catch (Exception ignored) {}
} }
} }
@ -281,12 +259,6 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
}); });
} }
private void setupScrollingListener() {
final CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) binding.bottomNavView.getLayoutParams();
layoutParams.setBehavior(new CustomHideBottomViewOnScrollBehavior());
binding.bottomNavView.requestLayout();
}
private boolean setupSearchView() { private boolean setupSearchView() {
final View actionView = searchMenuItem.getActionView(); final View actionView = searchMenuItem.getActionView();
if (!(actionView instanceof SearchView)) return false; if (!(actionView instanceof SearchView)) return false;
@ -478,16 +450,6 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
@SuppressLint("RestrictedApi") final Deque<NavBackStackEntry> backStack = navController.getBackStack(); @SuppressLint("RestrictedApi") final Deque<NavBackStackEntry> backStack = navController.getBackStack();
setupMenu(backStack.size(), destinationId); setupMenu(backStack.size(), destinationId);
binding.bottomNavView.setVisibility(SHOW_BOTTOM_VIEW_DESTINATIONS.contains(destinationId) ? View.VISIBLE : View.GONE); binding.bottomNavView.setVisibility(SHOW_BOTTOM_VIEW_DESTINATIONS.contains(destinationId) ? View.VISIBLE : View.GONE);
if (KEEP_SCROLL_BEHAVIOUR_DESTINATIONS.contains(destinationId)) {
setScrollingBehaviour();
} else {
removeScrollingBehaviour();
}
if (REMOVE_COLLAPSING_TOOLBAR_SCROLL_DESTINATIONS.contains(destinationId)) {
removeCollapsingToolbarScrollFlags();
} else {
setCollapsingToolbarScrollFlags();
}
}); });
} }
@ -514,22 +476,6 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
binding.mainNavHost.requestLayout(); binding.mainNavHost.requestLayout();
} }
private void setCollapsingToolbarScrollFlags() {
final CollapsingToolbarLayout collapsingToolbarLayout = binding.collapsingToolbarLayout;
final AppBarLayout.LayoutParams toolbarLayoutLayoutParams = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
toolbarLayoutLayoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
| AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP
| AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
binding.collapsingToolbarLayout.requestLayout();
}
private void removeCollapsingToolbarScrollFlags() {
final CollapsingToolbarLayout collapsingToolbarLayout = binding.collapsingToolbarLayout;
final AppBarLayout.LayoutParams toolbarLayoutLayoutParams = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
toolbarLayoutLayoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
binding.collapsingToolbarLayout.requestLayout();
}
private void handleIntent(final Intent intent) { private void handleIntent(final Intent intent) {
if (intent == null) return; if (intent == null) return;
final String action = intent.getAction(); final String action = intent.getAction();
@ -601,11 +547,16 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
.create(); .create();
alertDialog.show(); alertDialog.show();
new PostFetcher(shortCode, feedModel -> { new PostFetcher(shortCode, feedModel -> {
final PostViewV2Fragment fragment = PostViewV2Fragment if (feedModel != null) {
.builder(feedModel) final PostViewV2Fragment fragment = PostViewV2Fragment
.build(); .builder(feedModel)
fragment.setOnShowListener(dialog -> alertDialog.dismiss()); .build();
fragment.show(getSupportFragmentManager(), "post_view"); fragment.setOnShowListener(dialog -> alertDialog.dismiss());
fragment.show(getSupportFragmentManager(), "post_view");
}
else {
Toast.makeText(getApplicationContext(), R.string.post_not_found, Toast.LENGTH_SHORT).show();
}
}).execute(); }).execute();
} }
@ -654,23 +605,17 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
return binding.bottomNavView; return binding.bottomNavView;
} }
// public void fitSystemWindows(final boolean fit) { public void setCollapsingView(@NonNull final View view) {
// binding.appBarLayout.setBackground(null); binding.collapsingToolbarLayout.addView(view, 0);
// binding.appBarLayout.setFitsSystemWindows(fit); }
// binding.collapsingToolbarLayout.setBackground(null);
// binding.collapsingToolbarLayout.setFitsSystemWindows(fit); public void removeCollapsingView(@NonNull final View view) {
// final Drawable toolbarBackground = binding.toolbar.getBackground(); binding.collapsingToolbarLayout.removeView(view);
// binding.toolbar.setFitsSystemWindows(fit); }
// binding.toolbar.setBackground(null);
// binding.toolbar.setClickable(false);
// }
//
// public int getNavHostContainerId() {
// return binding.mainNavHost.getId();
// }
public void setToolbar(final Toolbar toolbar) { public void setToolbar(final Toolbar toolbar) {
binding.appBarLayout.setVisibility(View.GONE); binding.appBarLayout.setVisibility(View.GONE);
removeScrollingBehaviour();
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
if (currentNavControllerLiveData == null) return; if (currentNavControllerLiveData == null) return;
setupNavigation(toolbar, currentNavControllerLiveData.getValue()); setupNavigation(toolbar, currentNavControllerLiveData.getValue());
@ -678,8 +623,13 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
public void resetToolbar() { public void resetToolbar() {
binding.appBarLayout.setVisibility(View.VISIBLE); binding.appBarLayout.setVisibility(View.VISIBLE);
setScrollingBehaviour();
setSupportActionBar(binding.toolbar); setSupportActionBar(binding.toolbar);
if (currentNavControllerLiveData == null) return; if (currentNavControllerLiveData == null) return;
setupNavigation(binding.toolbar, currentNavControllerLiveData.getValue()); setupNavigation(binding.toolbar, currentNavControllerLiveData.getValue());
} }
public CollapsingToolbarLayout getCollapsingToolbarView() {
return binding.collapsingToolbarLayout;
}
} }

View File

@ -22,7 +22,7 @@ public final class SliderItemsAdapter extends ListAdapter<PostChild, SliderItemV
private final VerticalDragHelper.OnVerticalDragListener onVerticalDragListener; private final VerticalDragHelper.OnVerticalDragListener onVerticalDragListener;
private final boolean loadVideoOnItemClick; private final boolean loadVideoOnItemClick;
private final SliderCallback sliderCallback; private final SliderCallback sliderCallback;
private final awais.instagrabber.databinding.LayoutExoCustomControlsBinding controlsBinding; private final LayoutExoCustomControlsBinding controlsBinding;
private static final DiffUtil.ItemCallback<PostChild> DIFF_CALLBACK = new DiffUtil.ItemCallback<PostChild>() { private static final DiffUtil.ItemCallback<PostChild> DIFF_CALLBACK = new DiffUtil.ItemCallback<PostChild>() {
@Override @Override

View File

@ -135,6 +135,16 @@ public class SliderVideoViewHolder extends SliderItemViewHolder {
videoPlayerViewHelper.releasePlayer(); videoPlayerViewHelper.releasePlayer();
} }
public void resetPlayerTimeline() {
if (videoPlayerViewHelper == null) return;
videoPlayerViewHelper.resetTimeline();
}
public void removeCallbacks() {
if (videoPlayerViewHelper == null) return;
videoPlayerViewHelper.removeCallbacks();
}
// private void setDimensions(final FeedModel feedModel, final int spanCount, final boolean animate) { // private void setDimensions(final FeedModel feedModel, final int spanCount, final boolean animate) {
// final ViewGroup.LayoutParams layoutParams = binding.imageViewer.getLayoutParams(); // final ViewGroup.LayoutParams layoutParams = binding.imageViewer.getLayoutParams();
// final int deviceWidth = Utils.displayMetrics.widthPixels; // final int deviceWidth = Utils.displayMetrics.widthPixels;

View File

@ -15,11 +15,13 @@ import awais.instagrabber.BuildConfig;
import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.interfaces.FetchListener;
import awais.instagrabber.models.ProfileModel; import awais.instagrabber.models.ProfileModel;
import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.CookieUtils;
import awais.instagrabber.utils.NetworkUtils; import awais.instagrabber.utils.NetworkUtils;
import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.TextUtils;
import awaisomereport.LogCollector; import awaisomereport.LogCollector;
import static awais.instagrabber.utils.Utils.logCollector; import static awais.instagrabber.utils.Utils.logCollector;
import static awais.instagrabber.utils.Utils.settingsHelper;
public final class ProfileFetcher extends AsyncTask<Void, Void, ProfileModel> { public final class ProfileFetcher extends AsyncTask<Void, Void, ProfileModel> {
private final FetchListener<ProfileModel> fetchListener; private final FetchListener<ProfileModel> fetchListener;
@ -43,21 +45,23 @@ public final class ProfileFetcher extends AsyncTask<Void, Void, ProfileModel> {
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
final JSONObject user = new JSONObject(NetworkUtils.readFromConnection(conn)).getJSONObject("graphql").getJSONObject(Constants.EXTRAS_USER); final JSONObject user = new JSONObject(NetworkUtils.readFromConnection(conn)).getJSONObject("graphql").getJSONObject(Constants.EXTRAS_USER);
final String cookie = settingsHelper.getString(Constants.COOKIE);
boolean isPrivate = user.getBoolean("is_private"); boolean isPrivate = user.getBoolean("is_private");
boolean reallyPrivate = isPrivate; final String id = user.getString(Constants.EXTRAS_ID);
final String uid = CookieUtils.getUserIdFromCookie(cookie);
final JSONObject timelineMedia = user.getJSONObject("edge_owner_to_timeline_media"); final JSONObject timelineMedia = user.getJSONObject("edge_owner_to_timeline_media");
if (timelineMedia.has("edges")) { if (timelineMedia.has("edges")) {
final JSONArray edges = timelineMedia.getJSONArray("edges"); final JSONArray edges = timelineMedia.getJSONArray("edges");
if (edges.length() > 0 && timelineMedia.getLong("count") > 0L) reallyPrivate = false;
} }
String url = user.optString("external_url"); String url = user.optString("external_url");
if (TextUtils.isEmpty(url)) url = null; if (TextUtils.isEmpty(url)) url = null;
result = new ProfileModel(isPrivate, result = new ProfileModel(isPrivate,
reallyPrivate, user.optBoolean("followed_by_viewer") ? false : (id.equals(uid) ? false : isPrivate),
user.getBoolean("is_verified"), user.getBoolean("is_verified"),
user.getString(Constants.EXTRAS_ID), id,
userName, userName,
user.getString("full_name"), user.getString("full_name"),
user.getString("biography"), user.getString("biography"),

View File

@ -66,9 +66,6 @@ public final class InboxFetcher extends AsyncTask<Void, Void, InboxModel> {
return null; return null;
} }
JSONObject data = new JSONObject(NetworkUtils.readFromConnection(conn)); JSONObject data = new JSONObject(NetworkUtils.readFromConnection(conn));
// try (FileWriter fileWriter = new FileWriter(new File("/sdcard/test.json"))) {
// fileWriter.write(data.toString(2));
// }
final long seqId = data.optLong("seq_id"); final long seqId = data.optLong("seq_id");
final int pendingRequestsCount = data.optInt("pending_requests_total"); final int pendingRequestsCount = data.optInt("pending_requests_total");
@ -94,8 +91,8 @@ public final class InboxFetcher extends AsyncTask<Void, Void, InboxModel> {
} }
result = new InboxModel(hasOlder, hasPendingTopRequests, result = new InboxModel(hasOlder, hasPendingTopRequests,
blendedInboxEnabled, unseenCount, pendingRequestsCount, blendedInboxEnabled, unseenCount, pendingRequestsCount,
seqId, unseenCountTimestamp, oldestCursor, inboxThreadModels); seqId, unseenCountTimestamp, oldestCursor, inboxThreadModels);
conn.disconnect(); conn.disconnect();
} catch (final Exception e) { } catch (final Exception e) {

View File

@ -216,6 +216,7 @@ public class PostsRecyclerView extends RecyclerView {
if (progressPercent != 100) continue; if (progressPercent != 100) continue;
final String url = progress.getString(DownloadWorker.URL); final String url = progress.getString(DownloadWorker.URL);
final List<FeedModel> feedModels = feedViewModel.getList().getValue(); final List<FeedModel> feedModels = feedViewModel.getList().getValue();
if (feedModels == null) continue;
for (int i = 0; i < feedModels.size(); i++) { for (int i = 0; i < feedModels.size(); i++) {
final FeedModel feedModel = feedModels.get(i); final FeedModel feedModel = feedModels.get(i);
final List<String> displayUrls = getDisplayUrl(feedModel); final List<String> displayUrls = getDisplayUrl(feedModel);
@ -254,10 +255,15 @@ public class PostsRecyclerView extends RecyclerView {
post(() -> { post(() -> {
TransitionManager.beginDelayedTransition(this, transition); TransitionManager.beginDelayedTransition(this, transition);
feedAdapter.notifyDataSetChanged(); feedAdapter.notifyDataSetChanged();
final int itemDecorationCount = getItemDecorationCount();
if (!layoutPreferences.getHasGap()) { if (!layoutPreferences.getHasGap()) {
removeItemDecoration(gridSpacingItemDecoration); if (itemDecorationCount == 1) {
removeItemDecoration(gridSpacingItemDecoration);
}
} else { } else {
addItemDecoration(gridSpacingItemDecoration); if (itemDecorationCount == 0) {
addItemDecoration(gridSpacingItemDecoration);
}
} }
if (layoutPreferences.getType() == PostsLayoutPreferences.PostsLayoutType.LINEAR) { if (layoutPreferences.getType() == PostsLayoutPreferences.PostsLayoutType.LINEAR) {
if (layoutManager.getSpanCount() != 1) { if (layoutManager.getSpanCount() != 1) {
@ -277,9 +283,13 @@ public class PostsRecyclerView extends RecyclerView {
} }
public void refresh() { public void refresh() {
lazyLoader.resetState(); if (lazyLoader != null) {
postFetcher.reset(); lazyLoader.resetState();
postFetcher.fetch(); }
if (postFetcher != null) {
postFetcher.reset();
postFetcher.fetch();
}
dispatchFetchStatus(); dispatchFetchStatus();
} }

View File

@ -138,7 +138,6 @@ public abstract class SharedElementTransitionDialogFragment extends DialogFragme
final int initY = location[1]; final int initY = location[1];
destView.setX(initX); destView.setX(initX);
destView.setY(initY - Utils.getStatusBarHeight(getContext())); destView.setY(initY - Utils.getStatusBarHeight(getContext()));
destView.requestLayout();
boundsCalculatedCount++; boundsCalculatedCount++;
if (startCalled) { if (startCalled) {
startPostponedEnterTransition(); startPostponedEnterTransition();

View File

@ -1,24 +1,22 @@
package awais.instagrabber.customviews; package awais.instagrabber.customviews;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewParent; import android.view.ViewParent;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
public class VerticalDragHelper { public class VerticalDragHelper {
private static final String TAG = "VerticalDragHelper"; // private static final String TAG = "VerticalDragHelper";
private static final float PIXELS_PER_SECOND = 10; private static final double SWIPE_THRESHOLD_VELOCITY = 80;
private final View view; private final View view;
private GestureDetector gestureDetector; private GestureDetector gestureDetector;
private Context context; private Context context;
private float flingVelocity; private double flingVelocity;
private OnVerticalDragListener onVerticalDragListener; private OnVerticalDragListener onVerticalDragListener;
private final GestureDetector.OnGestureListener gestureListener = new GestureDetector.SimpleOnGestureListener() { private final GestureDetector.OnGestureListener gestureListener = new GestureDetector.SimpleOnGestureListener() {
@ -31,32 +29,13 @@ public class VerticalDragHelper {
@Override @Override
public boolean onFling(final MotionEvent e1, final MotionEvent e2, final float velocityX, final float velocityY) { public boolean onFling(final MotionEvent e1, final MotionEvent e2, final float velocityX, final float velocityY) {
float maxFlingVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity(); double yDir = e1.getY() - e2.getY();
float velocityPercentY = velocityY / maxFlingVelocity; // Log.d(TAG, "onFling: yDir: " + yDir);
float normalizedVelocityY = velocityPercentY * PIXELS_PER_SECOND; if (yDir < -SWIPE_THRESHOLD_VELOCITY || yDir > SWIPE_THRESHOLD_VELOCITY) {
if (Math.abs(normalizedVelocityY) > 4) { flingVelocity = yDir;
flingVelocity = normalizedVelocityY;
} }
return super.onFling(e1, e2, velocityX, velocityY); return super.onFling(e1, e2, velocityX, velocityY);
} }
};
private final GestureDetector.OnGestureListener dragPreventionGestureListener = new GestureDetector.SimpleOnGestureListener() {
float prevDistanceY = 0;
@Override
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX, final float distanceY) {
Log.d(TAG, "onScroll: distanceX: " + distanceX + ", distanceY: " + distanceY);
return super.onScroll(e1, e2, distanceX, distanceY);
}
@Override
public boolean onSingleTapUp(final MotionEvent e) {
Log.d(TAG, "onSingleTapUp");
return super.onSingleTapUp(e);
}
}; };
private float prevRawY; private float prevRawY;
@ -64,7 +43,6 @@ public class VerticalDragHelper {
private float prevRawX; private float prevRawX;
private float dX; private float dX;
private float prevDY; private float prevDY;
private GestureDetector dragPreventionGestureDetector;
public VerticalDragHelper(@NonNull final View view) { public VerticalDragHelper(@NonNull final View view) {
this.view = view; this.view = view;
@ -80,14 +58,12 @@ public class VerticalDragHelper {
protected void init() { protected void init() {
gestureDetector = new GestureDetector(context, gestureListener); gestureDetector = new GestureDetector(context, gestureListener);
dragPreventionGestureDetector = new GestureDetector(context, dragPreventionGestureListener);
} }
public boolean onDragTouch(final MotionEvent event) { public boolean onDragTouch(final MotionEvent event) {
if (onVerticalDragListener == null) { if (onVerticalDragListener == null) {
return false; return false;
} }
// dragPreventionGestureDetector.onTouchEvent(event);
if (gestureDetector.onTouchEvent(event)) { if (gestureDetector.onTouchEvent(event)) {
return true; return true;
} }
@ -151,53 +127,11 @@ public class VerticalDragHelper {
return gestureDetector.onTouchEvent(event); return gestureDetector.onTouchEvent(event);
} }
private final static int DIRECTION_UP = 0;
private final static int DIRECTION_DOWN = 1;
float prevY = -1;
int edgeHitCount = 0;
float prevDirection = -1;
// private boolean shouldPreventDrag(final MotionEvent event) {
// switch (event.getAction()) {
// case MotionEvent.ACTION_DOWN:
// if (!firstDrag) {
// firstDrag = true;
// }
// return false;
// case MotionEvent.ACTION_MOVE:
// float y = event.getY();
// int direction = -2;
// if (prevY != -1) {
// final float dy = y - prevY;
// // Log.d(TAG, "shouldPreventDrag: dy: " + dy);
// if (dy > 0) {
// direction = DIRECTION_DOWN;
// // move direction is down
// } else {
// direction = DIRECTION_UP;
// // move direction is up
// }
// }
// prevY = y;
// if (prevDirection == direction) {
// edgeHitCount++;
// } else {
// edgeHitCount = 1;
// }
// if (edgeHitCount >= 2) {
// return false;
// }
// return true;
// break;
// }
// }
public interface OnVerticalDragListener { public interface OnVerticalDragListener {
void onDrag(final float dY); void onDrag(final float dY);
void onDragEnd(); void onDragEnd();
void onFling(final float flingVelocity); void onFling(final double flingVelocity);
} }
} }

View File

@ -10,6 +10,7 @@ import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.view.ContextThemeWrapper; import androidx.appcompat.view.ContextThemeWrapper;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.drawee.backends.pipeline.Fresco;
@ -26,6 +27,8 @@ import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.audio.AudioListener; import com.google.android.exoplayer2.audio.AudioListener;
import com.google.android.exoplayer2.source.ProgressiveMediaSource; import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.material.slider.LabelFormatter;
import com.google.android.material.slider.Slider;
import awais.instagrabber.R; import awais.instagrabber.R;
import awais.instagrabber.databinding.LayoutExoCustomControlsBinding; import awais.instagrabber.databinding.LayoutExoCustomControlsBinding;
@ -39,6 +42,8 @@ import static com.google.android.exoplayer2.Player.STATE_READY;
public class VideoPlayerViewHelper implements Player.EventListener { public class VideoPlayerViewHelper implements Player.EventListener {
private static final String TAG = "VideoPlayerViewHelper"; private static final String TAG = "VideoPlayerViewHelper";
private static final long INITIAL_DELAY = 0;
private static final long RECURRING_DELAY = 60;
private final Context context; private final Context context;
private final awais.instagrabber.databinding.LayoutVideoPlayerWithThumbnailBinding binding; private final awais.instagrabber.databinding.LayoutVideoPlayerWithThumbnailBinding binding;
@ -52,6 +57,62 @@ public class VideoPlayerViewHelper implements Player.EventListener {
private final DefaultDataSourceFactory dataSourceFactory; private final DefaultDataSourceFactory dataSourceFactory;
private SimpleExoPlayer player; private SimpleExoPlayer player;
private PopupMenu speedPopup; private PopupMenu speedPopup;
private Runnable positionChecker;
private final Handler positionUpdateHandler = new Handler();
private final Player.EventListener listener = new Player.EventListener() {
@Override
public void onPlaybackStateChanged(final int state) {
switch (state) {
case Player.STATE_BUFFERING:
case STATE_IDLE:
case STATE_ENDED:
positionUpdateHandler.removeCallbacks(positionChecker);
return;
case STATE_READY:
setupTimeline();
positionUpdateHandler.postDelayed(positionChecker, INITIAL_DELAY);
break;
}
}
@Override
public void onPlayWhenReadyChanged(final boolean playWhenReady, final int reason) {
updatePlayPauseDrawable(playWhenReady);
}
};
private final AudioListener audioListener = new AudioListener() {
@Override
public void onVolumeChanged(final float volume) {
updateMuteIcon(volume);
}
};
private final Slider.OnChangeListener onChangeListener = (slider, value, fromUser) -> {
if (!fromUser) return;
long actualValue = (long) value;
if (actualValue < 0) {
actualValue = 0;
} else if (actualValue > player.getDuration()) {
actualValue = player.getDuration();
}
player.seekTo(actualValue);
};
private final View.OnClickListener onClickListener = v -> player.setPlayWhenReady(!player.getPlayWhenReady());
private final LabelFormatter labelFormatter = value -> TextUtils.millisToTimeString((long) value);
private final View.OnClickListener muteOnClickListener = v -> toggleMute();
private final View.OnClickListener rewOnClickListener = v -> {
final long positionMs = player.getCurrentPosition() - 5000;
player.seekTo(positionMs < 0 ? 0 : positionMs);
};
private final View.OnClickListener ffOnClickListener = v -> {
long positionMs = player.getCurrentPosition() + 5000;
long duration = player.getDuration();
if (duration == TIME_UNSET) {
duration = 0;
}
player.seekTo(Math.min(positionMs, duration));
};
private final View.OnClickListener showMenu = this::showMenu;
public VideoPlayerViewHelper(@NonNull final Context context, public VideoPlayerViewHelper(@NonNull final Context context,
@NonNull final LayoutVideoPlayerWithThumbnailBinding binding, @NonNull final LayoutVideoPlayerWithThumbnailBinding binding,
@ -130,6 +191,10 @@ public class VideoPlayerViewHelper implements Player.EventListener {
player = new SimpleExoPlayer.Builder(context) player = new SimpleExoPlayer.Builder(context)
.setLooper(Looper.getMainLooper()) .setLooper(Looper.getMainLooper())
.build(); .build();
positionChecker = new PositionCheckRunnable(positionUpdateHandler,
player,
controlsBinding.timeline,
controlsBinding.fromTime);
player.addListener(this); player.addListener(this);
player.setVolume(initialVolume); player.setVolume(initialVolume);
player.setPlayWhenReady(true); player.setPlayWhenReady(true);
@ -148,87 +213,22 @@ public class VideoPlayerViewHelper implements Player.EventListener {
binding.playerView.setUseController(false); binding.playerView.setUseController(false);
if (player == null) { if (player == null) {
enableControls(false); enableControls(false);
controlsBinding.playPause.setEnabled(true); // controlsBinding.playPause.setEnabled(true);
controlsBinding.playPause.setOnClickListener(v -> binding.thumbnailParent.performClick()); // controlsBinding.playPause.setOnClickListener(new NoPlayerPlayPauseClickListener(binding.thumbnailParent));
return; return;
} }
enableControls(true); enableControls(true);
final Handler handler = new Handler();
final long initialDelay = 0;
final long recurringDelay = 60;
final Runnable positionChecker = new Runnable() {
@Override
public void run() {
handler.removeCallbacks(this);
if (player == null) return;
final long currentPosition = player.getCurrentPosition();
final long duration = player.getDuration();
if (duration == TIME_UNSET) {
controlsBinding.timeline.setValueFrom(0);
controlsBinding.timeline.setValueTo(0);
controlsBinding.timeline.setEnabled(false);
return;
}
controlsBinding.timeline.setValue(Math.min(currentPosition, duration));
controlsBinding.fromTime.setText(TextUtils.millisToTimeString(currentPosition));
handler.postDelayed(this, recurringDelay);
}
};
updatePlayPauseDrawable(player.getPlayWhenReady()); updatePlayPauseDrawable(player.getPlayWhenReady());
updateMuteIcon(player.getVolume()); updateMuteIcon(player.getVolume());
player.addListener(new Player.EventListener() { player.addListener(listener);
@Override player.addAudioListener(audioListener);
public void onPlaybackStateChanged(final int state) { controlsBinding.timeline.addOnChangeListener(onChangeListener);
switch (state) { controlsBinding.timeline.setLabelFormatter(labelFormatter);
case Player.STATE_BUFFERING: controlsBinding.playPause.setOnClickListener(onClickListener);
case STATE_IDLE: controlsBinding.mute.setOnClickListener(muteOnClickListener);
case STATE_ENDED: controlsBinding.rewWithAmount.setOnClickListener(rewOnClickListener);
handler.removeCallbacks(positionChecker); controlsBinding.ffWithAmount.setOnClickListener(ffOnClickListener);
return; controlsBinding.speed.setOnClickListener(showMenu);
case STATE_READY:
setupTimeline();
handler.postDelayed(positionChecker, initialDelay);
break;
}
}
@Override
public void onPlayWhenReadyChanged(final boolean playWhenReady, final int reason) {
updatePlayPauseDrawable(playWhenReady);
}
});
player.addAudioListener(new AudioListener() {
@Override
public void onVolumeChanged(final float volume) {
updateMuteIcon(volume);
}
});
controlsBinding.timeline.addOnChangeListener((slider, value, fromUser) -> {
if (!fromUser) return;
long actualValue = (long) value;
if (actualValue < 0) {
actualValue = 0;
} else if (actualValue > player.getDuration()) {
actualValue = player.getDuration();
}
player.seekTo(actualValue);
});
controlsBinding.timeline.setLabelFormatter(value -> TextUtils.millisToTimeString((long) value));
controlsBinding.playPause.setOnClickListener(v -> player.setPlayWhenReady(!player.getPlayWhenReady()));
controlsBinding.mute.setOnClickListener(v -> toggleMute());
controlsBinding.rewWithAmount.setOnClickListener(v -> {
final long positionMs = player.getCurrentPosition() - 5000;
player.seekTo(positionMs < 0 ? 0 : positionMs);
});
controlsBinding.ffWithAmount.setOnClickListener(v -> {
long positionMs = player.getCurrentPosition() + 5000;
long duration = player.getDuration();
if (duration == TIME_UNSET) {
duration = 0;
}
player.seekTo(Math.min(positionMs, duration));
});
controlsBinding.speed.setOnClickListener(this::showMenu);
} }
private void setupTimeline() { private void setupTimeline() {
@ -242,12 +242,18 @@ public class VideoPlayerViewHelper implements Player.EventListener {
private void enableControls(final boolean enable) { private void enableControls(final boolean enable) {
controlsBinding.speed.setEnabled(enable); controlsBinding.speed.setEnabled(enable);
controlsBinding.speed.setClickable(enable);
controlsBinding.mute.setEnabled(enable); controlsBinding.mute.setEnabled(enable);
controlsBinding.mute.setClickable(enable);
controlsBinding.ffWithAmount.setEnabled(enable); controlsBinding.ffWithAmount.setEnabled(enable);
controlsBinding.ffWithAmount.setClickable(enable);
controlsBinding.rewWithAmount.setEnabled(enable); controlsBinding.rewWithAmount.setEnabled(enable);
controlsBinding.rewWithAmount.setClickable(enable);
controlsBinding.fromTime.setEnabled(enable); controlsBinding.fromTime.setEnabled(enable);
controlsBinding.toTime.setEnabled(enable); controlsBinding.toTime.setEnabled(enable);
controlsBinding.playPause.setEnabled(enable); controlsBinding.playPause.setEnabled(enable);
controlsBinding.playPause.setClickable(enable);
controlsBinding.timeline.setEnabled(enable);
} }
public void showMenu(View anchor) { public void showMenu(View anchor) {
@ -302,10 +308,10 @@ public class VideoPlayerViewHelper implements Player.EventListener {
private void updateMuteIcon(final float volume) { private void updateMuteIcon(final float volume) {
if (volume == 0) { if (volume == 0) {
controlsBinding.mute.setIconResource(R.drawable.ic_volume_off_24); controlsBinding.mute.setIconResource(R.drawable.ic_volume_off_24_states);
return; return;
} }
controlsBinding.mute.setIconResource(R.drawable.ic_volume_up_24); controlsBinding.mute.setIconResource(R.drawable.ic_volume_up_24_states);
} }
private void updatePlayPauseDrawable(final boolean playWhenReady) { private void updatePlayPauseDrawable(final boolean playWhenReady) {
@ -313,7 +319,7 @@ public class VideoPlayerViewHelper implements Player.EventListener {
controlsBinding.playPause.setIconResource(R.drawable.ic_pause_24); controlsBinding.playPause.setIconResource(R.drawable.ic_pause_24);
return; return;
} }
controlsBinding.playPause.setIconResource(R.drawable.ic_play_arrow_24); controlsBinding.playPause.setIconResource(R.drawable.ic_play_states);
} }
@Override @Override
@ -338,23 +344,88 @@ public class VideoPlayerViewHelper implements Player.EventListener {
return vol; return vol;
} }
public void togglePlayback() { // public void togglePlayback() {
if (player == null) return; // if (player == null) return;
final int playbackState = player.getPlaybackState(); // final int playbackState = player.getPlaybackState();
if (playbackState == STATE_IDLE || playbackState == STATE_ENDED) return; // if (playbackState == STATE_IDLE || playbackState == STATE_ENDED) return;
final boolean playWhenReady = player.getPlayWhenReady(); // final boolean playWhenReady = player.getPlayWhenReady();
player.setPlayWhenReady(!playWhenReady); // player.setPlayWhenReady(!playWhenReady);
} // }
public void releasePlayer() { public void releasePlayer() {
if (player == null) return; if (player == null) return;
player.release(); player.release();
player = null; player = null;
if (positionUpdateHandler != null && positionChecker != null) {
positionUpdateHandler.removeCallbacks(positionChecker);
}
} }
public void pause() { public void pause() {
if (player == null) return; if (player == null) return;
player.pause(); player.pause();
if (positionUpdateHandler != null && positionChecker != null) {
positionUpdateHandler.removeCallbacks(positionChecker);
}
}
public void resetTimeline() {
if (player == null) {
enableControls(false);
return;
}
setupTimeline();
final long currentPosition = player.getCurrentPosition();
controlsBinding.timeline.setValue(Math.min(currentPosition, player.getDuration()));
setupControls();
}
public void removeCallbacks() {
if (player != null) {
player.removeListener(listener);
player.removeAudioListener(audioListener);
}
controlsBinding.timeline.removeOnChangeListener(onChangeListener);
controlsBinding.timeline.setLabelFormatter(null);
controlsBinding.playPause.setOnClickListener(null);
controlsBinding.mute.setOnClickListener(null);
controlsBinding.rewWithAmount.setOnClickListener(null);
controlsBinding.ffWithAmount.setOnClickListener(null);
controlsBinding.speed.setOnClickListener(null);
}
private static class PositionCheckRunnable implements Runnable {
private final Handler positionUpdateHandler;
private final SimpleExoPlayer player;
private final Slider timeline;
private final AppCompatTextView fromTime;
public PositionCheckRunnable(final Handler positionUpdateHandler,
final SimpleExoPlayer simpleExoPlayer,
final Slider slider,
final AppCompatTextView fromTime) {
this.positionUpdateHandler = positionUpdateHandler;
this.player = simpleExoPlayer;
this.timeline = slider;
this.fromTime = fromTime;
}
@Override
public void run() {
positionUpdateHandler.removeCallbacks(this);
if (player == null) return;
final long currentPosition = player.getCurrentPosition();
final long duration = player.getDuration();
if (duration == TIME_UNSET) {
timeline.setValueFrom(0);
timeline.setValueTo(0);
timeline.setEnabled(false);
return;
}
timeline.setValue(Math.min(currentPosition, duration));
fromTime.setText(TextUtils.millisToTimeString(currentPosition));
positionUpdateHandler.postDelayed(this, RECURRING_DELAY);
}
} }
public interface VideoPlayerCallback { public interface VideoPlayerCallback {

View File

@ -33,12 +33,14 @@ import static awais.instagrabber.utils.DownloadUtils.PERMS;
public class RestoreBackupDialogFragment extends DialogFragment { public class RestoreBackupDialogFragment extends DialogFragment {
private static final int STORAGE_PERM_REQUEST_CODE = 8020; private static final int STORAGE_PERM_REQUEST_CODE = 8020;
private final OnResultListener onResultListener; private OnResultListener onResultListener;
private DialogRestoreBackupBinding binding; private DialogRestoreBackupBinding binding;
private File file; private File file;
private boolean isEncrypted; private boolean isEncrypted;
public RestoreBackupDialogFragment() {}
public RestoreBackupDialogFragment(final OnResultListener onResultListener) { public RestoreBackupDialogFragment(final OnResultListener onResultListener) {
this.onResultListener = onResultListener; this.onResultListener = onResultListener;
} }

View File

@ -24,6 +24,7 @@ import androidx.activity.OnBackPressedDispatcher;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.PermissionChecker; import androidx.core.content.PermissionChecker;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.NavController; import androidx.navigation.NavController;
@ -46,8 +47,8 @@ import awais.instagrabber.asyncs.HashtagFetcher;
import awais.instagrabber.asyncs.HashtagPostFetchService; import awais.instagrabber.asyncs.HashtagPostFetchService;
import awais.instagrabber.asyncs.PostFetcher; import awais.instagrabber.asyncs.PostFetcher;
import awais.instagrabber.customviews.PrimaryActionModeCallback; import awais.instagrabber.customviews.PrimaryActionModeCallback;
import awais.instagrabber.customviews.helpers.NestedCoordinatorLayout;
import awais.instagrabber.databinding.FragmentHashtagBinding; import awais.instagrabber.databinding.FragmentHashtagBinding;
import awais.instagrabber.databinding.LayoutHashtagDetailsBinding;
import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment; import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment;
import awais.instagrabber.models.FeedModel; import awais.instagrabber.models.FeedModel;
import awais.instagrabber.models.HashtagModel; import awais.instagrabber.models.HashtagModel;
@ -79,7 +80,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
private MainActivity fragmentActivity; private MainActivity fragmentActivity;
private FragmentHashtagBinding binding; private FragmentHashtagBinding binding;
private NestedCoordinatorLayout root; private CoordinatorLayout root;
private boolean shouldRefresh = true; private boolean shouldRefresh = true;
private boolean hasStories = false; private boolean hasStories = false;
private boolean opening = false; private boolean opening = false;
@ -94,7 +95,8 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
private Set<FeedModel> selectedFeedModels; private Set<FeedModel> selectedFeedModels;
private FeedModel downloadFeedModel; private FeedModel downloadFeedModel;
private int downloadChildPosition = -1; private int downloadChildPosition = -1;
private PostsLayoutPreferences layoutPreferences = PostsLayoutPreferences.fromJson(settingsHelper.getString(Constants.PREF_HASHTAG_POSTS_LAYOUT)); private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_HASHTAG_POSTS_LAYOUT);
private LayoutHashtagDetailsBinding hashtagDetailsBinding;
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) { private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) {
@Override @Override
@ -198,15 +200,18 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
Utils.openEmailAddress(getContext(), emailId); Utils.openEmailAddress(getContext(), emailId);
} }
private void openPostDialog(final FeedModel feedModel, private void openPostDialog(@NonNull final FeedModel feedModel,
final View profilePicView, final View profilePicView,
final View mainPostImage, final View mainPostImage,
final int position) { final int position) {
if (opening) return; if (opening) return;
if (TextUtils.isEmpty(feedModel.getProfileModel().getUsername())) { if (TextUtils.isEmpty(feedModel.getProfileModel().getUsername())) {
opening = true; opening = true;
new PostFetcher(feedModel.getShortCode(), newFeedModel -> openPostDialog(newFeedModel, profilePicView, mainPostImage, position)) new PostFetcher(feedModel.getShortCode(), newFeedModel -> {
.execute(); opening = false;
if (newFeedModel == null) return;
openPostDialog(newFeedModel, profilePicView, mainPostImage, position);
}).execute();
return; return;
} }
opening = true; opening = true;
@ -272,10 +277,13 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
if (root != null) { if (root != null) {
shouldRefresh = false; shouldRefresh = false;
fragmentActivity.setCollapsingView(hashtagDetailsBinding.getRoot());
return root; return root;
} }
binding = FragmentHashtagBinding.inflate(inflater, container, false); binding = FragmentHashtagBinding.inflate(inflater, container, false);
root = binding.getRoot(); root = binding.getRoot();
hashtagDetailsBinding = LayoutHashtagDetailsBinding.inflate(inflater, fragmentActivity.getCollapsingToolbarView(), false);
fragmentActivity.setCollapsingView(hashtagDetailsBinding.getRoot());
return root; return root;
} }
@ -332,6 +340,14 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
} }
@Override
public void onDestroyView() {
super.onDestroyView();
if (hashtagDetailsBinding != null) {
fragmentActivity.removeCollapsingView(hashtagDetailsBinding.getRoot());
}
}
private void init() { private void init() {
if (getArguments() == null) return; if (getArguments() == null) return;
final String cookie = settingsHelper.getString(Constants.COOKIE); final String cookie = settingsHelper.getString(Constants.COOKIE);
@ -374,21 +390,21 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
private void setHashtagDetails() { private void setHashtagDetails() {
if (isLoggedIn) { if (isLoggedIn) {
binding.btnFollowTag.setVisibility(View.VISIBLE); hashtagDetailsBinding.btnFollowTag.setVisibility(View.VISIBLE);
binding.btnFollowTag.setText(hashtagModel.getFollowing() ? R.string.unfollow : R.string.follow); hashtagDetailsBinding.btnFollowTag.setText(hashtagModel.getFollowing() ? R.string.unfollow : R.string.follow);
binding.btnFollowTag.setChipIconResource(hashtagModel.getFollowing() hashtagDetailsBinding.btnFollowTag.setChipIconResource(hashtagModel.getFollowing()
? R.drawable.ic_outline_person_add_disabled_24 ? R.drawable.ic_outline_person_add_disabled_24
: R.drawable.ic_outline_person_add_24); : R.drawable.ic_outline_person_add_24);
binding.btnFollowTag.setOnClickListener(v -> { hashtagDetailsBinding.btnFollowTag.setOnClickListener(v -> {
final String cookie = settingsHelper.getString(Constants.COOKIE); final String cookie = settingsHelper.getString(Constants.COOKIE);
final String csrfToken = CookieUtils.getCsrfTokenFromCookie(cookie); final String csrfToken = CookieUtils.getCsrfTokenFromCookie(cookie);
if (csrfToken != null) { if (csrfToken != null) {
binding.btnFollowTag.setClickable(false); hashtagDetailsBinding.btnFollowTag.setClickable(false);
if (!hashtagModel.getFollowing()) { if (!hashtagModel.getFollowing()) {
tagsService.follow(hashtag.substring(1), csrfToken, new ServiceCallback<Boolean>() { tagsService.follow(hashtag.substring(1), csrfToken, new ServiceCallback<Boolean>() {
@Override @Override
public void onSuccess(final Boolean result) { public void onSuccess(final Boolean result) {
binding.btnFollowTag.setClickable(true); hashtagDetailsBinding.btnFollowTag.setClickable(true);
if (!result) { if (!result) {
Log.e(TAG, "onSuccess: result is false"); Log.e(TAG, "onSuccess: result is false");
return; return;
@ -398,7 +414,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
@Override @Override
public void onFailure(@NonNull final Throwable t) { public void onFailure(@NonNull final Throwable t) {
binding.btnFollowTag.setClickable(true); hashtagDetailsBinding.btnFollowTag.setClickable(true);
Log.e(TAG, "onFailure: ", t); Log.e(TAG, "onFailure: ", t);
final String message = t.getMessage(); final String message = t.getMessage();
Snackbar.make(root, Snackbar.make(root,
@ -413,7 +429,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
tagsService.unfollow(hashtag.substring(1), csrfToken, new ServiceCallback<Boolean>() { tagsService.unfollow(hashtag.substring(1), csrfToken, new ServiceCallback<Boolean>() {
@Override @Override
public void onSuccess(final Boolean result) { public void onSuccess(final Boolean result) {
binding.btnFollowTag.setClickable(true); hashtagDetailsBinding.btnFollowTag.setClickable(true);
if (!result) { if (!result) {
Log.e(TAG, "onSuccess: result is false"); Log.e(TAG, "onSuccess: result is false");
return; return;
@ -423,7 +439,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
@Override @Override
public void onFailure(@NonNull final Throwable t) { public void onFailure(@NonNull final Throwable t) {
binding.btnFollowTag.setClickable(true); hashtagDetailsBinding.btnFollowTag.setClickable(true);
Log.e(TAG, "onFailure: ", t); Log.e(TAG, "onFailure: ", t);
final String message = t.getMessage(); final String message = t.getMessage();
Snackbar.make(root, Snackbar.make(root,
@ -436,22 +452,22 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
}); });
} else { } else {
binding.btnFollowTag.setVisibility(View.GONE); hashtagDetailsBinding.btnFollowTag.setVisibility(View.GONE);
} }
final DataBox.FavoriteModel favorite = Utils.dataBox.getFavorite(hashtag.substring(1), FavoriteType.HASHTAG); final DataBox.FavoriteModel favorite = Utils.dataBox.getFavorite(hashtag.substring(1), FavoriteType.HASHTAG);
final boolean isFav = favorite != null; final boolean isFav = favorite != null;
binding.favChip.setVisibility(View.VISIBLE); hashtagDetailsBinding.favChip.setVisibility(View.VISIBLE);
binding.favChip.setChipIconResource(isFav ? R.drawable.ic_star_check_24 hashtagDetailsBinding.favChip.setChipIconResource(isFav ? R.drawable.ic_star_check_24
: R.drawable.ic_outline_star_plus_24); : R.drawable.ic_outline_star_plus_24);
binding.favChip.setText(isFav ? R.string.favorite_short : R.string.add_to_favorites); hashtagDetailsBinding.favChip.setText(isFav ? R.string.favorite_short : R.string.add_to_favorites);
binding.favChip.setOnClickListener(v -> { hashtagDetailsBinding.favChip.setOnClickListener(v -> {
final DataBox.FavoriteModel fav = Utils.dataBox.getFavorite(hashtag.substring(1), FavoriteType.HASHTAG); final DataBox.FavoriteModel fav = Utils.dataBox.getFavorite(hashtag.substring(1), FavoriteType.HASHTAG);
final boolean isFavorite = fav != null; final boolean isFavorite = fav != null;
final String message; final String message;
if (isFavorite) { if (isFavorite) {
Utils.dataBox.deleteFavorite(hashtag.substring(1), FavoriteType.HASHTAG); Utils.dataBox.deleteFavorite(hashtag.substring(1), FavoriteType.HASHTAG);
binding.favChip.setText(R.string.add_to_favorites); hashtagDetailsBinding.favChip.setText(R.string.add_to_favorites);
binding.favChip.setChipIconResource(R.drawable.ic_outline_star_plus_24); hashtagDetailsBinding.favChip.setChipIconResource(R.drawable.ic_outline_star_plus_24);
message = getString(R.string.removed_from_favs); message = getString(R.string.removed_from_favs);
} else { } else {
Utils.dataBox.addOrUpdateFavorite(new DataBox.FavoriteModel( Utils.dataBox.addOrUpdateFavorite(new DataBox.FavoriteModel(
@ -462,8 +478,8 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
null, null,
new Date() new Date()
)); ));
binding.favChip.setText(R.string.favorite_short); hashtagDetailsBinding.favChip.setText(R.string.favorite_short);
binding.favChip.setChipIconResource(R.drawable.ic_star_check_24); hashtagDetailsBinding.favChip.setChipIconResource(R.drawable.ic_star_check_24);
message = getString(R.string.added_to_favs); message = getString(R.string.added_to_favs);
} }
final Snackbar snackbar = Snackbar.make(root, message, BaseTransientBottomBar.LENGTH_LONG); final Snackbar snackbar = Snackbar.make(root, message, BaseTransientBottomBar.LENGTH_LONG);
@ -472,14 +488,14 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
.setAnchorView(fragmentActivity.getBottomNavView()) .setAnchorView(fragmentActivity.getBottomNavView())
.show(); .show();
}); });
binding.mainHashtagImage.setImageURI(hashtagModel.getSdProfilePic()); hashtagDetailsBinding.mainHashtagImage.setImageURI(hashtagModel.getSdProfilePic());
final String postCount = String.valueOf(hashtagModel.getPostCount()); final String postCount = String.valueOf(hashtagModel.getPostCount());
final SpannableStringBuilder span = new SpannableStringBuilder(getString(R.string.main_posts_count_inline, postCount)); final SpannableStringBuilder span = new SpannableStringBuilder(getString(R.string.main_posts_count_inline, postCount));
span.setSpan(new RelativeSizeSpan(1.2f), 0, postCount.length(), 0); span.setSpan(new RelativeSizeSpan(1.2f), 0, postCount.length(), 0);
span.setSpan(new StyleSpan(Typeface.BOLD), 0, postCount.length(), 0); span.setSpan(new StyleSpan(Typeface.BOLD), 0, postCount.length(), 0);
binding.mainTagPostCount.setText(span); hashtagDetailsBinding.mainTagPostCount.setText(span);
binding.mainTagPostCount.setVisibility(View.VISIBLE); hashtagDetailsBinding.mainTagPostCount.setVisibility(View.VISIBLE);
binding.mainHashtagImage.setOnClickListener(v -> { hashtagDetailsBinding.mainHashtagImage.setOnClickListener(v -> {
if (!hasStories) return; if (!hasStories) return;
// show stories // show stories
final NavDirections action = HashTagFragmentDirections final NavDirections action = HashTagFragmentDirections
@ -501,7 +517,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
@Override @Override
public void onSuccess(final List<StoryModel> storyModels) { public void onSuccess(final List<StoryModel> storyModels) {
if (storyModels != null && !storyModels.isEmpty()) { if (storyModels != null && !storyModels.isEmpty()) {
binding.mainHashtagImage.setStoriesBorder(); hashtagDetailsBinding.mainHashtagImage.setStoriesBorder();
hasStories = true; hasStories = true;
} else { } else {
hasStories = false; hasStories = false;

View File

@ -27,6 +27,7 @@ import androidx.activity.OnBackPressedDispatcher;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.PermissionChecker; import androidx.core.content.PermissionChecker;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.NavController; import androidx.navigation.NavController;
@ -49,8 +50,8 @@ import awais.instagrabber.asyncs.LocationFetcher;
import awais.instagrabber.asyncs.LocationPostFetchService; import awais.instagrabber.asyncs.LocationPostFetchService;
import awais.instagrabber.asyncs.PostFetcher; import awais.instagrabber.asyncs.PostFetcher;
import awais.instagrabber.customviews.PrimaryActionModeCallback; import awais.instagrabber.customviews.PrimaryActionModeCallback;
import awais.instagrabber.customviews.helpers.NestedCoordinatorLayout;
import awais.instagrabber.databinding.FragmentLocationBinding; import awais.instagrabber.databinding.FragmentLocationBinding;
import awais.instagrabber.databinding.LayoutLocationDetailsBinding;
import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment; import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment;
import awais.instagrabber.models.FeedModel; import awais.instagrabber.models.FeedModel;
import awais.instagrabber.models.LocationModel; import awais.instagrabber.models.LocationModel;
@ -79,7 +80,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
private MainActivity fragmentActivity; private MainActivity fragmentActivity;
private FragmentLocationBinding binding; private FragmentLocationBinding binding;
private NestedCoordinatorLayout root; private CoordinatorLayout root;
private boolean shouldRefresh = true; private boolean shouldRefresh = true;
private boolean hasStories = false; private boolean hasStories = false;
private boolean opening = false; private boolean opening = false;
@ -93,8 +94,8 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
private Set<FeedModel> selectedFeedModels; private Set<FeedModel> selectedFeedModels;
private FeedModel downloadFeedModel; private FeedModel downloadFeedModel;
private int downloadChildPosition = -1; private int downloadChildPosition = -1;
private PostsLayoutPreferences layoutPreferences = PostsLayoutPreferences private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_LOCATION_POSTS_LAYOUT);
.fromJson(settingsHelper.getString(Constants.PREF_LOCATION_POSTS_LAYOUT)); private LayoutLocationDetailsBinding locationDetailsBinding;
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) { private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) {
@Override @Override
@ -197,15 +198,18 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
Utils.openEmailAddress(getContext(), emailId); Utils.openEmailAddress(getContext(), emailId);
} }
private void openPostDialog(final FeedModel feedModel, private void openPostDialog(@NonNull final FeedModel feedModel,
final View profilePicView, final View profilePicView,
final View mainPostImage, final View mainPostImage,
final int position) { final int position) {
if (opening) return; if (opening) return;
if (TextUtils.isEmpty(feedModel.getProfileModel().getUsername())) { if (TextUtils.isEmpty(feedModel.getProfileModel().getUsername())) {
opening = true; opening = true;
new PostFetcher(feedModel.getShortCode(), newFeedModel -> openPostDialog(newFeedModel, profilePicView, mainPostImage, position)) new PostFetcher(feedModel.getShortCode(), newFeedModel -> {
.execute(); opening = false;
if (newFeedModel == null) return;
openPostDialog(newFeedModel, profilePicView, mainPostImage, position);
}).execute();
return; return;
} }
opening = true; opening = true;
@ -273,10 +277,13 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
@Nullable final Bundle savedInstanceState) { @Nullable final Bundle savedInstanceState) {
if (root != null) { if (root != null) {
shouldRefresh = false; shouldRefresh = false;
fragmentActivity.setCollapsingView(locationDetailsBinding.getRoot());
return root; return root;
} }
binding = FragmentLocationBinding.inflate(inflater, container, false); binding = FragmentLocationBinding.inflate(inflater, container, false);
root = binding.getRoot(); root = binding.getRoot();
locationDetailsBinding = LayoutLocationDetailsBinding.inflate(inflater, fragmentActivity.getCollapsingToolbarView(), false);
fragmentActivity.setCollapsingView(locationDetailsBinding.getRoot());
return root; return root;
} }
@ -333,14 +340,22 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
} }
} }
@Override
public void onDestroyView() {
super.onDestroyView();
if (locationDetailsBinding != null) {
fragmentActivity.removeCollapsingView(locationDetailsBinding.getRoot());
}
}
private void init() { private void init() {
if (getArguments() == null) return; if (getArguments() == null) return;
final String cookie = settingsHelper.getString(Constants.COOKIE); final String cookie = settingsHelper.getString(Constants.COOKIE);
isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) != null; isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) != null;
final LocationFragmentArgs fragmentArgs = LocationFragmentArgs.fromBundle(getArguments()); final LocationFragmentArgs fragmentArgs = LocationFragmentArgs.fromBundle(getArguments());
locationId = fragmentArgs.getLocationId(); locationId = fragmentArgs.getLocationId();
binding.favChip.setVisibility(View.GONE); locationDetailsBinding.favChip.setVisibility(View.GONE);
binding.btnMap.setVisibility(View.GONE); locationDetailsBinding.btnMap.setVisibility(View.GONE);
setTitle(); setTitle();
fetchLocationModel(); fetchLocationModel();
} }
@ -380,68 +395,68 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
private void setupLocationDetails() { private void setupLocationDetails() {
final String locationId = locationModel.getId(); final String locationId = locationModel.getId();
// binding.swipeRefreshLayout.setRefreshing(true); // binding.swipeRefreshLayout.setRefreshing(true);
binding.mainLocationImage.setImageURI(locationModel.getSdProfilePic()); locationDetailsBinding.mainLocationImage.setImageURI(locationModel.getSdProfilePic());
final String postCount = String.valueOf(locationModel.getPostCount()); final String postCount = String.valueOf(locationModel.getPostCount());
final SpannableStringBuilder span = new SpannableStringBuilder(getString(R.string.main_posts_count_inline, final SpannableStringBuilder span = new SpannableStringBuilder(getString(R.string.main_posts_count_inline,
postCount)); postCount));
span.setSpan(new RelativeSizeSpan(1.2f), 0, postCount.length(), 0); span.setSpan(new RelativeSizeSpan(1.2f), 0, postCount.length(), 0);
span.setSpan(new StyleSpan(Typeface.BOLD), 0, postCount.length(), 0); span.setSpan(new StyleSpan(Typeface.BOLD), 0, postCount.length(), 0);
binding.mainLocPostCount.setText(span); locationDetailsBinding.mainLocPostCount.setText(span);
binding.mainLocPostCount.setVisibility(View.VISIBLE); locationDetailsBinding.mainLocPostCount.setVisibility(View.VISIBLE);
binding.locationFullName.setText(locationModel.getName()); locationDetailsBinding.locationFullName.setText(locationModel.getName());
CharSequence biography = locationModel.getBio(); CharSequence biography = locationModel.getBio();
// binding.locationBiography.setCaptionIsExpandable(true); // binding.locationBiography.setCaptionIsExpandable(true);
// binding.locationBiography.setCaptionIsExpanded(true); // binding.locationBiography.setCaptionIsExpanded(true);
if (TextUtils.isEmpty(biography)) { if (TextUtils.isEmpty(biography)) {
binding.locationBiography.setVisibility(View.GONE); locationDetailsBinding.locationBiography.setVisibility(View.GONE);
} else if (TextUtils.hasMentions(biography)) { } else if (TextUtils.hasMentions(biography)) {
binding.locationBiography.setVisibility(View.VISIBLE); locationDetailsBinding.locationBiography.setVisibility(View.VISIBLE);
biography = TextUtils.getMentionText(biography); biography = TextUtils.getMentionText(biography);
binding.locationBiography.setText(biography, TextView.BufferType.SPANNABLE); locationDetailsBinding.locationBiography.setText(biography, TextView.BufferType.SPANNABLE);
// binding.locationBiography.setMentionClickListener(mentionClickListener); // binding.locationBiography.setMentionClickListener(mentionClickListener);
} else { } else {
binding.locationBiography.setVisibility(View.VISIBLE); locationDetailsBinding.locationBiography.setVisibility(View.VISIBLE);
binding.locationBiography.setText(biography); locationDetailsBinding.locationBiography.setText(biography);
binding.locationBiography.setMentionClickListener(null); locationDetailsBinding.locationBiography.setMentionClickListener(null);
} }
if (!locationModel.getGeo().startsWith("geo:0.0,0.0?z=17")) { if (!locationModel.getGeo().startsWith("geo:0.0,0.0?z=17")) {
binding.btnMap.setVisibility(View.VISIBLE); locationDetailsBinding.btnMap.setVisibility(View.VISIBLE);
binding.btnMap.setOnClickListener(v -> { locationDetailsBinding.btnMap.setOnClickListener(v -> {
final Intent intent = new Intent(Intent.ACTION_VIEW); final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(locationModel.getGeo())); intent.setData(Uri.parse(locationModel.getGeo()));
startActivity(intent); startActivity(intent);
}); });
} else { } else {
binding.btnMap.setVisibility(View.GONE); locationDetailsBinding.btnMap.setVisibility(View.GONE);
binding.btnMap.setOnClickListener(null); locationDetailsBinding.btnMap.setOnClickListener(null);
} }
final String url = locationModel.getUrl(); final String url = locationModel.getUrl();
if (TextUtils.isEmpty(url)) { if (TextUtils.isEmpty(url)) {
binding.locationUrl.setVisibility(View.GONE); locationDetailsBinding.locationUrl.setVisibility(View.GONE);
} else if (!url.startsWith("http")) { } else if (!url.startsWith("http")) {
binding.locationUrl.setVisibility(View.VISIBLE); locationDetailsBinding.locationUrl.setVisibility(View.VISIBLE);
binding.locationUrl.setText(TextUtils.getSpannableUrl("http://" + url)); locationDetailsBinding.locationUrl.setText(TextUtils.getSpannableUrl("http://" + url));
} else { } else {
binding.locationUrl.setVisibility(View.VISIBLE); locationDetailsBinding.locationUrl.setVisibility(View.VISIBLE);
binding.locationUrl.setText(TextUtils.getSpannableUrl(url)); locationDetailsBinding.locationUrl.setText(TextUtils.getSpannableUrl(url));
} }
final DataBox.FavoriteModel favorite = Utils.dataBox.getFavorite(locationId, FavoriteType.LOCATION); final DataBox.FavoriteModel favorite = Utils.dataBox.getFavorite(locationId, FavoriteType.LOCATION);
final boolean isFav = favorite != null; final boolean isFav = favorite != null;
binding.favChip.setVisibility(View.VISIBLE); locationDetailsBinding.favChip.setVisibility(View.VISIBLE);
binding.favChip.setChipIconResource(isFav ? R.drawable.ic_star_check_24 locationDetailsBinding.favChip.setChipIconResource(isFav ? R.drawable.ic_star_check_24
: R.drawable.ic_outline_star_plus_24); : R.drawable.ic_outline_star_plus_24);
binding.favChip.setText(isFav ? R.string.favorite_short : R.string.add_to_favorites); locationDetailsBinding.favChip.setText(isFav ? R.string.favorite_short : R.string.add_to_favorites);
binding.favChip.setOnClickListener(v -> { locationDetailsBinding.favChip.setOnClickListener(v -> {
final DataBox.FavoriteModel fav = Utils.dataBox.getFavorite(locationId, FavoriteType.LOCATION); final DataBox.FavoriteModel fav = Utils.dataBox.getFavorite(locationId, FavoriteType.LOCATION);
final boolean isFavorite = fav != null; final boolean isFavorite = fav != null;
final String message; final String message;
if (isFavorite) { if (isFavorite) {
Utils.dataBox.deleteFavorite(locationId, FavoriteType.LOCATION); Utils.dataBox.deleteFavorite(locationId, FavoriteType.LOCATION);
binding.favChip.setText(R.string.add_to_favorites); locationDetailsBinding.favChip.setText(R.string.add_to_favorites);
binding.favChip.setChipIconResource(R.drawable.ic_outline_star_plus_24); locationDetailsBinding.favChip.setChipIconResource(R.drawable.ic_outline_star_plus_24);
message = getString(R.string.removed_from_favs); message = getString(R.string.removed_from_favs);
} else { } else {
Utils.dataBox.addOrUpdateFavorite(new DataBox.FavoriteModel( Utils.dataBox.addOrUpdateFavorite(new DataBox.FavoriteModel(
@ -452,8 +467,8 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
locationModel.getSdProfilePic(), locationModel.getSdProfilePic(),
new Date() new Date()
)); ));
binding.favChip.setText(R.string.favorite_short); locationDetailsBinding.favChip.setText(R.string.favorite_short);
binding.favChip.setChipIconResource(R.drawable.ic_star_check_24); locationDetailsBinding.favChip.setChipIconResource(R.drawable.ic_star_check_24);
message = getString(R.string.added_to_favs); message = getString(R.string.added_to_favs);
} }
final Snackbar snackbar = Snackbar.make(root, message, BaseTransientBottomBar.LENGTH_LONG); final Snackbar snackbar = Snackbar.make(root, message, BaseTransientBottomBar.LENGTH_LONG);
@ -462,7 +477,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
.setAnchorView(fragmentActivity.getBottomNavView()) .setAnchorView(fragmentActivity.getBottomNavView())
.show(); .show();
}); });
binding.mainLocationImage.setOnClickListener(v -> { locationDetailsBinding.mainLocationImage.setOnClickListener(v -> {
if (hasStories) { if (hasStories) {
// show stories // show stories
final NavDirections action = LocationFragmentDirections final NavDirections action = LocationFragmentDirections
@ -484,7 +499,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
@Override @Override
public void onSuccess(final List<StoryModel> storyModels) { public void onSuccess(final List<StoryModel> storyModels) {
if (storyModels != null && !storyModels.isEmpty()) { if (storyModels != null && !storyModels.isEmpty()) {
binding.mainLocationImage.setStoriesBorder(); locationDetailsBinding.mainLocationImage.setStoriesBorder();
hasStories = true; hasStories = true;
} }
storiesFetching = false; storiesFetching = false;

View File

@ -35,6 +35,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.PermissionChecker; import androidx.core.content.PermissionChecker;
import androidx.core.view.ViewCompat;
import androidx.core.widget.NestedScrollView; import androidx.core.widget.NestedScrollView;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import androidx.navigation.NavController; import androidx.navigation.NavController;
@ -71,6 +72,7 @@ import awais.instagrabber.customviews.drawee.AnimatedZoomableController;
import awais.instagrabber.databinding.DialogPostViewBinding; import awais.instagrabber.databinding.DialogPostViewBinding;
import awais.instagrabber.models.FeedModel; import awais.instagrabber.models.FeedModel;
import awais.instagrabber.models.PostChild; import awais.instagrabber.models.PostChild;
import awais.instagrabber.models.ProfileModel;
import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.CookieUtils; import awais.instagrabber.utils.CookieUtils;
@ -111,6 +113,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
private int sliderPosition = -1; private int sliderPosition = -1;
private DialogInterface.OnShowListener onShowListener; private DialogInterface.OnShowListener onShowListener;
private boolean isLoggedIn; private boolean isLoggedIn;
private boolean hasBeenToggled = false;
private final VerticalDragHelper.OnVerticalDragListener onVerticalDragListener = new VerticalDragHelper.OnVerticalDragListener() { private final VerticalDragHelper.OnVerticalDragListener onVerticalDragListener = new VerticalDragHelper.OnVerticalDragListener() {
@ -125,8 +128,8 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
@Override @Override
public void onDragEnd() { public void onDragEnd() {
// animate and dismiss if user drags the view more that 30% of the view // animate and dismiss if user drags the view more that 30% of the view
if (Math.abs(binding.getRoot().getY()) > Utils.displayMetrics.heightPixels * 0.35) { if (Math.abs(binding.getRoot().getY()) > Utils.displayMetrics.heightPixels * 0.25) {
animateAndDismiss(binding.getRoot().getY() < 0 ? -1 : 1); animateAndDismiss(binding.getRoot().getY() < 0 ? 1 : -1);
return; return;
} }
// animate back the view to proper position // animate back the view to proper position
@ -134,16 +137,16 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
} }
@Override @Override
public void onFling(final float flingVelocity) { public void onFling(final double flingVelocity) {
// animate and dismiss if user flings up/down // animate and dismiss if user flings up/down
animateAndDismiss(flingVelocity < 0 ? -1 : 1); animateAndDismiss(flingVelocity > 0 ? 1 : -1);
} }
private void animateAndDismiss(final int direction) { private void animateAndDismiss(final int direction) {
final int height = binding.getRoot().getHeight(); final int height = binding.getRoot().getHeight();
final int finalYDist = height + Utils.getStatusBarHeight(context); final int finalYDist = height + Utils.getStatusBarHeight(context);
// less than 0 means up direction, else down // less than 0 means up direction, else down
final int finalY = direction < 0 ? -finalYDist : finalYDist; final int finalY = direction > 0 ? -finalYDist : finalYDist;
animateY(binding.getRoot(), finalY, 200, new AnimatorListenerAdapter() { animateY(binding.getRoot(), finalY, 200, new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(final Animator animation) { public void onAnimationEnd(final Animator animation) {
@ -231,6 +234,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
return; return;
} }
feedModel = (FeedModel) feedModelSerializable; feedModel = (FeedModel) feedModelSerializable;
if (feedModel == null) return;
if (feedModel.getItemType() == MediaItemType.MEDIA_TYPE_SLIDER) { if (feedModel.getItemType() == MediaItemType.MEDIA_TYPE_SLIDER) {
sliderPosition = arguments.getInt(ARG_SLIDER_POSITION, 0); sliderPosition = arguments.getInt(ARG_SLIDER_POSITION, 0);
} }
@ -242,12 +246,20 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
@Nullable final ViewGroup container, @Nullable final ViewGroup container,
@Nullable final Bundle savedInstanceState) { @Nullable final Bundle savedInstanceState) {
binding = DialogPostViewBinding.inflate(inflater, container, false); binding = DialogPostViewBinding.inflate(inflater, container, false);
return binding.getRoot(); final ConstraintLayout root = binding.getRoot();
final ViewTreeObserver.OnPreDrawListener preDrawListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
root.getViewTreeObserver().removeOnPreDrawListener(this);
return false;
}
};
root.getViewTreeObserver().addOnPreDrawListener(preDrawListener);
return root;
} }
@Override @Override
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) { public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
setupToolbar();
init(); init();
} }
@ -292,8 +304,8 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
} }
@Override @Override
public void onDestroy() { public void onDestroyView() {
super.onDestroy(); super.onDestroyView();
switch (feedModel.getItemType()) { switch (feedModel.getItemType()) {
case MEDIA_TYPE_VIDEO: case MEDIA_TYPE_VIDEO:
if (videoPlayerViewHelper != null) { if (videoPlayerViewHelper != null) {
@ -311,6 +323,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
@Override @Override
public void onSaveInstanceState(@NonNull final Bundle outState) { public void onSaveInstanceState(@NonNull final Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
if (feedModel == null) return;
if (feedModel.getItemType() == MediaItemType.MEDIA_TYPE_SLIDER) { if (feedModel.getItemType() == MediaItemType.MEDIA_TYPE_SLIDER) {
outState.putInt(ARG_SLIDER_POSITION, sliderPosition); outState.putInt(ARG_SLIDER_POSITION, sliderPosition);
} }
@ -400,6 +413,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
} }
private void init() { private void init() {
if (feedModel == null) return;
final String cookie = settingsHelper.getString(Constants.COOKIE); final String cookie = settingsHelper.getString(Constants.COOKIE);
isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) != null; isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) != null;
if (!wasPaused && (sharedProfilePicElement != null || sharedMainPostElement != null)) { if (!wasPaused && (sharedProfilePicElement != null || sharedMainPostElement != null)) {
@ -422,12 +436,14 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
private void setupComment() { private void setupComment() {
binding.comment.setOnClickListener(v -> { binding.comment.setOnClickListener(v -> {
final ProfileModel profileModel = feedModel.getProfileModel();
if (profileModel == null) return;
final NavController navController = getNavController(); final NavController navController = getNavController();
if (navController == null) return; if (navController == null) return;
final Bundle bundle = new Bundle(); final Bundle bundle = new Bundle();
bundle.putString("shortCode", feedModel.getShortCode()); bundle.putString("shortCode", feedModel.getShortCode());
bundle.putString("postId", feedModel.getPostId()); bundle.putString("postId", feedModel.getPostId());
bundle.putString("postUserId", feedModel.getProfileModel().getId()); bundle.putString("postUserId", profileModel.getId());
navController.navigate(R.id.action_global_commentsViewerFragment, bundle); navController.navigate(R.id.action_global_commentsViewerFragment, bundle);
}); });
binding.comment.setOnLongClickListener(v -> { binding.comment.setOnLongClickListener(v -> {
@ -505,12 +521,12 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
final String userId = CookieUtils.getUserIdFromCookie(COOKIE); final String userId = CookieUtils.getUserIdFromCookie(COOKIE);
final String csrfToken = CookieUtils.getCsrfTokenFromCookie(COOKIE); final String csrfToken = CookieUtils.getCsrfTokenFromCookie(COOKIE);
v.setEnabled(false); v.setEnabled(false);
final int textRes; // final int textRes;
if (!feedModel.getLike()) { // if (!feedModel.getLike()) {
textRes = R.string.liking; // textRes = R.string.liking;
} else { // } else {
textRes = R.string.unliking; // textRes = R.string.unliking;
} // }
if (!feedModel.getLike()) { if (!feedModel.getLike()) {
mediaService.like(feedModel.getPostId(), userId, csrfToken, likeCallback); mediaService.like(feedModel.getPostId(), userId, csrfToken, likeCallback);
} else { } else {
@ -526,15 +542,15 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
private void setLikedResources(final boolean liked) { private void setLikedResources(final boolean liked) {
final int iconResource; final int iconResource;
final int tintResource; final int tintResource;
final int textResId; // final int textResId;
if (liked) { if (liked) {
iconResource = R.drawable.ic_like; iconResource = R.drawable.ic_like;
tintResource = R.color.red_600; tintResource = R.color.red_600;
textResId = R.string.unlike_without_count; // textResId = R.string.unlike_without_count;
} else { } else {
iconResource = R.drawable.ic_not_liked; iconResource = R.drawable.ic_not_liked;
tintResource = R.color.white; tintResource = R.color.white;
textResId = R.string.like_without_count; // textResId = R.string.like_without_count;
} }
binding.like.setIconResource(iconResource); binding.like.setIconResource(iconResource);
binding.like.setIconTintResource(tintResource); binding.like.setIconTintResource(tintResource);
@ -586,12 +602,12 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
final String userId = CookieUtils.getUserIdFromCookie(COOKIE); final String userId = CookieUtils.getUserIdFromCookie(COOKIE);
final String csrfToken = CookieUtils.getCsrfTokenFromCookie(COOKIE); final String csrfToken = CookieUtils.getCsrfTokenFromCookie(COOKIE);
binding.save.setEnabled(false); binding.save.setEnabled(false);
final int textRes; // final int textRes;
if (!feedModel.isSaved()) { // if (!feedModel.isSaved()) {
textRes = R.string.saving; // textRes = R.string.saving;
} else { // } else {
textRes = R.string.removing; // textRes = R.string.removing;
} // }
if (!feedModel.isSaved()) { if (!feedModel.isSaved()) {
mediaService.save(feedModel.getPostId(), userId, csrfToken, saveCallback); mediaService.save(feedModel.getPostId(), userId, csrfToken, saveCallback);
} else { } else {
@ -607,15 +623,15 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
private void setSavedResources(final boolean saved) { private void setSavedResources(final boolean saved) {
final int iconResource; final int iconResource;
final int tintResource; final int tintResource;
final int textResId; // final int textResId;
if (saved) { if (saved) {
iconResource = R.drawable.ic_class_24; iconResource = R.drawable.ic_class_24;
tintResource = R.color.blue_700; tintResource = R.color.blue_700;
textResId = R.string.saved; // textResId = R.string.saved;
} else { } else {
iconResource = R.drawable.ic_outline_class_24; iconResource = R.drawable.ic_outline_class_24;
tintResource = R.color.white; tintResource = R.color.white;
textResId = R.string.save; // textResId = R.string.save;
} }
binding.save.setIconResource(iconResource); binding.save.setIconResource(iconResource);
binding.save.setIconTintResource(tintResource); binding.save.setIconTintResource(tintResource);
@ -626,7 +642,12 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
if (!wasPaused && sharedProfilePicElement != null) { if (!wasPaused && sharedProfilePicElement != null) {
addSharedElement(sharedProfilePicElement, binding.profilePic); addSharedElement(sharedProfilePicElement, binding.profilePic);
} }
final String uri = feedModel.getProfileModel().getSdProfilePic(); final ProfileModel profileModel = feedModel.getProfileModel();
if (profileModel == null) {
binding.profilePic.setVisibility(View.GONE);
return;
}
final String uri = profileModel.getSdProfilePic();
final ImageRequest requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)).build(); final ImageRequest requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)).build();
final DraweeController controller = Fresco final DraweeController controller = Fresco
.newDraweeControllerBuilder() .newDraweeControllerBuilder()
@ -647,23 +668,22 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
}) })
.build(); .build();
binding.profilePic.setController(controller); binding.profilePic.setController(controller);
binding.profilePic.setOnClickListener(v -> navigateToProfile("@" + feedModel.getProfileModel().getUsername())); binding.profilePic.setOnClickListener(v -> navigateToProfile("@" + profileModel.getUsername()));
}
private void setupToolbar() {
// fragmentActivity.fitSystemWindows(true);
// final ActionBar actionBar = fragmentActivity.getSupportActionBar();
// if (actionBar == null) return;
// actionBar.setTitle(null);
// actionBar.setSubtitle(null);
} }
private void setupTitles() { private void setupTitles() {
binding.title.setText(feedModel.getProfileModel().getUsername()); final ProfileModel profileModel = feedModel.getProfileModel();
binding.righttitle.setText(feedModel.getProfileModel().getName()); if (profileModel == null) {
binding.isVerified.setVisibility(feedModel.getProfileModel().isVerified() ? View.VISIBLE : View.GONE); binding.title.setVisibility(View.GONE);
binding.title.setOnClickListener(v -> navigateToProfile("@" + feedModel.getProfileModel().getUsername())); binding.righttitle.setVisibility(View.GONE);
binding.righttitle.setOnClickListener(v -> navigateToProfile("@" + feedModel.getProfileModel().getUsername())); binding.subtitle.setVisibility(View.GONE);
return;
}
binding.title.setText(profileModel.getUsername());
binding.righttitle.setText(profileModel.getName());
binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE);
binding.title.setOnClickListener(v -> navigateToProfile("@" + profileModel.getUsername()));
binding.righttitle.setOnClickListener(v -> navigateToProfile("@" + profileModel.getUsername()));
final String locationName = feedModel.getLocationName(); final String locationName = feedModel.getLocationName();
if (!TextUtils.isEmpty(locationName)) { if (!TextUtils.isEmpty(locationName)) {
binding.subtitle.setText(locationName); binding.subtitle.setText(locationName);
@ -761,7 +781,9 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
return true; return true;
}); });
binding.share.setOnClickListener(v -> { binding.share.setOnClickListener(v -> {
final boolean isPrivate = feedModel.getProfileModel().isPrivate(); final ProfileModel profileModel = feedModel.getProfileModel();
if (profileModel == null) return;
final boolean isPrivate = profileModel.isPrivate();
if (isPrivate) if (isPrivate)
Toast.makeText(context, R.string.share_private_post, Toast.LENGTH_LONG).show(); Toast.makeText(context, R.string.share_private_post, Toast.LENGTH_LONG).show();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
@ -849,6 +871,20 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
if (!wasPaused && sharedMainPostElement != null) { if (!wasPaused && sharedMainPostElement != null) {
addSharedElement(sharedMainPostElement, binding.sliderParent); addSharedElement(sharedMainPostElement, binding.sliderParent);
} }
final boolean hasVideo = feedModel.getSliderItems()
.stream()
.anyMatch(postChild -> postChild.getItemType() == MediaItemType.MEDIA_TYPE_VIDEO);
if (hasVideo) {
final View child = binding.sliderParent.getChildAt(0);
if (child instanceof RecyclerView) {
((RecyclerView) child).setItemViewCacheSize(feedModel.getSliderItems().size());
((RecyclerView) child).addRecyclerListener(holder -> {
if (holder instanceof SliderVideoViewHolder) {
((SliderVideoViewHolder) holder).releasePlayer();
}
});
}
}
sliderItemsAdapter = new SliderItemsAdapter(onVerticalDragListener, binding.playerControls, true, new SliderCallbackAdapter() { sliderItemsAdapter = new SliderItemsAdapter(onVerticalDragListener, binding.playerControls, true, new SliderCallbackAdapter() {
@Override @Override
public void onThumbnailLoaded(final int position) { public void onThumbnailLoaded(final int position) {
@ -858,19 +894,17 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
@Override @Override
public void onItemClicked(final int position) { public void onItemClicked(final int position) {
toggleDetails();
} }
@Override @Override
public void onPlayerPlay(final int position) { public void onPlayerPlay(final int position) {
if (!detailsVisible) return; if (!detailsVisible || hasBeenToggled) return;
toggleDetails();
showPlayerControls(); showPlayerControls();
} }
@Override @Override
public void onPlayerPause(final int position) { public void onPlayerPause(final int position) {
if (detailsVisible) return; if (detailsVisible || hasBeenToggled) return;
toggleDetails(); toggleDetails();
} }
}); });
@ -903,7 +937,22 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
final String text = (position + 1) + "/" + size; final String text = (position + 1) + "/" + size;
binding.mediaCounter.setText(text); binding.mediaCounter.setText(text);
final PostChild postChild = feedModel.getSliderItems().get(position); final PostChild postChild = feedModel.getSliderItems().get(position);
final View view = binding.sliderParent.getChildAt(0);
if (prevPosition != -1) {
if (view instanceof RecyclerView) {
final RecyclerView.ViewHolder viewHolder = ((RecyclerView) view).findViewHolderForAdapterPosition(prevPosition);
if (viewHolder instanceof SliderVideoViewHolder) {
((SliderVideoViewHolder) viewHolder).removeCallbacks();
}
}
}
if (postChild.getItemType() == MediaItemType.MEDIA_TYPE_VIDEO) { if (postChild.getItemType() == MediaItemType.MEDIA_TYPE_VIDEO) {
if (view instanceof RecyclerView) {
final RecyclerView.ViewHolder viewHolder = ((RecyclerView) view).findViewHolderForAdapterPosition(position);
if (viewHolder instanceof SliderVideoViewHolder) {
((SliderVideoViewHolder) viewHolder).resetPlayerTimeline();
}
}
enablePlayerControls(true); enablePlayerControls(true);
return; return;
} }
@ -1029,9 +1078,15 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
private void showPlayerControls() { private void showPlayerControls() {
hideCaption(); hideCaption();
// previously invisible view // previously invisible view
View view = binding.playerControls.getRoot(); View view = binding.playerControls.getRoot();
if (view != null && view.getVisibility() == View.VISIBLE) {
return;
}
if (!ViewCompat.isAttachedToWindow(view)) {
view.setVisibility(View.VISIBLE);
return;
}
// get the center for the clipping circle // get the center for the clipping circle
int cx = view.getWidth() / 2; int cx = view.getWidth() / 2;
// int cy = view.getHeight() / 2; // int cy = view.getHeight() / 2;
@ -1052,6 +1107,13 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
private void hidePlayerControls() { private void hidePlayerControls() {
// previously visible view // previously visible view
final View view = binding.playerControls.getRoot(); final View view = binding.playerControls.getRoot();
if (view != null && view.getVisibility() == View.GONE) {
return;
}
if (!ViewCompat.isAttachedToWindow(view)) {
view.setVisibility(View.GONE);
return;
}
// get the center for the clipping circle // get the center for the clipping circle
int cx = view.getWidth() / 2; int cx = view.getWidth() / 2;
@ -1078,6 +1140,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
} }
private void toggleDetails() { private void toggleDetails() {
hasBeenToggled = true;
binding.getRoot().post(() -> { binding.getRoot().post(() -> {
TransitionManager.beginDelayedTransition(binding.getRoot()); TransitionManager.beginDelayedTransition(binding.getRoot());
if (detailsVisible) { if (detailsVisible) {
@ -1111,7 +1174,9 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
} }
binding.profilePic.setVisibility(View.VISIBLE); binding.profilePic.setVisibility(View.VISIBLE);
binding.title.setVisibility(View.VISIBLE); binding.title.setVisibility(View.VISIBLE);
binding.isVerified.setVisibility(feedModel.getProfileModel().isVerified() ? View.VISIBLE : View.GONE); binding.isVerified.setVisibility(feedModel.getProfileModel() != null
? feedModel.getProfileModel().isVerified() ? View.VISIBLE : View.GONE
: View.GONE);
binding.righttitle.setVisibility(View.VISIBLE); binding.righttitle.setVisibility(View.VISIBLE);
binding.topBg.setVisibility(View.VISIBLE); binding.topBg.setVisibility(View.VISIBLE);
if (!TextUtils.isEmpty(binding.subtitle.getText())) { if (!TextUtils.isEmpty(binding.subtitle.getText())) {

View File

@ -45,7 +45,6 @@ import awais.instagrabber.utils.Utils;
import static androidx.core.content.PermissionChecker.checkSelfPermission; import static androidx.core.content.PermissionChecker.checkSelfPermission;
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION; import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
import static awais.instagrabber.utils.Utils.settingsHelper;
public final class SavedViewerFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { public final class SavedViewerFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
private static final int STORAGE_PERM_REQUEST_CODE = 8020; private static final int STORAGE_PERM_REQUEST_CODE = 8020;
@ -62,7 +61,7 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
private Set<FeedModel> selectedFeedModels; private Set<FeedModel> selectedFeedModels;
private FeedModel downloadFeedModel; private FeedModel downloadFeedModel;
private int downloadChildPosition = -1; private int downloadChildPosition = -1;
private PostsLayoutPreferences layoutPreferences = PostsLayoutPreferences.fromJson(settingsHelper.getString(getPostsLayoutPreferenceKey())); private PostsLayoutPreferences layoutPreferences;
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) { private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) {
@Override @Override
@ -275,46 +274,8 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
username = fragmentArgs.getUsername(); username = fragmentArgs.getUsername();
profileId = fragmentArgs.getProfileId(); profileId = fragmentArgs.getProfileId();
type = fragmentArgs.getType(); type = fragmentArgs.getType();
layoutPreferences = Utils.getPostsLayoutPreferences(getPostsLayoutPreferenceKey());
setupPosts(); setupPosts();
// postsAdapter = new PostsAdapter((postModel, position) -> {
// if (postsAdapter.isSelecting()) {
// if (actionMode == null) return;
// final String title = getString(R.string.number_selected, postsAdapter.getSelectedModels().size());
// actionMode.setTitle(title);
// return;
// }
// if (checkAndResetAction()) return;
// final List<PostModel> postModels = postsViewModel.getList().getValue();
// if (postModels == null || postModels.size() == 0) return;
// if (postModels.get(0) == null) return;
// final String postId = postModels.get(0).getPostId();
// final boolean isId = postId != null;
// final String[] idsOrShortCodes = new String[postModels.size()];
// for (int i = 0; i < postModels.size(); i++) {
// final PostModel tempPostModel = postModels.get(i);
// final String tempId = tempPostModel.getPostId();
// final String finalPostId = type == PostItemType.LIKED ? tempId.substring(0, tempId.indexOf("_")) : tempId;
// idsOrShortCodes[i] = isId ? finalPostId
// : tempPostModel.getShortCode();
// }
// final NavDirections action = ProfileFragmentDirections.actionGlobalPostViewFragment(
// position,
// idsOrShortCodes,
// isId);
// NavHostFragment.findNavController(this).navigate(action);
// }, (model, position) -> {
// if (!postsAdapter.isSelecting()) {
// checkAndResetAction();
// return true;
// }
// final OnBackPressedDispatcher onBackPressedDispatcher = fragmentActivity.getOnBackPressedDispatcher();
// if (onBackPressedCallback.isEnabled()) return true;
// actionMode = fragmentActivity.startActionMode(multiSelectAction);
// final String title = getString(R.string.number_selected, 1);
// actionMode.setTitle(title);
// onBackPressedDispatcher.addCallback(getViewLifecycleOwner(), onBackPressedCallback);
// return true;
// });
} }
private void setupPosts() { private void setupPosts() {

View File

@ -484,7 +484,7 @@ public class StoryViewerFragment extends Fragment {
if (isHighlight) { if (isHighlight) {
final HighlightsViewModel highlightsViewModel = (HighlightsViewModel) viewModel; final HighlightsViewModel highlightsViewModel = (HighlightsViewModel) viewModel;
final List<HighlightModel> models = highlightsViewModel.getList().getValue(); final List<HighlightModel> models = highlightsViewModel.getList().getValue();
if (models == null) return; if (models == null || models.isEmpty() || currentFeedStoryIndex >= models.size()) return;
final HighlightModel model = models.get(currentFeedStoryIndex); final HighlightModel model = models.get(currentFeedStoryIndex);
currentStoryMediaId = model.getId(); currentStoryMediaId = model.getId();
currentStoryUsername = model.getTitle(); currentStoryUsername = model.getTitle();

View File

@ -22,6 +22,7 @@ import androidx.activity.OnBackPressedCallback;
import androidx.activity.OnBackPressedDispatcher; import androidx.activity.OnBackPressedDispatcher;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.PermissionChecker; import androidx.core.content.PermissionChecker;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -46,7 +47,6 @@ import awais.instagrabber.activities.MainActivity;
import awais.instagrabber.adapters.FeedAdapterV2; import awais.instagrabber.adapters.FeedAdapterV2;
import awais.instagrabber.asyncs.DiscoverPostFetchService; import awais.instagrabber.asyncs.DiscoverPostFetchService;
import awais.instagrabber.customviews.PrimaryActionModeCallback; import awais.instagrabber.customviews.PrimaryActionModeCallback;
import awais.instagrabber.customviews.helpers.NestedCoordinatorLayout;
import awais.instagrabber.databinding.FragmentTopicPostsBinding; import awais.instagrabber.databinding.FragmentTopicPostsBinding;
import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment; import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment;
import awais.instagrabber.fragments.main.DiscoverFragmentDirections; import awais.instagrabber.fragments.main.DiscoverFragmentDirections;
@ -60,7 +60,6 @@ import awais.instagrabber.webservices.DiscoverService;
import static androidx.core.content.PermissionChecker.checkSelfPermission; import static androidx.core.content.PermissionChecker.checkSelfPermission;
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION; import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
import static awais.instagrabber.utils.Utils.settingsHelper;
public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
private static final int STORAGE_PERM_REQUEST_CODE = 8020; private static final int STORAGE_PERM_REQUEST_CODE = 8020;
@ -68,14 +67,14 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O
private MainActivity fragmentActivity; private MainActivity fragmentActivity;
private FragmentTopicPostsBinding binding; private FragmentTopicPostsBinding binding;
private NestedCoordinatorLayout root; private CoordinatorLayout root;
private boolean shouldRefresh = true; private boolean shouldRefresh = true;
private TopicCluster topicCluster; private TopicCluster topicCluster;
private ActionMode actionMode; private ActionMode actionMode;
private Set<FeedModel> selectedFeedModels; private Set<FeedModel> selectedFeedModels;
private FeedModel downloadFeedModel; private FeedModel downloadFeedModel;
private int downloadChildPosition = -1; private int downloadChildPosition = -1;
private PostsLayoutPreferences layoutPreferences = PostsLayoutPreferences.fromJson(settingsHelper.getString(Constants.PREF_TOPIC_POSTS_LAYOUT)); private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_TOPIC_POSTS_LAYOUT);
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) { private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) {
@Override @Override

View File

@ -10,6 +10,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
@ -29,7 +30,6 @@ import java.util.List;
import awais.instagrabber.BuildConfig; import awais.instagrabber.BuildConfig;
import awais.instagrabber.adapters.DirectMessageInboxAdapter; import awais.instagrabber.adapters.DirectMessageInboxAdapter;
import awais.instagrabber.asyncs.direct_messages.InboxFetcher; import awais.instagrabber.asyncs.direct_messages.InboxFetcher;
import awais.instagrabber.customviews.helpers.NestedCoordinatorLayout;
import awais.instagrabber.customviews.helpers.RecyclerLazyLoader; import awais.instagrabber.customviews.helpers.RecyclerLazyLoader;
import awais.instagrabber.databinding.FragmentDirectMessagesInboxBinding; import awais.instagrabber.databinding.FragmentDirectMessagesInboxBinding;
import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.interfaces.FetchListener;
@ -41,7 +41,7 @@ public class DirectMessageInboxFragment extends Fragment implements SwipeRefresh
private static final String TAG = "DirectMessagesInboxFrag"; private static final String TAG = "DirectMessagesInboxFrag";
private FragmentActivity fragmentActivity; private FragmentActivity fragmentActivity;
private NestedCoordinatorLayout root; private CoordinatorLayout root;
private RecyclerView inboxList; private RecyclerView inboxList;
private RecyclerLazyLoader lazyLoader; private RecyclerLazyLoader lazyLoader;
private LinearLayoutManager layoutManager; private LinearLayoutManager layoutManager;

View File

@ -21,7 +21,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatButton; import androidx.appcompat.widget.AppCompatButton;
import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatImageView;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.NavDirections;
import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.fragment.NavHostFragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -35,7 +34,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import awais.instagrabber.BuildConfig; import awais.instagrabber.BuildConfig;
import awais.instagrabber.ProfileNavGraphDirections;
import awais.instagrabber.R; import awais.instagrabber.R;
import awais.instagrabber.adapters.DirectMessageMembersAdapter; import awais.instagrabber.adapters.DirectMessageMembersAdapter;
import awais.instagrabber.asyncs.direct_messages.DirectMessageInboxThreadFetcher; import awais.instagrabber.asyncs.direct_messages.DirectMessageInboxThreadFetcher;
@ -68,6 +66,7 @@ public class DirectMessageSettingsFragment extends Fragment implements SwipeRefr
@Override @Override
public void onResult(final InboxThreadModel threadModel) { public void onResult(final InboxThreadModel threadModel) {
if (threadModel == null) return;
final List<Long> adminList = Arrays.asList(threadModel.getAdmins()); final List<Long> adminList = Arrays.asList(threadModel.getAdmins());
final String userIdFromCookie = CookieUtils.getUserIdFromCookie(cookie); final String userIdFromCookie = CookieUtils.getUserIdFromCookie(cookie);
if (userIdFromCookie == null) return; if (userIdFromCookie == null) return;
@ -93,8 +92,9 @@ public class DirectMessageSettingsFragment extends Fragment implements SwipeRefr
final Object tag = v.getTag(); final Object tag = v.getTag();
if (tag instanceof ProfileModel) { if (tag instanceof ProfileModel) {
ProfileModel model = (ProfileModel) tag; ProfileModel model = (ProfileModel) tag;
final NavDirections action = DirectMessageThreadFragmentDirections.actionGlobalProfileFragment("@" + model.getUsername()); final Bundle bundle = new Bundle();
NavHostFragment.findNavController(this).navigate(action); bundle.putString("username", "@" + model.getUsername());
NavHostFragment.findNavController(this).navigate(R.id.action_global_profileFragment, bundle);
} }
}; };
@ -110,8 +110,9 @@ public class DirectMessageSettingsFragment extends Fragment implements SwipeRefr
}); });
final DialogInterface.OnClickListener clickListener = (d, w) -> { final DialogInterface.OnClickListener clickListener = (d, w) -> {
if (w == 0) { if (w == 0) {
final NavDirections action = DirectMessageThreadFragmentDirections.actionGlobalProfileFragment("@" + model.getUsername()); final Bundle bundle = new Bundle();
NavHostFragment.findNavController(this).navigate(action); bundle.putString("username", "@" + model.getUsername());
NavHostFragment.findNavController(this).navigate(R.id.action_global_profileFragment, bundle);
} else if (w == 1) { } else if (w == 1) {
new ChangeSettings(titleText.getText().toString()).execute("remove_users", model.getId()); new ChangeSettings(titleText.getText().toString()).execute("remove_users", model.getId());
onRefresh(); onRefresh();

View File

@ -18,8 +18,8 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -33,7 +33,6 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.NavController;
import androidx.navigation.NavDirections; import androidx.navigation.NavDirections;
import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.fragment.NavHostFragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -54,7 +53,6 @@ import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import awais.instagrabber.ProfileNavGraphDirections;
import awais.instagrabber.R; import awais.instagrabber.R;
import awais.instagrabber.adapters.DirectMessageItemsAdapter; import awais.instagrabber.adapters.DirectMessageItemsAdapter;
import awais.instagrabber.asyncs.ImageUploader; import awais.instagrabber.asyncs.ImageUploader;
@ -71,7 +69,6 @@ import awais.instagrabber.models.ProfileModel;
import awais.instagrabber.models.direct_messages.DirectItemModel; import awais.instagrabber.models.direct_messages.DirectItemModel;
import awais.instagrabber.models.direct_messages.InboxThreadModel; import awais.instagrabber.models.direct_messages.InboxThreadModel;
import awais.instagrabber.models.enums.DirectItemType; import awais.instagrabber.models.enums.DirectItemType;
import awais.instagrabber.models.enums.DownloadMethod;
import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.models.enums.UserInboxDirection; import awais.instagrabber.models.enums.UserInboxDirection;
import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.Constants;
@ -479,9 +476,16 @@ public class DirectMessageThreadFragment extends Fragment {
if (text != null) { if (text != null) {
binding.commentText.setText(""); binding.commentText.setText("");
} else { } else {
final LinearLayout dim = (LinearLayout) binding.messageList.findViewWithTag(directItemModel).getParent(); final View viewWithTag = binding.messageList.findViewWithTag(directItemModel);
if (dim.findViewById(R.id.liked_container) != null) { if (viewWithTag != null) {
dim.findViewById(R.id.liked_container).setVisibility(delete ? View.GONE : View.VISIBLE); 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(); directItemModel.setLiked();
} }
@ -549,8 +553,9 @@ public class DirectMessageThreadFragment extends Fragment {
} }
private void searchUsername(final String text) { private void searchUsername(final String text) {
final NavDirections action = DirectMessageThreadFragmentDirections.actionGlobalProfileFragment("@" + text); final Bundle bundle = new Bundle();
NavHostFragment.findNavController(this).navigate(action); bundle.putString("username", "@" + text);
NavHostFragment.findNavController(this).navigate(R.id.action_global_profileFragment, bundle);
} }
public static class DirectItemModelListViewModel extends ViewModel { public static class DirectItemModelListViewModel extends ViewModel {

View File

@ -2,13 +2,10 @@ package awais.instagrabber.fragments.main;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.ActionMode;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
@ -18,10 +15,8 @@ import androidx.navigation.fragment.FragmentNavigator;
import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.fragment.NavHostFragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import awais.instagrabber.R;
import awais.instagrabber.activities.MainActivity; import awais.instagrabber.activities.MainActivity;
import awais.instagrabber.adapters.DiscoverTopicsAdapter; import awais.instagrabber.adapters.DiscoverTopicsAdapter;
import awais.instagrabber.customviews.PrimaryActionModeCallback;
import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration; import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration;
import awais.instagrabber.databinding.FragmentDiscoverBinding; import awais.instagrabber.databinding.FragmentDiscoverBinding;
import awais.instagrabber.utils.Utils; import awais.instagrabber.utils.Utils;
@ -35,77 +30,10 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR
private MainActivity fragmentActivity; private MainActivity fragmentActivity;
private CoordinatorLayout root; private CoordinatorLayout root;
private FragmentDiscoverBinding binding; private FragmentDiscoverBinding binding;
private ActionMode actionMode;
private TopicClusterViewModel topicClusterViewModel; private TopicClusterViewModel topicClusterViewModel;
private boolean shouldRefresh = true; private boolean shouldRefresh = true;
private DiscoverService discoverService; private DiscoverService discoverService;
// private final FetchListener<DiscoverItemModel[]> postsFetchListener = new FetchListener<DiscoverItemModel[]>() {
// @Override
// public void doBefore() {}
//
// @Override
// public void onResult(final DiscoverItemModel[] result) {
// if (result == null || result.length <= 0) {
// binding.swipeRefreshLayout.setRefreshing(false);
// final Context context = getContext();
// if (context == null) return;
// Toast.makeText(context, R.string.discover_empty, Toast.LENGTH_SHORT).show();
// return;
// }
// List<DiscoverItemModel> current = discoverItemViewModel.getList().getValue();
// final List<DiscoverItemModel> resultList = Arrays.asList(result);
// current = current == null ? new ArrayList<>() : new ArrayList<>(current); // copy to modifiable list
// if (isPullToRefresh) {
// current = resultList;
// isPullToRefresh = false;
// } else {
// current.addAll(resultList);
// }
// discoverItemViewModel.getList().postValue(current);
// binding.swipeRefreshLayout.setRefreshing(false);
// final DiscoverItemModel discoverItemModel = result[result.length - 1];
// if (discoverItemModel != null) {
// discoverEndMaxId = discoverItemModel.getNextMaxId();
// discoverHasMore = discoverItemModel.hasMore();
// discoverItemModel.setMore(false, null);
// }
// }
// };
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) {
@Override
public void handleOnBackPressed() {
setEnabled(false);
remove();
// if (discoverAdapter == null) return;
// discoverAdapter.clearSelection();
}
};
private final PrimaryActionModeCallback multiSelectAction = new PrimaryActionModeCallback(
R.menu.multi_select_download_menu,
new PrimaryActionModeCallback.CallbacksHelper() {
@Override
public void onDestroy(final ActionMode mode) {
onBackPressedCallback.handleOnBackPressed();
}
@Override
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
if (item.getItemId() == R.id.action_download) {
// if (discoverAdapter == null) return false;
// final Context context = getContext();
// if (context == null) return false;
// DownloadUtils.batchDownload(context,
// null,
// DownloadMethod.DOWNLOAD_DISCOVER,
// discoverAdapter.getSelectedModels());
// checkAndResetAction();
return true;
}
return false;
}
});
@Override @Override
public void onCreate(@Nullable final Bundle savedInstanceState) { public void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -135,31 +63,6 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR
} }
private void init() { private void init() {
// setExitSharedElementCallback(new SharedElementCallback() {
// @Override
// public void onSharedElementsArrived(final List<String> sharedElementNames,
// final List<View> sharedElements,
// final OnSharedElementsReadyListener listener) {
// super.onSharedElementsArrived(sharedElementNames, sharedElements, listener);
// Log.d(TAG, "onSharedElementsArrived: sharedElementNames: " + sharedElementNames);
// }
//
// @Override
// public void onSharedElementEnd(final List<String> sharedElementNames,
// final List<View> sharedElements,
// final List<View> sharedElementSnapshots) {
// super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);
// Log.d(TAG, "onSharedElementEnd: sharedElementNames: " + sharedElementNames);
// }
//
// @Override
// public void onSharedElementStart(final List<String> sharedElementNames,
// final List<View> sharedElements,
// final List<View> sharedElementSnapshots) {
// super.onSharedElementStart(sharedElementNames, sharedElements, sharedElementSnapshots);
// Log.d(TAG, "onSharedElementStart: sharedElementNames: " + sharedElementNames);
// }
// });
setupTopics(); setupTopics();
fetchTopics(); fetchTopics();
} }
@ -175,7 +78,6 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR
final DiscoverTopicsAdapter adapter = new DiscoverTopicsAdapter((topicCluster, root, cover, title, titleColor, backgroundColor) -> { final DiscoverTopicsAdapter adapter = new DiscoverTopicsAdapter((topicCluster, root, cover, title, titleColor, backgroundColor) -> {
final FragmentNavigator.Extras.Builder builder = new FragmentNavigator.Extras.Builder() final FragmentNavigator.Extras.Builder builder = new FragmentNavigator.Extras.Builder()
.addSharedElement(cover, "cover-" + topicCluster.getId()); .addSharedElement(cover, "cover-" + topicCluster.getId());
// .addSharedElement(title, "title-" + topicCluster.getId());
final DiscoverFragmentDirections.ActionDiscoverFragmentToTopicPostsFragment action = DiscoverFragmentDirections final DiscoverFragmentDirections.ActionDiscoverFragmentToTopicPostsFragment action = DiscoverFragmentDirections
.actionDiscoverFragmentToTopicPostsFragment(topicCluster, titleColor, backgroundColor); .actionDiscoverFragmentToTopicPostsFragment(topicCluster, titleColor, backgroundColor);
NavHostFragment.findNavController(this).navigate(action, builder.build()); NavHostFragment.findNavController(this).navigate(action, builder.build());
@ -184,86 +86,12 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR
topicClusterViewModel.getList().observe(getViewLifecycleOwner(), adapter::submitList); topicClusterViewModel.getList().observe(getViewLifecycleOwner(), adapter::submitList);
} }
private void setupExplore() {
// discoverItemViewModel = new ViewModelProvider(fragmentActivity).get(DiscoverItemViewModel.class);
// final Context context = getContext();
// if (context == null) return;
// final GridAutofitLayoutManager layoutManager = new GridAutofitLayoutManager(context, Utils.convertDpToPx(110));
// binding.postsRecyclerView.setLayoutManager(layoutManager);
// binding.postsRecyclerView.addItemDecoration(new GridSpacingItemDecoration(Utils.convertDpToPx(4)));
// binding.discoverType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
// @Override
// public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
// if (topicIds == null || topicIds.length <= 0) return;
// currentTopic = topicIds[pos];
// onRefresh();
// }
//
// @Override
// public void onNothingSelected(AdapterView<?> parent) {}
// });
// discoverAdapter = new DiscoverAdapter((model, position) -> {
// if (discoverAdapter.isSelecting()) {
// if (actionMode == null) return;
// final String title = getString(R.string.number_selected, discoverAdapter.getSelectedModels().size());
// actionMode.setTitle(title);
// return;
// }
// if (checkAndResetAction()) return;
// final List<DiscoverItemModel> discoverItemModels = discoverItemViewModel.getList().getValue();
// if (discoverItemModels == null || discoverItemModels.size() == 0) return;
// if (discoverItemModels.get(0) == null) return;
// final String postId = discoverItemModels.get(0).getPostId();
// final boolean isId = postId != null;
// final String[] idsOrShortCodes = new String[discoverItemModels.size()];
// for (int i = 0; i < discoverItemModels.size(); i++) {
// idsOrShortCodes[i] = isId ? discoverItemModels.get(i).getPostId()
// : discoverItemModels.get(i).getShortCode();
// }
// final NavDirections action = DiscoverFragmentDirections.actionGlobalPostViewFragment(
// position,
// idsOrShortCodes,
// isId);
// NavHostFragment.findNavController(this).navigate(action);
// }, (model, position) -> {
// if (!discoverAdapter.isSelecting()) {
// checkAndResetAction();
// return true;
// }
// final OnBackPressedDispatcher onBackPressedDispatcher = fragmentActivity.getOnBackPressedDispatcher();
// if (onBackPressedCallback.isEnabled()) {
// return true;
// }
// actionMode = fragmentActivity.startActionMode(multiSelectAction);
// final String title = getString(R.string.number_selected, 1);
// actionMode.setTitle(title);
// onBackPressedDispatcher.addCallback(getViewLifecycleOwner(), onBackPressedCallback);
// return true;
// });
// binding.postsRecyclerView.setAdapter(discoverAdapter);
// discoverItemViewModel.getList().observe(fragmentActivity, discoverAdapter::submitList);
// lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {
// if (discoverHasMore) {
// fetchPosts();
// }
// }, 3);
// binding.postsRecyclerView.addOnScrollListener(lazyLoader);
// binding.postsRecyclerView.setViewModelStoreOwner(this)
// .setLifeCycleOwner(this)
// .setPostFetchService(new DiscoverPostFetchService())
// .setLayoutPreferences(PostsLayoutPreferences.fromJson(settingsHelper.getString(Constants.PREF_PROFILE_POSTS_LAYOUT)))
// .addFetchStatusChangeListener(fetching -> updateSwipeRefreshState())
// .setFeedItemCallback(feedItemCallback)
// .init();
// binding.swipeRefreshLayout.setRefreshing(true);
}
private void fetchTopics() { private void fetchTopics() {
// new iTopicFetcher(topicFetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
binding.swipeRefreshLayout.setRefreshing(true); binding.swipeRefreshLayout.setRefreshing(true);
discoverService.topicalExplore(new DiscoverService.TopicalExploreRequest(), new ServiceCallback<DiscoverService.TopicalExploreResponse>() { discoverService.topicalExplore(new DiscoverService.TopicalExploreRequest(), new ServiceCallback<DiscoverService.TopicalExploreResponse>() {
@Override @Override
public void onSuccess(final DiscoverService.TopicalExploreResponse result) { public void onSuccess(final DiscoverService.TopicalExploreResponse result) {
if (result == null) return;
topicClusterViewModel.getList().postValue(result.getClusters()); topicClusterViewModel.getList().postValue(result.getClusters());
binding.swipeRefreshLayout.setRefreshing(false); binding.swipeRefreshLayout.setRefreshing(false);
} }
@ -275,25 +103,4 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR
} }
}); });
} }
// private void fetchPosts() {
// binding.swipeRefreshLayout.setRefreshing(true);
// new DiscoverFetcher(currentTopic, discoverEndMaxId, rankToken, postsFetchListener, false)
// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
// }
private boolean checkAndResetAction() {
if (!onBackPressedCallback.isEnabled() && actionMode == null) {
return false;
}
if (onBackPressedCallback.isEnabled()) {
onBackPressedCallback.setEnabled(false);
onBackPressedCallback.remove();
}
if (actionMode != null) {
actionMode.finish();
actionMode = null;
}
return true;
}
} }

View File

@ -28,6 +28,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.List; import java.util.List;
@ -54,7 +55,6 @@ import awais.instagrabber.webservices.StoriesService;
import static androidx.core.content.PermissionChecker.checkSelfPermission; import static androidx.core.content.PermissionChecker.checkSelfPermission;
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION; import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
import static awais.instagrabber.utils.Utils.settingsHelper;
public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
private static final String TAG = "FeedFragment"; private static final String TAG = "FeedFragment";
@ -72,7 +72,8 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
private Set<FeedModel> selectedFeedModels; private Set<FeedModel> selectedFeedModels;
private FeedModel downloadFeedModel; private FeedModel downloadFeedModel;
private int downloadChildPosition = -1; private int downloadChildPosition = -1;
private PostsLayoutPreferences layoutPreferences = PostsLayoutPreferences.fromJson(settingsHelper.getString(Constants.PREF_POSTS_LAYOUT)); private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_POSTS_LAYOUT);
private RecyclerView storiesRecyclerView;
private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() { private final FeedAdapterV2.FeedItemCallback feedItemCallback = new FeedAdapterV2.FeedItemCallback() {
@Override @Override
@ -249,6 +250,9 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
final Bundle savedInstanceState) { final Bundle savedInstanceState) {
if (root != null) { if (root != null) {
shouldRefresh = false; shouldRefresh = false;
if (storiesRecyclerView != null) {
fragmentActivity.setCollapsingView(storiesRecyclerView);
}
return root; return root;
} }
binding = FragmentFeedBinding.inflate(inflater, container, false); binding = FragmentFeedBinding.inflate(inflater, container, false);
@ -279,18 +283,10 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@Override
public void onPause() {
super.onPause();
// if (videoAwareRecyclerScroller != null) {
// videoAwareRecyclerScroller.stopPlaying();
// }
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
binding.feedSwipeRefreshLayout.setRefreshing(false); updateSwipeRefreshState();
// if (videoAwareRecyclerScroller != null && shouldAutoPlay) { // if (videoAwareRecyclerScroller != null && shouldAutoPlay) {
// videoAwareRecyclerScroller.startPlaying(); // videoAwareRecyclerScroller.startPlaying();
// } // }
@ -302,6 +298,14 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
fetchStories(); fetchStories();
} }
@Override
public void onDestroyView() {
super.onDestroyView();
if (storiesRecyclerView != null) {
fragmentActivity.removeCollapsingView(storiesRecyclerView);
}
}
@Override @Override
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) { public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);
@ -349,8 +353,15 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
}); });
final Context context = getContext(); final Context context = getContext();
if (context == null) return; if (context == null) return;
binding.feedStoriesRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)); storiesRecyclerView = new RecyclerView(context);
binding.feedStoriesRecyclerView.setAdapter(feedStoriesAdapter); final CollapsingToolbarLayout.LayoutParams params = new CollapsingToolbarLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, Utils.getActionBarHeight(context), 0, 0);
storiesRecyclerView.setLayoutParams(params);
storiesRecyclerView.setClipToPadding(false);
storiesRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false));
storiesRecyclerView.setAdapter(feedStoriesAdapter);
fragmentActivity.setCollapsingView(storiesRecyclerView);
feedStoriesViewModel.getList().observe(fragmentActivity, feedStoriesAdapter::submitList); feedStoriesViewModel.getList().observe(fragmentActivity, feedStoriesAdapter::submitList);
fetchStories(); fetchStories();
} }
@ -387,6 +398,6 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
public void scrollToTop() { public void scrollToTop() {
binding.feedRecyclerView.smoothScrollToPosition(0); binding.feedRecyclerView.smoothScrollToPosition(0);
binding.storiesContainer.setExpanded(true); // binding.storiesContainer.setExpanded(true);
} }
} }

View File

@ -13,6 +13,7 @@ import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import android.util.Log; import android.util.Log;
import android.view.ActionMode; import android.view.ActionMode;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -60,8 +61,8 @@ import awais.instagrabber.asyncs.UsernameFetcher;
import awais.instagrabber.asyncs.direct_messages.CreateThreadAction; import awais.instagrabber.asyncs.direct_messages.CreateThreadAction;
import awais.instagrabber.customviews.PrimaryActionModeCallback; import awais.instagrabber.customviews.PrimaryActionModeCallback;
import awais.instagrabber.customviews.PrimaryActionModeCallback.CallbacksHelper; import awais.instagrabber.customviews.PrimaryActionModeCallback.CallbacksHelper;
import awais.instagrabber.customviews.helpers.NestedCoordinatorLayout;
import awais.instagrabber.databinding.FragmentProfileBinding; import awais.instagrabber.databinding.FragmentProfileBinding;
import awais.instagrabber.databinding.LayoutProfileDetailsBinding;
import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment; import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment;
import awais.instagrabber.dialogs.ProfilePicDialogFragment; import awais.instagrabber.dialogs.ProfilePicDialogFragment;
import awais.instagrabber.fragments.PostViewV2Fragment; import awais.instagrabber.fragments.PostViewV2Fragment;
@ -117,7 +118,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
private Set<FeedModel> selectedFeedModels; private Set<FeedModel> selectedFeedModels;
private FeedModel downloadFeedModel; private FeedModel downloadFeedModel;
private int downloadChildPosition = -1; private int downloadChildPosition = -1;
private PostsLayoutPreferences layoutPreferences = PostsLayoutPreferences.fromJson(settingsHelper.getString(Constants.PREF_PROFILE_POSTS_LAYOUT)); private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_PROFILE_POSTS_LAYOUT);
private final Runnable usernameSettingRunnable = () -> { private final Runnable usernameSettingRunnable = () -> {
final ActionBar actionBar = fragmentActivity.getSupportActionBar(); final ActionBar actionBar = fragmentActivity.getSupportActionBar();
@ -281,6 +282,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
} }
}; };
private LayoutProfileDetailsBinding profileDetailsBinding;
@Override @Override
public void onCreate(@Nullable final Bundle savedInstanceState) { public void onCreate(@Nullable final Bundle savedInstanceState) {
@ -306,21 +308,26 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
final boolean isSame = ("@" + profileModelUsername).equals(this.username); final boolean isSame = ("@" + profileModelUsername).equals(this.username);
if (isSame) { if (isSame) {
setUsernameDelayed(); setUsernameDelayed();
fragmentActivity.setCollapsingView(profileDetailsBinding.getRoot());
shouldRefresh = false; shouldRefresh = false;
return root; return root;
} }
} }
if (username == null || !username.equals(this.username)) { if (username == null || !username.equals(this.username)) {
fragmentActivity.setCollapsingView(profileDetailsBinding.getRoot());
shouldRefresh = true; shouldRefresh = true;
return root; return root;
} }
} }
setUsernameDelayed(); setUsernameDelayed();
fragmentActivity.setCollapsingView(profileDetailsBinding.getRoot());
shouldRefresh = false; shouldRefresh = false;
return root; return root;
} }
binding = FragmentProfileBinding.inflate(inflater, container, false); binding = FragmentProfileBinding.inflate(inflater, container, false);
root = binding.getRoot(); root = binding.getRoot();
profileDetailsBinding = LayoutProfileDetailsBinding.inflate(inflater, fragmentActivity.getCollapsingToolbarView(), false);
fragmentActivity.setCollapsingView(profileDetailsBinding.getRoot());
return root; return root;
} }
@ -431,6 +438,14 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
} }
@Override
public void onDestroyView() {
super.onDestroyView();
if (profileDetailsBinding != null) {
fragmentActivity.removeCollapsingView(profileDetailsBinding.getRoot());
}
}
@Override @Override
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) { public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);
@ -457,12 +472,13 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
setUsernameDelayed(); setUsernameDelayed();
} }
if (TextUtils.isEmpty(username) && !isLoggedIn) { if (TextUtils.isEmpty(username) && !isLoggedIn) {
binding.infoContainer.setVisibility(View.GONE); profileDetailsBinding.infoContainer.setVisibility(View.GONE);
binding.swipeRefreshLayout.setEnabled(false); binding.swipeRefreshLayout.setEnabled(false);
binding.privatePage1.setImageResource(R.drawable.ic_outline_info_24); binding.privatePage1.setImageResource(R.drawable.ic_outline_info_24);
binding.privatePage2.setText(R.string.no_acc); binding.privatePage2.setText(R.string.no_acc);
final NestedCoordinatorLayout.LayoutParams layoutParams = (NestedCoordinatorLayout.LayoutParams) binding.privatePage.getLayoutParams(); final CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) binding.privatePage.getLayoutParams();
layoutParams.topMargin = 0; layoutParams.topMargin = 0;
layoutParams.gravity = Gravity.CENTER;
binding.privatePage.setLayoutParams(layoutParams); binding.privatePage.setLayoutParams(layoutParams);
binding.privatePage.setVisibility(View.VISIBLE); binding.privatePage.setVisibility(View.VISIBLE);
return; return;
@ -531,7 +547,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} else { } else {
binding.postsRecyclerView.refresh(); binding.postsRecyclerView.refresh();
} }
binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE); profileDetailsBinding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE);
final String profileId = profileModel.getId(); final String profileId = profileModel.getId();
final String myId = CookieUtils.getUserIdFromCookie(cookie); final String myId = CookieUtils.getUserIdFromCookie(cookie);
if (isLoggedIn) { if (isLoggedIn) {
@ -539,14 +555,14 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
setupButtons(profileId, myId); setupButtons(profileId, myId);
if (!profileId.equals(myId)) { if (!profileId.equals(myId)) {
binding.favCb.setVisibility(View.VISIBLE); profileDetailsBinding.favCb.setVisibility(View.VISIBLE);
final boolean isFav = Utils.dataBox.getFavorite(username.substring(1), FavoriteType.USER) != null; final boolean isFav = Utils.dataBox.getFavorite(username.substring(1), FavoriteType.USER) != null;
binding.favCb.setChecked(isFav); profileDetailsBinding.favCb.setChecked(isFav);
binding.favCb.setButtonDrawable(isFav ? R.drawable.ic_star_check_24 : R.drawable.ic_outline_star_plus_24); profileDetailsBinding.favCb.setButtonDrawable(isFav ? R.drawable.ic_star_check_24 : R.drawable.ic_outline_star_plus_24);
} else { } else {
binding.favCb.setVisibility(View.GONE); profileDetailsBinding.favCb.setVisibility(View.GONE);
} }
binding.mainProfileImage.setImageURI(profileModel.getHdProfilePic()); profileDetailsBinding.mainProfileImage.setImageURI(profileModel.getHdProfilePic());
final long followersCount = profileModel.getFollowersCount(); final long followersCount = profileModel.getFollowersCount();
final long followingCount = profileModel.getFollowingCount(); final long followingCount = profileModel.getFollowingCount();
@ -557,7 +573,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
postCount)); postCount));
span.setSpan(new RelativeSizeSpan(1.2f), 0, postCount.length(), 0); span.setSpan(new RelativeSizeSpan(1.2f), 0, postCount.length(), 0);
span.setSpan(new StyleSpan(Typeface.BOLD), 0, postCount.length(), 0); span.setSpan(new StyleSpan(Typeface.BOLD), 0, postCount.length(), 0);
binding.mainPostCount.setText(span); profileDetailsBinding.mainPostCount.setText(span);
final String followersCountStr = String.valueOf(followersCount); final String followersCountStr = String.valueOf(followersCount);
final int followersCountStrLen = followersCountStr.length(); final int followersCountStrLen = followersCountStr.length();
@ -565,7 +581,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
followersCountStr)); followersCountStr));
span.setSpan(new RelativeSizeSpan(1.2f), 0, followersCountStrLen, 0); span.setSpan(new RelativeSizeSpan(1.2f), 0, followersCountStrLen, 0);
span.setSpan(new StyleSpan(Typeface.BOLD), 0, followersCountStrLen, 0); span.setSpan(new StyleSpan(Typeface.BOLD), 0, followersCountStrLen, 0);
binding.mainFollowers.setText(span); profileDetailsBinding.mainFollowers.setText(span);
final String followingCountStr = String.valueOf(followingCount); final String followingCountStr = String.valueOf(followingCount);
final int followingCountStrLen = followingCountStr.length(); final int followingCountStrLen = followingCountStr.length();
@ -573,68 +589,67 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
followingCountStr)); followingCountStr));
span.setSpan(new RelativeSizeSpan(1.2f), 0, followingCountStrLen, 0); span.setSpan(new RelativeSizeSpan(1.2f), 0, followingCountStrLen, 0);
span.setSpan(new StyleSpan(Typeface.BOLD), 0, followingCountStrLen, 0); span.setSpan(new StyleSpan(Typeface.BOLD), 0, followingCountStrLen, 0);
binding.mainFollowing.setText(span); profileDetailsBinding.mainFollowing.setText(span);
binding.mainFullName.setText(TextUtils.isEmpty(profileModel.getName()) ? profileModel.getUsername() profileDetailsBinding.mainFullName.setText(TextUtils.isEmpty(profileModel.getName()) ? profileModel.getUsername()
: profileModel.getName()); : profileModel.getName());
final String biography = profileModel.getBiography(); final String biography = profileModel.getBiography();
if (!TextUtils.isEmpty(biography)) { if (!TextUtils.isEmpty(biography)) {
binding.mainBiography.setText(biography); profileDetailsBinding.mainBiography.setText(biography);
binding.mainBiography.addOnHashtagListener(autoLinkItem -> { profileDetailsBinding.mainBiography.addOnHashtagListener(autoLinkItem -> {
final NavController navController = NavHostFragment.findNavController(this); final NavController navController = NavHostFragment.findNavController(this);
final Bundle bundle = new Bundle(); final Bundle bundle = new Bundle();
final String originalText = autoLinkItem.getOriginalText().trim(); final String originalText = autoLinkItem.getOriginalText().trim();
bundle.putString(ARG_HASHTAG, originalText); bundle.putString(ARG_HASHTAG, originalText);
navController.navigate(R.id.action_global_hashTagFragment, bundle); navController.navigate(R.id.action_global_hashTagFragment, bundle);
}); });
binding.mainBiography.addOnMentionClickListener(autoLinkItem -> { profileDetailsBinding.mainBiography.addOnMentionClickListener(autoLinkItem -> {
final String originalText = autoLinkItem.getOriginalText().trim(); final String originalText = autoLinkItem.getOriginalText().trim();
navigateToProfile(originalText); navigateToProfile(originalText);
}); });
binding.mainBiography.addOnEmailClickListener(autoLinkItem -> Utils.openEmailAddress(getContext(), profileDetailsBinding.mainBiography.addOnEmailClickListener(autoLinkItem -> Utils.openEmailAddress(getContext(),
autoLinkItem.getOriginalText().trim())); autoLinkItem.getOriginalText()
binding.mainBiography.addOnURLClickListener(autoLinkItem -> Utils.openURL(getContext(), autoLinkItem.getOriginalText().trim())); .trim()));
binding.mainBiography.setOnLongClickListener(v -> { profileDetailsBinding.mainBiography
if (context != null) Utils.copyText(context, biography); .addOnURLClickListener(autoLinkItem -> Utils.openURL(getContext(), autoLinkItem.getOriginalText().trim()));
profileDetailsBinding.mainBiography.setOnLongClickListener(v -> {
Utils.copyText(context, biography);
return true; return true;
}); });
} }
final String url = profileModel.getUrl(); final String url = profileModel.getUrl();
if (TextUtils.isEmpty(url)) { if (TextUtils.isEmpty(url)) {
binding.mainUrl.setVisibility(View.GONE); profileDetailsBinding.mainUrl.setVisibility(View.GONE);
} else { } else {
binding.mainUrl.setVisibility(View.VISIBLE); profileDetailsBinding.mainUrl.setVisibility(View.VISIBLE);
binding.mainUrl.setText(url); profileDetailsBinding.mainUrl.setText(url);
binding.mainUrl.addOnURLClickListener(autoLinkItem -> Utils.openURL(getContext(), autoLinkItem.getOriginalText().trim())); profileDetailsBinding.mainUrl.addOnURLClickListener(autoLinkItem -> Utils.openURL(getContext(), autoLinkItem.getOriginalText().trim()));
binding.mainUrl.setOnLongClickListener(v -> { profileDetailsBinding.mainUrl.setOnLongClickListener(v -> {
if (context != null) Utils.copyText(context, url); Utils.copyText(context, url);
return true; return true;
}); });
} }
if (!profileModel.isReallyPrivate() && isLoggedIn) { if (!profileModel.isReallyPrivate()) {
binding.mainFollowing.setClickable(true);
binding.mainFollowers.setClickable(true);
if (isLoggedIn) { if (isLoggedIn) {
profileDetailsBinding.mainFollowing.setClickable(true);
profileDetailsBinding.mainFollowers.setClickable(true);
final View.OnClickListener followClickListener = v -> { final View.OnClickListener followClickListener = v -> {
final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToFollowViewerFragment( final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToFollowViewerFragment(
profileId, profileId,
v == binding.mainFollowers, v == profileDetailsBinding.mainFollowers,
profileModel.getUsername()); profileModel.getUsername());
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
}; };
profileDetailsBinding.mainFollowers.setOnClickListener(followersCount > 0 ? followClickListener : null);
binding.mainFollowers.setOnClickListener(followersCount > 0 ? followClickListener : null); profileDetailsBinding.mainFollowing.setOnClickListener(followingCount > 0 ? followClickListener : null);
binding.mainFollowing.setOnClickListener(followingCount > 0 ? followClickListener : null);
} }
binding.swipeRefreshLayout.setRefreshing(true); binding.swipeRefreshLayout.setRefreshing(true);
binding.postsRecyclerView.setVisibility(View.VISIBLE); binding.postsRecyclerView.setVisibility(View.VISIBLE);
fetchPosts(); fetchPosts();
} else { } else {
binding.mainFollowers.setClickable(false); profileDetailsBinding.mainFollowers.setClickable(false);
binding.mainFollowing.setClickable(false); profileDetailsBinding.mainFollowing.setClickable(false);
binding.swipeRefreshLayout.setRefreshing(false); binding.swipeRefreshLayout.setRefreshing(false);
// error // error
binding.privatePage1.setImageResource(R.drawable.lock); binding.privatePage1.setImageResource(R.drawable.lock);
@ -647,27 +662,27 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
private void setupButtons(final String profileId, final String myId) { private void setupButtons(final String profileId, final String myId) {
if (isLoggedIn) { if (isLoggedIn) {
if (profileId.equals(myId)) { if (profileId.equals(myId)) {
binding.btnTagged.setVisibility(View.VISIBLE); profileDetailsBinding.btnTagged.setVisibility(View.VISIBLE);
binding.btnSaved.setVisibility(View.VISIBLE); profileDetailsBinding.btnSaved.setVisibility(View.VISIBLE);
binding.btnLiked.setVisibility(View.VISIBLE); profileDetailsBinding.btnLiked.setVisibility(View.VISIBLE);
binding.btnDM.setVisibility(View.GONE); profileDetailsBinding.btnDM.setVisibility(View.GONE);
binding.btnSaved.setText(R.string.saved); profileDetailsBinding.btnSaved.setText(R.string.saved);
return; return;
} }
binding.btnTagged.setVisibility(View.GONE); profileDetailsBinding.btnTagged.setVisibility(View.GONE);
binding.btnSaved.setVisibility(View.GONE); profileDetailsBinding.btnSaved.setVisibility(View.GONE);
binding.btnLiked.setVisibility(View.GONE); profileDetailsBinding.btnLiked.setVisibility(View.GONE);
binding.btnDM.setVisibility(View.VISIBLE); // maybe there is a judgment mechanism? profileDetailsBinding.btnDM.setVisibility(View.VISIBLE); // maybe there is a judgment mechanism?
binding.btnFollow.setVisibility(View.VISIBLE); profileDetailsBinding.btnFollow.setVisibility(View.VISIBLE);
if (profileModel.getFollowing()) { if (profileModel.getFollowing()) {
binding.btnFollow.setText(R.string.unfollow); profileDetailsBinding.btnFollow.setText(R.string.unfollow);
binding.btnFollow.setIconResource(R.drawable.ic_outline_person_add_disabled_24); profileDetailsBinding.btnFollow.setIconResource(R.drawable.ic_outline_person_add_disabled_24);
} else if (profileModel.getRequested()) { } else if (profileModel.getRequested()) {
binding.btnFollow.setText(R.string.cancel); profileDetailsBinding.btnFollow.setText(R.string.cancel);
binding.btnFollow.setIconResource(R.drawable.ic_outline_person_add_disabled_24); profileDetailsBinding.btnFollow.setIconResource(R.drawable.ic_outline_person_add_disabled_24);
} else { } else {
binding.btnFollow.setText(R.string.follow); profileDetailsBinding.btnFollow.setText(R.string.follow);
binding.btnFollow.setIconResource(R.drawable.ic_outline_person_add_24); profileDetailsBinding.btnFollow.setIconResource(R.drawable.ic_outline_person_add_24);
} }
if (restrictMenuItem != null) { if (restrictMenuItem != null) {
restrictMenuItem.setVisible(true); restrictMenuItem.setVisible(true);
@ -677,7 +692,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
restrictMenuItem.setTitle(R.string.restrict); restrictMenuItem.setTitle(R.string.restrict);
} }
} }
binding.btnTagged.setVisibility(profileModel.isReallyPrivate() ? View.GONE : View.VISIBLE); profileDetailsBinding.btnTagged.setVisibility(profileModel.isReallyPrivate() ? View.GONE : View.VISIBLE);
if (blockMenuItem != null) { if (blockMenuItem != null) {
blockMenuItem.setVisible(true); blockMenuItem.setVisible(true);
if (profileModel.getBlocked()) { if (profileModel.getBlocked()) {
@ -708,7 +723,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
@Override @Override
public void onSuccess(final List<StoryModel> storyModels) { public void onSuccess(final List<StoryModel> storyModels) {
if (storyModels != null && !storyModels.isEmpty()) { if (storyModels != null && !storyModels.isEmpty()) {
binding.mainProfileImage.setStoriesBorder(); profileDetailsBinding.mainProfileImage.setStoriesBorder();
hasStories = true; hasStories = true;
} }
} }
@ -722,15 +737,15 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
result -> { result -> {
highlightsFetching = false; highlightsFetching = false;
if (result != null) { if (result != null) {
binding.highlightsList.setVisibility(View.VISIBLE); profileDetailsBinding.highlightsList.setVisibility(View.VISIBLE);
highlightsViewModel.getList().postValue(result); highlightsViewModel.getList().postValue(result);
} else binding.highlightsList.setVisibility(View.GONE); } else profileDetailsBinding.highlightsList.setVisibility(View.GONE);
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
private void setupCommonListeners() { private void setupCommonListeners() {
final String userIdFromCookie = CookieUtils.getUserIdFromCookie(cookie); final String userIdFromCookie = CookieUtils.getUserIdFromCookie(cookie);
binding.btnFollow.setOnClickListener(v -> { profileDetailsBinding.btnFollow.setOnClickListener(v -> {
if (profileModel.getFollowing() || profileModel.getRequested()) { if (profileModel.getFollowing() || profileModel.getRequested()) {
friendshipService.unfollow( friendshipService.unfollow(
userIdFromCookie, userIdFromCookie,
@ -767,29 +782,29 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
}); });
} }
}); });
binding.btnSaved.setOnClickListener(v -> { profileDetailsBinding.btnSaved.setOnClickListener(v -> {
final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToSavedViewerFragment(profileModel.getUsername(), final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToSavedViewerFragment(profileModel.getUsername(),
profileModel.getId(), profileModel.getId(),
PostItemType.SAVED); PostItemType.SAVED);
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
}); });
binding.btnLiked.setOnClickListener(v -> { profileDetailsBinding.btnLiked.setOnClickListener(v -> {
final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToSavedViewerFragment(profileModel.getUsername(), final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToSavedViewerFragment(profileModel.getUsername(),
profileModel.getId(), profileModel.getId(),
PostItemType.LIKED); PostItemType.LIKED);
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
}); });
binding.btnTagged.setOnClickListener(v -> { profileDetailsBinding.btnTagged.setOnClickListener(v -> {
final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToSavedViewerFragment(profileModel.getUsername(), final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToSavedViewerFragment(profileModel.getUsername(),
profileModel.getId(), profileModel.getId(),
PostItemType.TAGGED); PostItemType.TAGGED);
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
}); });
binding.btnDM.setOnClickListener(v -> new CreateThreadAction(cookie, profileModel.getId(), threadId -> { profileDetailsBinding.btnDM.setOnClickListener(v -> new CreateThreadAction(cookie, profileModel.getId(), threadId -> {
final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToDMThreadFragment(threadId, profileModel.getUsername()); final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToDMThreadFragment(threadId, profileModel.getUsername());
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
}).execute()); }).execute());
binding.mainProfileImage.setOnClickListener(v -> { profileDetailsBinding.mainProfileImage.setOnClickListener(v -> {
if (!hasStories) { if (!hasStories) {
// show profile pic // show profile pic
showProfilePicDialog(); showProfilePicDialog();
@ -818,7 +833,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.show(); .show();
}); });
binding.favCb.setOnCheckedChangeListener((buttonView, isChecked) -> { profileDetailsBinding.favCb.setOnCheckedChangeListener((buttonView, isChecked) -> {
// do not do anything if state matches the db, as listener is set before profile details are set // do not do anything if state matches the db, as listener is set before profile details are set
final String finalUsername = username.startsWith("@") ? username.substring(1) : username; final String finalUsername = username.startsWith("@") ? username.substring(1) : username;
final DataBox.FavoriteModel favorite = Utils.dataBox.getFavorite(finalUsername, FavoriteType.USER); final DataBox.FavoriteModel favorite = Utils.dataBox.getFavorite(finalUsername, FavoriteType.USER);
@ -826,7 +841,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
return; return;
} }
buttonView.setVisibility(View.GONE); buttonView.setVisibility(View.GONE);
binding.favProgress.setVisibility(View.VISIBLE); profileDetailsBinding.favProgress.setVisibility(View.VISIBLE);
final String message; final String message;
if (isChecked) { if (isChecked) {
final DataBox.FavoriteModel model = new DataBox.FavoriteModel( final DataBox.FavoriteModel model = new DataBox.FavoriteModel(
@ -838,20 +853,20 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
new Date() new Date()
); );
Utils.dataBox.addOrUpdateFavorite(model); Utils.dataBox.addOrUpdateFavorite(model);
binding.favCb.setButtonDrawable(R.drawable.ic_star_check_24); profileDetailsBinding.favCb.setButtonDrawable(R.drawable.ic_star_check_24);
message = getString(R.string.added_to_favs); message = getString(R.string.added_to_favs);
} else { } else {
Utils.dataBox.deleteFavorite(finalUsername, FavoriteType.USER); Utils.dataBox.deleteFavorite(finalUsername, FavoriteType.USER);
message = getString(R.string.removed_from_favs); message = getString(R.string.removed_from_favs);
binding.favCb.setButtonDrawable(R.drawable.ic_outline_star_plus_24); profileDetailsBinding.favCb.setButtonDrawable(R.drawable.ic_outline_star_plus_24);
} }
final Snackbar snackbar = Snackbar.make(root, message, BaseTransientBottomBar.LENGTH_LONG); final Snackbar snackbar = Snackbar.make(root, message, BaseTransientBottomBar.LENGTH_LONG);
snackbar.setAction(R.string.ok, v -> snackbar.dismiss()) snackbar.setAction(R.string.ok, v -> snackbar.dismiss())
.setAnimationMode(BaseTransientBottomBar.ANIMATION_MODE_SLIDE) .setAnimationMode(BaseTransientBottomBar.ANIMATION_MODE_SLIDE)
.setAnchorView(fragmentActivity.getBottomNavView()) .setAnchorView(fragmentActivity.getBottomNavView())
.show(); .show();
binding.favProgress.setVisibility(View.GONE); profileDetailsBinding.favProgress.setVisibility(View.GONE);
binding.favCb.setVisibility(View.VISIBLE); profileDetailsBinding.favCb.setVisibility(View.VISIBLE);
}); });
} }
@ -900,8 +915,8 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
final Context context = getContext(); final Context context = getContext();
if (context == null) return; if (context == null) return;
final RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false); final RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false);
binding.highlightsList.setLayoutManager(layoutManager); profileDetailsBinding.highlightsList.setLayoutManager(layoutManager);
binding.highlightsList.setAdapter(highlightsAdapter); profileDetailsBinding.highlightsList.setAdapter(highlightsAdapter);
highlightsViewModel.getList().observe(getViewLifecycleOwner(), highlightModels -> highlightsAdapter.submitList(highlightModels)); highlightsViewModel.getList().observe(getViewLifecycleOwner(), highlightModels -> highlightsAdapter.submitList(highlightModels));
} }

View File

@ -453,7 +453,7 @@ public final class ResponseBodyUtils {
case VIDEO_CALL_EVENT: { case VIDEO_CALL_EVENT: {
final JSONObject videoCallEvent = itemObject.getJSONObject("video_call_event"); final JSONObject videoCallEvent = itemObject.getJSONObject("video_call_event");
videoCallEventModel = new DirectItemModel.DirectItemVideoCallEventModel(videoCallEvent.getLong("vc_id"), videoCallEventModel = new DirectItemModel.DirectItemVideoCallEventModel(videoCallEvent.optLong("vc_id"),
videoCallEvent.optBoolean("thread_has_audio_only_call"), videoCallEvent.optBoolean("thread_has_audio_only_call"),
videoCallEvent.getString("action"), videoCallEvent.getString("action"),
videoCallEvent.getString("description")); videoCallEvent.getString("description"));
@ -743,13 +743,13 @@ public final class ResponseBodyUtils {
String thumbnailUrl = null; String thumbnailUrl = null;
try { try {
thumbnailUrl = feedItem.getJSONArray("display_resources") thumbnailUrl = feedItem.getJSONArray("display_resources")
.getJSONObject(0) .getJSONObject(0)
.getString("src"); .getString("src");
} catch (JSONException ignored) {} } catch (JSONException ignored) {}
final FeedModel.Builder feedModelBuilder = new FeedModel.Builder() final FeedModel.Builder feedModelBuilder = new FeedModel.Builder()
.setProfileModel(profileModel) .setProfileModel(profileModel)
.setItemType(isVideo ? MediaItemType.MEDIA_TYPE_VIDEO .setItemType(isVideo ? MediaItemType.MEDIA_TYPE_VIDEO
: MediaItemType.MEDIA_TYPE_IMAGE) : MediaItemType.MEDIA_TYPE_IMAGE)
.setViewCount(videoViews) .setViewCount(videoViews)
.setPostId(feedItem.getString(Constants.EXTRAS_ID)) .setPostId(feedItem.getString(Constants.EXTRAS_ID))
.setDisplayUrl(resourceUrl) .setDisplayUrl(resourceUrl)
@ -843,17 +843,17 @@ public final class ResponseBodyUtils {
String thumbnailUrl = null; String thumbnailUrl = null;
try { try {
thumbnailUrl = childNode.getJSONArray("display_resources") thumbnailUrl = childNode.getJSONArray("display_resources")
.getJSONObject(0) .getJSONObject(0)
.getString("src"); .getString("src");
} catch (JSONException ignored) {} } catch (JSONException ignored) {}
final PostChild sliderItem = new PostChild.Builder() final PostChild sliderItem = new PostChild.Builder()
.setItemType(isChildVideo ? MediaItemType.MEDIA_TYPE_VIDEO .setItemType(isChildVideo ? MediaItemType.MEDIA_TYPE_VIDEO
: MediaItemType.MEDIA_TYPE_IMAGE) : MediaItemType.MEDIA_TYPE_IMAGE)
.setPostId(childNode.getString(Constants.EXTRAS_ID)) .setPostId(childNode.getString(Constants.EXTRAS_ID))
.setDisplayUrl(isChildVideo ? childNode.getString("video_url") .setDisplayUrl(isChildVideo ? childNode.getString("video_url")
: childNode.getString("display_url")) : childNode.getString("display_url"))
.setThumbnailUrl(thumbnailUrl != null ? thumbnailUrl .setThumbnailUrl(thumbnailUrl != null ? thumbnailUrl
: childNode.getString("display_url")) : childNode.getString("display_url"))
.setVideoViews(childNode.optLong("video_view_count", 0)) .setVideoViews(childNode.optLong("video_view_count", 0))
.setHeight(height) .setHeight(height)
.setWidth(width) .setWidth(width)

View File

@ -1,6 +1,7 @@
package awais.instagrabber.utils; package awais.instagrabber.utils;
import android.app.Activity; import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.ContentResolver; import android.content.ContentResolver;
@ -11,6 +12,7 @@ import android.net.Uri;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
@ -34,6 +36,7 @@ import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import awais.instagrabber.R; import awais.instagrabber.R;
import awais.instagrabber.models.PostsLayoutPreferences;
import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.models.enums.FavoriteType;
import awaisomereport.LogCollector; import awaisomereport.LogCollector;
@ -51,6 +54,7 @@ public final class Utils {
public static SimpleDateFormat datetimeParser; public static SimpleDateFormat datetimeParser;
public static SimpleCache simpleCache; public static SimpleCache simpleCache;
private static int statusBarHeight; private static int statusBarHeight;
private static int actionBarHeight;
public static int convertDpToPx(final float dp) { public static int convertDpToPx(final float dp) {
if (displayMetrics == null) if (displayMetrics == null)
@ -162,13 +166,30 @@ public final class Utils {
return statusBarHeight; return statusBarHeight;
} }
public static int getActionBarHeight(@NonNull final Context context) {
if (actionBarHeight > 0) {
return actionBarHeight;
}
final TypedValue tv = new TypedValue();
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, displayMetrics);
}
return actionBarHeight;
}
public static void openURL(final Context context, final String url) { public static void openURL(final Context context, final String url) {
if (context == null || TextUtils.isEmpty(url)) { if (context == null || TextUtils.isEmpty(url)) {
return; return;
} }
final Intent i = new Intent(Intent.ACTION_VIEW); final Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url)); i.setData(Uri.parse(url));
context.startActivity(i); try {
context.startActivity(i);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "openURL: No activity found to handle URL view", e);
} catch (Exception e) {
Log.e(TAG, "openURL", e);
}
} }
public static void openEmailAddress(final Context context, final String emailAddress) { public static void openEmailAddress(final Context context, final String emailAddress) {
@ -190,4 +211,13 @@ public final class Utils {
view.getTop() - view.getHeight() - 4); view.getTop() - view.getHeight() - 4);
toast.show(); toast.show();
} }
public static PostsLayoutPreferences getPostsLayoutPreferences(final String layoutPreferenceKey) {
PostsLayoutPreferences layoutPreferences = PostsLayoutPreferences.fromJson(settingsHelper.getString(layoutPreferenceKey));
if (layoutPreferences == null) {
layoutPreferences = PostsLayoutPreferences.builder().build();
settingsHelper.putString(layoutPreferenceKey, layoutPreferences.getJson());
}
return layoutPreferences;
}
} }

View File

@ -70,7 +70,7 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler {
.append("\r\nDEVICE : ").append(Build.DEVICE) .append("\r\nDEVICE : ").append(Build.DEVICE)
.append("\r\nPRODUCT : ").append(Build.PRODUCT) .append("\r\nPRODUCT : ").append(Build.PRODUCT)
.append("\r\nHOST : ").append(Build.HOST) .append("\r\nHOST : ").append(Build.HOST)
.append("\r\nTAGS : ").append(Build.TAGS) .append("\r\nTAGS : ").append(Build.TAGS);
reportBuilder.append("\r\n\r\nStack:\r\n==============\r\n"); reportBuilder.append("\r\n\r\nStack:\r\n==============\r\n");
final Writer result = new StringWriter(); final Writer result = new StringWriter();

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillAlpha="0.5"
android:fillColor="@android:color/white"
android:pathData="M18,13c0,3.31 -2.69,6 -6,6s-6,-2.69 -6,-6s2.69,-6 6,-6v4l5,-5l-5,-5v4c-4.42,0 -8,3.58 -8,8c0,4.42 3.58,8 8,8c4.42,0 8,-3.58 8,-8H18z" />
<path
android:fillAlpha="0.5"
android:fillColor="@android:color/white"
android:pathData="M12.03,15.38c-0.44,0 -0.58,-0.31 -0.6,-0.56h-0.84c0.03,0.85 0.79,1.25 1.44,1.25c0.93,0 1.44,-0.63 1.44,-1.43c0,-1.33 -0.97,-1.44 -1.3,-1.44c-0.2,0 -0.43,0.05 -0.64,0.16l0.11,-0.92h1.7v-0.71h-2.39l-0.25,2.17l0.67,0.17c0.13,-0.13 0.28,-0.23 0.57,-0.23c0.4,0 0.69,0.23 0.69,0.75C12.62,14.64 12.65,15.38 12.03,15.38z" />
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_forward_5_24_a50" android:state_enabled="false" />
<item android:drawable="@drawable/ic_forward_5_24" android:state_enabled="true" />
</selector>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:fillAlpha="0.5"
android:pathData="M8,5v14l11,-7z"/>
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_play_arrow_24_a50" android:state_enabled="false" />
<item android:drawable="@drawable/ic_play_arrow_24" android:state_enabled="true" />
</selector>

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillAlpha="0.5"
android:fillColor="@android:color/white"
android:pathData="M12,5V1L7,6l5,5V7c3.31,0 6,2.69 6,6s-2.69,6 -6,6s-6,-2.69 -6,-6H4c0,4.42 3.58,8 8,8s8,-3.58 8,-8S16.42,5 12,5z" />
<path
android:fillAlpha="0.5"
android:fillColor="@android:color/white"
android:pathData="M10.69,13.9l0.25,-2.17h2.39v0.71h-1.7l-0.11,0.92c0.03,-0.02 0.07,-0.03 0.11,-0.05s0.09,-0.04 0.15,-0.05s0.12,-0.03 0.18,-0.04s0.13,-0.02 0.2,-0.02c0.21,0 0.39,0.03 0.55,0.1s0.3,0.16 0.41,0.28s0.2,0.27 0.25,0.45s0.09,0.38 0.09,0.6c0,0.19 -0.03,0.37 -0.09,0.54s-0.15,0.32 -0.27,0.45s-0.27,0.24 -0.45,0.31s-0.39,0.12 -0.64,0.12c-0.18,0 -0.36,-0.03 -0.53,-0.08s-0.32,-0.14 -0.46,-0.24s-0.24,-0.24 -0.32,-0.39s-0.13,-0.33 -0.13,-0.53h0.84c0.02,0.18 0.08,0.32 0.19,0.41s0.25,0.15 0.42,0.15c0.11,0 0.2,-0.02 0.27,-0.06s0.14,-0.1 0.18,-0.17s0.08,-0.15 0.11,-0.25s0.03,-0.2 0.03,-0.31s-0.01,-0.21 -0.04,-0.31s-0.07,-0.17 -0.13,-0.24s-0.13,-0.12 -0.21,-0.15s-0.19,-0.05 -0.3,-0.05c-0.08,0 -0.15,0.01 -0.2,0.02s-0.11,0.03 -0.15,0.05s-0.08,0.05 -0.12,0.07s-0.07,0.06 -0.1,0.09L10.69,13.9z" />
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_replay_5_24_a50" android:state_enabled="false" />
<item android:drawable="@drawable/ic_replay_5_24" android:state_enabled="true" />
</selector>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillAlpha="0.5"
android:fillColor="@android:color/white"
android:pathData="M16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v2.21l2.45,2.45c0.03,-0.2 0.05,-0.41 0.05,-0.63zM19,12c0,0.94 -0.2,1.82 -0.54,2.64l1.51,1.51C20.63,14.91 21,13.5 21,12c0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM4.27,3L3,4.27 7.73,9L3,9v6h4l5,5v-6.73l4.25,4.25c-0.67,0.52 -1.42,0.93 -2.25,1.18v2.06c1.38,-0.31 2.63,-0.95 3.69,-1.81L19.73,21 21,19.73l-9,-9L4.27,3zM12,4L9.91,6.09 12,8.18L12,4z" />
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_volume_off_24_a50" android:state_enabled="false" />
<item android:drawable="@drawable/ic_volume_off_24" android:state_enabled="true" />
</selector>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillAlpha="0.5"
android:fillColor="@android:color/white"
android:pathData="M3,9v6h4l5,5L12,4L7,9L3,9zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,3.23v2.06c2.89,0.86 5,3.54 5,6.71s-2.11,5.85 -5,6.71v2.06c4.01,-0.91 7,-4.49 7,-8.77s-2.99,-7.86 -7,-8.77z" />
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_volume_up_24_a50" android:state_enabled="false" />
<item android:drawable="@drawable/ic_volume_up_24" android:state_enabled="true" />
</selector>

View File

@ -1,12 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:alpha="0.8"
android:tint="?attr/colorControlNormal" android:tint="?attr/colorControlNormal"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="@android:color/white" android:fillColor="#000"
android:pathData="M12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z M18,8 h-1 L17,6 c0,-2.76 -2.24,-5 -5,-5 S7,3.24 7,6 h1.9c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1 v2 L6,8 c-1.1,0 -2,0.9 -2,2 v10 c0,1.1 0.9,2 2,2 h12 c1.1,0 2,-0.9 2,-2 L20,10 c0,-1.1 -0.9,-2 -2,-2z M18,20L6,20L6,10h12v10z android:pathData="M12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z M18,8 h-1 L17,6 c0,-2.76 -2.24,-5 -5,-5 S7,3.24 7,6 h1.9c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1 v2 L6,8 c-1.1,0 -2,0.9 -2,2 v10 c0,1.1 0.9,2 2,2 h12 c1.1,0 2,-0.9 2,-2 L20,10 c0,-1.1 -0.9,-2 -2,-2z M18,20L6,20L6,10h12v10z
M7,6 L8.9,6 v2 h-2z" /> M7,6 L8.9,6 v2 h-2z" />
</vector> </vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/white_a50" android:state_enabled="false" />
<item android:color="@color/white" android:state_enabled="true" />
</selector>

View File

@ -20,14 +20,17 @@
android:id="@+id/collapsingToolbarLayout" android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|snap|enterAlways" android:animateLayoutChanges="true"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed|exitUntilCollapsed"
app:titleEnabled="false"> app:titleEnabled="false">
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="none" android:background="?attr/colorSurface"
app:layout_collapseMode="pin"
app:title="@string/app_name" app:title="@string/app_name"
tools:menu="@menu/main_menu" /> tools:menu="@menu/main_menu" />
</com.google.android.material.appbar.CollapsingToolbarLayout> </com.google.android.material.appbar.CollapsingToolbarLayout>
@ -45,5 +48,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
app:labelVisibilityMode="labeled" app:labelVisibilityMode="labeled"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
app:menu="@menu/main_bottom_navigation_menu" /> app:menu="@menu/main_bottom_navigation_menu" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<awais.instagrabber.customviews.helpers.NestedCoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -18,4 +18,4 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:listitem="@layout/layout_dm_inbox_item" /> tools:listitem="@layout/layout_dm_inbox_item" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</awais.instagrabber.customviews.helpers.NestedCoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -11,7 +11,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toTopOf="@id/comment_container" app:layout_constraintBottom_toTopOf="@id/comment_container"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@ -1,32 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<awais.instagrabber.customviews.helpers.NestedCoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="?attr/colorSurface"> android:background="?attr/colorSurface">
<!--<com.google.android.material.appbar.AppBarLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:background="?attr/colorSurface"-->
<!-- app:elevation="0dp">-->
<!-- <com.google.android.material.appbar.CollapsingToolbarLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_scrollFlags="scroll|snap|enterAlways">-->
<!-- <androidx.appcompat.widget.AppCompatSpinner-->
<!-- android:id="@+id/discoverType"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:entries="@array/discover_placeholder"-->
<!-- android:spinnerMode="dialog" />-->
<!-- </com.google.android.material.appbar.CollapsingToolbarLayout>-->
<!--</com.google.android.material.appbar.AppBarLayout>-->
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout" android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -42,4 +21,4 @@
tools:itemCount="10" tools:itemCount="10"
tools:listitem="@layout/item_discover_topic" /> tools:listitem="@layout/item_discover_topic" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</awais.instagrabber.customviews.helpers.NestedCoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,28 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<awais.instagrabber.customviews.helpers.NestedCoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface"> android:background="?attr/colorSurface">
<com.google.android.material.appbar.AppBarLayout <!--<com.google.android.material.appbar.AppBarLayout-->
android:id="@+id/stories_container" <!-- android:id="@+id/stories_container"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="wrap_content"> <!-- android:layout_height="wrap_content">-->
<com.google.android.material.appbar.CollapsingToolbarLayout <!-- <com.google.android.material.appbar.CollapsingToolbarLayout-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
app:layout_scrollFlags="scroll|snap"> <!-- app:layout_scrollFlags="scroll|snap">-->
<androidx.recyclerview.widget.RecyclerView <!--<androidx.recyclerview.widget.RecyclerView-->
android:id="@+id/feed_stories_recycler_view" <!-- android:id="@+id/feed_stories_recycler_view"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:clipToPadding="false" /> <!-- android:clipToPadding="false" />-->
</com.google.android.material.appbar.CollapsingToolbarLayout> <!-- </com.google.android.material.appbar.CollapsingToolbarLayout>-->
</com.google.android.material.appbar.AppBarLayout> <!--</com.google.android.material.appbar.AppBarLayout>-->
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/feed_swipe_refresh_layout" android:id="@+id/feed_swipe_refresh_layout"
@ -37,4 +37,4 @@
android:clipToPadding="false" android:clipToPadding="false"
tools:listitem="@layout/item_feed_photo" /> tools:listitem="@layout/item_feed_photo" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</awais.instagrabber.customviews.helpers.NestedCoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,84 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<awais.instagrabber.customviews.helpers.NestedCoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface"> android:background="?attr/colorSurface">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/tagInfoContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/profile_info_container_bottom_space">
<awais.instagrabber.customviews.CircularImageView
android:id="@+id/mainHashtagImage"
android:layout_width="@dimen/profile_picture_size"
android:layout_height="@dimen/profile_picture_size"
android:background="?selectableItemBackgroundBorderless"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/mainTagPostCount"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:background="@mipmap/ic_launcher" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainTagPostCount"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:padding="8dp"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toTopOf="@id/fav_chip"
app:layout_constraintStart_toEndOf="@id/mainHashtagImage"
app:layout_constraintTop_toTopOf="@id/mainHashtagImage"
tools:text="35 Posts" />
<com.google.android.material.chip.Chip
android:id="@+id/btnFollowTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/follow"
android:visibility="gone"
app:chipBackgroundColor="@null"
app:chipIcon="@drawable/ic_outline_person_add_24"
app:chipIconTint="@color/deep_purple_800"
app:layout_constraintBottom_toBottomOf="@id/mainHashtagImage"
app:layout_constraintStart_toEndOf="@id/mainHashtagImage"
app:layout_constraintTop_toBottomOf="@id/mainTagPostCount"
app:rippleColor="@color/purple_200" />
<com.google.android.material.chip.Chip
android:id="@+id/fav_chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/add_to_favorites"
android:visibility="gone"
app:chipBackgroundColor="@null"
app:chipIcon="@drawable/ic_outline_star_plus_24"
app:chipIconTint="@color/yellow_800"
app:layout_constraintBottom_toBottomOf="@id/mainHashtagImage"
app:layout_constraintStart_toEndOf="@id/btnFollowTag"
app:layout_constraintTop_toBottomOf="@id/mainTagPostCount"
app:rippleColor="@color/yellow_400" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout" android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -91,4 +17,4 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" /> android:clipToPadding="false" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</awais.instagrabber.customviews.helpers.NestedCoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,145 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<awais.instagrabber.customviews.helpers.NestedCoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface"> android:background="?attr/colorSurface">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/locInfoContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@null"
android:padding="8dp">
<awais.instagrabber.customviews.CircularImageView
android:id="@+id/mainLocationImage"
android:layout_width="@dimen/profile_picture_size"
android:layout_height="@dimen/profile_picture_size"
android:background="?selectableItemBackgroundBorderless"
app:actualImageScaleType="centerCrop"
app:layout_constraintEnd_toStartOf="@id/mainLocPostCount"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:background="@mipmap/ic_launcher" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainLocPostCount"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toTopOf="@id/btnMap"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mainLocationImage"
app:layout_constraintTop_toTopOf="parent"
tools:text="35 Posts" />
<com.google.android.material.chip.Chip
android:id="@+id/btnMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/map"
app:chipBackgroundColor="@null"
app:chipIcon="@drawable/ic_outline_map_24"
app:chipIconTint="@color/green_500"
app:layout_constraintBottom_toTopOf="@id/locationFullName"
app:layout_constraintStart_toEndOf="@id/mainLocationImage"
app:layout_constraintTop_toBottomOf="@id/mainLocPostCount"
app:rippleColor="@color/grey_500"
tools:visibility="visible" />
<com.google.android.material.chip.Chip
android:id="@+id/fav_chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/add_to_favorites"
app:chipBackgroundColor="@null"
app:chipIcon="@drawable/ic_outline_star_plus_24"
app:chipIconTint="@color/yellow_800"
app:layout_constraintBottom_toBottomOf="@id/mainLocationImage"
app:layout_constraintStart_toEndOf="@id/btnMap"
app:layout_constraintTop_toBottomOf="@id/mainLocPostCount"
app:rippleColor="@color/yellow_400" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/locationFullName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingTop="4dp"
android:paddingEnd="8dp"
android:paddingRight="8dp"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/locationBiography"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainLocationImage"
tools:text="OUR HOUSE" />
<awais.instagrabber.customviews.RamboTextView
android:id="@+id/locationBiography"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@id/locationFullName"
android:background="?android:selectableItemBackground"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingEnd="8dp"
android:paddingRight="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/locationUrl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/locationFullName"
tools:text="IN THE MIDDLE OF OUR STREET"
tools:visibility="visible" />
<awais.instagrabber.customviews.RamboTextView
android:id="@+id/locationUrl"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@id/locationBiography"
android:ellipsize="marquee"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingEnd="8dp"
android:paddingRight="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/locationBiography"
tools:text="https://austinhuang.me/"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout" android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -152,4 +17,4 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" /> android:clipToPadding="false" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</awais.instagrabber.customviews.helpers.NestedCoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,276 +1,27 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<awais.instagrabber.customviews.helpers.NestedCoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface"> android:background="?attr/colorSurface">
<com.google.android.material.appbar.AppBarLayout <!--<com.google.android.material.appbar.AppBarLayout-->
android:id="@+id/appBarLayout" <!-- android:id="@+id/appBarLayout"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:background="?attr/colorSurface" <!-- android:background="?attr/colorSurface"-->
app:elevation="0dp"> <!-- app:elevation="0dp"-->
<!-- app:layout_scrollFlags="scroll">-->
<com.google.android.material.appbar.CollapsingToolbarLayout <!-- <com.google.android.material.appbar.CollapsingToolbarLayout-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
app:layout_scrollFlags="scroll|snap"> <!-- app:layout_scrollFlags="scroll">-->
<androidx.constraintlayout.widget.ConstraintLayout <!-- <include layout="@layout/layout_profile_details" />-->
android:id="@+id/infoContainer" <!-- </com.google.android.material.appbar.CollapsingToolbarLayout>-->
android:layout_width="match_parent" <!--</com.google.android.material.appbar.AppBarLayout>-->
android:layout_height="wrap_content">
<awais.instagrabber.customviews.CircularImageView
android:id="@+id/mainProfileImage"
android:layout_width="@dimen/profile_picture_size"
android:layout_height="@dimen/profile_picture_size"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:transitionName="profile_pic"
app:actualImageScaleType="centerCrop"
app:layout_constraintEnd_toStartOf="@id/mainPostCount"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:background="@mipmap/ic_launcher" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainPostCount"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toBottomOf="@id/mainProfileImage"
app:layout_constraintEnd_toStartOf="@id/mainFollowers"
app:layout_constraintStart_toEndOf="@id/mainProfileImage"
app:layout_constraintTop_toTopOf="parent"
tools:text="35\nPosts" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainFollowers"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toBottomOf="@id/mainProfileImage"
app:layout_constraintEnd_toStartOf="@id/mainFollowing"
app:layout_constraintStart_toEndOf="@id/mainPostCount"
app:layout_constraintTop_toTopOf="parent"
tools:text="68\nFollowers" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainFollowing"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toBottomOf="@id/mainProfileImage"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mainFollowers"
app:layout_constraintTop_toTopOf="parent"
tools:text="64\nFollowing" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainFullName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:paddingStart="8dp"
android:paddingTop="8dp"
android:paddingEnd="4dp"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainProfileImage"
tools:text="Austin Huang" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/isVerified"
android:layout_width="30dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:paddingTop="8dp"
android:scaleType="fitCenter"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/mainFullName"
app:layout_constraintStart_toEndOf="@id/mainFullName"
app:layout_constraintTop_toBottomOf="@id/mainProfileImage"
app:srcCompat="@drawable/verified"
tools:visibility="visible" />
<CheckBox
android:id="@+id/fav_cb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/sl_favourite_24"
android:visibility="gone"
app:buttonTint="@color/yellow_800"
app:layout_constraintBaseline_toBaselineOf="@id/mainFullName"
app:layout_constraintBottom_toTopOf="@id/mainBiography"
app:layout_constraintStart_toEndOf="@id/isVerified" />
<ProgressBar
android:id="@+id/fav_progress"
style="@style/Widget.MaterialComponents.ProgressIndicator.Circular.Indeterminate"
android:layout_width="24dp"
android:layout_height="24dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/mainFullName"
app:layout_constraintStart_toEndOf="@id/isVerified"
app:layout_constraintTop_toTopOf="@id/mainFullName"
tools:visibility="gone" />
<awais.instagrabber.customviews.RamboTextViewV2
android:id="@+id/mainBiography"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="?android:selectableItemBackground"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
app:layout_constraintBottom_toTopOf="@id/mainUrl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainFullName"
tools:text="THE GLORIOUS (step)OWNER OF THIS APP. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec id justo lorem. In malesuada feugiat ornare. Suspendisse et mauris imperdiet, luctus augue eget, tempus eros. Cras vitae molestie ipsum. " />
<awais.instagrabber.customviews.RamboTextViewV2
android:id="@+id/mainUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/mainBiography"
android:ellipsize="marquee"
android:padding="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainBiography"
tools:text="https://austinhuang.me/"
tools:textColor="@android:color/holo_blue_dark"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnFollow"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/follow"
android:textColor="@color/deep_purple_200"
android:visibility="gone"
app:icon="@drawable/ic_outline_person_add_24"
app:iconGravity="top"
app:iconTint="@color/deep_purple_200"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toStartOf="@id/btnTagged"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
app:rippleColor="@color/purple_200"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnTagged"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/tagged"
android:textColor="@color/deep_orange_600"
android:visibility="gone"
app:icon="@drawable/ic_outline_person_pin_24"
app:iconGravity="top"
app:iconTint="@color/deep_orange_600"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toStartOf="@id/btnSaved"
app:layout_constraintStart_toEndOf="@id/btnFollow"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnSaved"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/saved"
android:textColor="@color/blue_700"
android:visibility="gone"
app:icon="@drawable/ic_outline_class_24"
app:iconGravity="top"
app:iconTint="@color/blue_700"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toStartOf="@id/btnLiked"
app:layout_constraintStart_toEndOf="@id/btnTagged"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
app:rippleColor="@color/blue_A400"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnLiked"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/liked"
android:textColor="@color/red_600"
android:visibility="gone"
app:icon="@drawable/ic_like"
app:iconGravity="top"
app:iconTint="@color/red_600"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/btnDM"
app:layout_constraintStart_toEndOf="@id/btnSaved"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
app:rippleColor="@color/red_300"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDM"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/dm_person"
android:textColor="@color/green"
android:visibility="gone"
app:icon="@drawable/ic_send_24"
app:iconGravity="top"
app:iconTint="@color/green"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/btnLiked"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
app:rippleColor="@color/green"
tools:visibility="visible" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/highlights_barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="btnTagged, btnSaved, btnLiked, btnFollow, btnDM" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/highlightsList"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingStart="5dp"
android:paddingLeft="5dp"
android:paddingEnd="5dp"
android:paddingRight="5dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/highlights_barrier"
tools:itemCount="2"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout" android:id="@+id/swipe_refresh_layout"
@ -290,12 +41,12 @@
android:id="@+id/privatePage" android:id="@+id/privatePage"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="top"
android:layout_marginTop="@dimen/private_page_margins" android:layout_marginTop="@dimen/private_page_margins"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" android:visibility="gone"
tools:visibility="gone"> tools:visibility="visible">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/privatePage1" android:id="@+id/privatePage1"
@ -311,4 +62,4 @@
android:text="@string/priv_acc" android:text="@string/priv_acc"
android:textAppearance="@style/TextAppearance.AppCompat.Large" /> android:textAppearance="@style/TextAppearance.AppCompat.Large" />
</LinearLayout> </LinearLayout>
</awais.instagrabber.customviews.helpers.NestedCoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<awais.instagrabber.customviews.helpers.NestedCoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -55,4 +55,4 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" /> android:clipToPadding="false" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</awais.instagrabber.customviews.helpers.NestedCoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -53,13 +53,14 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="visible" android:visibility="visible"
app:icon="@drawable/ic_replay_5_24" app:icon="@drawable/ic_replay_5_24_states"
app:iconSize="24dp" app:iconSize="24dp"
app:iconTint="@color/white" app:iconTint="@color/white"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/play_pause" app:layout_constraintEnd_toStartOf="@id/play_pause"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/timeline" app:layout_constraintTop_toBottomOf="@id/timeline"
tools:enabled="false"
tools:visibility="visible" /> tools:visibility="visible" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
@ -67,13 +68,14 @@
style="@style/Widget.App.MaterialButton.IconOnly.BorderlessRipple" style="@style/Widget.App.MaterialButton.IconOnly.BorderlessRipple"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:icon="@drawable/ic_play_arrow_24" app:icon="@drawable/ic_play_states"
app:iconSize="24dp" app:iconSize="24dp"
app:iconTint="@color/white" app:iconTint="@color/white"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/ff_with_amount" app:layout_constraintEnd_toStartOf="@id/ff_with_amount"
app:layout_constraintStart_toEndOf="@id/rew_with_amount" app:layout_constraintStart_toEndOf="@id/rew_with_amount"
app:layout_constraintTop_toBottomOf="@id/timeline" app:layout_constraintTop_toBottomOf="@id/timeline"
tools:enabled="false"
tools:visibility="visible" /> tools:visibility="visible" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
@ -81,13 +83,14 @@
style="@style/Widget.App.MaterialButton.IconOnly.BorderlessRipple" style="@style/Widget.App.MaterialButton.IconOnly.BorderlessRipple"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:icon="@drawable/ic_forward_5_24" app:icon="@drawable/ic_forward_5_24_states"
app:iconSize="24dp" app:iconSize="24dp"
app:iconTint="@color/white" app:iconTint="@color/white"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/mute" app:layout_constraintEnd_toStartOf="@id/mute"
app:layout_constraintStart_toEndOf="@id/play_pause" app:layout_constraintStart_toEndOf="@id/play_pause"
app:layout_constraintTop_toBottomOf="@id/timeline" app:layout_constraintTop_toBottomOf="@id/timeline"
tools:enabled="false"
tools:visibility="visible" /> tools:visibility="visible" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
@ -95,13 +98,14 @@
style="@style/Widget.App.MaterialButton.IconOnly.BorderlessRipple" style="@style/Widget.App.MaterialButton.IconOnly.BorderlessRipple"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:icon="@drawable/ic_volume_off_24" app:icon="@drawable/ic_volume_off_24_states"
app:iconSize="24dp" app:iconSize="24dp"
app:iconTint="@color/white" app:iconTint="@color/white"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/speed" app:layout_constraintEnd_toStartOf="@id/speed"
app:layout_constraintStart_toEndOf="@id/ff_with_amount" app:layout_constraintStart_toEndOf="@id/ff_with_amount"
app:layout_constraintTop_toBottomOf="@id/timeline" app:layout_constraintTop_toBottomOf="@id/timeline"
tools:enabled="false"
tools:visibility="visible" /> tools:visibility="visible" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
@ -111,10 +115,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/one_x" android:text="@string/one_x"
android:textAllCaps="false" android:textAllCaps="false"
android:textColor="@color/white" android:textColor="@drawable/speed_text_color_states"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mute" app:layout_constraintStart_toEndOf="@id/mute"
app:layout_constraintTop_toBottomOf="@id/timeline" app:layout_constraintTop_toBottomOf="@id/timeline"
tools:enabled="false"
tools:visibility="visible" /> tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tagInfoContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:padding="@dimen/profile_info_container_bottom_space">
<awais.instagrabber.customviews.CircularImageView
android:id="@+id/mainHashtagImage"
android:layout_width="@dimen/profile_picture_size"
android:layout_height="@dimen/profile_picture_size"
android:background="?selectableItemBackgroundBorderless"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/mainTagPostCount"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:background="@mipmap/ic_launcher" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainTagPostCount"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:padding="8dp"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toTopOf="@id/fav_chip"
app:layout_constraintStart_toEndOf="@id/mainHashtagImage"
app:layout_constraintTop_toTopOf="@id/mainHashtagImage"
tools:text="35 Posts" />
<com.google.android.material.chip.Chip
android:id="@+id/btnFollowTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/follow"
android:visibility="gone"
app:chipBackgroundColor="@null"
app:chipIcon="@drawable/ic_outline_person_add_24"
app:chipIconTint="@color/deep_purple_800"
app:layout_constraintBottom_toBottomOf="@id/mainHashtagImage"
app:layout_constraintStart_toEndOf="@id/mainHashtagImage"
app:layout_constraintTop_toBottomOf="@id/mainTagPostCount"
app:rippleColor="@color/purple_200" />
<com.google.android.material.chip.Chip
android:id="@+id/fav_chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/add_to_favorites"
android:visibility="gone"
app:chipBackgroundColor="@null"
app:chipIcon="@drawable/ic_outline_star_plus_24"
app:chipIconTint="@color/yellow_800"
app:layout_constraintBottom_toBottomOf="@id/mainHashtagImage"
app:layout_constraintStart_toEndOf="@id/btnFollowTag"
app:layout_constraintTop_toBottomOf="@id/mainTagPostCount"
app:rippleColor="@color/yellow_400" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/locInfoContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:animateLayoutChanges="true"
android:padding="8dp">
<awais.instagrabber.customviews.CircularImageView
android:id="@+id/mainLocationImage"
android:layout_width="@dimen/profile_picture_size"
android:layout_height="@dimen/profile_picture_size"
android:background="?selectableItemBackgroundBorderless"
app:actualImageScaleType="centerCrop"
app:layout_constraintEnd_toStartOf="@id/mainLocPostCount"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:background="@mipmap/ic_launcher" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainLocPostCount"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toTopOf="@id/btnMap"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mainLocationImage"
app:layout_constraintTop_toTopOf="parent"
tools:text="35 Posts" />
<com.google.android.material.chip.Chip
android:id="@+id/btnMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/map"
app:chipBackgroundColor="@null"
app:chipIcon="@drawable/ic_outline_map_24"
app:chipIconTint="@color/green_500"
app:layout_constraintBottom_toTopOf="@id/locationFullName"
app:layout_constraintStart_toEndOf="@id/mainLocationImage"
app:layout_constraintTop_toBottomOf="@id/mainLocPostCount"
app:rippleColor="@color/grey_500"
tools:visibility="visible" />
<com.google.android.material.chip.Chip
android:id="@+id/fav_chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/add_to_favorites"
app:chipBackgroundColor="@null"
app:chipIcon="@drawable/ic_outline_star_plus_24"
app:chipIconTint="@color/yellow_800"
app:layout_constraintBottom_toBottomOf="@id/mainLocationImage"
app:layout_constraintStart_toEndOf="@id/btnMap"
app:layout_constraintTop_toBottomOf="@id/mainLocPostCount"
app:rippleColor="@color/yellow_400" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/locationFullName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingTop="4dp"
android:paddingEnd="8dp"
android:paddingRight="8dp"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/locationBiography"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainLocationImage"
tools:text="OUR HOUSE" />
<awais.instagrabber.customviews.RamboTextView
android:id="@+id/locationBiography"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@id/locationFullName"
android:background="?android:selectableItemBackground"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingEnd="8dp"
android:paddingRight="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/locationUrl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/locationFullName"
tools:text="IN THE MIDDLE OF OUR STREET"
tools:visibility="visible" />
<awais.instagrabber.customviews.RamboTextView
android:id="@+id/locationUrl"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@id/locationBiography"
android:ellipsize="marquee"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingEnd="8dp"
android:paddingRight="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/locationBiography"
tools:text="https://austinhuang.me/"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,255 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/infoContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize">
<awais.instagrabber.customviews.CircularImageView
android:id="@+id/mainProfileImage"
android:layout_width="@dimen/profile_picture_size"
android:layout_height="@dimen/profile_picture_size"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:transitionName="profile_pic"
app:actualImageScaleType="centerCrop"
app:layout_constraintEnd_toStartOf="@id/mainPostCount"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:background="@mipmap/ic_launcher" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainPostCount"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toBottomOf="@id/mainProfileImage"
app:layout_constraintEnd_toStartOf="@id/mainFollowers"
app:layout_constraintStart_toEndOf="@id/mainProfileImage"
app:layout_constraintTop_toTopOf="parent"
tools:text="35\nPosts" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainFollowers"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toBottomOf="@id/mainProfileImage"
app:layout_constraintEnd_toStartOf="@id/mainFollowing"
app:layout_constraintStart_toEndOf="@id/mainPostCount"
app:layout_constraintTop_toTopOf="parent"
tools:text="68\nFollowers" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainFollowing"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat"
app:layout_constraintBottom_toBottomOf="@id/mainProfileImage"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mainFollowers"
app:layout_constraintTop_toTopOf="parent"
tools:text="64\nFollowing" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mainFullName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:paddingStart="8dp"
android:paddingTop="8dp"
android:paddingEnd="4dp"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainProfileImage"
tools:text="Austin Huang" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/isVerified"
android:layout_width="30dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:paddingTop="8dp"
android:scaleType="fitCenter"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/mainFullName"
app:layout_constraintStart_toEndOf="@id/mainFullName"
app:layout_constraintTop_toBottomOf="@id/mainProfileImage"
app:srcCompat="@drawable/verified"
tools:visibility="visible" />
<CheckBox
android:id="@+id/fav_cb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/sl_favourite_24"
android:visibility="gone"
app:buttonTint="@color/yellow_800"
app:layout_constraintBaseline_toBaselineOf="@id/mainFullName"
app:layout_constraintBottom_toTopOf="@id/mainBiography"
app:layout_constraintStart_toEndOf="@id/isVerified" />
<ProgressBar
android:id="@+id/fav_progress"
style="@style/Widget.MaterialComponents.ProgressIndicator.Circular.Indeterminate"
android:layout_width="24dp"
android:layout_height="24dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/mainFullName"
app:layout_constraintStart_toEndOf="@id/isVerified"
app:layout_constraintTop_toTopOf="@id/mainFullName"
tools:visibility="gone" />
<awais.instagrabber.customviews.RamboTextViewV2
android:id="@+id/mainBiography"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="?android:selectableItemBackground"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
app:layout_constraintBottom_toTopOf="@id/mainUrl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainFullName"
tools:text="THE GLORIOUS (step)OWNER OF THIS APP. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec id justo lorem. In malesuada feugiat ornare. Suspendisse et mauris imperdiet, luctus augue eget, tempus eros. Cras vitae molestie ipsum. " />
<awais.instagrabber.customviews.RamboTextViewV2
android:id="@+id/mainUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/mainBiography"
android:ellipsize="marquee"
android:padding="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainBiography"
tools:text="https://austinhuang.me/"
tools:textColor="@android:color/holo_blue_dark"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnFollow"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/follow"
android:textColor="@color/deep_purple_200"
android:visibility="gone"
app:icon="@drawable/ic_outline_person_add_24"
app:iconGravity="top"
app:iconTint="@color/deep_purple_200"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toStartOf="@id/btnTagged"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
app:rippleColor="@color/purple_200"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnTagged"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/tagged"
android:textColor="@color/deep_orange_600"
android:visibility="gone"
app:icon="@drawable/ic_outline_person_pin_24"
app:iconGravity="top"
app:iconTint="@color/deep_orange_600"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toStartOf="@id/btnSaved"
app:layout_constraintStart_toEndOf="@id/btnFollow"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnSaved"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/saved"
android:textColor="@color/blue_700"
android:visibility="gone"
app:icon="@drawable/ic_outline_class_24"
app:iconGravity="top"
app:iconTint="@color/blue_700"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toStartOf="@id/btnLiked"
app:layout_constraintStart_toEndOf="@id/btnTagged"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
app:rippleColor="@color/blue_A400"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnLiked"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/liked"
android:textColor="@color/red_600"
android:visibility="gone"
app:icon="@drawable/ic_like"
app:iconGravity="top"
app:iconTint="@color/red_600"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/btnDM"
app:layout_constraintStart_toEndOf="@id/btnSaved"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
app:rippleColor="@color/red_300"
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDM"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/dm_person"
android:textColor="@color/green"
android:visibility="gone"
app:icon="@drawable/ic_send_24"
app:iconGravity="top"
app:iconTint="@color/green"
app:layout_constraintBottom_toTopOf="@id/highlights_barrier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/btnLiked"
app:layout_constraintTop_toBottomOf="@id/mainUrl"
app:rippleColor="@color/green"
tools:visibility="visible" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/highlights_barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="btnTagged, btnSaved, btnLiked, btnFollow, btnDM" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/highlightsList"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingStart="5dp"
android:paddingLeft="5dp"
android:paddingEnd="5dp"
android:paddingRight="5dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/highlights_barrier"
tools:itemCount="2"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -44,6 +44,25 @@
android:id="@+id/action_global_notificationsViewerFragment" android:id="@+id/action_global_notificationsViewerFragment"
app:destination="@id/notification_viewer_nav_graph" /> app:destination="@id/notification_viewer_nav_graph" />
<include app:graph="@navigation/comments_nav_graph" />
<action
android:id="@+id/action_global_commentsViewerFragment"
app:destination="@id/comments_nav_graph">
<argument
android:name="shortCode"
app:argType="string"
app:nullable="false" />
<argument
android:name="postId"
app:argType="string"
app:nullable="false" />
<argument
android:name="postUserId"
app:argType="string"
app:nullable="false" />
</action>
<fragment <fragment
android:id="@+id/directMessagesInboxFragment" android:id="@+id/directMessagesInboxFragment"
android:name="awais.instagrabber.fragments.directmessages.DirectMessageInboxFragment" android:name="awais.instagrabber.fragments.directmessages.DirectMessageInboxFragment"

View File

@ -33,6 +33,7 @@
<color name="comment_selected">#888888</color> <color name="comment_selected">#888888</color>
<color name="white">#FFFFFF</color> <color name="white">#FFFFFF</color>
<color name="white_a50">#80FFFFFF</color>
<color name="black">#000000</color> <color name="black">#000000</color>
<color name="black_800">#121212</color> <color name="black_800">#121212</color>

View File

@ -309,6 +309,7 @@
<string name="show_grid_gap">Show grid gap</string> <string name="show_grid_gap">Show grid gap</string>
<string name="disable_animation">Disable animation</string> <string name="disable_animation">Disable animation</string>
<string name="follower_wait_to_load">Please wait for the current task to complete first!</string> <string name="follower_wait_to_load">Please wait for the current task to complete first!</string>
<string name="post_not_found">Post not found!</string>
<plurals name="likes_count"> <plurals name="likes_count">
<item quantity="one">%d like</item> <item quantity="one">%d like</item>
<item quantity="other">%d likes</item> <item quantity="other">%d likes</item>