mirror of https://codeberg.org/gitnex/GitNex.git
Fix various bugs (#1118)
1. bad layout on translation settings 2. fix ACRA notifications (happened during the cleanup of the deprecated code) 3. final newline in file viewer 4. top newline in diffs 5. missing newline if diff has multiple parts Closes https://codeberg.org/gitnex/GitNex/issues/1093 Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1118 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
685844d41f
commit
e8c223ba1d
|
@ -17,7 +17,6 @@ import org.mian.gitnex.helpers.FontsOverride;
|
|||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.AccountContext;
|
||||
import org.mian.gitnex.notifications.Notifications;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author opyale
|
||||
|
@ -59,7 +58,7 @@ public class MainApplication extends Application {
|
|||
ACRABuilder.withBuildConfigClass(BuildConfig.class).withReportContent(ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL,
|
||||
ReportField.STACK_TRACE, ReportField.AVAILABLE_MEM_SIZE, ReportField.BRAND).setReportFormat(StringFormat.KEY_VALUE_LIST);
|
||||
ACRABuilder.getPluginConfigurationBuilder(NotificationConfigurationBuilder.class).withResTitle(R.string.crashTitle)
|
||||
.withResIcon(R.drawable.gitnex_transparent).withResChannelName(R.string.setCrashReports).withResText(R.string.crashMessage);
|
||||
.withResIcon(R.drawable.gitnex_transparent).withResChannelName(R.string.setCrashReports).withResText(R.string.crashMessage).withEnabled(true);
|
||||
ACRABuilder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class).withMailTo(getResources().getString(R.string.appEmail))
|
||||
.withSubject(getResources().getString(R.string.crashReportEmailSubject, AppUtil
|
||||
.getAppBuildNo(context)))
|
||||
|
|
|
@ -338,7 +338,9 @@ public class AppUtil {
|
|||
|
||||
public static long getLineCount(String s) {
|
||||
|
||||
long lines = 0;
|
||||
if(s.length() < 1) return 0;
|
||||
|
||||
long lines = 1; // we start counting at 1 because there is always at least one line
|
||||
|
||||
Pattern pattern = Pattern.compile("(\r\n|\n)");
|
||||
Matcher matcher = pattern.matcher(s);
|
||||
|
@ -346,11 +348,6 @@ public class AppUtil {
|
|||
while(matcher.find())
|
||||
lines++;
|
||||
|
||||
// Sometimes there may be text, but no line breaks.
|
||||
// This should still count as one line.
|
||||
if(s.length() > 0 && lines == 0)
|
||||
return 1;
|
||||
|
||||
return lines;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package org.mian.gitnex.helpers;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* Author 6543
|
||||
* @author M M Arif
|
||||
* @author 6543
|
||||
*/
|
||||
|
||||
public class FileDiffView implements Serializable {
|
||||
|
@ -137,12 +138,17 @@ public class FileDiffView implements Serializable {
|
|||
return fileInfo;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder raw = new StringBuilder();
|
||||
if(this.contents != null) {
|
||||
for(Content c : this.contents) {
|
||||
raw.append(c.getRaw());
|
||||
if(!c.getRaw().endsWith("\n")) {
|
||||
raw.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
return raw.toString();
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Author 6543
|
||||
* @author 6543
|
||||
*/
|
||||
|
||||
public class ParseDiff {
|
||||
|
@ -108,6 +108,9 @@ public class ParseDiff {
|
|||
if(rawDiff.length <= 1) {
|
||||
continue;
|
||||
}
|
||||
if(rawDiff[1].startsWith("\n")) {
|
||||
rawDiff[1] = rawDiff[1].substring(1);
|
||||
}
|
||||
|
||||
// extract the diff stats info of the first line
|
||||
String statsLine = rawDiffs[j].split("\n")[0].split(" @@")[0];
|
||||
|
|
|
@ -107,15 +107,7 @@ public class SyntaxHighlightedArea extends LinearLayout {
|
|||
.create(new Prism4j(mainGrammarLocator), prism4jTheme, MainGrammarLocator.DEFAULT_FALLBACK_LANGUAGE)
|
||||
.highlight(mainGrammarLocator.fromExtension(extension), source);
|
||||
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if(highlightedSource.charAt(highlightedSource.length() - 1) == '\n') {
|
||||
// Removes a line break which is probably added by Prism4j but not actually present in the source.
|
||||
// This line should be altered in case this gets fixed.
|
||||
sourceView.setText(highlightedSource.subSequence(0, highlightedSource.length() - 1));
|
||||
} else {
|
||||
sourceView.setText(highlightedSource);
|
||||
}
|
||||
});
|
||||
getActivity().runOnUiThread(() -> sourceView.setText(highlightedSource));
|
||||
|
||||
} catch(Throwable ignored) {
|
||||
// Fall back to plaintext if something fails
|
||||
|
|
|
@ -55,8 +55,7 @@
|
|||
android:focusable="true"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
android:padding="15dp"
|
||||
android:layout_marginBottom="5dp">
|
||||
android:padding="15dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLanguageHeaderSelector"
|
||||
|
@ -78,18 +77,20 @@
|
|||
android:textColor="?attr/selectedTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/helpTranslate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:autoLink="web"
|
||||
android:text="@string/settingsHelpTranslateText"
|
||||
android:textColor="@color/lightBlue"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/helpTranslate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="39dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:autoLink="web"
|
||||
android:text="@string/settingsHelpTranslateText"
|
||||
android:textColor="@color/lightBlue"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in New Issue