├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── runConfigurations.xml ├── compiler.xml ├── modules.xml ├── gradle.xml └── misc.xml ├── app ├── .gitignore ├── src │ ├── main │ │ ├── ic_launcher-web.png │ │ ├── res │ │ │ ├── drawable │ │ │ │ └── logo.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── ids.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── values-v19 │ │ │ │ └── styles.xml │ │ │ └── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── item_tiny_action.xml │ │ │ │ └── activity_login.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── pddstudio │ │ │ └── tinyifttt │ │ │ ├── connection │ │ │ ├── ConnectionInfo.java │ │ │ ├── SendActionRequest.java │ │ │ └── ServerConnection.java │ │ │ ├── adapter │ │ │ └── TinyActionItem.java │ │ │ ├── utils │ │ │ └── Dialog.java │ │ │ ├── LoginActivity.java │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── pddstudio │ │ │ └── tinyifttt │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── pddstudio │ │ └── tinyifttt │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── tinyifttt-model ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── pddstudio │ │ └── tinyifttt │ │ └── models │ │ ├── TinyActionReceivedListener.java │ │ └── TinyAction.java └── build.gradle ├── tinyifttt-server ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── pddstudio │ │ └── tinyifttt │ │ └── server │ │ ├── utils │ │ ├── Log.java │ │ └── Logger.java │ │ ├── ActionExecutor.java │ │ ├── ServerRunner.java │ │ ├── async │ │ └── ClientConnectionListener.java │ │ └── TinyIFTTT.java ├── build.gradle └── tiny-sample.json ├── settings.gradle ├── readme_logo.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── tinyIFTTT-android-app-sample.png ├── .gitignore ├── test-tinyIFTTT.sh ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /.idea/.name: -------------------------------------------------------------------------------- 1 | tinyIFTT -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /tinyifttt-model/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /tinyifttt-server/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':tinyifttt-server', ':tinyifttt-model' 2 | -------------------------------------------------------------------------------- /readme_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/readme_logo.png -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /tinyIFTTT-android-app-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/tinyIFTTT-android-app-sample.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/app/src/main/res/drawable/logo.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/tinyIFTTT/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /test-tinyIFTTT.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | java -jar tinyifttt-server/build/libs/tinyifttt-server-full-1.0.jar -p 1337 -c ./tinyifttt-server/tiny-sample.json 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #00897B 4 | #00695C 5 | #00897B 6 | #FAFAFA 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 20sp 6 | 14sp 7 | 8 | -------------------------------------------------------------------------------- /tinyifttt-model/src/main/java/com/pddstudio/tinyifttt/models/TinyActionReceivedListener.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt.models; 2 | 3 | /** 4 | * This Class was created by Patrick J 5 | * on 29.03.16. For more Details and Licensing 6 | * have a look at the README.md 7 | */ 8 | public interface TinyActionReceivedListener { 9 | void onTinyActionReceived(TinyAction tinyAction); 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/pddstudio/tinyifttt/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/pddstudio/tinyifttt/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /tinyifttt-server/src/main/java/com/pddstudio/tinyifttt/server/utils/Log.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt.server.utils; 2 | 3 | /** 4 | * Project : WetterSuite 5 | * Author : pddstudio 6 | * Year : 2016 7 | */ 8 | public enum Log { 9 | DEBUG("D"), 10 | INFO("I"), 11 | WARNING("W"), 12 | ERROR("E"); 13 | 14 | final String log; 15 | 16 | Log(String log) { 17 | this.log = log; 18 | } 19 | 20 | public String getPrefix() { 21 | return log; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 13 | 14 | 17 | 18 | -------------------------------------------------------------------------------- /tinyifttt-model/src/main/java/com/pddstudio/tinyifttt/models/TinyAction.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt.models; 2 | 3 | /** 4 | * This Class was created by Patrick J 5 | * on 29.03.16. For more Details and Licensing 6 | * have a look at the README.md 7 | */ 8 | public class TinyAction { 9 | 10 | private int actionIdentifier; 11 | private String actionTitle; 12 | private String actionDescription; 13 | private String[] actionExec; 14 | 15 | public TinyAction() {} 16 | 17 | public int getActionIdentifier() { 18 | return actionIdentifier; 19 | } 20 | 21 | public String getActionTitle() { 22 | return actionTitle; 23 | } 24 | 25 | public String getActionDescription() { 26 | return actionDescription; 27 | } 28 | 29 | public String[] getActionExec() { 30 | return actionExec; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /tinyifttt-server/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | version = '1.0' 4 | sourceCompatibility = 1.7 5 | targetCompatibility = 1.7 6 | 7 | //create a single Jar with all dependencies 8 | task tinyIFTTTserver(type: Jar) { 9 | manifest { 10 | attributes 'Implementation-Title': 'tinyIFTT Server', 11 | 'Implementation-Version': version, 12 | 'Main-Class': 'com.pddstudio.tinyifttt.server.ServerRunner' 13 | } 14 | baseName = project.name + '-full' 15 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } 16 | with jar 17 | } 18 | 19 | //Get dependencies from Maven central repository 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile fileTree(include: ['*.jar'], dir: 'libs') 26 | compile 'com.google.code.gson:gson:2.6.2' 27 | compile 'io.airlift:airline:0.7' 28 | compile project(':tinyifttt-model') 29 | } -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "24.0.0 rc1" 6 | 7 | defaultConfig { 8 | applicationId "com.pddstudio.tinyifttt" 9 | minSdkVersion 16 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.2.1' 26 | compile 'com.android.support:design:23.2.1' 27 | compile 'com.android.support:cardview-v7:23.2.1' 28 | compile 'com.google.code.gson:gson:2.6.2' 29 | compile('com.mikepenz:fastadapter:1.3.0@aar') { 30 | transitive = true 31 | } 32 | compile project(':tinyifttt-model') 33 | } 34 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | tinyIFTTT 3 | tinyIFTTT Server IP-Address 4 | tinyIFTTT Server Port 5 | Remember Server IP-Address and Port 6 | Connect 7 | IP-Address can\'t be empty! 8 | Port can\'t be negative or empty! 9 | Action send successfully! 10 | Send action failed! 11 | Failed to connect! 12 | Unable to connect to tinyIFTTT Server:\n%s 13 | Server connection closed! 14 | The tinyIFTTT Server was shut down or is no longer reachable. 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/pddstudio/tinyifttt/connection/ConnectionInfo.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt.connection; 2 | 3 | /** 4 | * This Class was created by Patrick J 5 | * on 30.03.16. For more Details and Licensing 6 | * have a look at the README.md 7 | */ 8 | public class ConnectionInfo { 9 | 10 | private static ConnectionInfo mConnectionInfo; 11 | 12 | private String mRemoteHost; 13 | private int mRemotePort; 14 | 15 | private ConnectionInfo(String remoteHost, int remotePort) { 16 | this.mRemoteHost = remoteHost; 17 | this.mRemotePort = remotePort; 18 | } 19 | 20 | public static ConnectionInfo setConnectionData(String remoteHost, int remotePort) { 21 | mConnectionInfo = new ConnectionInfo(remoteHost, remotePort); 22 | return mConnectionInfo; 23 | } 24 | 25 | public static ConnectionInfo getConnectionInfo() { 26 | return mConnectionInfo; 27 | } 28 | 29 | public String getmRemoteHost() { 30 | return mRemoteHost; 31 | } 32 | 33 | public int getmRemotePort() { 34 | return mRemotePort; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /tinyifttt-server/src/main/java/com/pddstudio/tinyifttt/server/ActionExecutor.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt.server; 2 | 3 | import com.pddstudio.tinyifttt.models.TinyAction; 4 | import com.pddstudio.tinyifttt.server.utils.Logger; 5 | 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.util.Scanner; 9 | 10 | /** 11 | * This Class was created by Patrick J 12 | * on 29.03.16. For more Details and Licensing 13 | * have a look at the README.md 14 | */ 15 | public class ActionExecutor { 16 | 17 | private final TinyAction tinyAction; 18 | 19 | protected ActionExecutor(TinyAction tinyAction) { 20 | this.tinyAction = tinyAction; 21 | } 22 | 23 | protected void execute() { 24 | try { 25 | ProcessBuilder processBuilder = new ProcessBuilder(tinyAction.getActionExec()).redirectErrorStream(true); 26 | Process process = processBuilder.start(); 27 | inheritIO(process.getErrorStream()); 28 | inheritIO(process.getInputStream()); 29 | } catch (IOException io) { 30 | io.printStackTrace(); 31 | } 32 | } 33 | 34 | private static void inheritIO(final InputStream src) { 35 | new Thread(new Runnable() { 36 | public void run() { 37 | Scanner sc = new Scanner(src); 38 | while (sc.hasNextLine()) { 39 | Logger.log(ActionExecutor.class, sc.nextLine()); 40 | } 41 | } 42 | }).start(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /tinyifttt-server/src/main/java/com/pddstudio/tinyifttt/server/ServerRunner.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt.server; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.inject.Inject; 6 | 7 | import io.airlift.airline.Command; 8 | import io.airlift.airline.HelpOption; 9 | import io.airlift.airline.Option; 10 | import io.airlift.airline.SingleCommand; 11 | 12 | /** 13 | * This Class was created by Patrick J 14 | * on 29.03.16. For more Details and Licensing 15 | * have a look at the README.md 16 | */ 17 | @Command(name = "tinyIFTT ServerRunner", description = "Run a tinyIFTTT-Server") 18 | public class ServerRunner { 19 | 20 | @Inject 21 | public HelpOption helpOption; 22 | 23 | @Option(name = { "-c", "--config" }, description = "The location to the tinyIFTTT configuration file.") 24 | public String configFileLocation; 25 | 26 | @Option(name = { "-p", "--port" }, description = "The port the tinyIFTTT server should run on.") 27 | public int configPort = 1337; 28 | 29 | public static void main(String[] args) { 30 | ServerRunner serverRunner = SingleCommand.singleCommand(ServerRunner.class).parse(args); 31 | if(serverRunner.helpOption.showHelpIfRequested()) return; 32 | serverRunner.startService(); 33 | } 34 | 35 | public void startService() { 36 | try { 37 | TinyIFTTT tinyIFTTT = new TinyIFTTT(configFileLocation); 38 | tinyIFTTT.start(configPort); 39 | } catch (IOException io) { 40 | io.printStackTrace(); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /tinyifttt-server/tiny-sample.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "actionIdentifier" : 1, 4 | "actionTitle" : "Home PC Shutdown", 5 | "actionDescription" : "Power off my machine upstairs.", 6 | "actionExec" : [ "shutdown", "-h", "now" ] 7 | }, 8 | { 9 | "actionIdentifier" : 2, 10 | "actionTitle" : "Home PC Reboot", 11 | "actionDescription" : "Reboot my machine upstairs.", 12 | "actionExec" : [ "reboot" ] 13 | }, 14 | { 15 | "actionIdentifier" : 3, 16 | "actionTitle" : "Raspberry Pi Update", 17 | "actionDescription" : "Update the packages on my Pi.", 18 | "actionExec" : [ "apt-get", "update" ] 19 | }, 20 | { 21 | "actionIdentifier" : 4, 22 | "actionTitle" : "Raspberry Pi XBMC", 23 | "actionDescription" : "Start XBMC on my Pi.", 24 | "actionExec" : [ "xbmc" ] 25 | }, 26 | { 27 | "actionIdentifier" : 5, 28 | "actionTitle" : "Run Backup Script", 29 | "actionDescription" : "Run the backup script to save my data stored on my NAS.", 30 | "actionExec" : [ "sh", "/opt/backup/backup_all.sh" ] 31 | }, 32 | { 33 | "actionIdentifier" : 6, 34 | "actionTitle" : "Kitchen Light", 35 | "actionDescription" : "Switch on the Light in the kitchen.", 36 | "actionExec" : [ "python", "/opt/mods/switch_light.py" ] 37 | }, 38 | { 39 | "actionIdentifier" : 7, 40 | "actionTitle" : "Android TV", 41 | "actionDescription" : "Power on/off my AndroidTV.", 42 | "actionExec" : [ "sh", "/opt/mods/tv_power.sh" ] 43 | }, 44 | { 45 | "actionIdentifier" : 8, 46 | "actionTitle" : "Ping Google.com", 47 | "actionDescription" : "Ping Google's Website to make sure the internet connection is available.", 48 | "actionExec" : [ "ping", "google.com" ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/pddstudio/tinyifttt/adapter/TinyActionItem.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import com.mikepenz.fastadapter.items.AbstractItem; 8 | import com.pddstudio.tinyifttt.R; 9 | import com.pddstudio.tinyifttt.models.TinyAction; 10 | 11 | /** 12 | * This Class was created by Patrick J 13 | * on 29.03.16. For more Details and Licensing 14 | * have a look at the README.md 15 | */ 16 | public class TinyActionItem extends AbstractItem { 17 | 18 | private final TinyAction mTinyAction; 19 | 20 | public TinyActionItem(TinyAction tinyAction) { 21 | this.mTinyAction = tinyAction; 22 | } 23 | 24 | public TinyAction getTinyAction() { 25 | return mTinyAction; 26 | } 27 | 28 | @Override 29 | public int getType() { 30 | return R.id.tiny_action_item; 31 | } 32 | 33 | @Override 34 | public int getLayoutRes() { 35 | return R.layout.item_tiny_action; 36 | } 37 | 38 | @Override 39 | public void bindView(ViewHolder viewHolder) { 40 | super.bindView(viewHolder); 41 | viewHolder.actionTitle.setText(mTinyAction.getActionTitle()); 42 | viewHolder.actionDescription.setText(mTinyAction.getActionDescription()); 43 | } 44 | 45 | protected static class ViewHolder extends RecyclerView.ViewHolder { 46 | 47 | TextView actionTitle; 48 | TextView actionDescription; 49 | 50 | public ViewHolder(View itemView) { 51 | super(itemView); 52 | this.actionTitle = (TextView) itemView.findViewById(R.id.actionName); 53 | this.actionDescription = (TextView) itemView.findViewById(R.id.actionDescription); 54 | } 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tinyifttt-server/src/main/java/com/pddstudio/tinyifttt/server/async/ClientConnectionListener.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt.server.async; 2 | 3 | import com.google.gson.Gson; 4 | import com.pddstudio.tinyifttt.models.TinyAction; 5 | import com.pddstudio.tinyifttt.models.TinyActionReceivedListener; 6 | 7 | import java.io.BufferedReader; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.io.InputStreamReader; 11 | import java.net.Socket; 12 | 13 | /** 14 | * This Class was created by Patrick J 15 | * on 29.03.16. For more Details and Licensing 16 | * have a look at the README.md 17 | */ 18 | public class ClientConnectionListener extends Thread { 19 | 20 | private final Socket clientSocket; 21 | private final TinyActionReceivedListener tinyActionReceivedListener; 22 | 23 | public ClientConnectionListener(Socket socket, TinyActionReceivedListener tinyActionReceivedListener) { 24 | //assign the client socket we want to communicate with 25 | this.clientSocket = socket; 26 | //assign the interface for the callbacks 27 | this.tinyActionReceivedListener = tinyActionReceivedListener; 28 | } 29 | 30 | public void startListening() { 31 | //start the new Thread 32 | start(); 33 | } 34 | 35 | @Override 36 | public void run() { 37 | //read the input from the socket's input stream 38 | try { 39 | InputStream inputStream = clientSocket.getInputStream(); 40 | InputStreamReader inputStreamReader = new InputStreamReader(inputStream); 41 | BufferedReader bufferedReader = new BufferedReader(inputStreamReader); 42 | Gson gson = new Gson(); 43 | String response; 44 | while((response = bufferedReader.readLine()) != null) { 45 | TinyAction tinyAction = gson.fromJson(response, TinyAction.class); 46 | if(tinyAction != null) tinyActionReceivedListener.onTinyActionReceived(tinyAction); 47 | } 48 | 49 | } catch (IOException io) { 50 | io.printStackTrace(); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /tinyifttt-server/src/main/java/com/pddstudio/tinyifttt/server/utils/Logger.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.tinyifttt.server.utils; 2 | 3 | import java.io.File; 4 | import java.util.Calendar; 5 | import java.util.GregorianCalendar; 6 | 7 | /** 8 | * Project : WetterSuite 9 | * Author : pddstudio 10 | * Year : 2016 11 | */ 12 | public class Logger { 13 | 14 | private static File LOG_FILE; 15 | 16 | private Logger() {} 17 | 18 | public static void init(String location) { 19 | LOG_FILE = new File(location); 20 | } 21 | 22 | public static void log(Class className, String message) { 23 | log(className.getSimpleName(), message); 24 | } 25 | 26 | public static void log(String logPrefix, String message) { 27 | String logMsg = getSystemTime() + "[" + logPrefix + "::/" + Log.DEBUG.getPrefix() + "] " + message; 28 | printLogMessage(logMsg); 29 | } 30 | 31 | public static void log(Object object, String message) { 32 | log(object, Log.DEBUG, message); 33 | } 34 | 35 | public static void log(Object object, Log logType, String message) { 36 | String logMsg = getSystemTime() + "[" + object.getClass().getSimpleName() + "::/" + logType.getPrefix() + "] " + message; 37 | printLogMessage(logMsg); 38 | } 39 | 40 | private static synchronized void printLogMessage(String logMessage) { 41 | System.out.println(logMessage); 42 | } 43 | 44 | private static String getSystemTime() { 45 | Calendar calendar = GregorianCalendar.getInstance(); 46 | int day = calendar.get(Calendar.DAY_OF_MONTH); 47 | String newday; 48 | String newmnth; 49 | 50 | if(day < 10) { 51 | newday = "0" + day; 52 | } else { 53 | newday = "" + day; 54 | } 55 | 56 | int mnth = calendar.get(Calendar.MONTH); 57 | //cuz of stupid month -1 rule 58 | mnth++; 59 | 60 | if(mnth < 10) { 61 | newmnth = "0" + mnth; 62 | } else { 63 | newmnth = "" + mnth; 64 | } 65 | 66 | int year = calendar.get(Calendar.YEAR); 67 | int hr = calendar.get(Calendar.HOUR_OF_DAY); 68 | int min = calendar.get(Calendar.MINUTE); 69 | int sec = calendar.get(Calendar.SECOND); 70 | String secs; 71 | if(sec < 10) { 72 | secs = "0" + sec; 73 | } else { 74 | secs = "" + sec; 75 | } 76 | return "[" + newmnth + "-" + newday + "-" + year + "|" + hr + ":" + min + ":" +secs + "]"; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_tiny_action.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 20 | 21 | 28 | 29 | 40 | 41 | 42 | 43 | 48 | 49 | 58 | 59 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 25 | 26 | 30 | 31 | 37 | 38 | 39 | 40 | 44 | 45 | 51 | 52 | 53 | 54 | 60 | 61 |