mirror of
https://github.com/gitnex-org/gitnex.git
synced 2026-07-16 09:52:49 -05:00
format java code
This commit is contained in:
@@ -3,7 +3,11 @@ package org.mian.gitnex.actions;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.gitnex.tea4j.v2.models.Comment;
|
||||
import org.gitnex.tea4j.v2.models.CreateIssueCommentOption;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueCommentOption;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
|
||||
@@ -3,7 +3,15 @@ package org.mian.gitnex.clients;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.gitnex.tea4j.v2.apis.*;
|
||||
import org.gitnex.tea4j.v2.apis.AdminApi;
|
||||
import org.gitnex.tea4j.v2.apis.IssueApi;
|
||||
import org.gitnex.tea4j.v2.apis.MiscellaneousApi;
|
||||
import org.gitnex.tea4j.v2.apis.NotificationApi;
|
||||
import org.gitnex.tea4j.v2.apis.OrganizationApi;
|
||||
import org.gitnex.tea4j.v2.apis.PackageApi;
|
||||
import org.gitnex.tea4j.v2.apis.RepositoryApi;
|
||||
import org.gitnex.tea4j.v2.apis.SettingsApi;
|
||||
import org.gitnex.tea4j.v2.apis.UserApi;
|
||||
import org.gitnex.tea4j.v2.apis.custom.CustomApi;
|
||||
import org.gitnex.tea4j.v2.apis.custom.OTPApi;
|
||||
import org.gitnex.tea4j.v2.apis.custom.WebApi;
|
||||
|
||||
@@ -27,14 +27,14 @@ public class CustomCodeViewAdapter extends CodeViewAdapter {
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
if(convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.list_items_autocomplete, parent, false);
|
||||
}
|
||||
|
||||
//ImageView codeType = convertView.findViewById(R.id.code_type);
|
||||
TextView codeTitle = convertView.findViewById(R.id.code_title);
|
||||
Code currentCode = (Code) getItem(position);
|
||||
if (currentCode != null) {
|
||||
if(currentCode != null) {
|
||||
codeTitle.setText(currentCode.getCodeTitle());
|
||||
/*if (currentCode instanceof Snippet) {
|
||||
//codeType.setImageResource(R.drawable.ic_snippet);
|
||||
@@ -45,4 +45,5 @@ public class CustomCodeViewAdapter extends CodeViewAdapter {
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,55 +37,83 @@ public class LanguageManager {
|
||||
}
|
||||
|
||||
public String[] getLanguageKeywords(LanguageName language) {
|
||||
switch (language) {
|
||||
case JAVA: return JavaLanguage.getKeywords(context);
|
||||
case PY: return PythonLanguage.getKeywords(context);
|
||||
case GO: return GoLanguage.getKeywords(context);
|
||||
case PHP: return PhpLanguage.getKeywords(context);
|
||||
case XML: return XmlLanguage.getKeywords(context);
|
||||
case HTML: return HtmlLanguage.getKeywords(context);
|
||||
default: return new String[]{};
|
||||
switch(language) {
|
||||
case JAVA:
|
||||
return JavaLanguage.getKeywords(context);
|
||||
case PY:
|
||||
return PythonLanguage.getKeywords(context);
|
||||
case GO:
|
||||
return GoLanguage.getKeywords(context);
|
||||
case PHP:
|
||||
return PhpLanguage.getKeywords(context);
|
||||
case XML:
|
||||
return XmlLanguage.getKeywords(context);
|
||||
case HTML:
|
||||
return HtmlLanguage.getKeywords(context);
|
||||
default:
|
||||
return new String[]{};
|
||||
}
|
||||
}
|
||||
|
||||
public List<Code> getLanguageCodeList(LanguageName language) {
|
||||
switch (language) {
|
||||
case JAVA: return JavaLanguage.getCodeList(context);
|
||||
case PY: return PythonLanguage.getCodeList(context);
|
||||
case GO: return GoLanguage.getCodeList(context);
|
||||
case PHP: return PhpLanguage.getCodeList(context);
|
||||
case XML: return XmlLanguage.getCodeList(context);
|
||||
case HTML: return HtmlLanguage.getCodeList(context);
|
||||
default: return new ArrayList<>();
|
||||
switch(language) {
|
||||
case JAVA:
|
||||
return JavaLanguage.getCodeList(context);
|
||||
case PY:
|
||||
return PythonLanguage.getCodeList(context);
|
||||
case GO:
|
||||
return GoLanguage.getCodeList(context);
|
||||
case PHP:
|
||||
return PhpLanguage.getCodeList(context);
|
||||
case XML:
|
||||
return XmlLanguage.getCodeList(context);
|
||||
case HTML:
|
||||
return HtmlLanguage.getCodeList(context);
|
||||
default:
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Character> getLanguageIndentationStarts(LanguageName language) {
|
||||
switch (language) {
|
||||
case JAVA: return JavaLanguage.getIndentationStarts();
|
||||
case PY: return PythonLanguage.getIndentationStarts();
|
||||
case GO: return GoLanguage.getIndentationStarts();
|
||||
case PHP: return PhpLanguage.getIndentationStarts();
|
||||
case XML: return XmlLanguage.getIndentationStarts();
|
||||
case HTML: return HtmlLanguage.getIndentationStarts();
|
||||
default: return new HashSet<>();
|
||||
switch(language) {
|
||||
case JAVA:
|
||||
return JavaLanguage.getIndentationStarts();
|
||||
case PY:
|
||||
return PythonLanguage.getIndentationStarts();
|
||||
case GO:
|
||||
return GoLanguage.getIndentationStarts();
|
||||
case PHP:
|
||||
return PhpLanguage.getIndentationStarts();
|
||||
case XML:
|
||||
return XmlLanguage.getIndentationStarts();
|
||||
case HTML:
|
||||
return HtmlLanguage.getIndentationStarts();
|
||||
default:
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Character> getLanguageIndentationEnds(LanguageName language) {
|
||||
switch (language) {
|
||||
case JAVA: return JavaLanguage.getIndentationEnds();
|
||||
case PY: return PythonLanguage.getIndentationEnds();
|
||||
case GO: return GoLanguage.getIndentationEnds();
|
||||
case PHP: return PhpLanguage.getIndentationEnds();
|
||||
case XML: return XmlLanguage.getIndentationEnds();
|
||||
case HTML: return HtmlLanguage.getIndentationEnds();
|
||||
default: return new HashSet<>();
|
||||
switch(language) {
|
||||
case JAVA:
|
||||
return JavaLanguage.getIndentationEnds();
|
||||
case PY:
|
||||
return PythonLanguage.getIndentationEnds();
|
||||
case GO:
|
||||
return GoLanguage.getIndentationEnds();
|
||||
case PHP:
|
||||
return PhpLanguage.getIndentationEnds();
|
||||
case XML:
|
||||
return XmlLanguage.getIndentationEnds();
|
||||
case HTML:
|
||||
return HtmlLanguage.getIndentationEnds();
|
||||
default:
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
private void applyFiveColorsDarkTheme(LanguageName language) {
|
||||
switch (language) {
|
||||
switch(language) {
|
||||
case JAVA:
|
||||
JavaLanguage.applyFiveColorsDarkTheme(context, codeView);
|
||||
break;
|
||||
@@ -106,4 +134,5 @@ public class LanguageManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@ public class SourcePositionListener {
|
||||
|
||||
@FunctionalInterface
|
||||
public interface OnPositionChanged {
|
||||
|
||||
void onPositionChange(int line, int column);
|
||||
|
||||
}
|
||||
|
||||
private OnPositionChanged onPositionChanged;
|
||||
@@ -28,8 +30,9 @@ public class SourcePositionListener {
|
||||
if(eventType == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED && onPositionChanged != null) {
|
||||
int selectionStart = editText.getSelectionStart();
|
||||
Layout layout = editText.getLayout();
|
||||
if(layout == null)
|
||||
if(layout == null) {
|
||||
return;
|
||||
}
|
||||
int line = editText.getLayout().getLineForOffset(selectionStart);
|
||||
int column = selectionStart - editText.getLayout().getLineStart(line);
|
||||
onPositionChanged.onPositionChange(line + 1, column + 1);
|
||||
|
||||
@@ -19,10 +19,8 @@ import java.util.regex.Pattern;
|
||||
public class HtmlLanguage {
|
||||
|
||||
//Language Keywords
|
||||
private static final Pattern PATTERN_KEYWORDS = Pattern.compile("\\b(<html|<DOCTYPE|<head|<title|<body|<style|<script|src|href" +
|
||||
"<h1|<h2|<h3|<h4|<h5|<h6|<br|<hr|<section|<header|<footer|<select|<img|<embed|<iframe|<div|<p|code|strong|small|template|" +
|
||||
"input|form|textarea|button|option|label|fieldset|legend|datalist|frame|map|area|canvas|picture|svg|audio|source|track|video|" +
|
||||
"link|nav|ul|ol|li|table|caption|th|tr|td|thead|tbody|tfooter|col|span|main|article|aside|meta|base|noscript|object|param|)\\b");
|
||||
private static final Pattern PATTERN_KEYWORDS = Pattern.compile(
|
||||
"\\b(<html|<DOCTYPE|<head|<title|<body|<style|<script|src|href" + "<h1|<h2|<h3|<h4|<h5|<h6|<br|<hr|<section|<header|<footer|<select|<img|<embed|<iframe|<div|<p|code|strong|small|template|" + "input|form|textarea|button|option|label|fieldset|legend|datalist|frame|map|area|canvas|picture|svg|audio|source|track|video|" + "link|nav|ul|ol|li|table|caption|th|tr|td|thead|tbody|tfooter|col|span|main|article|aside|meta|base|noscript|object|param|)\\b");
|
||||
|
||||
//Brackets and Colons
|
||||
private static final Pattern PATTERN_BUILTINS = Pattern.compile("[,:;[->]{}()]");
|
||||
@@ -35,7 +33,7 @@ public class HtmlLanguage {
|
||||
private static final Pattern PATTERN_SINGLE_LINE_COMMENT = Pattern.compile("//[^\\n]*");
|
||||
private static final Pattern PATTERN_MULTI_LINE_COMMENT = Pattern.compile("/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/");
|
||||
private static final Pattern PATTERN_ATTRIBUTE = Pattern.compile("\\.[a-zA-Z0-9_]+");
|
||||
private static final Pattern PATTERN_OPERATION =Pattern.compile( ":|==|>|<|!=|>=|<=|->|=|>|<|%|-|-=|%=|\\+|\\-|\\-=|\\+=|\\^|\\&|\\|::|\\?|\\*");
|
||||
private static final Pattern PATTERN_OPERATION = Pattern.compile(":|==|>|<|!=|>=|<=|->|=|>|<|%|-|-=|%=|\\+|\\-|\\-=|\\+=|\\^|\\&|\\|::|\\?|\\*");
|
||||
|
||||
public static void applyFiveColorsDarkTheme(Context context, CodeView codeView) {
|
||||
codeView.resetSyntaxPatternList();
|
||||
@@ -71,7 +69,7 @@ public class HtmlLanguage {
|
||||
public static List<Code> getCodeList(Context context) {
|
||||
List<Code> codeList = new ArrayList<>();
|
||||
String[] keywords = getKeywords(context);
|
||||
for (String keyword : keywords) {
|
||||
for(String keyword : keywords) {
|
||||
codeList.add(new Keyword(keyword));
|
||||
}
|
||||
return codeList;
|
||||
@@ -96,4 +94,5 @@ public class HtmlLanguage {
|
||||
public static String getCommentEnd() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,12 +19,8 @@ import java.util.regex.Pattern;
|
||||
public class PhpLanguage {
|
||||
|
||||
//Language Keywords
|
||||
private static final Pattern PATTERN_KEYWORDS = Pattern.compile("\\b(<?php|__construct|var_dump|define|echo|var|float|" +
|
||||
"int|bool|false|true|function|private|public|protected|interface|return|copy|struct|abstract|extends|" +
|
||||
"trait|static|namespace|implements|__set|__get|unlink|this|try|catch|Throwable|Exception|pdo|" +
|
||||
"str_replace|form|date|abs|min|max|strtotime|mktime|" +
|
||||
"foreach|require_once|include_once|hash|array|range|break|continue|preg_match|preg_match_all|preg_replace|" +
|
||||
"throw|new|and|or|if|else|elseif|switch|case|default|match|require|include|goto|do|while|for|map|)\\b");
|
||||
private static final Pattern PATTERN_KEYWORDS = Pattern.compile(
|
||||
"\\b(<?php|__construct|var_dump|define|echo|var|float|" + "int|bool|false|true|function|private|public|protected|interface|return|copy|struct|abstract|extends|" + "trait|static|namespace|implements|__set|__get|unlink|this|try|catch|Throwable|Exception|pdo|" + "str_replace|form|date|abs|min|max|strtotime|mktime|" + "foreach|require_once|include_once|hash|array|range|break|continue|preg_match|preg_match_all|preg_replace|" + "throw|new|and|or|if|else|elseif|switch|case|default|match|require|include|goto|do|while|for|map|)\\b");
|
||||
|
||||
//Brackets and Colons
|
||||
private static final Pattern PATTERN_BUILTINS = Pattern.compile("[,:;[->]{}()]");
|
||||
@@ -37,7 +33,7 @@ public class PhpLanguage {
|
||||
private static final Pattern PATTERN_SINGLE_LINE_COMMENT = Pattern.compile("//[^\\n]*");
|
||||
private static final Pattern PATTERN_MULTI_LINE_COMMENT = Pattern.compile("/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/");
|
||||
private static final Pattern PATTERN_ATTRIBUTE = Pattern.compile("\\.[a-zA-Z0-9_]+");
|
||||
private static final Pattern PATTERN_OPERATION =Pattern.compile( ":|==|>|<|!=|>=|<=|->|=|>|<|%|-|-=|%=|\\+|\\-|\\-=|\\+=|\\^|\\&|\\|::|\\?|\\*");
|
||||
private static final Pattern PATTERN_OPERATION = Pattern.compile(":|==|>|<|!=|>=|<=|->|=|>|<|%|-|-=|%=|\\+|\\-|\\-=|\\+=|\\^|\\&|\\|::|\\?|\\*");
|
||||
|
||||
public static void applyFiveColorsDarkTheme(Context context, CodeView codeView) {
|
||||
codeView.resetSyntaxPatternList();
|
||||
@@ -73,7 +69,7 @@ public class PhpLanguage {
|
||||
public static List<Code> getCodeList(Context context) {
|
||||
List<Code> codeList = new ArrayList<>();
|
||||
String[] keywords = getKeywords(context);
|
||||
for (String keyword : keywords) {
|
||||
for(String keyword : keywords) {
|
||||
codeList.add(new Keyword(keyword));
|
||||
}
|
||||
return codeList;
|
||||
@@ -98,4 +94,5 @@ public class PhpLanguage {
|
||||
public static String getCommentEnd() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class XmlLanguage {
|
||||
private static final Pattern PATTERN_SINGLE_LINE_COMMENT = Pattern.compile("//[^\\n]*");
|
||||
private static final Pattern PATTERN_MULTI_LINE_COMMENT = Pattern.compile("/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/");
|
||||
private static final Pattern PATTERN_ATTRIBUTE = Pattern.compile("\\.[a-zA-Z0-9_]+");
|
||||
private static final Pattern PATTERN_OPERATION =Pattern.compile( ":|==|>|<|!=|>=|<=|->|=|>|<|%|-|-=|%=|\\+|\\-|\\-=|\\+=|\\^|\\&|\\|::|\\?|\\*");
|
||||
private static final Pattern PATTERN_OPERATION = Pattern.compile(":|==|>|<|!=|>=|<=|->|=|>|<|%|-|-=|%=|\\+|\\-|\\-=|\\+=|\\^|\\&|\\|::|\\?|\\*");
|
||||
|
||||
public static void applyFiveColorsDarkTheme(Context context, CodeView codeView) {
|
||||
codeView.resetSyntaxPatternList();
|
||||
@@ -68,7 +68,7 @@ public class XmlLanguage {
|
||||
public static List<Code> getCodeList(Context context) {
|
||||
List<Code> codeList = new ArrayList<>();
|
||||
String[] keywords = getKeywords(context);
|
||||
for (String keyword : keywords) {
|
||||
for(String keyword : keywords) {
|
||||
codeList.add(new Keyword(keyword));
|
||||
}
|
||||
return codeList;
|
||||
@@ -93,4 +93,5 @@ public class XmlLanguage {
|
||||
public static String getCommentEnd() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,13 +21,23 @@ import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.*;
|
||||
import java.security.cert.CertPathValidatorException;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateEncodingException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateExpiredException;
|
||||
import java.security.cert.CertificateParsingException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import javax.net.ssl.*;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
/**
|
||||
* @author Georg Lukas, modified by opyale
|
||||
|
||||
Reference in New Issue
Block a user