-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Acegugu/develop
RowIRSender를 구현한 내용에 대한 PR
- Loading branch information
Showing
18 changed files
with
478 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
RowClient/wear/src/main/java/com/gdgssu/rowclient/ControlSendingThread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.gdgssu.rowclient; | ||
|
||
import android.content.Context; | ||
|
||
public class ControlSendingThread implements Runnable { | ||
|
||
private Context mContext; | ||
|
||
public ControlSendingThread(Context mContext) { | ||
this.mContext = mContext; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
RowClient/wear/src/main/java/com/gdgssu/rowclient/RowClientReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.gdgssu.rowclient; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.net.wifi.WifiManager; | ||
|
||
public class RowClientReceiver extends BroadcastReceiver { | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
String action = intent.getAction(); | ||
|
||
if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { | ||
|
||
} else { | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
RowClient/wear/src/main/java/com/gdgssu/rowclient/StateSyncThread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.gdgssu.rowclient; | ||
|
||
import android.content.Context; | ||
|
||
public class StateSyncThread extends Thread { | ||
|
||
/** | ||
* IRSender 애플리케이션과 소켓으로 연결하여 현재 가정에서 컨트롤할 디바이스의 종류를 받아와야한다 | ||
* 만약 30초동안 찾지 못한다면 본 Thread는 종료된다 | ||
*/ | ||
|
||
private int foundDeviceSecond = 0; | ||
private Context mContext; | ||
|
||
public StateSyncThread(Context mContext) { | ||
this.mContext = mContext; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
while(true){ | ||
try { | ||
|
||
//Todo : 소켓을 IRSender측으로 보내는 로직 작성 | ||
|
||
Thread.sleep(1000); | ||
foundDeviceSecond++; | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
if (foundDeviceSecond==30){ | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
RowIRSender/app/src/main/java/com/gdgssu/rowirsender/DeviceControlInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.gdgssu.rowirsender; | ||
|
||
import android.util.Log; | ||
|
||
import com.lge.hardware.IRBlaster.Device; | ||
import com.lge.hardware.IRBlaster.IRFunction; | ||
|
||
import java.util.List; | ||
|
||
public class DeviceControlInfo { | ||
|
||
/** | ||
* 웨어러블로부터 전송받은 데이터를 파싱하며, 일시적으로 인스턴스를 통해 저장하여 활용하는 모델 클래스입니다 | ||
*/ | ||
private final static String TAG = DeviceControlInfo.class.getSimpleName(); | ||
|
||
public int deviceId; | ||
public String functionName; | ||
public String deviceName; | ||
|
||
public int getDeviceId() { | ||
return deviceId; | ||
} | ||
|
||
public void setDeviceId(int deviceId) { | ||
this.deviceId = deviceId; | ||
} | ||
|
||
public String getFunctionName() { | ||
return functionName; | ||
} | ||
|
||
public void setFunctionName(String functionName) { | ||
this.functionName = functionName; | ||
} | ||
|
||
public String getDeviceName() { | ||
return deviceName; | ||
} | ||
|
||
public void setDeviceName(String deviceName) { | ||
this.deviceName = deviceName; | ||
} | ||
|
||
/** | ||
* String 형태의 funcLabel을 int형태의 Keycode로 변환합니다 | ||
* @param deviceList | ||
* @param funcLabel | ||
* @return function id | ||
*/ | ||
public int getFunctionKeyCode(List<Device> deviceList, String funcLabel) { | ||
|
||
if (deviceList.size() == 0) { | ||
Log.e(TAG, "A device is not selected."); | ||
return -1; | ||
} | ||
for (Device device : deviceList){ | ||
for (IRFunction function : device.KeyFunctions) { | ||
if (function.Name.equalsIgnoreCase(funcLabel)) { | ||
return function.Id; | ||
} | ||
} | ||
} | ||
Log.e(TAG, "[" + funcLabel + "] search function failed"); | ||
|
||
return -1; | ||
} | ||
|
||
// An example to use IR function labels.[E] | ||
} |
18 changes: 18 additions & 0 deletions
18
RowIRSender/app/src/main/java/com/gdgssu/rowirsender/DeviceInfoParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.gdgssu.rowirsender; | ||
|
||
import com.google.gson.Gson; | ||
|
||
public class DeviceInfoParser { | ||
|
||
/** | ||
* 소켓을 통해서 전송된 json형태의 데이터를 파싱하는 클래스입니다 | ||
* @param jsonData | ||
* @return DeviceControlInfo | ||
*/ | ||
|
||
public static DeviceControlInfo parsedInfo(String jsonData){ | ||
|
||
Gson gson = new Gson(); | ||
return gson.fromJson(jsonData, DeviceControlInfo.class); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
RowIRSender/app/src/main/java/com/gdgssu/rowirsender/DevicePreferenceHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.gdgssu.rowirsender; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import com.google.gson.Gson; | ||
import com.lge.hardware.IRBlaster.Device; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* 유저가 컨트롤할 Device(AIRCON, TV, STB, DVD 등)을 저장하고 저장된 내용을 가져오는 PrefenceHelper 클래스 | ||
* mIR.getDevices()를 이용해 애플리케이션을 완전히 종료하고 다시 실행해도 디바이스 목록을 가져올수있다면 이 클래스는 효용성이 없습니다 | ||
*/ | ||
|
||
public class DevicePreferenceHelper { | ||
private final static String PREF_NAME = "com.gdgssu.rowirsender.devicepref"; | ||
public final static String PREF_DEVICE_STORE = "PREF_DEVICE_STORE"; | ||
|
||
private Context mContext; | ||
|
||
public DevicePreferenceHelper(Context mContext) { | ||
this.mContext = mContext; | ||
} | ||
|
||
public void setDevicePref(String key, List<Device> deviceList){ | ||
SharedPreferences pref = mContext.getSharedPreferences(PREF_NAME, Activity.MODE_PRIVATE); | ||
SharedPreferences.Editor editor = pref.edit(); | ||
|
||
Gson gson = new Gson(); | ||
String devicesJsonData = gson.toJson(deviceList); | ||
|
||
editor.putString(key, devicesJsonData); | ||
editor.apply(); | ||
} | ||
|
||
public List<Device> getDevicePref(String key){ | ||
List<Device> deviceList; | ||
SharedPreferences pref = mContext.getSharedPreferences(PREF_NAME, Activity.MODE_PRIVATE); | ||
|
||
if (pref.contains(PREF_DEVICE_STORE)){ | ||
String devicesJsonData = pref.getString(key, null); | ||
Gson gson = new Gson(); | ||
Device[] deviceArray = gson.fromJson(devicesJsonData, Device[].class); | ||
deviceList = Arrays.asList(deviceArray); | ||
}else{ | ||
return null; | ||
} | ||
|
||
return deviceList; | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
RowIRSender/app/src/main/java/com/gdgssu/rowirsender/MainActivity.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
RowIRSender/app/src/main/java/com/gdgssu/rowirsender/RowIRReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.gdgssu.rowirsender; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
public class RowIRReceiver extends BroadcastReceiver { | ||
|
||
/** | ||
* 스마트폰이 부팅되자마자 RowIRService를 구동하게끔하는 기능을 담당하는 Receiver입니다 | ||
* @param context | ||
* @param intent | ||
*/ | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
|
||
if (intent.getAction().equals("gdgssu.com.rowirsender.getaction")){ | ||
context.startService(new Intent(context, RowIRService.class)); | ||
}else{ | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
} | ||
} | ||
} |
Oops, something went wrong.