Skip to content

Commit 5ba343e

Browse files
authored
Merge pull request #14 from devmil/dev
Merge current dev state into master
2 parents ae8945d + 8cfaa8f commit 5ba343e

26 files changed

+1065
-171
lines changed

.ci/build.sh

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,47 @@
11
#!/bin/bash
2-
set -ex
3-
gradle build
4-
gradle assembleDebug
5-
gradle assembleRelease
6-
chown -R `stat -c "%u:%g" $(pwd)/app` $(pwd)/app/build
7-
chown -R `stat -c "%u:%g" $(pwd)/app` $(pwd)/build
2+
#set -xeuo pipefail
3+
set -x pipefail
4+
5+
source_root=/home/app
6+
7+
echo copying code to build to /tmp/Paperlaunch
8+
9+
if [ -d /tmp/Paperlaunch ]; then
10+
rm -rf /tmp/Paperlaunch
11+
fi
12+
cp -r $source_root /tmp/Paperlaunch
13+
cd /tmp/Paperlaunch
14+
15+
# rename local properties if they are present (e.g. when the docker build is started locally)
16+
if [ -f ./local.properties ]; then
17+
mv ./local.properties ./local.properties.tmp
18+
fi
19+
20+
# build scope
21+
(
22+
set -e
23+
gradle test
24+
gradle assembleDebug
25+
gradle assembleRelease
26+
chown -R `stat -c "%u:%g" $(pwd)/app` $(pwd)/app/build
27+
chown -R `stat -c "%u:%g" $(pwd)/app` $(pwd)/build
28+
)
29+
30+
cmdresult=$?
31+
32+
# rename the local properties back after the build is finished
33+
if [ -f ./local.properties.tmp ]; then
34+
mv ./local.properties.tmp ./local.properties
35+
fi
36+
37+
if [ $cmdresult -eq 0 ]; then
38+
if [ -d $source_root/app/build ]; then
39+
rm -rf $source_root/app/app/build
40+
fi
41+
cp -r $(pwd)/app/build $source_root/app/build
42+
cd $source_root
43+
chown -R `stat -c "%u:%g" $(pwd)/app` $(pwd)/app/build
44+
fi
45+
46+
# return the build result
47+
exit $cmdresult

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77
/captures
88
.idea/
99
Key/
10-
/.project
10+
/.project
11+
.ci/build_lf.sh
12+
local.properties.tmp

Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ FROM anapsix/alpine-java:8_jdk
22

33
# Install Gradle
44
RUN apk add --update openssl \
5-
&& wget https://services.gradle.org/distributions/gradle-4.6-bin.zip \
6-
&& unzip gradle-4.6-bin.zip -d /opt/ \
7-
&& mv opt/gradle-4.6/ opt/gradle \
8-
&& rm gradle-4.6-bin.zip
5+
&& wget https://services.gradle.org/distributions/gradle-5.1.1-bin.zip \
6+
&& unzip gradle-5.1.1-bin.zip -d /opt/ \
7+
&& mv opt/gradle-5.1.1/ opt/gradle \
8+
&& rm gradle-5.1.1-bin.zip
99

1010
ENV GRADLE /opt/gradle/bin
1111
ENV PATH ${PATH}:${GRADLE}
@@ -24,4 +24,10 @@ RUN wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip \
2424
ENV PATH ${PATH}:${ANDROID_HOME}/tools/bin
2525

2626
RUN yes | sdkmanager --licenses \
27-
&& sdkmanager "platforms;android-27" "platform-tools" "extras;google;m2repository" "build-tools;27.0.3" --verbose
27+
&& sdkmanager "platforms;android-27" "platform-tools" "extras;google;m2repository" "build-tools;28.0.3" --verbose
28+
29+
# Support for CRLF scripts
30+
RUN apk add dos2unix
31+
32+
# bash_r is a wrapper for bash that removes \r
33+
ADD bash_r.tgz /bin

