mirror of https://codeberg.org/gitnex/GitNex.git
Fix bugs (#1127)
Fix the bugs reported by @mmarif on Discord. The image bug is not completely fixed, but if the image couldn't be decoded, it will view the "not processable" warning (it shouldn't crash anymore). **Note:** I didn't test it yet due to lack of time. I would be happy if you could do this. Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1127 Reviewed-by: 6543 <6543@noreply.codeberg.org> Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
c571e6cb95
commit
055b08ef77
|
@ -111,7 +111,7 @@ dependencies {
|
||||||
implementation 'com.github.chrisvest:stormpot:2.4.2'
|
implementation 'com.github.chrisvest:stormpot:2.4.2'
|
||||||
implementation 'androidx.browser:browser:1.4.0'
|
implementation 'androidx.browser:browser:1.4.0'
|
||||||
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
||||||
implementation('org.codeberg.gitnex:tea4j-autodeploy:4cd6803f8f') {
|
implementation('org.codeberg.gitnex:tea4j-autodeploy:3111bc1b18') {
|
||||||
exclude module: 'org.apache.oltu.oauth2.common'
|
exclude module: 'org.apache.oltu.oauth2.common'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
|
@ -39,7 +40,7 @@ import retrofit2.Call;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* @author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FileViewActivity extends BaseActivity implements BottomSheetListener {
|
public class FileViewActivity extends BaseActivity implements BottomSheetListener {
|
||||||
|
@ -116,17 +117,19 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||||
// See https://developer.android.com/guide/topics/media/media-formats#core
|
// See https://developer.android.com/guide/topics/media/media-formats#core
|
||||||
if(Arrays.asList("bmp", "gif", "jpg", "jpeg", "png", "webp", "heic", "heif").contains(fileExtension.toLowerCase())) {
|
if(Arrays.asList("bmp", "gif", "jpg", "jpeg", "png", "webp", "heic", "heif").contains(fileExtension.toLowerCase())) {
|
||||||
|
|
||||||
processable = true;
|
|
||||||
|
|
||||||
byte[] pictureBytes = responseBody.bytes();
|
byte[] pictureBytes = responseBody.bytes();
|
||||||
|
|
||||||
runOnUiThread(() -> {
|
Bitmap image = Images.scaleImage(pictureBytes, 1920);
|
||||||
binding.contents.setVisibility(View.GONE);
|
processable = image != null;
|
||||||
binding.markdownFrame.setVisibility(View.GONE);
|
if(processable) {
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
binding.contents.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(image);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ import moe.feng.common.view.breadcrumbs.DefaultBreadcrumbsCallback;
|
||||||
import moe.feng.common.view.breadcrumbs.model.BreadcrumbItem;
|
import moe.feng.common.view.breadcrumbs.model.BreadcrumbItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* @author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapterListener {
|
public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapterListener {
|
||||||
|
@ -151,7 +151,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||||
switch(file.getType()) {
|
switch(file.getType()) {
|
||||||
|
|
||||||
case "dir":
|
case "dir":
|
||||||
path.add(file.getName());
|
path.addWithoutEncoding(file.getName());
|
||||||
binding.breadcrumbsView.addItem(new BreadcrumbItem(Collections.singletonList(file.getName())));
|
binding.breadcrumbsView.addItem(new BreadcrumbItem(Collections.singletonList(file.getName())));
|
||||||
refresh();
|
refresh();
|
||||||
break;
|
break;
|
||||||
|
@ -173,6 +173,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
|
|
||||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(requireContext(), UserAccountsApi.class);
|
UserAccountsApi userAccountsApi = BaseApi.getInstance(requireContext(), UserAccountsApi.class);
|
||||||
|
assert userAccountsApi != null;
|
||||||
List<UserAccount> userAccounts = userAccountsApi.loggedInUserAccounts();
|
List<UserAccount> userAccounts = userAccountsApi.loggedInUserAccounts();
|
||||||
UserAccount account = null;
|
UserAccount account = null;
|
||||||
|
|
||||||
|
@ -252,7 +253,6 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||||
binding.progressBar.setVisibility(View.VISIBLE);
|
binding.progressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||||
|
|
||||||
filesModel.getFilesList2(owner, repo, filesDir, ref, getContext(), binding.progressBar, binding.noDataFiles).observe(getViewLifecycleOwner(), filesListMain2 -> {
|
filesModel.getFilesList2(owner, repo, filesDir, ref, getContext(), binding.progressBar, binding.noDataFiles).observe(getViewLifecycleOwner(), filesListMain2 -> {
|
||||||
|
|
||||||
filesAdapter.getOriginalFiles().clear();
|
filesAdapter.getOriginalFiles().clear();
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.mian.gitnex.fragments;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -36,7 +35,7 @@ import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* @author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RepoInfoFragment extends Fragment {
|
public class RepoInfoFragment extends Fragment {
|
||||||
|
@ -164,7 +163,7 @@ public class RepoInfoFragment extends Fragment {
|
||||||
|
|
||||||
binding.repoMetaForks.setText(String.valueOf(repoInfo.getForksCount()));
|
binding.repoMetaForks.setText(String.valueOf(repoInfo.getForksCount()));
|
||||||
binding.repoMetaWatchers.setText(String.valueOf(repoInfo.getWatchersCount()));
|
binding.repoMetaWatchers.setText(String.valueOf(repoInfo.getWatchersCount()));
|
||||||
binding.repoMetaSize.setText(FileUtils.byteCountToDisplaySize(repoInfo.getSize().intValue() * 1024));
|
binding.repoMetaSize.setText(FileUtils.byteCountToDisplaySize(repoInfo.getSize() * 1024));
|
||||||
|
|
||||||
binding.repoMetaCreatedAt.setText(TimeHelper.formatTime(repoInfo.getCreatedAt(), locale, timeFormat, ctx));
|
binding.repoMetaCreatedAt.setText(TimeHelper.formatTime(repoInfo.getCreatedAt(), locale, timeFormat, ctx));
|
||||||
if(timeFormat.equals("pretty")) {
|
if(timeFormat.equals("pretty")) {
|
||||||
|
@ -300,12 +299,8 @@ public class RepoInfoFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||||
|
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||||
Log.e("onFailure", t.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* @author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Images {
|
public class Images {
|
||||||
|
@ -12,6 +12,7 @@ public class Images {
|
||||||
public static Bitmap scaleImage(byte[] imageData, int sizeLimit) {
|
public static Bitmap scaleImage(byte[] imageData, int sizeLimit) {
|
||||||
|
|
||||||
Bitmap original = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
|
Bitmap original = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
|
||||||
|
if(original == null) return null; // something went wrong
|
||||||
|
|
||||||
if(original.getHeight() > sizeLimit && original.getWidth() <= original.getHeight()) {
|
if(original.getHeight() > sizeLimit && original.getWidth() <= original.getHeight()) {
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,17 @@ public class Path {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public Path addWithoutEncoding(String segment) {
|
||||||
|
|
||||||
|
if(segment != null && !segment.trim().isEmpty()) {
|
||||||
|
segments.add(segment);
|
||||||
|
}
|
||||||
|
|
||||||
|
pathChanged();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
|
||||||
return segments.size();
|
return segments.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
android:paddingStart="10dp"
|
android:paddingStart="10dp"
|
||||||
android:paddingEnd="10dp"
|
android:paddingEnd="10dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
tools:ignore="UseCompoundDrawables">
|
tools:ignore="UseCompoundDrawables">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|
Loading…
Reference in New Issue