1
0
mirror of https://codeberg.org/gitnex/GitNex synced 2025-03-09 16:10:50 +01:00

Update for issue 267

This commit is contained in:
M M Arif 2020-03-09 21:13:40 +05:00
parent 3a481084b6
commit f7d5ee9e7a
3 changed files with 27 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package org.mian.gitnex.activities;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
@ -11,6 +12,7 @@ import android.os.Environment;
import android.text.method.ScrollingMovementMethod; import android.text.method.ScrollingMovementMethod;
import android.util.Base64; import android.util.Base64;
import android.util.Log; import android.util.Log;
import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -206,6 +208,18 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
.nightMode(pdfNightMode) .nightMode(pdfNightMode)
.load(); .load();
}
else if (appUtil.excludeFilesInFileViewerExtension(fileExtension)) { // files need to be excluded
imageView.setVisibility(View.GONE);
singleCodeContents.setVisibility(View.GONE);
pdfViewFrame.setVisibility(View.GONE);
singleFileContentsFrame.setVisibility(View.VISIBLE);
singleFileContents.setText(getResources().getString(R.string.excludeFilesInFileviewer));
singleFileContents.setGravity(Gravity.CENTER);
singleFileContents.setTypeface(null, Typeface.BOLD);
} }
else { // file type not known - plain text view else { // file type not known - plain text view

View File

@ -218,7 +218,8 @@ public class AppUtil {
"coffee", "rc", "rs", "rust", "basic", "clj", "css", "dart", "lisp", "erl", "hs", "lsp", "rkt", "coffee", "rc", "rs", "rust", "basic", "clj", "css", "dart", "lisp", "erl", "hs", "lsp", "rkt",
"ss", "llvm", "ll", "lua", "matlab", "pascal", "r", "scala", "sql", "latex", "tex", "vb", "vbs", "ss", "llvm", "ll", "lua", "matlab", "pascal", "r", "scala", "sql", "latex", "tex", "vb", "vbs",
"vhd", "tcl", "wiki.meta", "yaml", "yml", "markdown", "xml", "proto", "regex", "py", "pl", "js", "vhd", "tcl", "wiki.meta", "yaml", "yml", "markdown", "xml", "proto", "regex", "py", "pl", "js",
"html", "htm", "volt", "ini", "htaccess", "conf", "gitignore", "gradle", "txt", "properties", "bat"}; "html", "htm", "volt", "ini", "htaccess", "conf", "gitignore", "gradle", "txt", "properties", "bat",
"twig"};
return Arrays.asList(extValues).contains(ext); return Arrays.asList(extValues).contains(ext);
@ -240,6 +241,16 @@ public class AppUtil {
} }
public Boolean excludeFilesInFileViewerExtension(String ext) {
String[] extValues = new String[] {"doc", "docx", "ppt", "pptx", "xls", "xlsx", "xlsm", "odt",
"ott", "odf", "ods", "ots", "exe", "jar", "odg", "otg", "odp", "otp", "bin", "dmg", "psd",
"xcf"};
return Arrays.asList(extValues).contains(ext);
}
public String getLastCharactersOfWord( String str, int count ) { public String getLastCharactersOfWord( String str, int count ) {
return str.substring(str.length() - count); return str.substring(str.length() - count);

View File

@ -554,4 +554,5 @@
<string name="downloadFile">Download This File</string> <string name="downloadFile">Download This File</string>
<string name="waitLoadingDownloadFile">Please wait for the file to load to memory</string> <string name="waitLoadingDownloadFile">Please wait for the file to load to memory</string>
<string name="downloadFileSaved">File is saved to Download directory</string> <string name="downloadFileSaved">File is saved to Download directory</string>
<string name="excludeFilesInFileviewer">This file type is not supported in file viewer. Download it instead from the three dotted menu?</string>
</resources> </resources>