Skip to content

Commit

Permalink
NClientV2 2.7.3
Browse files Browse the repository at this point in the history
* Added beta summary
* Fix page in vertical mode
* fixed page not loading in GalleryAdapter
  • Loading branch information
Dar9586 committed Feb 5, 2021
1 parent 3f31b48 commit d0083cb
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 21 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.dar.nclientv2"
minSdkVersion 14
targetSdkVersion 30
versionCode 272
versionName "2.7.2"
versionCode 273
versionName "2.7.3-stable"
vectorDrawables.useSupportLibrary true
proguardFiles 'proguard-rules.pro'
}
Expand All @@ -17,6 +17,7 @@ android {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
versionNameSuffix "-release"
resValue "string", "app_name", "NClientV2"
}
debug {
Expand Down
30 changes: 17 additions & 13 deletions app/src/main/java/com/dar/nclientv2/ZoomActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import java.io.File;
import java.util.concurrent.atomic.AtomicLong;

public class ZoomActivity extends GeneralActivity {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Expand All @@ -53,6 +54,8 @@ public class ZoomActivity extends GeneralActivity {
private final static int showFlags = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
private static final String VOLUME_SIDE_KEY = "volumeSide";
private static final String SCROLL_TYPE_KEY = "zoomScrollType";
private static final int CHANGE_VISIBILITY_DELAY=150;
private final AtomicLong aLong=new AtomicLong(System.currentTimeMillis());
private GenericGallery gallery;
private int actualPage = 0;
private boolean isHidden = false;
Expand Down Expand Up @@ -86,7 +89,6 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayShowTitleEnabled(true);
setTitle(gallery.getTitle());

//getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
Expand Down Expand Up @@ -125,8 +127,8 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
public void onPageSelected(int newPage) {
int oldPage = actualPage;
actualPage = newPage;
setPageText(Global.useRtl() ? gallery.getPageCount() - newPage : newPage + 1);
seekBar.setProgress(Global.useRtl() ? gallery.getPageCount() - 1 - newPage : newPage);
setPageText(offsetPage(newPage)+1);
seekBar.setProgress(offsetPage(newPage));
clearFarRequests(oldPage, newPage);
}

Expand Down Expand Up @@ -169,7 +171,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {

changePage(offsetPage(page));
setPageText(page + 1);
seekBar.setProgress(Global.useRtl() ? gallery.getPageCount() - 1 - offsetPage(page) : offsetPage(page));
seekBar.setProgress(offsetPage(offsetPage(page)));
}

private void setPageText(int page) {
Expand All @@ -178,7 +180,11 @@ private void setPageText(int page) {
}

int offsetPage(int page) {
return Global.useRtl() ? gallery.getPageCount() - 1 - page : page;
return invertDirection() ? gallery.getPageCount() - 1 - page : page;
}

private boolean invertDirection(){
return Global.useRtl()&&scrollType==ScrollType.HORIZONTAL;
}

@Override
Expand Down Expand Up @@ -221,19 +227,16 @@ private void changeSide() {
}

private void changeClosePage(boolean next) {
if(scrollType==ScrollType.VERTICAL)next=!next;
if (next && mViewPager.getCurrentItem() < (mViewPager.getAdapter().getCount() - 1))
changePage(mViewPager.getCurrentItem() + 1);
if (!next && mViewPager.getCurrentItem() > 0) changePage(mViewPager.getCurrentItem() - 1);
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
changeLayout(true);
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
changeLayout(false);
}
changeLayout(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE);
}

private boolean hardwareKeys() {
Expand All @@ -242,7 +245,7 @@ private boolean hardwareKeys() {

private void applyMargin(boolean landscape, View view) {
ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) view.getLayoutParams();
lp.setMargins(0, 0, landscape || hardwareKeys() ? Global.getNavigationBarHeight(this) : 0, 0);
lp.setMargins(0, 0, landscape && !hardwareKeys() ? Global.getNavigationBarHeight(this) : 0, 0);
view.setLayoutParams(lp);
}

Expand All @@ -267,6 +270,7 @@ private void changeScrollTypeDialog() {
scrollType = tmpScrollType;
mViewPager.setVerticalMode(scrollType == ScrollType.VERTICAL);
getSharedPreferences("Settings", 0).edit().putInt(SCROLL_TYPE_KEY, scrollType.ordinal()).apply();
changePage(gallery.getPageCount()-1-mViewPager.getCurrentItem());
}
}).setNegativeButton(R.string.cancel, null);
builder.show();
Expand Down Expand Up @@ -403,7 +407,7 @@ public SectionsPagerAdapter(@NonNull FragmentManager fm) {
@NonNull
@Override
public Fragment getItem(int position) {
ZoomFragment f = ZoomFragment.newInstance(gallery, position, directory);
ZoomFragment f = ZoomFragment.newInstance(gallery, offsetPage(position), directory);
f.setClickListener(v -> {
isHidden = !isHidden;
LogUtility.d("Clicked " + isHidden);
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/com/dar/nclientv2/adapters/GalleryAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.dar.nclientv2.api.components.TagList;
import com.dar.nclientv2.api.enums.SpecialTagIds;
import com.dar.nclientv2.api.enums.TagType;
import com.dar.nclientv2.api.local.LocalGallery;
import com.dar.nclientv2.async.database.Queries;
import com.dar.nclientv2.components.GlideX;
import com.dar.nclientv2.components.classes.Size;
Expand Down Expand Up @@ -65,7 +66,7 @@ public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.ViewHold
private final SparseIntArray angles = new SparseIntArray();
private final GalleryActivity context;
private final GenericGallery gallery;
private GalleryFolder directory;
private GalleryFolder directory=null;
private final HashMap<ImageView, BitmapTarget> map = new HashMap<>(5);
private final HashSet<BitmapTarget> toDelete = new HashSet<>();
private Size maxImageSize = null;
Expand All @@ -79,15 +80,16 @@ public GalleryAdapter(GalleryActivity cont, GenericGallery gallery, int colCount
minSize = gallery.getMinSize();
setColCount(colCount);
try {
if (Global.hasStoragePermission(cont)) {
if(gallery instanceof LocalGallery){
directory=gallery.getGalleryFolder();
}else if (Global.hasStoragePermission(cont)) {
if (gallery.getId() != -1) {
File f = Global.findGalleryFolder(context, gallery.getId());
if (f != null) directory = new GalleryFolder(f);
else directory = null;
} else {
directory = new GalleryFolder(gallery.getTitle());
}
} else directory = null;
}
} catch (IllegalArgumentException ignore) {
directory = null;
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/dar/nclientv2/async/VersionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public void onResponse(@NonNull Call call, @NonNull Response response) throws IO
}

private static int extractVersion(String version) {
int index=version.indexOf('-');
if(index>=0)version=version.substring(0,index);
return Integer.parseInt(version.replace(".", ""));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;

import com.dar.nclientv2.components.widgets.CustomViewPager;
Expand All @@ -14,10 +16,11 @@
public class VerticalViewPager extends ViewPager {
private CustomViewPager.OnItemClickListener mOnItemClickListener;
private boolean verticalMode = true;
@Nullable
private OnClickListener onClickListener;

public VerticalViewPager(Context context) {
this(context, null);
init();
}

public VerticalViewPager(Context context, AttributeSet attrs) {
Expand Down Expand Up @@ -48,6 +51,11 @@ private void init() {
setup();
}

@Override
public void setOnClickListener(@Nullable final OnClickListener onClickListener) {
this.onClickListener = onClickListener;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {

Expand Down Expand Up @@ -97,8 +105,12 @@ private MotionEvent flipXY(MotionEvent ev) {

private void setup() {
final GestureDetector tapGestureDetector = new GestureDetector(getContext(), new VerticalViewPager.TapGestureListener());
final GestureDetector onSingleTapConfirmedGestureDetector =
new GestureDetector(getContext(), new OnSingleTapConfirmedGestureListener(this));

setOnTouchListener((v, event) -> {
tapGestureDetector.onTouchEvent(event);
onSingleTapConfirmedGestureDetector.onTouchEvent(event);
performClick();
return false;
});
Expand Down Expand Up @@ -140,6 +152,22 @@ public boolean onSingleTapConfirmed(MotionEvent e) {
return true;
}
}
private class OnSingleTapConfirmedGestureListener extends GestureDetector.SimpleOnGestureListener {

@NonNull
private final View view;

public OnSingleTapConfirmedGestureListener(@NonNull final View view) {
this.view = view;
}

@Override
public boolean onSingleTapConfirmed(final MotionEvent e) {
if (onClickListener != null) {
onClickListener.onClick(view);
}
return true;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public ZoomFragment() {

public static ZoomFragment newInstance(GenericGallery gallery, int page, @Nullable GalleryFolder directory) {
Bundle args = new Bundle();
if (Global.useRtl()) page = gallery.getPageCount() - 1 - page;
args.putInt("PAGE", page);
args.putInt("ID", gallery.getId());
args.putString("URL", gallery.isLocal() ? null : ((Gallery) gallery).getPageUrl(page).toString());
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ar-rSA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,6 @@
<string name="insert_path">Insert path:</string>
<string name="requesting_storage_access">Requesting storage access</string>
<string name="request_storage_manager_summary">Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog.</string>
<string name="summary_beta">Updating to a beta version can make you unable to return to a stable version without uninstalling</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,6 @@
<string name="insert_path">Insert path:</string>
<string name="requesting_storage_access">Requesting storage access</string>
<string name="request_storage_manager_summary">Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog.</string>
<string name="summary_beta">Updating to a beta version can make you unable to return to a stable version without uninstalling</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,6 @@
<string name="insert_path">Insert path:</string>
<string name="requesting_storage_access">Requesting storage access</string>
<string name="request_storage_manager_summary">Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog.</string>
<string name="summary_beta">Updating to a beta version can make you unable to return to a stable version without uninstalling</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-it-rIT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,6 @@
<string name="insert_path">Inserisci percorso</string>
<string name="requesting_storage_access">Richiesta accesso alla memoria</string>
<string name="request_storage_manager_summary">Per via di alcune restrizioni sull\'accesso alla memoria su Android 11 sono richiesti ulteriori permessi per usare i percorsi personalizzati.\nSe vuoi dare questi permessi abilitali nella prossima schermata.</string>
<string name="summary_beta">Updating to a beta version can make you unable to return to a stable version without uninstalling</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-tr-rTR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,5 @@
<string name="insert_path">Dizin Gir:</string>
<string name="requesting_storage_access">Depolamaya erişim izni isteniyor</string>
<string name="request_storage_manager_summary">Android 11\'de depolama erişimine yönelik bazı kısıtlamalar nedeniyle, bu uygulama özel yolları kullanmak için ek izin vermenizi gerektirecektir. \nBu izinleri vermek istiyorsanız, lütfen sonraki iletişim kutusunda uygulamaya izin verin.</string>
<string name="summary_beta">Updating to a beta version can make you unable to return to a stable version without uninstalling</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
<string name="insert_path">Insert path:</string>
<string name="requesting_storage_access">Requesting storage access</string>
<string name="request_storage_manager_summary">Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog.</string>
<string name="summary_beta">Updating to a beta version can make you unable to return to a stable version without uninstalling</string>


</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@
<string name="insert_path">Insert path:</string>
<string name="requesting_storage_access">Requesting storage access</string>
<string name="request_storage_manager_summary">Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog.</string>
<string name="summary_beta">Updating to a beta version can make you unable to return to a stable version without uninstalling</string>


</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
<string name="insert_path">Insert path:</string>
<string name="requesting_storage_access">Requesting storage access</string>
<string name="request_storage_manager_summary">Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog.</string>
<string name="summary_beta">Updating to a beta version can make you unable to return to a stable version without uninstalling</string>

<string-array name="scroll_type">
<item>Horizontal</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
android:defaultValue="false"
android:key="@string/key_enable_beta"
android:title="@string/check_beta_releases"
android:summary="@string/summary_beta"
app:iconSpaceReserved="false" />
<Preference
android:key="@string/key_update"
Expand Down

0 comments on commit d0083cb

Please sign in to comment.