Beta project push.

This commit is contained in:
Xi-Sheng
2017-10-05 10:47:56 +02:00
commit 29199c90af
57 changed files with 1217 additions and 0 deletions

9
.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

22
.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

3
.idea/copyright/profiles_settings.xml generated Normal file
View File

@@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

18
.idea/gradle.xml generated Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

61
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ScopeChooserConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

9
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/UCSAndroidWidget.iml" filepath="$PROJECT_DIR$/UCSAndroidWidget.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>

12
.idea/runConfigurations.xml generated Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

1
app/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

30
app/build.gradle Normal file
View File

@@ -0,0 +1,30 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "sdn.ucsandroidwidget"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}

25
app/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Android\Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,26 @@
package sdn.ucsandroidwidget;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("sdn.ucsandroidwidget", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sdn.ucsandroidwidget">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/sdn_logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/sdn_logo"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".WidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_provider_info" />
</receiver>
<receiver android:name=".WidgetReceiver">
<intent-filter>
<action android:name="UN_LOCK"></action>
<action android:name="UPDATE"></action>
</intent-filter>
</receiver>
<service
android:name=".UDPIntentService"
android:exported="false">
<intent-filter>
<action android:name="SEND_UDP"></action>
</intent-filter>
</service>
</application>
</manifest>

View File

@@ -0,0 +1,106 @@
package sdn.ucsandroidwidget;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.InputFilter;
import android.text.Spanned;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
private EditText lbl_0;
private EditText lbl_1;
private EditText IP;
private SharedPreferences programSettings;
private void init() {
lbl_0 = (EditText) findViewById(R.id.tb_lbl0);
lbl_1 = (EditText) findViewById(R.id.tb_lbl1);
InputFilter[] IPFilter = new InputFilter[1];
IPFilter[0] = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
if (end > start) {
String destTxt = dest.toString();
String resultingTxt = destTxt.substring(0, dstart) + source.subSequence(start, end) + destTxt.substring(dend);
if (!resultingTxt.matches ("^\\d{1,3}(\\.(\\d{1,3}(\\.(\\d{1,3}(\\.(\\d{1,3})?)?)?)?)?)?")) {
return "";
} else {
String[] splits = resultingTxt.split("\\.");
for (int i=0; i<splits.length; i++) {
if (Integer.valueOf(splits[i]) > 255) {
return "";
}
}
}
}
return null;
}
};
IP = (EditText) findViewById(R.id.tb_IP);
IP.setFilters(IPFilter);
programSettings = getSharedPreferences("SDN UCSAndroidWidget", MODE_PRIVATE);
String txt_0 = programSettings.getString("Label_0", "...");
String txt_1 = programSettings.getString("Label_1", "...");
String txt_IP = programSettings.getString("Text_IP", "192.168.0.255");
lbl_0.setText(txt_0);
lbl_1.setText(txt_1);
IP.setText(txt_IP);
}
private void saveSettings(){
programSettings = getSharedPreferences("SDN UCSAndroidWidget", MODE_PRIVATE);
SharedPreferences.Editor settingsEditor = programSettings.edit();
settingsEditor.putString("Label_0", lbl_0.getText().toString());
settingsEditor.putString("Label_1", lbl_1.getText().toString());
settingsEditor.putString("Text_IP", IP.getText().toString());
settingsEditor.commit();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
final Button btn1 = (Button) findViewById(R.id.btn_t0);
final Button btn2 = (Button) findViewById(R.id.btn_t1);
final Button btnSave = (Button) findViewById(R.id.btn_save);
btnSave.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
saveSettings();
}
});
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
broadcastMessage(0);
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
broadcastMessage(1);
}
});
}
public void broadcastMessage(int device) {
Intent intent = new Intent();
intent.setAction("UN_LOCK");
intent.putExtra("action",R.integer.actionUpdate);
intent.putExtra("device",device);
sendBroadcast(intent);
}
}

View File

