├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── back.png │ │ │ │ ├── clear.png │ │ │ │ ├── light_off.png │ │ │ │ ├── light_on.png │ │ │ │ ├── main_set_time.png │ │ │ │ ├── main_setting.png │ │ │ │ ├── seek_bar_thumb.png │ │ │ │ ├── wifi_connect_n.png │ │ │ │ ├── wifi_connect_y.png │ │ │ │ └── wifi_list_icon.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 │ │ │ ├── drawable │ │ │ │ ├── white_shape.xml │ │ │ │ ├── yellow_shape.xml │ │ │ │ ├── black_shape.xml │ │ │ │ └── seekbar_bg.xml │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── layout │ │ │ │ ├── wifi_list.xml │ │ │ │ ├── fragment_color.xml │ │ │ │ ├── fragment_always_bright.xml │ │ │ │ ├── fragment_catch_light.xml │ │ │ │ ├── activity_change_language.xml │ │ │ │ ├── fragment_gradient.xml │ │ │ │ ├── fragment_twinkle.xml │ │ │ │ ├── activity_change_wifi_psd.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── activity_chnage_ssid.xml │ │ │ │ ├── activity_wifi_state.xml │ │ │ │ ├── activity_setting.xml │ │ │ │ └── activity_timing.xml │ │ │ └── values-en │ │ │ │ └── strings.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── lamps │ │ │ │ └── lamps │ │ │ │ ├── util │ │ │ │ ├── TimeUtils.java │ │ │ │ ├── CustomViewpager.java │ │ │ │ ├── CommandUtils.java │ │ │ │ ├── TcpClient.java │ │ │ │ ├── SocketTransceiver.java │ │ │ │ └── ControlLight.java │ │ │ │ ├── activity │ │ │ │ ├── BaseActivity.java │ │ │ │ ├── ChangeSSIDActivity.java │ │ │ │ ├── ChangeWifiPsdActivity.java │ │ │ │ ├── SettingActivity.java │ │ │ │ ├── ChangeLanguageActivity.java │ │ │ │ ├── WifiConnectActivity.java │ │ │ │ ├── TimingActivity.java │ │ │ │ └── MainActivity.java │ │ │ │ ├── adapter │ │ │ │ └── MyPagerAdapter.java │ │ │ │ └── fragment │ │ │ │ ├── ColorFragment.java │ │ │ │ ├── BrightFragment.java │ │ │ │ ├── LightFragment.java │ │ │ │ ├── GradientFragment.java │ │ │ │ └── TwinkleFragment.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── lamps │ │ │ └── lamps │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── lamps │ │ └── lamps │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── app-debug.apk ├── images ├── image1.png ├── image2.png ├── image3.png └── image4.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── LICENSE ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app-debug.apk -------------------------------------------------------------------------------- /images/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/images/image1.png -------------------------------------------------------------------------------- /images/image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/images/image2.png -------------------------------------------------------------------------------- /images/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/images/image3.png -------------------------------------------------------------------------------- /images/image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/images/image4.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/clear.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/light_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/light_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/light_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/light_on.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/main_set_time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/main_set_time.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/main_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/main_setting.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/seek_bar_thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/seek_bar_thumb.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/wifi_connect_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/wifi_connect_n.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/wifi_connect_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/wifi_connect_y.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/wifi_list_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stewForAni/Lamp/HEAD/app/src/main/res/drawable-xxhdpi/wifi_list_icon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | 10 | .idea 11 | -------------------------------------------------------------------------------- /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/drawable/white_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/yellow_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/black_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 9 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 2dp 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/lamps/lamps/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps; 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/lamps/lamps/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps; 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 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #333333 5 | #FF4081 6 | 7 | 8 | #333333 9 | #F3C935 10 | #ffffff 11 | #999999 12 | #fefefe 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/seekbar_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/lamps/lamps/util/TimeUtils.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created by stew on 16/9/7. 8 | * mail: stewforani@gmail.com 9 | */ 10 | public class TimeUtils { 11 | 12 | /** 13 | * 时间戳转为年月日,时分秒 14 | * @param cc_time 15 | * @return 16 | */ 17 | public static String getStrTime(String cc_time) { 18 | String re_StrTime = null; 19 | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); 20 | long lcc_time = Long.valueOf(cc_time); 21 | re_StrTime = sdf.format(new Date(lcc_time * 1000L)); 22 | return re_StrTime; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/stew/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/lamps/lamps/activity/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.activity; 2 | 3 | import android.os.Build; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.MenuItem; 8 | 9 | import com.lamps.lamps.R; 10 | 11 | /** 12 | * Created by stew on 16/8/30. 13 | * mail: stewforani@gmail.com 14 | */ 15 | public class BaseActivity extends AppCompatActivity { 16 | @Override 17 | protected void onCreate(@Nullable Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setStatusBar(); 20 | } 21 | 22 | private void setStatusBar() { 23 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 24 | getWindow().setStatusBarColor(getResources().getColor(R.color.app_main_color)); 25 | 26 | } 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.lamps.lamps" 9 | minSdkVersion 14 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 | repositories { 22 | maven { 23 | url "https://jitpack.io" 24 | } 25 | } 26 | 27 | } 28 | 29 | dependencies { 30 | compile fileTree(dir: 'libs', include: ['*.jar']) 31 | testCompile 'junit:junit:4.12' 32 | compile 'com.android.support:appcompat-v7:23.4.0' 33 | compile 'com.github.hackware1993:MagicIndicator:1.2.1' 34 | 35 | } 36 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/src/main/java/com/lamps/lamps/adapter/MyPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.adapter; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentPagerAdapter; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by stew on 16/8/30. 11 | * mail: stewforani@gmail.com 12 | */ 13 | public class MyPagerAdapter extends FragmentPagerAdapter{ 14 | private List tabNames; 15 | private List fragments; 16 | 17 | public MyPagerAdapter(FragmentManager fm, List tabNames, List fragments) { 18 | super(fm); 19 | this.tabNames = tabNames; 20 | this.fragments = fragments; 21 | } 22 | 23 | @Override 24 | public int getCount() { 25 | return fragments.size(); 26 | } 27 | 28 | @Override 29 | public Fragment getItem(int position) { 30 | return fragments.get(position); 31 | } 32 | 33 | @Override 34 | public CharSequence getPageTitle(int position) { 35 | return tabNames.get(position); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/lamps/lamps/util/CustomViewpager.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.util; 2 | 3 | import android.content.Context; 4 | import android.support.v4.view.ViewPager; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | 8 | /** 9 | * Created by stew on 16/9/6. 10 | * mail: stewforani@gmail.com 11 | */ 12 | public class CustomViewpager extends ViewPager { 13 | 14 | private boolean isPagingEnabled = true; 15 | 16 | public CustomViewpager(Context context) { 17 | super(context); 18 | } 19 | 20 | public CustomViewpager(Context context, AttributeSet attrs) { 21 | super(context, attrs); 22 | } 23 | 24 | @Override 25 | public boolean onTouchEvent(MotionEvent event) { 26 | return this.isPagingEnabled && super.onTouchEvent(event); 27 | } 28 | 29 | @Override 30 | public boolean onInterceptTouchEvent(MotionEvent event) { 31 | return this.isPagingEnabled && super.onInterceptTouchEvent(event); 32 | } 33 | 34 | public void setPagingEnabled(boolean b) { 35 | this.isPagingEnabled = b; 36 | }} 37 | -------------------------------------------------------------------------------- /app/src/main/res/layout/wifi_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | 11 | 21 | 22 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/lamps/lamps/util/CommandUtils.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.util; 2 | 3 | /** 4 | * Created by stew on 16/9/7. 5 | * mail: stewforani@gmail.com 6 | */ 7 | public class CommandUtils { 8 | 9 | public static final String ON=""; 10 | public static final String OFF=""; 11 | 12 | public static final String BRIGHT_1=""; 13 | public static final String BRIGHT_2=""; 14 | public static final String BRIGHT_3=""; 15 | 16 | public static final String TWIN_1=""; 17 | public static final String TWIN_2=""; 18 | public static final String TWIN_3=""; 19 | 20 | public static final String GRAD_1=""; 21 | public static final String GRAD_2=""; 22 | public static final String GRAD_3=""; 23 | 24 | public static final String COLOR_1=""; 25 | public static final String COLOR_2=""; 26 | public static final String COLOR_3=""; 27 | 28 | public static final String LIGHT_1=""; 29 | public static final String LIGHT_2=""; 30 | 31 | public static final String SPEED_1=""; 32 | public static final String SPEED_2=""; 33 | public static final String SPEED_3=""; 34 | 35 | public static final String TIMING_OFF=""; 36 | public static final String TIMING_ON_1=""; 37 | public static final String TIMING_ON_2=""; 38 | public static final String TIMING_CURRENT=""; 39 | public static final String RESTART=""; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | 20 | 21 | 27 | 28 | 32 | 33 | 38 | 39 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_always_bright.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | 20 | 21 | 27 | 28 | 32 | 33 | 38 | 39 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, stew 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 20 | 21 | 27 | 28 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/lamps/lamps/activity/ChangeSSIDActivity.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.view.View; 6 | import android.widget.Button; 7 | import android.widget.EditText; 8 | import android.widget.ImageView; 9 | import android.widget.Toast; 10 | 11 | import com.lamps.lamps.R; 12 | import com.lamps.lamps.util.ControlLight; 13 | 14 | /** 15 | * Created by stew on 16/9/4. 16 | * mail: stewforani@gmail.com 17 | */ 18 | public class ChangeSSIDActivity extends BaseActivity { 19 | @Override 20 | protected void onCreate(@Nullable Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_chnage_ssid); 23 | initView(); 24 | } 25 | 26 | 27 | private void initView() { 28 | 29 | ImageView back = (ImageView) findViewById(R.id.setting_back); 30 | final EditText ssid = (EditText) findViewById(R.id.edit_ssid); 31 | Button btn = (Button) findViewById(R.id.button_send); 32 | 33 | if (back == null || ssid == null || btn == null) { 34 | return; 35 | } 36 | 37 | back.setOnClickListener(new View.OnClickListener() { 38 | @Override 39 | public void onClick(View v) { 40 | finish(); 41 | } 42 | }); 43 | btn.setOnClickListener(new View.OnClickListener() { 44 | @Override 45 | public void onClick(View v) { 46 | if (ssid.getText().toString().isEmpty()) { 47 | Toast.makeText(ChangeSSIDActivity.this, R.string.ssid_can_not_be_null, Toast.LENGTH_SHORT).show(); 48 | return; 49 | } 50 | 51 | ControlLight.sendSSID(ssid.getText().toString()); 52 | finish(); 53 | 54 | } 55 | }); 56 | 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 43 | 44 | 47 | 48 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lamp 2 | A simple controller of craft lamp for Android. 3 | 4 | #### Intro: 5 | It’s a simple app which can control artificial lights. There is a wifi list on the App’s home page. You can use the wifi of your phone to connect with the lights’wifi module. The data is sent through the Socket in the app, then a new thread is used to monitor the data received by Socket. The data sent are **hexadecimal instructions**, the specific instructions are set based on the wifi module. Due to privacy, the instruction set has been deleted. You can set your own instruction set. Just copy the code if you need it.(Thanks to my friend **Lela** for the translation work) 6 | 7 | Any suggestion, please send to:stewforani@gmail.com,welcome star and fork. Thank you! 8 | 9 | #### show: 10 | 11 | You can see it live downloading [**this apk**](https://github.com/stewForAni/Lamp/raw/master/app-debug.apk) 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | # License 22 | ``` 23 | BSD 3-Clause License 24 | 25 | Copyright (c) 2017, stew 26 | All rights reserved. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 32 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 34 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 36 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/lamps/lamps/activity/ChangeWifiPsdActivity.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.view.View; 6 | import android.widget.Button; 7 | import android.widget.EditText; 8 | import android.widget.ImageView; 9 | import android.widget.Toast; 10 | 11 | import com.lamps.lamps.R; 12 | import com.lamps.lamps.util.ControlLight; 13 | 14 | /** 15 | * Created by stew on 16/9/4. 16 | * mail: stewforani@gmail.com 17 | */ 18 | public class ChangeWifiPsdActivity extends BaseActivity { 19 | @Override 20 | protected void onCreate(@Nullable Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_change_wifi_psd); 23 | initView(); 24 | } 25 | 26 | private void initView() { 27 | 28 | ImageView back = (ImageView) findViewById(R.id.setting_back); 29 | final EditText ssid = (EditText) findViewById(R.id.edit_psd); 30 | Button btn = (Button) findViewById(R.id.btn_reset); 31 | 32 | if (back == null || ssid == null || btn == null) { 33 | return; 34 | } 35 | 36 | back.setOnClickListener(new View.OnClickListener() { 37 | @Override 38 | public void onClick(View v) { 39 | finish(); 40 | } 41 | }); 42 | btn.setOnClickListener(new View.OnClickListener() { 43 | @Override 44 | public void onClick(View v) { 45 | if (ssid.getText().toString().isEmpty()) { 46 | Toast.makeText(ChangeWifiPsdActivity.this, R.string.psd_null, Toast.LENGTH_SHORT).show(); 47 | return; 48 | } 49 | 50 | if (ssid.getText().toString().length() > 12 || ssid.getText().toString().length() < 8) { 51 | Toast.makeText(ChangeWifiPsdActivity.this, R.string.psd_8_12, Toast.LENGTH_SHORT).show(); 52 | return; 53 | } 54 | 55 | ControlLight.sendPassword(ssid.getText().toString()); 56 | Toast.makeText(ChangeWifiPsdActivity.this, R.string.psd_change_success, Toast.LENGTH_SHORT).show(); 57 | finish(); 58 | 59 | } 60 | }); 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_catch_light.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | 20 | 21 | 27 | 28 | 32 | 33 | 38 | 39 | 40 | 41 | 45 | 46 | 47 | 52 | 53 | 59 | 60 | 64 | 65 | 70 | 71 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /app/src/main/java/com/lamps/lamps/fragment/ColorFragment.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.SeekBar; 10 | 11 | import com.lamps.lamps.R; 12 | import com.lamps.lamps.activity.MainActivity; 13 | import com.lamps.lamps.util.CommandUtils; 14 | 15 | /** 16 | * Created by stew on 16/9/3. 17 | * mail: stewforani@gmail.com 18 | */ 19 | public class ColorFragment extends Fragment { 20 | private View rootView; 21 | private String order = CommandUtils.COLOR_1; 22 | 23 | @Nullable 24 | @Override 25 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 26 | rootView = inflater.inflate(R.layout.fragment_color, container, false); 27 | return rootView; 28 | } 29 | 30 | @Override 31 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 32 | super.onViewCreated(view, savedInstanceState); 33 | initView(); 34 | } 35 | 36 | private void initView() { 37 | SeekBar seekBar = (SeekBar) rootView.findViewById(R.id.seekBar_color); 38 | seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 39 | @Override 40 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 41 | 42 | } 43 | 44 | @Override 45 | public void onStartTrackingTouch(SeekBar seekBar) { 46 | 47 | } 48 | 49 | @Override 50 | public void onStopTrackingTouch(SeekBar seekBar) { 51 | 52 | int progress = seekBar.getProgress(); 53 | if (progress < 25) { 54 | seekBar.setProgress(0); 55 | order=CommandUtils.COLOR_1; 56 | } else if (progress < 75) { 57 | seekBar.setProgress(50); 58 | order=CommandUtils.COLOR_2; 59 | } else { 60 | seekBar.setProgress(100); 61 | order=CommandUtils.COLOR_3; 62 | } 63 | ((MainActivity) getActivity()).sendOrder(order); 64 | } 65 | }); 66 | 67 | 68 | } 69 | 70 | public String getOrder() { 71 | return order; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/lamps/lamps/fragment/BrightFragment.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.SeekBar; 10 | 11 | import com.lamps.lamps.R; 12 | import com.lamps.lamps.activity.MainActivity; 13 | import com.lamps.lamps.util.CommandUtils; 14 | 15 | /** 16 | * Created by stew on 16/8/30. 17 | * mail: stewforani@gmail.com 18 | */ 19 | public class BrightFragment extends Fragment { 20 | private View rootView; 21 | private String order = CommandUtils.BRIGHT_1; 22 | 23 | @Nullable 24 | @Override 25 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 26 | rootView = inflater.inflate(R.layout.fragment_always_bright, container, false); 27 | return rootView; 28 | } 29 | 30 | @Override 31 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 32 | super.onViewCreated(view, savedInstanceState); 33 | initView(); 34 | } 35 | 36 | private void initView() { 37 | SeekBar seekBar = (SeekBar) rootView.findViewById(R.id.seekBar_bright); 38 | seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 39 | @Override 40 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 41 | 42 | } 43 | 44 | @Override 45 | public void onStartTrackingTouch(SeekBar seekBar) { 46 | 47 | } 48 | 49 | @Override 50 | public void onStopTrackingTouch(SeekBar seekBar) { 51 | 52 | int progress = seekBar.getProgress(); 53 | if (progress < 25) { 54 | seekBar.setProgress(0); 55 | order = CommandUtils.BRIGHT_1; 56 | } else if (progress < 75) { 57 | seekBar.setProgress(50); 58 | order = CommandUtils.BRIGHT_2; 59 | } else { 60 | seekBar.setProgress(100); 61 | order = CommandUtils.BRIGHT_3; 62 | } 63 | ((MainActivity) getActivity()).sendOrder(order); 64 | } 65 | }); 66 | } 67 | 68 | public String getOrder() { 69 | return order; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_change_language.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 12 | 19 | 20 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 40 | 49 | 50 | 56 | 57 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_gradient.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | 20 | 21 | 27 | 28 | 32 | 33 | 38 | 39 | 44 | 45 | 46 | 47 | 51 | 52 | 53 | 58 | 59 | 65 | 66 | 70 | 71 | 76 | 77 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_twinkle.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | 20 | 21 | 27 | 28 | 32 | 33 | 38 | 39 | 44 | 45 | 46 | 47 | 51 | 52 | 53 | 58 | 59 | 65 | 66 | 70 | 71 | 76 | 77 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /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/java/com/lamps/lamps/activity/SettingActivity.java: -------------------------------------------------------------------------------- 1 | package com.lamps.lamps.activity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.lamps.lamps.R; 12 | import com.lamps.lamps.util.CommandUtils; 13 | import com.lamps.lamps.util.ControlLight; 14 | 15 | /** 16 | * Created by stew on 16/9/4. 17 | * mail: stewforani@gmail.com 18 | */ 19 | public class SettingActivity extends BaseActivity implements View.OnClickListener { 20 | 21 | @Override 22 | protected void onCreate(@Nullable Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_setting); 25 | initView(); 26 | } 27 | 28 | private void initView() { 29 | 30 | ImageView back = (ImageView) findViewById(R.id.setting_back); 31 | TextView tv1 = (TextView) findViewById(R.id.change_ssid); 32 | TextView tv2 = (TextView) findViewById(R.id.change_wifi_psd); 33 | TextView tv3 = (TextView) findViewById(R.id.change_language); 34 | Button restart = (Button) findViewById(R.id.restart); 35 | if (back == null || tv1 == null || tv2 == null || tv3 == null||restart==null) { 36 | return; 37 | } 38 | 39 | back.setOnClickListener(new View.OnClickListener() { 40 | @Override 41 | public void onClick(View v) { 42 | finish(); 43 | } 44 | }); 45 | 46 | tv1.setOnClickListener(this); 47 | tv2.setOnClickListener(this); 48 | tv3.setOnClickListener(this); 49 | restart.setOnClickListener(this); 50 | } 51 | 52 | @Override 53 | public void onClick(View v) { 54 | switch (v.getId()) { 55 | 56 | 57 | case R.id.change_ssid: { 58 | Intent intent = new Intent(SettingActivity.this, ChangeSSIDActivity.class); 59 | startActivity(intent); 60 | } 61 | break; 62 | 63 | 64 | case R.id.change_wifi_psd: { 65 | Intent intent = new Intent(SettingActivity.this, ChangeWifiPsdActivity.class); 66 | startActivity(intent); 67 | } 68 | break; 69 | 70 | 71 | case R.id.change_language: { 72 | Intent intent = new Intent(SettingActivity.this, ChangeLanguageActivity.class); 73 | startActivity(intent); 74 | } 75 | break; 76 | 77 | case R.id.restart: { 78 | ControlLight.sendOrder(CommandUtils.RESTART); 79 | } 80 | break; 81 | 82 | } 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Lamp 3 | wifi未连接,请先 4 | 连接 5 | 亮度 6 | 7 | 正常 8 | 9 | 闪烁 10 | 速度 11 | 交替 12 | 整体 13 | 组合 14 | 15 | 16 | 17 | 渐明暗 18 | 颜色 19 | 颜色一 20 | 颜色二 21 | 彩色 22 | 追光 23 | 修改SSID 24 | 修改SSID 25 | 修改密码 26 | 设置语言 27 | 重启 28 | 设置 29 | 重置密码 30 | 设置语言 31 | 重置 32 | 简体中文 33 | English 34 | 连接失败 35 | 36 | 37 | 常亮 38 | 闪烁 39 | 渐变 40 | 颜色 41 | 追光 42 | 新密码 43 | 请输入SSID 44 | 进入 45 | 定时 46 | 保存 47 | SSID不能为空! 48 | 开启时间 49 | 关闭时间 50 | 请先打开定时开关! 51 | 提示 52 | 未保存,确定退出么? 53 | 确定 54 | 取消 55 | 请稍等... 56 | 模式二 57 | 模式一 58 | 密码不能为空! 59 | 密码长度必须8-12位 60 | 密码修改成功,请重新连接wifi! 61 | 62 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_change_wifi_psd.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | 20 | 21 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 42 | 43 | 44 | 56 | 57 | 58 | 65 | 66 | 67 | 68 |