Merge branch 'main' into delete-release

This commit is contained in:
M M Arif
2022-04-30 16:57:25 +05:00
7 changed files with 36 additions and 35 deletions

View File

@@ -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)))

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -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];

View File

@@ -51,7 +51,10 @@ public class Version {
final Pattern patternNumberDotNumber = Pattern.compile("^\\d+(\\.(\\d)+)*");
if(!valid(raw) || raw.equals("main")) {
if(!valid(raw)) {
throw new IllegalArgumentException("Invalid version format: " + raw);
}
if(raw.equals("main")) {
dev = true;
values = new ArrayList<>();
return;

View File

@@ -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

View File

@@ -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>