Skip to content

Commit

Permalink
NClientV2 2.3.6
Browse files Browse the repository at this point in the history
- Bug fixes
  • Loading branch information
Dar9586 committed Jun 8, 2020
1 parent c790a9f commit 90390db
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.dar.nclientv2"
minSdkVersion 14
targetSdkVersion 29
versionCode 235
versionName "2.3.5"
versionCode 236
versionName "2.3.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/com/dar/nclientv2/GalleryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,21 @@ private boolean tryLoadFromURL() {
if(data != null && data.getPathSegments().size() >= 2){//if using an URL
List<String> params = data.getPathSegments();
LogUtility.d(params.size()+": "+params);
if(params.size()>2){
int id;
try{//if not an id return
id=Integer.parseInt(params.get(1));
}catch (NumberFormatException ignore){
return false;
}
if(params.size()>2){//check if it has a specific page
try{
zoom=Integer.parseInt(params.get(2));
}catch (NumberFormatException e){
LogUtility.e(e.getLocalizedMessage(),e);
zoom=0;
}
}
InspectorV3.galleryInspector(this,Integer.parseInt(params.get(1)),new InspectorV3.DefaultInspectorResponse(){
InspectorV3.galleryInspector(this,id,new InspectorV3.DefaultInspectorResponse(){

@Override
public void onSuccess(List<GenericGallery> galleries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int pos) {
int position=holder.getAdapterPosition();
final int position=holder.getAdapterPosition();
Bookmark bookmark=bookmarks.get(position);

holder.queryText.setText(bookmark.toString());
Expand All @@ -67,6 +67,7 @@ private void loadBookmark(Bookmark bookmark) {
* @param position index to delete
* */
private void removeBookmarkAtPosition(int position) {
if(position>=bookmarks.size())return;
Bookmark bookmark=bookmarks.get(position);
bookmark.deleteBookmark();
bookmarks.remove(bookmark);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/dar/nclientv2/adapters/TagsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@ private void showBlacklistDialog(final Tag tag,final ImageView imgView) {
}).setNegativeButton(R.string.no,null).show();
}
private void onlineTagUpdate(final Tag tag, final boolean add,final ImageView imgView) throws IOException{
if(!Login.isLogged()&&Login.getUser()!=null)return;
StringWriter sw=new StringWriter();
JsonWriter jw=new JsonWriter(sw);
jw.beginObject().name("added").beginArray();
if(add)writeTag(jw,tag);
jw.endArray().name("removed").beginArray();
if(!add)writeTag(jw,tag);
jw.endArray().endObject();

final String url=String.format(Locale.US,"https://"+ Utility.getHost()+"/users/%d/%s/blacklist",Login.getUser().getId(),Login.getUser().getCodename());
final RequestBody ss=RequestBody.create(MediaType.get("application/json"),sw.toString());
Global.getClient(context).newCall(new Request.Builder().url(url).build()).enqueue(new Callback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private int oldReadId(){
if(!nomedia.exists())return SpecialTagIds.INVALID_ID;
try (BufferedReader br = new BufferedReader(new FileReader(nomedia))){//ID check with nomedia
return Integer.parseInt(br.readLine());
}catch (IOException ignore){}
}catch (IOException|NumberFormatException ignore){}
return SpecialTagIds.INVALID_ID;
}

Expand Down
33 changes: 19 additions & 14 deletions app/src/main/java/com/dar/nclientv2/async/CreatePDF.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,9 @@ protected void onHandleWork(@Nullable Intent intent) {
notification.setProgress(0,0,false);
notification.setContentTitle(getString(R.string.created_pdf));
notification.setContentText(gallery.getTitle());
Intent i = new Intent(Intent.ACTION_VIEW);
Uri apkURI = FileProvider.getUriForFile(
getApplicationContext(),getApplicationContext().getPackageName() + ".provider", finalPath);
i.setDataAndType(apkURI, "application/pdf");
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
List<ResolveInfo> resInfoList = getApplicationContext().getPackageManager().queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
getApplicationContext().grantUriPermission(packageName, apkURI, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
}

notification.setContentIntent(PendingIntent.getActivity(getApplicationContext(),0,i,0));
createIntentOpen(finalPath);
NotificationSettings.notify(getString(R.string.channel2_name),notId,notification.build());
LogUtility.d(finalPath.getAbsolutePath());
LogUtility.d(apkURI.toString());
}catch(IOException e){
notification.setContentTitle(getString(R.string.error_pdf));
notification.setContentText(getString(R.string.failed));
Expand All @@ -110,6 +97,24 @@ protected void onHandleWork(@Nullable Intent intent) {

}

private void createIntentOpen(File finalPath) {
Intent i = new Intent(Intent.ACTION_VIEW);
Uri apkURI = FileProvider.getUriForFile(
getApplicationContext(),getApplicationContext().getPackageName() + ".provider", finalPath);
i.setDataAndType(apkURI, "application/pdf");
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
List<ResolveInfo> resInfoList = getApplicationContext().getPackageManager().queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
getApplicationContext().grantUriPermission(packageName, apkURI, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
}

notification.setContentIntent(PendingIntent.getActivity(getApplicationContext(),0,i,0));
LogUtility.d(apkURI.toString());

}

private void preExecute(File file) {
notification=new NotificationCompat.Builder(getApplicationContext(), Global.CHANNEL_ID2);
notification.setSmallIcon(R.drawable.ic_image)
Expand Down
14 changes: 6 additions & 8 deletions app/src/main/res/layout/activity_zoom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">





<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">



<TextView
android:id="@+id/page_text"
android:background="#5f000000"
android:textColor="#ffffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:paddingBottom="8dp"
android:paddingEnd="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:paddingLeft="8dp"
android:paddingStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down

0 comments on commit 90390db

Please sign in to comment.