Commit d2f4c819f2dc305b32d604c1d26c69b2d48c0880

Authored by wugian
1 parent ff67cca7

before play movie play ads ,and some other bugs fix

@@ -55,7 +55,7 @@ android { @@ -55,7 +55,7 @@ android {
55 } 55 }
56 56
57 defaultConfig { 57 defaultConfig {
58 - applicationId "com.qnbar.fangtang.cinema" 58 +// applicationId "com.qnbar.fangtang.cinema"
59 minSdkVersion ANDROID_MIN_SDK_VERSION as int 59 minSdkVersion ANDROID_MIN_SDK_VERSION as int
60 targetSdkVersion ANDROID_TARGET_SDK_VERSION as int 60 targetSdkVersion ANDROID_TARGET_SDK_VERSION as int
61 versionCode APP_VERSION_CODE 61 versionCode APP_VERSION_CODE
@@ -93,7 +93,7 @@ android { @@ -93,7 +93,7 @@ android {
93 // manifestPlaceholders = [label: "青柠影咖", icon: "@drawable/ic_luancher", channel: "QNJM"] 93 // manifestPlaceholders = [label: "青柠影咖", icon: "@drawable/ic_luancher", channel: "QNJM"]
94 buildConfigField 'String', 'MACHINE_TYPE', "\"gimi\"" 94 buildConfigField 'String', 'MACHINE_TYPE', "\"gimi\""
95 buildConfigField 'boolean', 'USE_GLIDE', "false" 95 buildConfigField 'boolean', 'USE_GLIDE', "false"
96 - manifestPlaceholders = [label: "在线影院", icon: "@drawable/ic_launcher", channel: "JSZC"] 96 + manifestPlaceholders = [label: "方糖", icon: "@drawable/ic_launcher", channel: "JSZC"]
97 minifyEnabled false 97 minifyEnabled false
98 signingConfig signingConfigs.myConfig 98 signingConfig signingConfigs.myConfig
99 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 99 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
@@ -438,6 +438,22 @@ public class NewDBManager { @@ -438,6 +438,22 @@ public class NewDBManager {
438 * 438 *
439 * @return persons 439 * @return persons
440 */ 440 */
  441 + public List<LocalMovieMessage> queryRandomMovies() {
  442 +// String sql = "SELECT * FROM movie_message order by cast(movie_dl_time as int) desc limit " + 1;/* + " path like '%" + key + "%'";*/
  443 +// ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  444 +// StringBuffer sb = new StringBuffer(sql);
  445 +//
  446 +// Cursor c = db.rawQuery(sb.toString(), null);
  447 +// readCursor2List(persons, c);
  448 +// c.close();
  449 + return queryTJLimit(1);
  450 + }
  451 +
  452 + /**
  453 + * query all recommend qn
  454 + *
  455 + * @return persons
  456 + */
441 public List<LocalMovieMessage> queryAllDemandMovies() { 457 public List<LocalMovieMessage> queryAllDemandMovies() {
442 String sql = "SELECT * FROM movie_message order by cast(" + NewDBHelper.MOVIE_COUNT + " as int) desc, cast(movie_dl_time as int) desc limit " + PXB_MOVIE_COUNT;/* + " path like '%" + key + "%'";*/ 458 String sql = "SELECT * FROM movie_message order by cast(" + NewDBHelper.MOVIE_COUNT + " as int) desc, cast(movie_dl_time as int) desc limit " + PXB_MOVIE_COUNT;/* + " path like '%" + key + "%'";*/
443 ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>(); 459 ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
@@ -623,7 +639,7 @@ public class NewDBManager { @@ -623,7 +639,7 @@ public class NewDBManager {
623 db.beginTransaction(); 639 db.beginTransaction();
624 ContentValues cv = constructCv(lmm); 640 ContentValues cv = constructCv(lmm);
625 // db.update(NewDBHelper.TABLE_NAME, cv, "id = ? ", new String[]{String.valueOf(lmm.getId())}); 641 // db.update(NewDBHelper.TABLE_NAME, cv, "id = ? ", new String[]{String.valueOf(lmm.getId())});
626 - db.updateWithOnConflict(NewDBHelper.TABLE_NAME, cv, "id = ? ", new String[]{String.valueOf(lmm.getId())},SQLiteDatabase.CONFLICT_REPLACE); 642 + db.updateWithOnConflict(NewDBHelper.TABLE_NAME, cv, "id = ? ", new String[]{String.valueOf(lmm.getId())}, SQLiteDatabase.CONFLICT_REPLACE);
627 db.setTransactionSuccessful(); // changes get rolled back if this not called 643 db.setTransactionSuccessful(); // changes get rolled back if this not called
628 result = true; 644 result = true;
629 db.endTransaction(); // commit or rollback 645 db.endTransaction(); // commit or rollback
@@ -7,6 +7,7 @@ import android.net.Uri; @@ -7,6 +7,7 @@ import android.net.Uri;
7 import android.text.TextUtils; 7 import android.text.TextUtils;
8 import com.gimi.common.cinema.model.Constant; 8 import com.gimi.common.cinema.model.Constant;
9 import com.xgimi.gimicinema.BuildConfig; 9 import com.xgimi.gimicinema.BuildConfig;
  10 +import com.xgimi.gimicinema.activity.AdsPreVideoPlayerActivity;
10 11
11 import java.util.ArrayList; 12 import java.util.ArrayList;
12 import java.util.List; 13 import java.util.List;
@@ -24,6 +25,15 @@ public class OpenMMUtils { @@ -24,6 +25,15 @@ public class OpenMMUtils {
24 // context.startActivity(intent); 25 // context.startActivity(intent);
25 } 26 }
26 27
  28 +
  29 + public static void openMMWithAds(Context context, String videoPath, String subtitlePath) {
  30 + //Splash Video Ads? find Ads,no ads play movie;ads exists play
  31 +// openMM(context, videoPath, null, subtitlePath);
  32 + Intent intent = new Intent(context, AdsPreVideoPlayerActivity.class);
  33 + intent.putExtra(AdsPreVideoPlayerActivity.MOVIE_PLAY_PATH, videoPath);
  34 + context.startActivity(intent);
  35 + }
  36 +
27 public static void openMM(Context context, String videoPath, ArrayList<String> list, String subtitlePath) { 37 public static void openMM(Context context, String videoPath, ArrayList<String> list, String subtitlePath) {
28 //Splash Video Ads? find Ads,no ads play movie;ads exists play 38 //Splash Video Ads? find Ads,no ads play movie;ads exists play
29 openPlayer(context, videoPath, list, 0); 39 openPlayer(context, videoPath, list, 0);
@@ -24,7 +24,8 @@ import android.view.View.OnClickListener; @@ -24,7 +24,8 @@ import android.view.View.OnClickListener;
24 import android.view.Window; 24 import android.view.Window;
25 import android.widget.Button; 25 import android.widget.Button;
26 import android.widget.SeekBar; 26 import android.widget.SeekBar;
27 - 27 +import android.widget.TextView;
  28 +import com.gimi.common.cinema.utils.Utils;
28 import com.qnbar.smc.model.Light; 29 import com.qnbar.smc.model.Light;
29 import com.qnbar.smc.model.Lights; 30 import com.qnbar.smc.model.Lights;
30 import com.qnbar.smc.service.TelinkLightService; 31 import com.qnbar.smc.service.TelinkLightService;
@@ -37,6 +38,8 @@ public class DeviceSettingActivity extends Activity implements OnClickListener { @@ -37,6 +38,8 @@ public class DeviceSettingActivity extends Activity implements OnClickListener {
37 38
38 private SeekBar brightnessBar; 39 private SeekBar brightnessBar;
39 private SeekBar temperatureBar; 40 private SeekBar temperatureBar;
  41 + private TextView temperatureTv;
  42 + private TextView brightnessTv;
40 private Button remove; 43 private Button remove;
41 private View delete; 44 private View delete;
42 private SeekBar.OnSeekBarChangeListener barChangeListener = new SeekBar.OnSeekBarChangeListener() { 45 private SeekBar.OnSeekBarChangeListener barChangeListener = new SeekBar.OnSeekBarChangeListener() {
@@ -81,17 +84,18 @@ public class DeviceSettingActivity extends Activity implements OnClickListener { @@ -81,17 +84,18 @@ public class DeviceSettingActivity extends Activity implements OnClickListener {
81 if (view == brightnessBar) { 84 if (view == brightnessBar) {
82 opcode = (byte) 0xD2; 85 opcode = (byte) 0xD2;
83 params = new byte[]{(byte) progress}; 86 params = new byte[]{(byte) progress};
84 - 87 + brightnessTv.setText("亮度:" + progress);
85 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, immediate); 88 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, immediate);
86 89
87 } else if (view == temperatureBar) { 90 } else if (view == temperatureBar) {
  91 + temperatureTv.setText("色温:" + progress);
88 92
89 opcode = (byte) 0xE2; 93 opcode = (byte) 0xE2;
90 params = new byte[]{0x05, (byte) progress}; 94 params = new byte[]{0x05, (byte) progress};
91 95
92 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, immediate); 96 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, immediate);
93 } 97 }
94 - } 98 + }
95 }; 99 };
96 private int meshAddress; 100 private int meshAddress;
97 101
@@ -113,13 +117,22 @@ public class DeviceSettingActivity extends Activity implements OnClickListener { @@ -113,13 +117,22 @@ public class DeviceSettingActivity extends Activity implements OnClickListener {
113 // txtTitle.setText(TextUtils.isEmpty(light.getLabel2()) ? "" : light.getLabel2()); 117 // txtTitle.setText(TextUtils.isEmpty(light.getLabel2()) ? "" : light.getLabel2());
114 // } 118 // }
115 119
  120 + this.temperatureTv = (TextView) findViewById(R.id.temperatureTv);
  121 + this.brightnessTv = (TextView) findViewById(R.id.brightnessTv);
  122 +
116 this.brightnessBar = (SeekBar) findViewById(R.id.sb_brightness); 123 this.brightnessBar = (SeekBar) findViewById(R.id.sb_brightness);
117 this.temperatureBar = (SeekBar) findViewById(R.id.sb_temperature); 124 this.temperatureBar = (SeekBar) findViewById(R.id.sb_temperature);
  125 + int brightness = Utils.getInt(this, "brightness", 50);
  126 + int temperature = Utils.getInt(this, "temperature", 50);
  127 + temperatureTv.setText("色温:" + temperature);
  128 + brightnessTv.setText("亮度:" + brightness);
  129 +
  130 + brightnessBar.setProgress(brightness);
  131 + temperatureBar.setProgress(temperature);
118 132
119 this.brightnessBar.setOnSeekBarChangeListener(barChangeListener); 133 this.brightnessBar.setOnSeekBarChangeListener(barChangeListener);
120 this.temperatureBar.setOnSeekBarChangeListener(barChangeListener); 134 this.temperatureBar.setOnSeekBarChangeListener(barChangeListener);
121 135
122 -  
123 this.remove = (Button) findViewById(R.id.btn_remove); 136 this.remove = (Button) findViewById(R.id.btn_remove);
124 this.remove.setOnClickListener(this); 137 this.remove.setOnClickListener(this);
125 138
@@ -174,6 +187,13 @@ public class DeviceSettingActivity extends Activity implements OnClickListener { @@ -174,6 +187,13 @@ public class DeviceSettingActivity extends Activity implements OnClickListener {
174 187
175 } 188 }
176 189
  190 + @Override
  191 + protected void onDestroy() {
  192 + super.onDestroy();
  193 + Utils.saveInt(this,"brightness",brightnessBar.getProgress());
  194 + Utils.saveInt(this,"temperature",temperatureBar.getProgress());
  195 + }
  196 +
177 public void changeBrightness(View view) { 197 public void changeBrightness(View view) {
178 brightnessUp(); 198 brightnessUp();
179 } 199 }
@@ -147,6 +147,6 @@ public class AdsPreVideoPlayerActivity extends BaseActivity { @@ -147,6 +147,6 @@ public class AdsPreVideoPlayerActivity extends BaseActivity {
147 } 147 }
148 148
149 public String getAdsVideoUrl() { 149 public String getAdsVideoUrl() {
150 - return "/mnt/samba/192.168.4.214/root/fl/ads.ts"; 150 + return Utils.getSambaMsg(this).getLocalPath() + "ads.mp4";
151 } 151 }
152 } 152 }
@@ -47,6 +47,7 @@ import com.bluetoothle.BLEOpenRecord; @@ -47,6 +47,7 @@ import com.bluetoothle.BLEOpenRecord;
47 import com.bluetoothle.GREENBluetoothLeService; 47 import com.bluetoothle.GREENBluetoothLeService;
48 import com.bluetoothle.greencity.GREENBLE; 48 import com.bluetoothle.greencity.GREENBLE;
49 import com.bluetoothle.greencity.GREENCITYBLEProtocolFactory; 49 import com.bluetoothle.greencity.GREENCITYBLEProtocolFactory;
  50 +import com.gimi.common.cinema.db.NewDBManager;
50 import com.gimi.common.cinema.model.ClassificationItem; 51 import com.gimi.common.cinema.model.ClassificationItem;
51 import com.gimi.common.cinema.model.Constant; 52 import com.gimi.common.cinema.model.Constant;
52 import com.gimi.common.cinema.model.FolderItem; 53 import com.gimi.common.cinema.model.FolderItem;
@@ -55,6 +56,7 @@ import com.gimi.common.cinema.model.MessageEvent; @@ -55,6 +56,7 @@ import com.gimi.common.cinema.model.MessageEvent;
55 import com.gimi.common.cinema.utils.AuthUtils; 56 import com.gimi.common.cinema.utils.AuthUtils;
56 import com.gimi.common.cinema.utils.LeeImageLoader; 57 import com.gimi.common.cinema.utils.LeeImageLoader;
57 import com.gimi.common.cinema.utils.M1905Utils; 58 import com.gimi.common.cinema.utils.M1905Utils;
  59 +import com.gimi.common.cinema.utils.OpenMMUtils;
58 import com.gimi.common.cinema.utils.ScreenUtils; 60 import com.gimi.common.cinema.utils.ScreenUtils;
59 import com.gimi.common.cinema.utils.SystemUtils; 61 import com.gimi.common.cinema.utils.SystemUtils;
60 import com.qnbar.smc.model.Light; 62 import com.qnbar.smc.model.Light;
@@ -882,5 +884,9 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -882,5 +884,9 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
882 884
883 }); 885 });
884 GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes()); 886 GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes());
  887 + List<LocalMovieMessage> localMovieMessages = new NewDBManager(this).queryRandomMovies();
  888 + if (localMovieMessages != null && localMovieMessages.size() > 0) {
  889 + OpenMMUtils.openMMWithAds(this, localMovieMessages.get(0).getPlayPath(), null);
  890 + }
885 } 891 }
886 } 892 }
@@ -83,16 +83,16 @@ public class UpdateModelImpl implements IUpdateModel { @@ -83,16 +83,16 @@ public class UpdateModelImpl implements IUpdateModel {
83 83
84 @Override 84 @Override
85 public void updateAppVersion(Context context, boolean bool) { 85 public void updateAppVersion(Context context, boolean bool) {
86 - if (appUpdateUtils == null) {  
87 - appUpdateUtils = new AppUpdateUtils(context);  
88 - }  
89 - appUpdateUtils.setShowNoUpdate(bool);  
90 - ThreadUtils.subThread(new ThreadUtils.DoSomeThing() {  
91 - @Override  
92 - public void doSomeThing() {  
93 - appUpdateUtils.updateAppVersion();  
94 - }  
95 - }); 86 +// if (appUpdateUtils == null) {
  87 +// appUpdateUtils = new AppUpdateUtils(context);
  88 +// }
  89 +// appUpdateUtils.setShowNoUpdate(bool);
  90 +// ThreadUtils.subThread(new ThreadUtils.DoSomeThing() {
  91 +// @Override
  92 +// public void doSomeThing() {
  93 +// appUpdateUtils.updateAppVersion();
  94 +// }
  95 +// });
96 } 96 }
97 97
98 @Override 98 @Override
@@ -17,22 +17,19 @@ @@ -17,22 +17,19 @@
17 package com.xgimi.gimicinema.service; 17 package com.xgimi.gimicinema.service;
18 18
19 import android.app.Service; 19 import android.app.Service;
20 -import android.content.ComponentName;  
21 import android.content.Context; 20 import android.content.Context;
22 import android.content.Intent; 21 import android.content.Intent;
23 -import android.content.ServiceConnection;  
24 import android.os.Handler; 22 import android.os.Handler;
25 import android.os.IBinder; 23 import android.os.IBinder;
26 import android.os.RemoteException; 24 import android.os.RemoteException;
27 import android.util.Log; 25 import android.util.Log;
28 - 26 +import com.gimi.common.cinema.utils.Utils;
29 import com.qnbar.smc.model.Light; 27 import com.qnbar.smc.model.Light;
30 import com.qnbar.smc.model.Lights; 28 import com.qnbar.smc.model.Lights;
31 import com.qnbar.smc.service.TelinkLightService; 29 import com.qnbar.smc.service.TelinkLightService;
32 import com.telink.bluetooth.light.ConnectionStatus; 30 import com.telink.bluetooth.light.ConnectionStatus;
33 import com.telink.bluetooth.light.DeviceInfo; 31 import com.telink.bluetooth.light.DeviceInfo;
34 import com.xgimi.gimicinema.ICinemaControl; 32 import com.xgimi.gimicinema.ICinemaControl;
35 -import com.xgimi.gimicinema.ICinemaSMC;  
36 import com.xgimi.gimicinema.application.FangTangApplication; 33 import com.xgimi.gimicinema.application.FangTangApplication;
37 34
38 import java.util.ArrayList; 35 import java.util.ArrayList;
@@ -79,7 +76,6 @@ public class CinemaControlService extends Service { @@ -79,7 +76,6 @@ public class CinemaControlService extends Service {
79 return currentState; 76 return currentState;
80 } 77 }
81 78
82 - //TODO 当状态改变时上报服务器状态,开始播放时,启动轮询上报当前状态及时间  
83 @Override 79 @Override
84 public void setCurrentStatus(int state) throws RemoteException { 80 public void setCurrentStatus(int state) throws RemoteException {
85 Log.d("aidl", "setCurrentStatus: " + state); 81 Log.d("aidl", "setCurrentStatus: " + state);
@@ -95,15 +91,12 @@ public class CinemaControlService extends Service { @@ -95,15 +91,12 @@ public class CinemaControlService extends Service {
95 // } 91 // }
96 switch (state) { 92 switch (state) {
97 case 0://空闲 93 case 0://空闲
98 -// open();  
99 fadeIn(); 94 fadeIn();
100 break; 95 break;
101 case 1://播放 96 case 1://播放
102 fadeOut(); 97 fadeOut();
103 -// close();  
104 break; 98 break;
105 case 2://暂停 99 case 2://暂停
106 -// open();  
107 fadeIn(); 100 fadeIn();
108 break; 101 break;
109 } 102 }
@@ -150,7 +143,7 @@ public class CinemaControlService extends Service { @@ -150,7 +143,7 @@ public class CinemaControlService extends Service {
150 @Override 143 @Override
151 public void run() { 144 public void run() {
152 setLightValue(value); 145 setLightValue(value);
153 - if (value-- == 50) { 146 + if (value-- == maxValue) {
154 handler.postDelayed(this, 4 * 1000); 147 handler.postDelayed(this, 4 * 1000);
155 } else { 148 } else {
156 if (value == 0) { 149 if (value == 0) {
@@ -161,7 +154,7 @@ public class CinemaControlService extends Service { @@ -161,7 +154,7 @@ public class CinemaControlService extends Service {
161 } 154 }
162 }, 3 * 1000); 155 }, 3 * 1000);
163 } else { 156 } else {
164 - handler.postDelayed(this, 200); 157 + handler.postDelayed(this, 80);
165 } 158 }
166 } 159 }
167 } 160 }
@@ -170,12 +163,12 @@ public class CinemaControlService extends Service { @@ -170,12 +163,12 @@ public class CinemaControlService extends Service {
170 private Runnable openRunnable = new Runnable() { 163 private Runnable openRunnable = new Runnable() {
171 @Override 164 @Override
172 public void run() { 165 public void run() {
173 - if (value++ == 0) { 166 + if (value++ == 10) {
174 open(); 167 open();
175 - handler.postDelayed(this, 4 * 1000); 168 + handler.postDelayed(this, 2 * 1000);
176 } else { 169 } else {
177 setLightValue(value); 170 setLightValue(value);
178 - if (value != 50) { 171 + if (value != maxValue) {
179 handler.postDelayed(this, 200); 172 handler.postDelayed(this, 200);
180 } 173 }
181 } 174 }
@@ -183,13 +176,12 @@ public class CinemaControlService extends Service { @@ -183,13 +176,12 @@ public class CinemaControlService extends Service {
183 }; 176 };
184 177
185 private FangTangApplication mApplication; 178 private FangTangApplication mApplication;
  179 + private Context context;
186 180
187 @Override 181 @Override
188 public void onCreate() { 182 public void onCreate() {
189 super.onCreate(); 183 super.onCreate();
190 - if (!mBound) {  
191 - attemptToBindService();  
192 - } 184 + context = this;
193 mApplication = (FangTangApplication) getApplication(); 185 mApplication = (FangTangApplication) getApplication();
194 } 186 }
195 187
@@ -198,36 +190,6 @@ public class CinemaControlService extends Service { @@ -198,36 +190,6 @@ public class CinemaControlService extends Service {
198 return cinemaControl; 190 return cinemaControl;
199 } 191 }
200 192
201 - //由AIDL文件生成的Java类  
202 - private ICinemaSMC cinemaSMC = null;  
203 -  
204 - //标志当前与服务端连接状况的布尔值,false为未连接,true为连接中  
205 - private boolean mBound = false;  
206 -  
207 -  
208 - private ServiceConnection mServiceConnection = new ServiceConnection() {  
209 - @Override  
210 - public void onServiceConnected(ComponentName name, IBinder service) {  
211 - cinemaSMC = ICinemaSMC.Stub.asInterface(service);  
212 - mBound = true;  
213 - }  
214 -  
215 - @Override  
216 - public void onServiceDisconnected(ComponentName name) {  
217 - mBound = false;  
218 - }  
219 - };  
220 -  
221 - /**  
222 - * 尝试与服务端建立连接  
223 - */  
224 - private void attemptToBindService() {  
225 - Intent intent = new Intent();  
226 - intent.setPackage("com.qnbar.smc");  
227 - intent.setAction("com.xgimi.cinemasmc");  
228 - bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);  
229 - }  
230 -  
231 // private boolean isSMCRun(Context context) { 193 // private boolean isSMCRun(Context context) {
232 // return isServiceRunning(context, "com.qnbar.smc.service.SMCService"); 194 // return isServiceRunning(context, "com.qnbar.smc.service.SMCService");
233 // } 195 // }
@@ -259,7 +221,7 @@ public class CinemaControlService extends Service { @@ -259,7 +221,7 @@ public class CinemaControlService extends Service {
259 int address = 0xFFFF; 221 int address = 0xFFFF;
260 byte[] params = new byte[]{0x01, 0x00, 0x00}; 222 byte[] params = new byte[]{0x01, 0x00, 0x00};
261 if (TelinkLightService.Instance().sendCommandNoResponse(opcode, address, params)) { 223 if (TelinkLightService.Instance().sendCommandNoResponse(opcode, address, params)) {
262 -// show("open all success"); 224 + Log.d("aidl","open all success");
263 } 225 }
264 } 226 }
265 227
@@ -268,10 +230,12 @@ public class CinemaControlService extends Service { @@ -268,10 +230,12 @@ public class CinemaControlService extends Service {
268 int address = 0xFFFF; 230 int address = 0xFFFF;
269 byte[] params = new byte[]{0x00, 0x00, 0x00}; 231 byte[] params = new byte[]{0x00, 0x00, 0x00};
270 if (TelinkLightService.Instance().sendCommandNoResponse(opcode, address, params)) { 232 if (TelinkLightService.Instance().sendCommandNoResponse(opcode, address, params)) {
271 -// show("open all success"); 233 + Log.d("aidl","open all success");
272 } 234 }
273 } 235 }
274 236
  237 + private int maxValue = 50;
  238 +
275 private void fadeIn() { 239 private void fadeIn() {
276 DeviceInfo connectDevice = mApplication.getConnectDevice(); 240 DeviceInfo connectDevice = mApplication.getConnectDevice();
277 if (connectDevice == null) { 241 if (connectDevice == null) {
@@ -280,11 +244,13 @@ public class CinemaControlService extends Service { @@ -280,11 +244,13 @@ public class CinemaControlService extends Service {
280 } 244 }
281 Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress); 245 Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress);
282 if (byMeshAddress.status == ConnectionStatus.ON) { 246 if (byMeshAddress.status == ConnectionStatus.ON) {
  247 + handler.removeCallbacks(closeRunnable);
283 return; 248 return;
284 } 249 }
  250 + maxValue = Utils.getInt(context, "brightness", 50);
285 // int status = mApplication.getConnectDevice().status; 251 // int status = mApplication.getConnectDevice().status;
286 // Log.d("status_charge", "fadeIn: " + status); 252 // Log.d("status_charge", "fadeIn: " + status);
287 - value = 0; 253 + value = 10;
288 handler.post(openRunnable); 254 handler.post(openRunnable);
289 } 255 }
290 256
@@ -296,11 +262,14 @@ public class CinemaControlService extends Service { @@ -296,11 +262,14 @@ public class CinemaControlService extends Service {
296 } 262 }
297 Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress); 263 Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress);
298 if (byMeshAddress.status == ConnectionStatus.OFF) { 264 if (byMeshAddress.status == ConnectionStatus.OFF) {
  265 + handler.removeCallbacks(openRunnable);
299 return; 266 return;
300 } 267 }
  268 + maxValue = Utils.getInt(context, "brightness", 50);
  269 +
301 // int status = connectDevice.status; 270 // int status = connectDevice.status;
302 // Log.d("status_charge", "fadeOut: " + status); 271 // Log.d("status_charge", "fadeOut: " + status);
303 - value = 50; 272 + value = maxValue;
304 handler.post(closeRunnable); 273 handler.post(closeRunnable);
305 } 274 }
306 275
@@ -316,8 +285,8 @@ public class CinemaControlService extends Service { @@ -316,8 +285,8 @@ public class CinemaControlService extends Service {
316 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true); 285 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true);
317 286
318 287
319 - opcode = (byte) 0xE2;  
320 - params = new byte[]{0x05, (byte) value};  
321 - TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true); 288 +// opcode = (byte) 0xE2;
  289 +// params = new byte[]{0x05, (byte) value};
  290 +// TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true);
322 } 291 }
323 } 292 }
@@ -15,138 +15,148 @@ @@ -15,138 +15,148 @@
15 --> 15 -->
16 16
17 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 17 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
18 - android:layout_width="match_parent"  
19 - android:layout_height="match_parent"  
20 - android:orientation="vertical"> 18 + android:layout_width="match_parent"
  19 + android:layout_height="match_parent"
  20 + android:orientation="vertical">