@@ -0,0 +1,110 @@
package sdn.ucsandroidwidget;
import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
/**
* Created by XSL on 26-9-2017.
*/
public class UDPIntentService extends IntentService {
private SharedPreferences programSettings;
String dstAddress;
int dstPort;
DatagramSocket socket;
InetAddress address;
public UDPIntentService(){
super("UdpIntentService");
}
private void readSettings(){
Log.i("UCS Android Widget", "readSettings.... ");
programSettings = getSharedPreferences("SDN UCSAndroidWidget", MODE_PRIVATE);
dstAddress = programSettings.getString("Text_IP", "192.168.0.255");
dstPort = 7000;
Log.i("UCS Android Widget", "dstAddress: "+dstAddress);
Log.i("UCS Android Widget", "dstPort: "+dstPort);
}
private void sendPackage(String messagePayload){
try{
Log.i("UCS Android Widget", "sendPackage.... ");
socket = new DatagramSocket(dstPort);
address = InetAddress.getByName(dstAddress);
DatagramPacket packet = new DatagramPacket(messagePayload.getBytes(), messagePayload.getBytes().length, address, dstPort);
socket.send(packet);
listner(socket);
}catch (SocketException e) {
Log.i("UCS Android Widget", "!!!!!!!!!!! Socket Exception! !!!!!!!!!!!");
e.printStackTrace();
} catch (UnknownHostException e) {
Log.i("UCS Android Widget", "!!!!!!!! Unknown Host Exception! !!!!!!!!");
e.printStackTrace();
} catch (IOException e) {
Log.i("UCS Android Widget", "!!!!!!!!!!!!! IO Exception !!!!!!!!!!!!!!");
e.printStackTrace();
}finally {
Log.i("UCS Android Widget", "cleanup.... ");
if (socket != null) {
socket.close();
}
}
}
private void listner(DatagramSocket Socket){
try {
String text;
byte[] recvBuffer = new byte[1024];
DatagramPacket rcvPacket = new DatagramPacket(recvBuffer, recvBuffer.length);
Socket.setSoTimeout(500);
Socket.receive(rcvPacket);
Socket.receive(rcvPacket);
Socket.receive(rcvPacket);
text = new String(rcvPacket.getData());
if(text.contains("D0..O01$"))
{
//Do Something
WidgetReceiver.Un_Locked[0][0] = 1;
}
if(text.contains("D0..O00$"))
{
//Do Something
WidgetReceiver.Un_Locked[0][0] = 2;
}
Intent update = new Intent();
update.setAction("UPDATE");
sendBroadcast(update);
} catch (IOException e) {
e.printStackTrace();
}finally {
if (socket != null) {
socket.close();
}
}
}
@Override
protected void onHandleIntent(Intent intent){
Log.i("UCS Android Widget", "============================================ Sending ============================================");
Log.i("UCS Android Widget", "messagePayload: " + intent.getStringExtra("messagePayload"));
readSettings();
sendPackage(intent.getStringExtra("messagePayload"));
Log.i("UCS Android Widget", "============================================== End ==============================================");
Log.i("UCS Android Widget", " ");Log.i("UCS Android Widget", " ");
}
}

View File

@@ -0,0 +1,60 @@
package sdn.ucsandroidwidget;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.RemoteViews;
import java.util.Arrays;
/**
* Implementation of App Widget functionality.
*/
public class WidgetProvider extends AppWidgetProvider {
private SharedPreferences programSettings;
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
Log.i("UCS Android Widget", "onReceive");
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
Log.i("UCS Android Widget", "Updating widgets " + Arrays.asList(appWidgetIds));
programSettings = context.getSharedPreferences("SDN UCSAndroidWidget", 0);
String txt_0 = programSettings.getString("Label_0", "...");
String txt_1 = programSettings.getString("Label_1", "...");
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_provider);
views.setTextViewText(R.id.lbl_1,txt_0);
views.setTextViewText(R.id.lbl_2,txt_1);
Intent intent = new Intent(context, WidgetReceiver.class);
intent.setAction("UN_LOCK");
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
intent.putExtra("device",0);
intent.putExtra("action",R.integer.actionLock);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.btn_1, pendingIntent);
intent.putExtra("device",1);
pendingIntent = PendingIntent.getBroadcast(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.btn_2, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
}

View File

