Merge branch 'master' into 7-assign-team-to-repo
This commit is contained in:
commit
e8f938bdb0
@ -84,7 +84,6 @@ Thanks to all the open source libraries, contributors and donators.
|
|||||||
- [HamidrezaAmz/BreadcrumbsView](https://github.com/HamidrezaAmz/BreadcrumbsView)
|
- [HamidrezaAmz/BreadcrumbsView](https://github.com/HamidrezaAmz/BreadcrumbsView)
|
||||||
- [Baseflow/PhotoView](https://github.com/Baseflow/PhotoView)
|
- [Baseflow/PhotoView](https://github.com/Baseflow/PhotoView)
|
||||||
- [apache/commons](https://github.com/apache/commons-io)
|
- [apache/commons](https://github.com/apache/commons-io)
|
||||||
- [barteksc/AndroidPdfViewer](https://github.com/barteksc/AndroidPdfViewer)
|
|
||||||
- [ge0rg/MemorizingTrustManager](https://github.com/ge0rg/MemorizingTrustManager)
|
- [ge0rg/MemorizingTrustManager](https://github.com/ge0rg/MemorizingTrustManager)
|
||||||
- [mikaelhg/urlbuilder](https://github.com/mikaelhg/urlbuilder)
|
- [mikaelhg/urlbuilder](https://github.com/mikaelhg/urlbuilder)
|
||||||
- [ACRA/acra](https://github.com/ACRA/acra)
|
- [ACRA/acra](https://github.com/ACRA/acra)
|
||||||
|
@ -100,7 +100,6 @@ dependencies {
|
|||||||
implementation "commons-io:commons-io:20030203.000550"
|
implementation "commons-io:commons-io:20030203.000550"
|
||||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||||
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
||||||
implementation "com.github.barteksc:android-pdf-viewer:3.2.0-beta.1"
|
|
||||||
implementation "ch.acra:acra-mail:$acra"
|
implementation "ch.acra:acra-mail:$acra"
|
||||||
implementation "ch.acra:acra-limiter:$acra"
|
implementation "ch.acra:acra-limiter:$acra"
|
||||||
implementation "ch.acra:acra-notification:$acra"
|
implementation "ch.acra:acra-notification:$acra"
|
||||||
|
@ -15,7 +15,6 @@ import android.view.View;
|
|||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import com.github.barteksc.pdfviewer.util.FitPolicy;
|
|
||||||
import com.vdurmont.emoji.EmojiParser;
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.gitnex.tea4j.models.Files;
|
import org.gitnex.tea4j.models.Files;
|
||||||
@ -45,8 +44,6 @@ import retrofit2.Response;
|
|||||||
public class FileViewActivity extends BaseActivity implements BottomSheetFileViewerFragment.BottomSheetListener {
|
public class FileViewActivity extends BaseActivity implements BottomSheetFileViewerFragment.BottomSheetListener {
|
||||||
|
|
||||||
private ActivityFileViewBinding binding;
|
private ActivityFileViewBinding binding;
|
||||||
private Boolean pdfNightMode;
|
|
||||||
|
|
||||||
private Files file;
|
private Files file;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,8 +52,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
binding = ActivityFileViewBinding.inflate(getLayoutInflater());
|
binding = ActivityFileViewBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
|
||||||
|
|
||||||
|
setContentView(binding.getRoot());
|
||||||
setSupportActionBar(binding.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
|
|
||||||
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||||
@ -84,7 +81,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if(tinyDB.getBoolean("fileModified")) {
|
if(tinyDB.getBoolean("fileModified")) {
|
||||||
|
|
||||||
String repoFullName = tinyDB.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoBranch = tinyDB.getString("repoBranch");
|
String repoBranch = tinyDB.getString("repoBranch");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -93,7 +89,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
getSingleFileContents(repoOwner, repoName, file.getPath(), repoBranch);
|
getSingleFileContents(repoOwner, repoName, file.getPath(), repoBranch);
|
||||||
tinyDB.putBoolean("fileModified", false);
|
tinyDB.putBoolean("fileModified", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +111,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
if(responseBody != null) {
|
if(responseBody != null) {
|
||||||
|
|
||||||
runOnUiThread(() -> binding.progressBar.setVisibility(View.GONE));
|
runOnUiThread(() -> binding.progressBar.setVisibility(View.GONE));
|
||||||
|
|
||||||
String fileExtension = FileUtils.getExtension(filename);
|
String fileExtension = FileUtils.getExtension(filename);
|
||||||
|
|
||||||
boolean processable = false;
|
boolean processable = false;
|
||||||
@ -133,14 +127,11 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
byte[] pictureBytes = responseBody.bytes();
|
byte[] pictureBytes = responseBody.bytes();
|
||||||
|
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
|
|
||||||
binding.contents.setVisibility(View.GONE);
|
binding.contents.setVisibility(View.GONE);
|
||||||
binding.pdfViewFrame.setVisibility(View.GONE);
|
|
||||||
binding.markdownFrame.setVisibility(View.GONE);
|
binding.markdownFrame.setVisibility(View.GONE);
|
||||||
|
|
||||||
binding.photoView.setVisibility(View.VISIBLE);
|
binding.photoView.setVisibility(View.VISIBLE);
|
||||||
binding.photoView.setImageBitmap(Images.scaleImage(pictureBytes, 1920));
|
binding.photoView.setImageBitmap(Images.scaleImage(pictureBytes, 1920));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -153,78 +144,31 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
processable = true;
|
processable = true;
|
||||||
|
|
||||||
String text = responseBody.string();
|
String text = responseBody.string();
|
||||||
|
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
|
|
||||||
binding.photoView.setVisibility(View.GONE);
|
binding.photoView.setVisibility(View.GONE);
|
||||||
binding.markdownFrame.setVisibility(View.GONE);
|
binding.markdownFrame.setVisibility(View.GONE);
|
||||||
binding.pdfViewFrame.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
binding.contents.setVisibility(View.VISIBLE);
|
binding.contents.setVisibility(View.VISIBLE);
|
||||||
binding.contents.setContent(text, fileExtension);
|
binding.contents.setContent(text, fileExtension);
|
||||||
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DOCUMENT:
|
|
||||||
|
|
||||||
if(fileExtension.equalsIgnoreCase("pdf")) {
|
|
||||||
|
|
||||||
processable = true;
|
|
||||||
|
|
||||||
byte[] documentBytes = responseBody.bytes();
|
|
||||||
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
|
|
||||||
binding.photoView.setVisibility(View.GONE);
|
|
||||||
binding.markdownFrame.setVisibility(View.GONE);
|
|
||||||
binding.contents.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
pdfNightMode = tinyDB.getBoolean("enablePdfMode");
|
|
||||||
|
|
||||||
binding.pdfViewFrame.setVisibility(View.VISIBLE);
|
|
||||||
binding.pdfView.fromBytes(documentBytes)
|
|
||||||
.enableSwipe(true)
|
|
||||||
.swipeHorizontal(false)
|
|
||||||
.enableDoubletap(true)
|
|
||||||
.defaultPage(0)
|
|
||||||
.enableAnnotationRendering(false)
|
|
||||||
.password(null)
|
|
||||||
.scrollHandle(null)
|
|
||||||
.enableAntialiasing(true)
|
|
||||||
.spacing(0)
|
|
||||||
.autoSpacing(true)
|
|
||||||
.pageFitPolicy(FitPolicy.WIDTH)
|
|
||||||
.fitEachPage(true)
|
|
||||||
.pageSnap(false)
|
|
||||||
.pageFling(true)
|
|
||||||
.nightMode(pdfNightMode).load();
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!processable) { // While the file could still be non-binary,
|
if(!processable) { // While the file could still be non-binary,
|
||||||
// it's better we don't show it (to prevent any crashes and/or unwanted behavior) and let the user download it instead.
|
// it's better we don't show it (to prevent any crashes and/or unwanted behavior) and let the user download it instead.
|
||||||
|
|
||||||
responseBody.close();
|
responseBody.close();
|
||||||
|
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
|
|
||||||
binding.photoView.setVisibility(View.GONE);
|
binding.photoView.setVisibility(View.GONE);
|
||||||
binding.contents.setVisibility(View.GONE);
|
binding.contents.setVisibility(View.GONE);
|
||||||
binding.pdfViewFrame.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
binding.markdownFrame.setVisibility(View.VISIBLE);
|
binding.markdownFrame.setVisibility(View.VISIBLE);
|
||||||
binding.markdown.setText(getString(R.string.excludeFilesInFileViewer));
|
binding.markdown.setText(getString(R.string.excludeFilesInFileViewer));
|
||||||
binding.markdown.setGravity(Gravity.CENTER);
|
binding.markdown.setGravity(Gravity.CENTER);
|
||||||
binding.markdown.setTypeface(null, Typeface.BOLD);
|
binding.markdown.setTypeface(null, Typeface.BOLD);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -233,7 +177,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
binding.markdown.setText("");
|
binding.markdown.setText("");
|
||||||
binding.progressBar.setVisibility(View.GONE);
|
binding.progressBar.setVisibility(View.GONE);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -304,27 +247,22 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
} else if(id == R.id.markdown) {
|
} else if(id == R.id.markdown) {
|
||||||
|
|
||||||
if(!tinyDB.getBoolean("enableMarkdownInFileView")) {
|
if(!tinyDB.getBoolean("enableMarkdownInFileView")) {
|
||||||
|
|
||||||
Markdown.render(ctx, EmojiParser.parseToUnicode(binding.contents.getContent()), binding.markdown);
|
Markdown.render(ctx, EmojiParser.parseToUnicode(binding.contents.getContent()), binding.markdown);
|
||||||
|
|
||||||
binding.contents.setVisibility(View.GONE);
|
binding.contents.setVisibility(View.GONE);
|
||||||
binding.markdownFrame.setVisibility(View.VISIBLE);
|
binding.markdownFrame.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
tinyDB.putBoolean("enableMarkdownInFileView", true);
|
tinyDB.putBoolean("enableMarkdownInFileView", true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
binding.markdownFrame.setVisibility(View.GONE);
|
binding.markdownFrame.setVisibility(View.GONE);
|
||||||
binding.contents.setVisibility(View.VISIBLE);
|
binding.contents.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,19 +271,16 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
public void onButtonClicked(String text) {
|
public void onButtonClicked(String text) {
|
||||||
|
|
||||||
if("downloadFile".equals(text)) {
|
if("downloadFile".equals(text)) {
|
||||||
|
|
||||||
requestFileDownload();
|
requestFileDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
if("deleteFile".equals(text)) {
|
if("deleteFile".equals(text)) {
|
||||||
|
|
||||||
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
||||||
intent.putExtra("fileAction", CreateFileActivity.FILE_ACTION_DELETE);
|
intent.putExtra("fileAction", CreateFileActivity.FILE_ACTION_DELETE);
|
||||||
intent.putExtra("filePath", file.getPath());
|
intent.putExtra("filePath", file.getPath());
|
||||||
intent.putExtra("fileSha", file.getSha());
|
intent.putExtra("fileSha", file.getSha());
|
||||||
|
|
||||||
ctx.startActivity(intent);
|
ctx.startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if("editFile".equals(text)) {
|
if("editFile".equals(text)) {
|
||||||
@ -363,7 +298,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
ctx.startActivity(intent);
|
ctx.startActivity(intent);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.fileTypeCannotBeEdited));
|
Toasty.error(ctx, getString(R.string.fileTypeCannotBeEdited));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,22 +83,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/pdfViewFrame"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?attr/primaryBackgroundColor"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<com.github.barteksc.pdfviewer.PDFView
|
|
||||||
android:id="@+id/pdfView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?attr/primaryBackgroundColor" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<org.mian.gitnex.helpers.views.SyntaxHighlightedArea
|
<org.mian.gitnex.helpers.views.SyntaxHighlightedArea
|
||||||
android:id="@+id/contents"
|
android:id="@+id/contents"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user