21 21
22 <LinearLayout 22 <LinearLayout
23 - android:layout_width="match_parent"  
24 - android:layout_height="wrap_content"  
25 - android:orientation="vertical">  
26 -  
27 - <!-- Brightness -->  
28 -  
29 - <LinearLayout  
30 android:layout_width="match_parent" 23 android:layout_width="match_parent"
31 android:layout_height="wrap_content" 24 android:layout_height="wrap_content"
32 - android:layout_marginLeft="5dp"  
33 - android:layout_marginRight="5dp"  
34 android:orientation="vertical"> 25 android:orientation="vertical">
35 26
36 - <TextView 27 + <!-- Brightness -->
  28 +
  29 + <LinearLayout
37 android:layout_width="match_parent" 30 android:layout_width="match_parent"
38 android:layout_height="wrap_content" 31 android:layout_height="wrap_content"
39 - android:padding="5dp"  
40 - android:text="亮度" /> 32 + android:layout_marginLeft="5dp"
  33 + android:layout_marginRight="5dp"
  34 + android:orientation="vertical">
  35 +
  36 + <TextView
  37 + android:layout_width="match_parent"
  38 + android:layout_height="wrap_content"
  39 + android:padding="5dp"
  40 + android:id="@+id/brightnessTv"
  41 + android:text="亮度"/>
