Compare commits

...

2 Commits

Author SHA1 Message Date
Sebastian Kürten
9c42af1489 Replace space indent with tabs 2022-08-22 11:45:35 +02:00
Sebastian Kürten
4496df723a Add checkstyle configuration and apply to all modules 2022-08-22 11:37:48 +02:00
10 changed files with 101 additions and 44 deletions

View File

@@ -5,6 +5,7 @@ targetCompatibility = 1.8
apply plugin: 'ru.vyarus.animalsniffer' apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'witness' apply plugin: 'witness'
apply from: 'witness.gradle' apply from: 'witness.gradle'
apply plugin: 'checkstyle'
dependencies { dependencies {
implementation "com.google.dagger:dagger:$dagger_version" implementation "com.google.dagger:dagger:$dagger_version"

View File

@@ -7,6 +7,7 @@ apply plugin: 'idea'
apply plugin: 'witness' apply plugin: 'witness'
apply from: 'witness.gradle' apply from: 'witness.gradle'
apply from: '../dagger.gradle' apply from: '../dagger.gradle'
apply plugin: 'checkstyle'
dependencies { dependencies {
implementation project(path: ':bramble-api', configuration: 'default') implementation project(path: ':bramble-api', configuration: 'default')

View File

@@ -9,9 +9,9 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
@NotNullByDefault @NotNullByDefault
interface UrlConverter { interface UrlConverter {
/** /**
* Converts a raw onion address, excluding the .onion suffix, into an * Converts a raw onion address, excluding the .onion suffix, into an
* HTTP URL. * HTTP URL.
*/ */
String convertOnionToBaseUrl(String onion); String convertOnionToBaseUrl(String onion);
} }

View File

@@ -6,6 +6,7 @@ apply plugin: 'idea'
apply plugin: 'witness' apply plugin: 'witness'
apply from: 'witness.gradle' apply from: 'witness.gradle'
apply from: '../dagger.gradle' apply from: '../dagger.gradle'
apply plugin: 'checkstyle'
configurations { configurations {
tor tor

View File

@@ -1,6 +1,10 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'witness' apply plugin: 'witness'
apply from: 'witness.gradle' apply from: 'witness.gradle'
apply plugin: 'checkstyle'
// Need to manually apply this as the Java plugin is not applied to this module hence this is not
// done automatically.
apply from: "${rootProject.rootDir}/gradle/checkstyle.gradle"
def getStdout = { command, defaultValue -> def getStdout = { command, defaultValue ->
def stdout = new ByteArrayOutputStream() def stdout = new ByteArrayOutputStream()

View File

@@ -16,48 +16,48 @@ import androidx.annotation.UiThread;
public class QrCodeView extends FrameLayout { public class QrCodeView extends FrameLayout {
private final ImageView qrCodeImageView; private final ImageView qrCodeImageView;
private boolean fullscreen = false; private boolean fullscreen = false;
private FullscreenListener listener; private FullscreenListener listener;
public QrCodeView(@NonNull Context context, @Nullable AttributeSet attrs) { public QrCodeView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs); super(context, attrs);
LayoutInflater inflater = (LayoutInflater) context LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.qr_code_view, this, true); inflater.inflate(R.layout.qr_code_view, this, true);
qrCodeImageView = findViewById(R.id.qr_code); qrCodeImageView = findViewById(R.id.qr_code);
ImageView fullscreenButton = findViewById(R.id.fullscreen_button); ImageView fullscreenButton = findViewById(R.id.fullscreen_button);
fullscreenButton.setOnClickListener(v -> { fullscreenButton.setOnClickListener(v -> {
fullscreen = !fullscreen; fullscreen = !fullscreen;
if (!fullscreen) { if (!fullscreen) {
fullscreenButton.setImageResource( fullscreenButton.setImageResource(
R.drawable.ic_fullscreen_black_48dp); R.drawable.ic_fullscreen_black_48dp);
} else { } else {
fullscreenButton.setImageResource( fullscreenButton.setImageResource(
R.drawable.ic_fullscreen_exit_black_48dp); R.drawable.ic_fullscreen_exit_black_48dp);
} }
if (listener != null) if (listener != null)
listener.setFullscreen(fullscreen); listener.setFullscreen(fullscreen);
} }
); );
} }
@UiThread @UiThread
public void setQrCode(Bitmap qrCode) { public void setQrCode(Bitmap qrCode) {
qrCodeImageView.setImageBitmap(qrCode); qrCodeImageView.setImageBitmap(qrCode);
// Simple fade-in animation // Simple fade-in animation
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(200); anim.setDuration(200);
qrCodeImageView.startAnimation(anim); qrCodeImageView.startAnimation(anim);
} }
@UiThread @UiThread
public void setFullscreenListener(FullscreenListener listener) { public void setFullscreenListener(FullscreenListener listener) {
this.listener = listener; this.listener = listener;
} }
public interface FullscreenListener { public interface FullscreenListener {
void setFullscreen(boolean fullscreen); void setFullscreen(boolean fullscreen);
} }
} }

View File

@@ -5,6 +5,7 @@ targetCompatibility = 1.8
apply plugin: 'ru.vyarus.animalsniffer' apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'witness' apply plugin: 'witness'
apply from: 'witness.gradle' apply from: 'witness.gradle'
apply plugin: 'checkstyle'
dependencies { dependencies {
implementation project(path: ':bramble-api', configuration: 'default') implementation project(path: ':bramble-api', configuration: 'default')

View File

@@ -7,6 +7,7 @@ apply plugin: 'idea'
apply plugin: 'witness' apply plugin: 'witness'
apply from: 'witness.gradle' apply from: 'witness.gradle'
apply from: '../dagger.gradle' apply from: '../dagger.gradle'
apply plugin: 'checkstyle'
dependencies { dependencies {
implementation project(path: ':briar-api', configuration: 'default') implementation project(path: ':briar-api', configuration: 'default')

View File

@@ -0,0 +1,19 @@
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="tabWidth" value="4"/>
<property name="charset" value="UTF-8"/>
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="1000"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="TreeWalker">
<module name="RegexpSinglelineJava">
<property name="format" value="^\t* +\t*\S"/>
<property name="message" value="Line has leading space characters; indentation should be performed with tabs only."/>
<property name="ignoreComments" value="true"/>
</module>
</module>
</module>

29
gradle/checkstyle.gradle Normal file
View File

@@ -0,0 +1,29 @@
task checkstyleMain(type: Checkstyle) {
source 'src/main/java'
include '**/*.java'
classpath = files()
reports {
xml {
destination file("build/reports/checkstyle/main.xml")
}
html {
destination file("build/reports/checkstyle/main.html")
}
}
check.dependsOn it
}
task checkstyleTest(type: Checkstyle) {
source 'src/test/java'
include '**/*.java'
classpath = files()
reports {
xml {
destination file("build/reports/checkstyle/test.xml")
}
html {
destination file("build/reports/checkstyle/test.html")
}
}
check.dependsOn it
}