Skip to content

Commit

Permalink
Added dedicated GIF post view with controls
Browse files Browse the repository at this point in the history
  • Loading branch information
Neywiny committed Sep 23, 2022
1 parent a87704b commit 719004e
Show file tree
Hide file tree
Showing 36 changed files with 1,054 additions and 473 deletions.
13 changes: 2 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

android {
compileSdk 32
compileSdk 31
defaultConfig {
applicationId "ml.docilealligator.infinityforreddit"
minSdk 21
Expand All @@ -29,10 +29,6 @@ android {
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix '.debug'
versionNameSuffix ' (DEBUG)'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
Expand All @@ -48,10 +44,6 @@ android {
enableSplit = false
}
}

buildFeatures {
viewBinding true
}
}

dependencies {
Expand Down Expand Up @@ -110,7 +102,6 @@ dependencies {
def butterknifeVersion = "10.2.3"
implementation "com.jakewharton:butterknife:$butterknifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$butterknifeVersion"
compileOnly 'com.android.databinding:viewbinding:7.3.0'

// Events
def eventbusVersion = "3.3.1"
Expand Down Expand Up @@ -148,7 +139,7 @@ dependencies {
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
implementation 'jp.wasabeef:glide-transformations:4.3.0'
implementation 'com.github.santalu:aspect-ratio-imageview:1.0.9'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.23'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'
def bivVersion = "1.8.1"
implementation "com.github.piasy:BigImageViewer:$bivVersion"
implementation "com.github.piasy:GlideImageLoader:$bivVersion"
Expand Down
3 changes: 0 additions & 3 deletions app/src/debug/res/values/strings.xml

This file was deleted.

15 changes: 13 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:replace="android:label">
<activity
android:name=".ViewGifActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".activities.HistoryActivity"
android:exported="false"
Expand Down Expand Up @@ -395,7 +402,11 @@
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".activities.ViewImageOrGifActivity"
android:name=".activities.ViewImageActivity"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.SlidableWithActionBar" />
<activity
android:name=".activities.ViewGifActivity"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.SlidableWithActionBar" />
<activity
Expand All @@ -419,7 +430,7 @@

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:authorities="ml.docilealligator.infinityforreddit.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
import ml.docilealligator.infinityforreddit.activities.SubscribedThingListingActivity;
import ml.docilealligator.infinityforreddit.activities.SuicidePreventionActivity;
import ml.docilealligator.infinityforreddit.activities.TrendingActivity;
import ml.docilealligator.infinityforreddit.activities.ViewImageOrGifActivity;
import ml.docilealligator.infinityforreddit.activities.ViewGifActivity;
import ml.docilealligator.infinityforreddit.activities.ViewImageActivity;
import ml.docilealligator.infinityforreddit.activities.ViewImgurMediaActivity;
import ml.docilealligator.infinityforreddit.activities.ViewMultiRedditDetailActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
Expand Down Expand Up @@ -175,7 +176,9 @@ public interface AppComponent {

void inject(AccountSavedThingActivity accountSavedThingActivity);

void inject(ViewImageOrGifActivity viewGIFActivity);
void inject(ViewImageActivity viewGIFActivity);

void inject(ViewGifActivity viewGIFActivity);

void inject(ViewMultiRedditDetailActivity viewMultiRedditDetailActivity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;

import org.greenrobot.eventbus.EventBus;
Expand All @@ -20,6 +25,8 @@
import javax.inject.Inject;
import javax.inject.Named;

import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
Expand All @@ -28,7 +35,6 @@
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.databinding.ActivityAccountPostsBinding;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
Expand All @@ -42,6 +48,14 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect

private static final String FRAGMENT_OUT_STATE = "FOS";

@BindView(R.id.coordinator_layout_account_posts_activity)
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_account_posts_activity)
AppBarLayout appBarLayout;
@BindView(R.id.collapsing_toolbar_layout_account_posts_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_account_posts_activity)
Toolbar toolbar;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
Expand All @@ -58,16 +72,16 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
private String mUserWhere;
private Fragment mFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
private ActivityAccountPostsBinding binding;

@Override
protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);

super.onCreate(savedInstanceState);

binding = ActivityAccountPostsBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setContentView(R.layout.activity_account_posts);

ButterKnife.bind(this);

EventBus.getDefault().register(this);

Expand All @@ -81,7 +95,7 @@ protected void onCreate(Bundle savedInstanceState) {
Window window = getWindow();

if (isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(binding.accountPostsAppbarLayout);
addOnOffsetChangedListener(appBarLayout);
}

if (isImmersiveInterface()) {
Expand All @@ -90,24 +104,24 @@ protected void onCreate(Bundle savedInstanceState) {
} else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
adjustToolbar(binding.accountPostsToolbar);
adjustToolbar(toolbar);
}
}

mUserWhere = getIntent().getExtras().getString(EXTRA_USER_WHERE);
if (mUserWhere.equals(PostPagingSource.USER_WHERE_UPVOTED)) {
binding.accountPostsToolbar.setTitle(R.string.upvoted);
toolbar.setTitle(R.string.upvoted);
} else if (mUserWhere.equals(PostPagingSource.USER_WHERE_DOWNVOTED)) {
binding.accountPostsToolbar.setTitle(R.string.downvoted);
toolbar.setTitle(R.string.downvoted);
} else if (mUserWhere.equals(PostPagingSource.USER_WHERE_HIDDEN)) {
binding.accountPostsToolbar.setTitle(R.string.hidden);
toolbar.setTitle(R.string.hidden);
} else if (mUserWhere.equals(PostPagingSource.USER_WHERE_GILDED)) {
binding.accountPostsToolbar.setTitle(R.string.gilded);
toolbar.setTitle(R.string.gilded);
}

setSupportActionBar(binding.accountPostsToolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(binding.accountPostsToolbar);
setToolbarGoToTop(toolbar);

postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();

Expand All @@ -116,9 +130,7 @@ protected void onCreate(Bundle savedInstanceState) {

if (savedInstanceState != null) {
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
getSupportFragmentManager().beginTransaction()
.replace(binding.accountPostsFrameLayout.getId(), mFragment)
.commit();
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit();
} else {
initializeFragment();
}
Expand All @@ -145,10 +157,8 @@ protected CustomThemeWrapper getCustomThemeWrapper() {

@Override
protected void applyCustomTheme() {
binding.accountPostsCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(
binding.accountPostsAppbarLayout, binding.accountPostsCollapsingToolbarLayout,
binding.accountPostsToolbar);
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}

private void initializeFragment() {
Expand All @@ -161,9 +171,7 @@ private void initializeFragment() {
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true);
mFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction()
.replace(binding.accountPostsFrameLayout.getId(), mFragment)
.commit();
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit();
}

@Override
Expand Down
Loading

0 comments on commit 719004e

Please sign in to comment.