41 42
42 <SeekBar 43 <SeekBar
43 - android:id="@+id/sb_brightness"  
44 - android:layout_width="match_parent"  
45 - android:layout_height="wrap_content"  
46 - android:max="100"  
47 - android:padding="5dp"  
48 - android:progress="10" /> 44 + android:id="@+id/sb_brightness"
  45 + android:layout_width="match_parent"
  46 + android:layout_height="wrap_content"
  47 + android:max="100"
  48 + android:padding="5dp"
  49 + android:progress="10"/>
49 </LinearLayout> 50 </LinearLayout>
50 51
51 <View 52 <View
52 - android:layout_width="match_parent"  
53 - android:layout_height="1dp"  
54 - android:layout_marginBottom="10dp"  
55 - android:layout_marginTop="10dp"  
56 - android:background="@color/gray" /> 53 + android:layout_width="match_parent"
  54 + android:layout_height="1dp"
  55 + android:layout_marginBottom="10dp"
  56 + android:layout_marginTop="10dp"
  57 + android:background="@color/gray"/>
57 58
58 59
59 <View 60 <View
60 - android:layout_width="match_parent"  
61 - android:layout_height="1dp"  
62 - android:layout_marginBottom="10dp"  
63 - android:layout_marginTop="10dp"  
64 - android:background="@color/gray" /> 61 + android:layout_width="match_parent"
  62 + android:layout_height="1dp"
  63 + android:layout_marginBottom="10dp"
  64 + android:layout_marginTop="10dp"
  65 + android:background="@color/gray"/>
