Skip to content

Commit

Permalink
lamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Stew authored and Stew committed Jan 19, 2017
1 parent 1051b58 commit c5f0b27
Show file tree
Hide file tree
Showing 72 changed files with 3,975 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures

.idea
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
35 changes: 35 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "com.lamps.lamps"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

repositories {
maven {
url "https://jitpack.io"
}
}

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.github.hackware1993:MagicIndicator:1.2.1'

}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/stew/Library/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 *;
#}
13 changes: 13 additions & 0 deletions app/src/androidTest/java/com/lamps/lamps/ApplicationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.lamps.lamps;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
53 changes: 53 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lamps.lamps">


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activity.WifiConnectActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".activity.MainActivity"
android:screenOrientation="portrait" />

<activity
android:name=".activity.SettingActivity"
android:screenOrientation="portrait" />

<activity
android:name=".activity.ChangeSSIDActivity"
android:screenOrientation="portrait" />

<activity
android:name=".activity.ChangeWifiPsdActivity"
android:screenOrientation="portrait" />

<activity
android:name=".activity.ChangeLanguageActivity"
android:screenOrientation="portrait" />

<activity
android:name=".activity.TimingActivity"
android:screenOrientation="portrait" />
</application>

</manifest>
30 changes: 30 additions & 0 deletions app/src/main/java/com/lamps/lamps/activity/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.lamps.lamps.activity;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;

import com.lamps.lamps.R;

/**
* Created by stew on 16/8/30.
* mail: [email protected]
*/
public class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStatusBar();
}

private void setStatusBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(getResources().getColor(R.color.app_main_color));

}
}


}
101 changes: 101 additions & 0 deletions app/src/main/java/com/lamps/lamps/activity/ChangeLanguageActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.lamps.lamps.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.lamps.lamps.R;

import java.util.Locale;

/**
* Created by stew on 16/9/4.
* mail: [email protected]
*/
public class ChangeLanguageActivity extends BaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_language);
initView();
}

private void initView() {
/**
* 保存设置
*/
SharedPreferences sharedPreferences = getSharedPreferences("set", MODE_PRIVATE);
final SharedPreferences.Editor editor = sharedPreferences.edit();

/**
* 获取系统配置
*/
final Resources resources = getResources();
final DisplayMetrics dm = resources.getDisplayMetrics();
final Configuration config = resources.getConfiguration();

ImageView back = (ImageView) findViewById(R.id.setting_back);
TextView CN = (TextView) findViewById(R.id.language_cn);
TextView EN = (TextView) findViewById(R.id.language_en);

if (back == null || CN == null || EN == null) {
return;
}

back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});


CN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

config.locale = Locale.SIMPLIFIED_CHINESE;
resources.updateConfiguration(config, dm);

editor.putString("language","0");
editor.apply();

Intent intent = new Intent(ChangeLanguageActivity.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);


}
});


EN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {


config.locale = Locale.ENGLISH;
resources.updateConfiguration(config, dm);

editor.putString("language","1");
editor.apply();

Intent intent = new Intent(ChangeLanguageActivity.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);

}
});



}

}
60 changes: 60 additions & 0 deletions app/src/main/java/com/lamps/lamps/activity/ChangeSSIDActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.lamps.lamps.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.lamps.lamps.R;
import com.lamps.lamps.util.ControlLight;

/**
* Created by stew on 16/9/4.
* mail: [email protected]
*/
public class ChangeSSIDActivity extends BaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chnage_ssid);
initView();
}


private void initView() {

ImageView back = (ImageView) findViewById(R.id.setting_back);
final EditText ssid = (EditText) findViewById(R.id.edit_ssid);
Button btn = (Button) findViewById(R.id.button_send);

if (back == null || ssid == null || btn == null) {
return;
}

back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ssid.getText().toString().isEmpty()) {
Toast.makeText(ChangeSSIDActivity.this, R.string.ssid_can_not_be_null, Toast.LENGTH_SHORT).show();
return;
}

ControlLight.sendSSID(ssid.getText().toString());
finish();

}
});


}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.lamps.lamps.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.lamps.lamps.R;
import com.lamps.lamps.util.ControlLight;

/**
* Created by stew on 16/9/4.
* mail: [email protected]
*/
public class ChangeWifiPsdActivity extends BaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_wifi_psd);
initView();
}

private void initView() {

ImageView back = (ImageView) findViewById(R.id.setting_back);
final EditText ssid = (EditText) findViewById(R.id.edit_psd);
Button btn = (Button) findViewById(R.id.btn_reset);

if (back == null || ssid == null || btn == null) {
return;
}

back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ssid.getText().toString().isEmpty()) {
Toast.makeText(ChangeWifiPsdActivity.this, R.string.psd_null, Toast.LENGTH_SHORT).show();
return;
}

if (ssid.getText().toString().length() > 12 || ssid.getText().toString().length() < 8) {
Toast.makeText(ChangeWifiPsdActivity.this, R.string.psd_8_12, Toast.LENGTH_SHORT).show();
return;
}

ControlLight.sendPassword(ssid.getText().toString());
Toast.makeText(ChangeWifiPsdActivity.this, R.string.psd_change_success, Toast.LENGTH_SHORT).show();
finish();

}
});

}
}
Loading

0 comments on commit c5f0b27

Please sign in to comment.