Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit 0de76aa

Browse files
committed
Merge branch 'refactoring'
2 parents 733940c + 590637b commit 0de76aa

File tree

103 files changed

+7165
-4471
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+7165
-4471
lines changed

.tx/config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[main]
2+
host = https://www.transifex.com
3+
4+
[syncthing-android.stringsxml]
5+
file_filter = src/main/res/values-<lang>/strings.xml
6+
source_file = src/main/res/values/strings.xml
7+
source_lang = en
8+
type = ANDROID

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ screenshots: *link to file* (only for UI problems)
4141

4242
Always welcome.
4343

44-
Code should follow the [Android Code Style Guidelines](https://source.android.com/source/code-style.html#java-language-rules), with the exception that we use tabs, not spaces for indentation.
44+
Code should follow the [Android Code Style Guidelines](https://source.android.com/source/code-style.html#java-language-rules). This can be done automatically in Android Studio.
45+
46+
Unit tests are available, and can be executed with `gradle connectedAndroidTest`, or from Android Studio. New code should always add or improve related tests.
4547

4648
Lint warnings should be fixed. If that's not possible, they should be ignored as specifically as possible.

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## syncthing-android
1+
# syncthing-android
22

33
[![tip for next commit](https://tip4commit.com/projects/914.svg)](https://tip4commit.com/github/Nutomic/syncthing-android)
44

@@ -10,12 +10,20 @@ A wrapper of [syncthing](https://github.com/syncthing/syncthing) for Android.
1010

1111
[![Get it on Google Play](https://developer.android.com/images/brand/en_generic_rgb_wo_60.png)](https://play.google.com/store/apps/details?id=com.nutomic.syncthingandroid) [![Get it on F-Droid](https://f-droid.org/wiki/images/0/06/F-Droid-button_get-it-on.png)](https://f-droid.org/repository/browse/?fdid=com.nutomic.syncthingandroid)
1212

13-
## Requirements
13+
# Translations
14+
15+
The project is translated on [Transifex](https://www.transifex.com/projects/p/syncthing-android/).
16+
17+
Translations can be updated using the [Transifex client](http://docs.transifex.com/developer/client/), using commands `tx push -s` and `tx pull -a`.
18+
19+
# Building
20+
21+
### Requirements
1422
- sudo apt-get install build-essential
1523
- Android SDK 19+ and the Android Support Repository are required.
1624
- Use `git clone --recursive https://github.com/Nutomic/syncthing-android` to download the source and its submodules.
1725

18-
## Building
26+
### Build instructions
1927

2028
Use `gradlew assembleDebug` to compile the APK.
2129

@@ -26,21 +34,25 @@ The build process follows three phases:
2634
- The Syncthing native libraries are compiled for the different architectures using `gradlew buildNative`.
2735
- The final APK is built using the `gradlew assembleDebug` task.
2836

37+
To check for updated gradle dependencies, run `gradle dependencyUpdates`. Additionally, the git modules in `ext/syncthing/src/github.com/syncthing/syncthing` and `libraries/android-support-v4-preferencefragment` may need to be updated.
38+
2939

30-
## Getting Syncthing without building natively
40+
### Getting Syncthing without building natively
3141

3242
To get Syncthing app for Android running on you device/emulator the native syncthing binary has to be available. There are multiple ways to get the native syncthing binary:
3343
- open the Syncthing apk (the one taken from the play store) running on your device as a zip, extract the `lib/` folder into your project directory and rename it to `libs/`.
3444
- Depending on your target architecture, download `syncthing-linux-386`, `syncthing-linux-armv5`, `syncthing-linux-armv7` or `syncthing-linux-mips` from [syncthing releases](https://github.com/calmh/syncthing/releases), and extract the binary to `libs/x86/libsyncthing.so`, `libs/armeabi/libsyncthing.so`, `libs/armeabi-v7a/libsyncthing.so` or `libs/mips/libsyncthing.so` respectively.
3545

3646

37-
## Development Notes
47+
### Development Notes
48+
49+
It is recommended to change the GUI and Listen Address ports for the debug app, eg to 8081 and 22001 respectively.
3850

3951
The syncthing backend used for this android application provides a web interface by default. It can be accessed via the Settings menu -> 'Web GUI'. It is quite helpful to access this web interface from your development machine. Read [android documentation](http://developer.android.com/tools/devices/emulator.html#redirection) on how to access the network of your emulator. Or use the following steps to connect to the single currently running emulator/AVD.
4052
- `telnet localhost 5554`
4153
- `redir add tcp:18080:8080`
4254
- Start syncthing app on your emulator and access the web interface from you favorite browser of your development machine via [http://127.0.0.1:18080](http://127.0.0.1:18080)
4355

44-
## License
56+
# License
4557

4658
All code is licensed under the [MIT License](https://github.com/Nutomic/syncthing-android/blob/master/LICENSE).

build.gradle

Lines changed: 116 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,155 @@
11
buildscript {
2-
repositories {
3-
mavenCentral()
4-
}
5-
6-
dependencies {
7-
classpath 'com.android.tools.build:gradle:0.12.+'
8-
classpath 'com.alexvasilkov:android_sign:0.2+'
9-
}
2+
repositories {
3+
mavenCentral()
4+
jcenter()
5+
6+
}
7+
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:0.12.2'
10+
classpath 'com.alexvasilkov:android_sign:0.2'
11+
classpath 'com.github.ben-manes:gradle-versions-plugin:0.5-beta-6'
12+
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
13+
}
1014
}
1115

1216
import java.util.regex.Pattern
1317

1418
apply plugin: 'com.android.application'
1519
apply plugin: 'android_sign'
20+
apply plugin: 'com.github.ben-manes.versions'
1621

1722
repositories {
18-
mavenCentral()
23+
mavenCentral()
24+
maven {
25+
url {
26+
'https://raw.github.com/kolavar/android-support-v4-preferencefragment/master/maven-repository/'
27+
}
28+
}
1929
}
2030

2131
dependencies {
22-
compile 'com.android.support:appcompat-v7:19.1.+'
32+
compile 'com.android.support:appcompat-v7:19.1.0'
33+
compile 'com.android.support:support-v4-preferencefragment:1.0.0@aar'
34+
androidTestCompile 'com.squareup.okhttp:mockwebserver:2.0.0'
2335
}
2436

2537
preBuild {
26-
dependsOn 'buildNative'
38+
dependsOn 'buildNative'
2739
}
2840

2941
android {
30-
compileSdkVersion 19
31-
buildToolsVersion "19.1.0"
32-
33-
defaultConfig {
34-
versionCode getVersionCodeFromManifest()
35-
}
36-
37-
sourceSets {
38-
main {
39-
jniLibs.srcDir file("libs/")
40-
}
41-
}
42-
43-
signingConfigs {
44-
release {
45-
// Android Studio does not pass environment variables.
46-
// This means you have to use the command line for release builds.
47-
def ks = System.getenv("KEYSTORE")
48-
def ka = System.getenv("KEY_ALIAS")
49-
if (ks != null && ka != null) {
50-
storeFile file(ks)
51-
keyAlias ka
52-
}
53-
}
54-
}
55-
56-
buildTypes {
57-
debug {
58-
applicationIdSuffix ".debug"
59-
debuggable true
60-
}
61-
release {
62-
signingConfig signingConfigs.release
63-
}
64-
}
65-
66-
productFlavors {
67-
x86 {
68-
versionCode Integer.parseInt("4" + defaultConfig.versionCode)
69-
ndk {
70-
abiFilter "x86"
71-
}
72-
}
73-
armeabi_v7a {
74-
versionCode Integer.parseInt("3" + defaultConfig.versionCode)
75-
ndk {
76-
abiFilter "armeabi-v7a"
77-
}
78-
}
79-
armeabi {
80-
versionCode Integer.parseInt("2" + defaultConfig.versionCode)
81-
ndk {
82-
abiFilter "armeabi"
83-
}
84-
}
85-
mips {
86-
versionCode Integer.parseInt("1" + defaultConfig.versionCode)
87-
ndk {
88-
abiFilter "mips"
89-
}
90-
}
91-
fat {
92-
versionCode Integer.parseInt("0" + defaultConfig.versionCode)
93-
}
94-
}
42+
compileSdkVersion 19
43+
buildToolsVersion "19.1.0"
44+
45+
defaultConfig {
46+
versionCode getVersionCodeFromManifest()
47+
testApplicationId 'com.nutomic.syncthingandroid.test'
48+
testInstrumentationRunner 'android.test.InstrumentationTestRunner'
49+
testHandleProfiling true
50+
testFunctionalTest true
51+
}
52+
53+
sourceSets {
54+
main {
55+
jniLibs.srcDir file("libs/")
56+
}
57+
}
58+
59+
signingConfigs {
60+
release {
61+
// Android Studio does not pass environment variables.
62+
// This means you have to use the command line for release builds.
63+
def ks = System.getenv("KEYSTORE")
64+
def ka = System.getenv("KEY_ALIAS")
65+
if (ks != null && ka != null) {
66+
storeFile file(ks)
67+
keyAlias ka
68+
}
69+
}
70+
}
71+
72+
buildTypes {
73+
debug {
74+
applicationIdSuffix ".debug"
75+
debuggable true
76+
}
77+
release {
78+
signingConfig signingConfigs.release
79+
}
80+
}
81+
82+
productFlavors {
83+
x86 {
84+
versionCode Integer.parseInt("4" + defaultConfig.versionCode)
85+
ndk {
86+
abiFilter "x86"
87+
}
88+
}
89+
armeabi_v7a {
90+
versionCode Integer.parseInt("3" + defaultConfig.versionCode)
91+
ndk {
92+
abiFilter "armeabi-v7a"
93+
}
94+
}
95+
armeabi {
96+
versionCode Integer.parseInt("2" + defaultConfig.versionCode)
97+
ndk {
98+
abiFilter "armeabi"
99+
}
100+
}
101+
mips {
102+
versionCode Integer.parseInt("1" + defaultConfig.versionCode)
103+
ndk {
104+
abiFilter "mips"
105+
}
106+
}
107+
fat {
108+
versionCode Integer.parseInt("0" + defaultConfig.versionCode)
109+
}
110+
}
111+
compileOptions {
112+
sourceCompatibility JavaVersion.VERSION_1_7
113+
targetCompatibility JavaVersion.VERSION_1_7
114+
}
95115
}
96116

97117
def getVersionCodeFromManifest() {
98-
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
99-
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
100-
def matcher = pattern.matcher(manifestFile.getText())
101-
matcher.find()
102-
return Integer.parseInt(matcher.group(1))
118+
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
119+
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
120+
def matcher = pattern.matcher(manifestFile.getText())
121+
matcher.find()
122+
return Integer.parseInt(matcher.group(1))
103123
}
104124

105125
task buildNative(type: Exec) {
106-
outputs.upToDateWhen { false }
107-
executable = './build-syncthing.sh'
126+
outputs.upToDateWhen { false }
127+
executable = './build-syncthing.sh'
108128
}
109129

110130
task copyNative(type: Copy) {
111-
def lib_dir = "libs/"
112-
new File(lib_dir).mkdirs()
113-
def st_dir = "bin/";
114-
from st_dir + 'syncthing-x86', st_dir + 'syncthing-armeabi', st_dir + 'syncthing-armeabi-v7a';
115-
into lib_dir
116-
rename('syncthing-x86', 'x86/libsyncthing.so')
131+
def lib_dir = "libs/"
132+
new File(lib_dir).mkdirs()
133+
def st_dir = "bin/";
134+
from st_dir + 'syncthing-x86', st_dir + 'syncthing-armeabi', st_dir + 'syncthing-armeabi-v7a';
135+
into lib_dir
136+
rename('syncthing-x86', 'x86/libsyncthing.so')
117137
rename('syncthing-armeabi-v7a', 'armeabi-v7a/libsyncthing.so')
118-
rename('syncthing-armeabi', 'armeabi/libsyncthing.so')
138+
rename('syncthing-armeabi', 'armeabi/libsyncthing.so')
119139
}
120140
buildNative.finalizedBy copyNative
121141

122142
task cleanBin(type: Delete) {
123-
delete 'bin/'
143+
delete 'bin/'
124144
}
125145
copyNative.finalizedBy cleanBin
126146

127147
task cleanNative(type: Delete) {
128-
delete 'bin/'
129-
delete 'build/'
130-
delete 'libs/'
131-
delete 'ext/syncthing/bin/'
132-
delete 'ext/syncthing/pkg/'
148+
delete 'bin/'
149+
delete 'build/'
150+
delete 'libs/'
151+
delete 'ext/syncthing/bin/'
152+
delete 'ext/syncthing/pkg/'
133153
}
134154
clean.dependsOn cleanNative
135155

Submodule syncthing updated 179 files

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include ':android-support-v4-preferencefragment'
2+
project(':android-support-v4-preferencefragment').projectDir = new File('libraries/android-support-v4-preferencefragment')

0 commit comments

Comments
 (0)