65 66
66 <!-- Temperature --> 67 <!-- Temperature -->
67 68
68 <LinearLayout 69 <LinearLayout
69 - android:layout_width="match_parent"  
70 - android:layout_height="wrap_content"  
71 - android:layout_marginLeft="5dp"  
72 - android:layout_marginRight="5dp"  
73 - android:orientation="vertical">  
74 -  
75 - <TextView  
76 android:layout_width="match_parent" 70 android:layout_width="match_parent"
77 android:layout_height="wrap_content" 71 android:layout_height="wrap_content"
78 - android:padding="5dp"  
79 - android:text="色温" /> 72 + android:layout_marginLeft="5dp"
  73 + android:layout_marginRight="5dp"
  74 + android:orientation="vertical">
  75 +
  76 + <TextView
  77 + android:layout_width="match_parent"
  78 + android:layout_height="wrap_content"
  79 + android:padding="5dp"
  80 + android:id="@+id/temperatureTv"
  81 + android:text="色温"/>
80 82
81 <SeekBar 83 <SeekBar
82 - android:id="@+id/sb_temperature"  
83 - android:layout_width="match_parent"  
84 - android:layout_height="wrap_content"  
85 - android:max="100"  
86 - android:padding="5dp"  
87 - android:progress="10" /> 84 + android:id="@+id/sb_temperature"
  85 + android:layout_width="match_parent"
  86 + android:layout_height="wrap_content"
  87 + android:max="100"
  88 + android:padding="5dp"
  89 + android:progress="10"/>