app/app.iml

Lines changed: 63 additions & 42 deletions
Large diffs are not rendered by default.

app/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ android {
1212
versionCode 14
1313
versionName "1.0.12"
1414
archivesBaseName = "paperlaunch-v${defaultConfig.versionName}-${buildTime()}"
15+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1516
}
1617
signingConfigs {
1718
release {
@@ -54,12 +55,15 @@ dependencies {
5455
implementation 'io.reactivex:rxjava:1.1.0'
5556
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
5657
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
58+
59+
testImplementation 'junit:junit:4.12'
60+
testImplementation 'org.mockito:mockito-core:1.10.19'
5761
}
5862
repositories {
5963
mavenCentral()
6064
}
6165

62-
def buildTime() {
66+
static def buildTime() {
6367
return new Date().format("yyyyMMdd")
6468
}
6569

app/src/main/java/de/devmil/paperlaunch/config/UserSettings.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ class UserSettings(context: Context) : IUserSettings {
6464

6565
companion object {
6666

67-
private val SHARED_PREFS_NAME = "paperLaunch"
67+
internal val SHARED_PREFS_NAME = "paperLaunch"
6868

69-
private val KEY_SENSITIVITY_DIP = "sensitivityDip"
70-
private val KEY_ACTIVATION_OFFSET_POSITION_DIP = "activationOffsetPositionDip"
71-
private val KEY_ACTIVATION_OFFSET_HEIGHT_DIP = "activationOffsetHeightDip"
72-
private val KEY_SHOW_BACKGROUND = "showBackground"
73-
private val KEY_VIBRATE_ON_ACTIVATION = "vibrateOnActivation"
74-
private val KEY_IS_ON_RIGHT_SIDE = "isOnRightSide"
75-
private val KEY_LAUNCHER_GRAVITY = "launcherGravity"
76-
private val KEY_SHOW_LOGO = "showLogo"
77-
private val KEY_ITEM_SCALE_PERCENT = "itemScalePercent"
69+
internal val KEY_SENSITIVITY_DIP = "sensitivityDip"
70+
internal val KEY_ACTIVATION_OFFSET_POSITION_DIP = "activationOffsetPositionDip"
71+
internal val KEY_ACTIVATION_OFFSET_HEIGHT_DIP = "activationOffsetHeightDip"
72+
internal val KEY_SHOW_BACKGROUND = "showBackground"
73+
internal val KEY_VIBRATE_ON_ACTIVATION = "vibrateOnActivation"
74+
internal val KEY_IS_ON_RIGHT_SIDE = "isOnRightSide"
75+
internal val KEY_LAUNCHER_GRAVITY = "launcherGravity"
76+
internal val KEY_SHOW_LOGO = "showLogo"
77+
internal val KEY_ITEM_SCALE_PERCENT = "itemScalePercent"
7878

7979
private val DEFAULT_SENSITIVITY_DIP = 10
8080
private val DEFAULT_ACTIVATION_OFFSET_POSITION_DIP = 0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package de.devmil.paperlaunch.model
2+
3+
import android.content.Context
4+
import android.content.Intent
5+
import android.graphics.drawable.Drawable
6+
import de.devmil.paperlaunch.utils.AppMetadataUtils
7+
8+
class AndroidContextAccess(private val context: Context) : IContextAccess {
9+
10+
override fun getDrawable(id: Int, themed : Boolean) : Drawable {
11+
if(themed) {
12+
return context.resources.getDrawable(id, context.theme)
13+
}
14+
return context.getDrawable(id)
15+
}
16+
17+
override fun getAppName(intent: Intent): String? {
18+
return AppMetadataUtils.getAppName(context, intent)
19+
}
20+
21+
override fun getAppIcon(intent: Intent): Drawable {
22+
return AppMetadataUtils.getAppIcon(context, intent)
23+
}
24+
}

app/src/main/java/de/devmil/paperlaunch/model/Folder.kt

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@
1515
*/
1616
package de.devmil.paperlaunch.model
1717

18-
import android.content.Context
1918
import android.graphics.drawable.Drawable
20-
2119
import de.devmil.paperlaunch.R
2220
import de.devmil.paperlaunch.storage.EntryDTO
2321
import de.devmil.paperlaunch.storage.FolderDTO
2422

25-
class Folder(val dto: FolderDTO, private val entryDto: EntryDTO, var subEntriesList: List<IEntry>?) : IFolder {
23+
class Folder(private val contextAccess: IContextAccess, val dto: FolderDTO, private val entryDto: EntryDTO, private var subEntriesList: List<IEntry>?) : IFolder {
2624

2725
override val id: Long
2826
get() = dto.id
@@ -33,28 +31,28 @@ class Folder(val dto: FolderDTO, private val entryDto: EntryDTO, var subEntriesL
3331
override val orderIndex: Long
3432
get() = entryDto.orderIndex
3533

36-
override fun getName(context: Context): String? {
37-
return dto.name
38-
}
34+
override val name: String?
35+
get() = dto.name
3936

40-
override fun getFolderSummaryIcon(context: Context): Drawable {
41-
return context.resources.getDrawable(R.mipmap.ic_folder_grey600_48dp, context.theme)
42-
}
37+
override val folderSummaryIcon: Drawable
38+
get() = contextAccess.getDrawable(R.mipmap.ic_folder_grey600_48dp, true)
4339

4440
override val isFolder: Boolean
4541
get() = true
4642

47-
override fun getIcon(context: Context): Drawable? {
48-
var result = dto.icon
49-
if (result == null) {
50-
result = context.getDrawable(R.mipmap.folder_frame)
43+
override val icon: Drawable?
44+
get() {
45+
var result = dto.icon
46+
if (result == null) {
47+
result = contextAccess.getDrawable(R.mipmap.folder_frame, false)
48+
}
49+
return result
5150
}
52-
return result
53-
}
5451

55-
override fun useIconColor(): Boolean {
56-
return true
57-
}
52+
override val useIconColor: Boolean
53+
get() {
54+
return true
55+
}
5856

5957
override var subEntries: List<IEntry>?
6058
get() = subEntriesList
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package de.devmil.paperlaunch.model
2+
3+
import android.content.Intent
4+
import android.graphics.drawable.Drawable
5+
6+
/**
7+
* @brief interface for accessing data that gets provided via the context
8+
* this interface can be used to push the Context dependency to the edge
9+
* and keep the core (j)unit testable
10+
*/
11+
interface IContextAccess {
12+
13+
/**
14+
* @brief returns a drawable with the given id
15+
* @param id the id of the drawable
16+
* @param themed when set to [true] the current theme gets applied, otherwise the default
17+
* "getDrawable" is called
18+
*/
19+
fun getDrawable(id: Int, themed : Boolean) : Drawable
20+
21+
/**
22+
* @brief returns the application name the given Intent is pointing to
23+
*/
24+
fun getAppName(intent: Intent): String?
25+
26+
/**
27+
* @brief returns the application icon the given Intent is pointing to
28+
*/
29+
fun getAppIcon(intent: Intent): Drawable
30+
}

app/src/main/java/de/devmil/paperlaunch/model/IEntry.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ interface IEntry {
2323
val id: Long
2424
val entryId: Long
2525
val orderIndex: Long
26-
fun getName(context: Context): String?
27-
fun getIcon(context: Context): Drawable?
28-
fun getFolderSummaryIcon(context: Context): Drawable?
26+
val name: String?
27+
val icon: Drawable?
28+
val folderSummaryIcon: Drawable?
2929
val isFolder: Boolean
30-
fun useIconColor(): Boolean
30+
val useIconColor: Boolean
3131
}

0 commit comments

Comments
 (0)