@@ -0,0 +1,166 @@
package sdn.ucsandroidwidget;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.widget.RemoteViews;
/**
* Created by XSL on 26-9-2017.
*/
public class WidgetReceiver extends BroadcastReceiver{
private SharedPreferences programSettings;
public static int Boxes = 2;
public static int[][] Un_Locked = new int[][]{{0},{0}};
@Override
public void onReceive(Context context, Intent intent){
if(intent.getAction() == "UN_LOCK"){
Log.i("UCS Android Widget", "======================================= Receive Request =========================================");
int action = intent.getIntExtra("action",-1);
int device = intent.getIntExtra("device",-1);
int output = intent.getIntExtra("output",0);
Log.i("UCS Android Widget", "onReceive: device " + device + ", action: (pointer)" + action+ ", output: " + output);
String payload = "";
if(action==R.integer.actionUpdate) {
payload=Update(context, device, output);
}
if(action==R.integer.actionLock) {
payload=Lock(context, device, output);
}
if(action==R.integer.actionUnLock) {
payload=Unlock(context, device, output);
}
if(action==R.integer.actionToggle) {
payload=Toggle(context, device, output);
}
Log.i("UCS Android Widget", "payload: " + payload);
executeIntentService(context, payload);
}
if(intent.getAction() == "UPDATE") {
updateVisuals(context);
}
}
public void updateVisuals(Context context){
Log.i("UCS Android Widget", "========================================== Set visuals ==========================================");
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_provider);
programSettings = context.getSharedPreferences("SDN UCSAndroidWidget", 0);
String txt_0 = programSettings.getString("Label_0", "...");
String txt_1 = programSettings.getString("Label_1", "...");
views.setTextViewText(R.id.lbl_1,txt_0);
views.setTextViewText(R.id.lbl_2,txt_1);
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
Bitmap[] images = {BitmapFactory.decodeResource(context.getResources(), R.mipmap.sdn_unknown),
BitmapFactory.decodeResource(context.getResources(), R.mipmap.sdn_locked),
BitmapFactory.decodeResource(context.getResources(), R.mipmap.sdn_unlocked)};
Intent intent = new Intent(context, WidgetReceiver.class);
intent.setAction("UN_LOCK");
int[] buttons = new int[Boxes];
buttons[0] = R.id.btn_1;
buttons[1] = R.id.btn_2;
for(int Box_I = 0; Box_I < Un_Locked.length; Box_I++)
{
//foreach box
for(int Output_I = 0; Output_I < Un_Locked[Box_I].length; Output_I++)
{
//foreach output
intent.putExtra("device",Box_I);
int img=-1;
if(Un_Locked[Box_I][Output_I]==0){
//show Locked Icon
img=context.getResources().getInteger(R.integer.actionUpdate);
//set Unlock Action
intent.putExtra("action",R.integer.actionUpdate);
}
//if active
if(Un_Locked[Box_I][Output_I]==1){
//show Unlocked Icon
img=context.getResources().getInteger(R.integer.actionUnLock);
//set Lock Action
intent.putExtra("action",R.integer.actionLock);
}
//if inactive
if(Un_Locked[Box_I][Output_I]==2){
//show Locked Icon
img=context.getResources().getInteger(R.integer.actionLock);
//set Unlock Action
intent.putExtra("action",R.integer.actionUnLock);
}
//if unknown
views.setImageViewBitmap(buttons[Box_I],images[img]);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, Box_I, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(buttons[Box_I], pendingIntent);
Log.i("UCS Android Widget", "Un_Locked[" + Box_I + "][" + Output_I + "]: " + Un_Locked[Box_I][Output_I]);
}
}
appWidgetManager.updateAppWidget(new ComponentName(context, WidgetProvider.class), views);
}
public String Update(Context context, int destination, int output){
String rt;
// Un_Locked[destination][output] = 0;
rt = payloadBuilder(context, destination, context.getString(R.string.cmdUpdate), output);
return rt;
}
public String Unlock(Context context, int destination, int output){
String rt;
// Un_Locked[destination][output] = 1;
rt = payloadBuilder(context, destination, context.getString(R.string.cmdUnLock), output);
return rt;
}
public String Lock(Context context, int destination, int output){
String rt;
// Un_Locked[destination][output] = 2;
rt = payloadBuilder(context, destination, context.getString(R.string.cmdLock), output);
return rt;
}
public String Toggle(Context context, int destination, int output){
String rt;
if(Un_Locked[destination][output] == 1){
Un_Locked[destination][output] = 2;
}
else if(Un_Locked[destination][output] == 2){
Un_Locked[destination][output] = 1;
}
rt = payloadBuilder(context, destination, context.getString(R.string.cmdToggle), output);
return rt;
}
public String payloadBuilder(Context context,int destination, String cmd, int output){
Log.i("UCS Android Widget", "========================================= Build payload =========================================");
Log.i("UCS Android Widget", "device: " + destination + ", cmd: " + cmd + ", output: " + output);
String ret;
ret = context.getString(R.string.strSender) + context.getString(R.string.strDevice) + destination + cmd + output + context.getString(R.string.str$) ;
return ret;
}
public void executeIntentService(Context context, String messagePayload){
Log.i("UCS Android Widget", "========================================== Set service ==========================================");
Log.i("UCS Android Widget", "messagePayload: " + messagePayload);
Intent serviceIntent = new Intent(context.getApplicationContext(), UDPIntentService.class);
serviceIntent.setAction("SEND_UDP");
serviceIntent.putExtra("messagePayload",messagePayload);
context.startService(serviceIntent);
}
}