88 </LinearLayout> 90 </LinearLayout>
  91 + <TextView android:layout_width="match_parent"
  92 + android:padding="15dp"
  93 + android:textColor="@android:color/holo_red_dark"
  94 + android:layout_marginTop="30dp"
  95 + android:layout_height="wrap_content"
  96 + android:text="调节亮度进度条可设置开灯时的亮度,10以下表示关闭,调节色温进度条可设置恒定色温,设置后返回即可保存"
  97 +
  98 + />
89 99
90 <View 100 <View
91 - android:layout_width="match_parent"  
92 - android:layout_height="1dp"  
93 - android:layout_marginBottom="10dp"  
94 - android:layout_marginTop="10dp"  
95 - android:background="@color/gray" /> 101 + android:layout_width="match_parent"
  102 + android:layout_height="1dp"
  103 + android:layout_marginBottom="10dp"
  104 + android:layout_marginTop="10dp"
  105 + android:background="@color/gray"/>
96 106
97 107
98 <View 108 <View
99 - android:layout_width="match_parent"  
100 - android:layout_height="1dp"  
101 - android:layout_marginBottom="10dp"  
102 - android:layout_marginTop="10dp"  
103 - android:background="@color/gray" /> 109 + android:layout_width="match_parent"
  110 + android:layout_height="1dp"
  111 + android:layout_marginBottom="10dp"
  112 + android:layout_marginTop="10dp"
  113 + android:background="@color/gray"/>
104 114
105 115
106 <View 116 <View
107 - android:layout_width="match_parent"  
108 - android:layout_height="1dp"  
109 - android:layout_marginBottom="10dp"  
110 - android:layout_marginTop="10dp"  
111 - android:background="@color/gray" /> 117 + android:layout_width="match_parent"
  118 + android:layout_height="1dp"
  119 + android:layout_marginBottom="10dp"
  120 + android:layout_marginTop="10dp"
  121 + android:background="@color/gray"/>
112 122
113 123
114 <!-- Remove DeviceSchema --> 124 <!-- Remove DeviceSchema -->
115 125
116 <Button 126 <Button
117 - android:id="@+id/btn_remove"  
118 - android:layout_width="match_parent"  
119 - android:layout_height="46dp"  
120 - android:layout_margin="10dp"  
121 - android:background="@color/theme_positive_color"  
122 - android:text="Remove Device(Kick out)"  
123 - android:textColor="@android:color/white" /> 127 + android:id="@+id/btn_remove"
  128 + android:layout_width="match_parent"
  129 + android:layout_height="46dp"
  130 + android:layout_margin="10dp"
  131 + android:background="@color/theme_positive_color"
  132 + android:text="Remove Device(Kick out)"
  133 + android:textColor="@android:color/white"/>