View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="sdn.ucsandroidwidget.MainActivity">
<EditText
android:id="@+id/tb_lbl0"
android:maxLength="18"
android:layout_width="150dp"
android:layout_height="40dp"
android:hint="Label 1"
android:singleLine="true"
android:text="St Jacobsstraat"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp" />
<Button
android:id="@+id/btn_t0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="Toggle"
app:layout_constraintBaseline_toBaselineOf="@+id/tb_lbl0"
app:layout_constraintLeft_toRightOf="@+id/tb_lbl0" />
<EditText
android:id="@+id/tb_lbl1"
android:maxLength="18"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:hint="Label 2"
android:singleLine="true"
android:text="Lange Viestraat"
app:layout_constraintRight_toRightOf="@+id/tb_lbl0"
app:layout_constraintTop_toBottomOf="@+id/tb_lbl0" />
<Button
android:id="@+id/btn_t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="Toggle"
app:layout_constraintBaseline_toBaselineOf="@+id/tb_lbl1"
app:layout_constraintLeft_toRightOf="@+id/tb_lbl1" />
<EditText
android:id="@+id/tb_IP"
android:layout_width="150dp"
android:layout_height="40dp"
android:hint="Broadcast Address"
android:inputType="phone"
android:singleLine="true"
android:text="192.168.0.255"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="16dp"
android:layout_marginRight="117dp"
app:layout_constraintRight_toRightOf="parent" />
<Button
android:id="@+id/btn_save"
android:layout_width="101dp"
android:layout_height="52dp"
android:layout_marginLeft="5dp"
android:text="Save"
app:layout_constraintBaseline_toBaselineOf="@+id/tb_IP"
app:layout_constraintLeft_toRightOf="@+id/tb_IP" />
</android.support.constraint.ConstraintLayout>

View File

@@ -0,0 +1,51 @@
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_column="2"
android:layout_margin="0dp"
android:columnCount="2"
android:columnOrderPreserved="false"
android:rowOrderPreserved="false"
android:saveEnabled="false">
<TextView
android:id="@+id/lbl_1"
android:layout_column="0"
android:layout_gravity="center_vertical|end"
android:layout_row="0"
android:text="Lange Viestraat"
android:textAllCaps="false"
android:textAppearance="@android:style/TextAppearance.Large"
android:textSize="36dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/btn_1"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_column="1"
android:layout_gravity="center_vertical|start"
android:layout_row="0"
android:background="@mipmap/sdn_unknown" />
<TextView
android:id="@+id/lbl_2"
android:layout_column="0"
android:layout_gravity="center_vertical|end"
android:layout_row="1"
android:text="St Jacobsstraat"
android:textAllCaps="false"
android:textAppearance="@android:style/TextAppearance.Large"
android:textSize="36dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/btn_2"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_column="1"
android:layout_gravity="center_vertical|start"
android:layout_row="1"
android:background="@mipmap/sdn_unknown" />
</GridLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Refer to App Widget Documentation for margin information
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
-->
<dimen name="widget_margin">0dp</dimen>
</resources>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="actionUpdate">0</integer>
<integer name="actionLock">1</integer>
<integer name="actionUnLock">2</integer>
<integer name="actionToggle">3</integer>
<string name="strSender">**</string>
<string name="strDevice">D</string>
<string name="cmdUnLock">A0</string>
<string name="cmdLock">B0</string>
<string name="cmdAll">C0</string>
<string name="cmdUpdate">D0</string>
<string name="cmdToggle">E0</string>
<string name="str$">$</string>
</resources>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Refer to App Widget Documentation for margin information
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
-->
<dimen name="widget_margin">8dp</dimen>
</resources>

View File

@@ -0,0 +1,5 @@
<resources>
<string name="app_name">UCS Android Widget</string>
<string name="appwidget_text">EXAMPLE</string>
<string name="add_widget">Add widget</string>
</resources>

View File

@@ -0,0 +1,11 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/widget_provider"
android:initialLayout="@layout/widget_provider"
android:minHeight="110dp"
android:minWidth="280dp"
android:previewImage="@mipmap/sdn_logo"
android:updatePeriodMillis="1800000"
android:widgetCategory="home_screen"></appwidget-provider>

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View File

@@ -0,0 +1,17 @@
package sdn.ucsandroidwidget;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

23
build.gradle Normal file
View File

@@ -0,0 +1,23 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

17
gradle.properties Normal file
View File

@@ -0,0 +1,17 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,6 @@
#Tue Sep 26 08:27:25 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

160
gradlew vendored Normal file
View File

@@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

1
settings.gradle Normal file
View File

@@ -0,0 +1 @@
include ':app'