124 134
125 <Button 135 <Button
126 - android:id="@+id/btn_delete"  
127 - android:layout_width="match_parent"  
128 - android:layout_height="46dp"  
129 - android:layout_margin="10dp"  
130 - android:background="@color/theme_positive_color"  
131 - android:text="Remove Device(Pair Delete)"  
132 - android:textColor="@android:color/white" /> 136 + android:id="@+id/btn_delete"
  137 + android:layout_width="match_parent"
  138 + android:layout_height="46dp"
  139 + android:layout_margin="10dp"
  140 + android:background="@color/theme_positive_color"
  141 + android:text="Remove Device(Pair Delete)"
  142 + android:textColor="@android:color/white"/>
133 143
134 <Button 144 <Button
135 - android:layout_width="match_parent"  
136 - android:layout_height="46dp"  
137 - android:layout_margin="10dp"  
138 - android:background="@color/theme_positive_color"  
139 - android:text="change brightness"  
140 - android:onClick="changeBrightness"  
141 - android:textColor="@android:color/white" /> 145 + android:layout_width="match_parent"
  146 + android:layout_height="46dp"
  147 + android:layout_margin="10dp"
  148 + android:background="@color/theme_positive_color"
  149 + android:text="change brightness"
  150 + android:onClick="changeBrightness"
  151 + android:textColor="@android:color/white"/>
142 <Button 152 <Button
143 - android:layout_width="match_parent"  
144 - android:layout_height="46dp"  
145 - android:layout_margin="10dp"  
146 - android:background="@color/theme_positive_color"  
147 - android:text="change color temperature"  
148 - android:onClick="changeTemperature"  
149 - android:textColor="@android:color/white" /> 153 + android:layout_width="match_parent"
  154 + android:layout_height="46dp"
  155 + android:layout_margin="10dp"
  156 + android:background="@color/theme_positive_color"
  157 + android:text="change color temperature"
  158 + android:onClick="changeTemperature"
  159 + android:textColor="@android:color/white"/>
150 </LinearLayout> 160 </LinearLayout>
151 161
152 </LinearLayout> 162 </LinearLayout>
Please register or login to post a comment