1
0
mirror of https://gitee.com/51danju/workclock.git synced 2025-06-08 03:44:05 +08:00

增加可以使用桌面壁纸,Log库替为timber,

This commit is contained in:
wushunlian 2019-10-16 10:07:14 +08:00
parent dd5505a5ab
commit c306a6772a
56 changed files with 620 additions and 251 deletions

View File

@ -115,6 +115,10 @@ dependencies {
implementation 'com.github.samlss:ClockView:1.0' implementation 'com.github.samlss:ClockView:1.0'
implementation "com.ironsource.aura.oneadapter:oneadapter:1.2.0" implementation "com.ironsource.aura.oneadapter:oneadapter:1.2.0"
// Timber logging
implementation 'com.jakewharton.timber:timber:4.7.1'
} }

View File

@ -3,7 +3,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="clock.socoolby.com.clock"> package="clock.socoolby.com.clock">
<uses-permission android:name="android.permission.VIBRATE" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
@ -15,14 +14,16 @@
android:installLocation="internalOnly" android:installLocation="internalOnly"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"> android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
<activity android:name=".MainActivity" android:screenOrientation="sensorLandscape"> <activity android:name=".MainActivity"
android:theme="@style/Activity.Translucent"
android:screenOrientation="sensorLandscape">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".SettingActivity" android:screenOrientation="sensorLandscape"/>
<activity android:name=".AboutActivity" android:screenOrientation="sensorLandscape"/> <activity android:name=".AboutActivity" android:screenOrientation="sensorLandscape"/>
<receiver android:name=".ActivateAdmin"> <receiver android:name=".ActivateAdmin">
<meta-data android:name="android.app.device_admin" <meta-data android:name="android.app.device_admin"
@ -53,7 +54,21 @@
android:path="/iLGKOXzrWf0i+iNudibv+zAM6mk=" /> android:path="/iLGKOXzrWf0i+iNudibv+zAM6mk=" />
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name=".screen.LockAccessibilityService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:label="@string/app_name"
android:description="@string/accessibility_desc"
>
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</service>
</application> </application>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
@ -64,5 +79,6 @@
<uses-permission android:name="android.permission.REAL_GET_TASKS" <uses-permission android:name="android.permission.REAL_GET_TASKS"
tools:ignore="ProtectedPermissions" /> tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.USES_POLICY_FORCE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
</manifest> </manifest>

View File

@ -1,7 +1,16 @@
package clock.socoolby.com.clock; package clock.socoolby.com.clock;
import android.app.admin.DeviceAdminReceiver; import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import timber.log.Timber;
public class ActivateAdmin extends DeviceAdminReceiver { public class ActivateAdmin extends DeviceAdminReceiver {
@Override
public void onDisabled(Context context, Intent intent) {
super.onDisabled(context, intent);
Timber.d("Disabled lock device admin");
}
} }

View File

@ -2,7 +2,6 @@ package clock.socoolby.com.clock;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import android.util.Log;
import com.blankj.utilcode.constant.PermissionConstants; import com.blankj.utilcode.constant.PermissionConstants;
import com.blankj.utilcode.util.PermissionUtils; import com.blankj.utilcode.util.PermissionUtils;
@ -23,6 +22,7 @@ import clock.socoolby.com.clock.model.SharePerferenceModel;
import e.odbo.DB; import e.odbo.DB;
import e.odbo.data.dao.EntityManager; import e.odbo.data.dao.EntityManager;
import e.odbo.data.sample.security.NoScuritySupportManager; import e.odbo.data.sample.security.NoScuritySupportManager;
import timber.log.Timber;
public class ClockApplication extends Application { public class ClockApplication extends Application {
@ -41,6 +41,11 @@ public class ClockApplication extends Application {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
sEndzoneBoxApp = this; sEndzoneBoxApp = this;
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
} else {
Timber.plant(new CrashReportingTree());
}
Utils.init(this); Utils.init(this);
init(); init();
initEnityManager(); initEnityManager();
@ -51,13 +56,13 @@ public class ClockApplication extends Application {
WorkClockDatabase database=new WorkClockDatabase(); WorkClockDatabase database=new WorkClockDatabase();
try { try {
localDB= SQLite.androidWithSQLDroid(this.getPackageName(),Constants.APP_NAME,null,null); localDB= SQLite.androidWithSQLDroid(this.getPackageName(),Constants.APP_NAME,null,null);
Log.d("e","setup database start...."); timber.log.Timber.d("setup database start....");
localDB.setup(database); localDB.setup(database);
}catch (BasicException e){ }catch (BasicException e){
Log.e("e","setup database false",e); timber.log.Timber.e(e,"setup database false");
} }
localDB.model(database); localDB.model(database);
Log.d("e","start database end...."); timber.log.Timber.d("start database end....");
DBSession dbSession=(DBSession) localDB.getDbSession(); DBSession dbSession=(DBSession) localDB.getDbSession();
entityManager=new EntityManager(dbSession,new TableDBSentenceBuilder(dbSession,new NoScuritySupportManager())); entityManager=new EntityManager(dbSession,new TableDBSentenceBuilder(dbSession,new NoScuritySupportManager()));
entityManager.addDaoToMap(new TimeFontStyleDao(dbSession)); entityManager.addDaoToMap(new TimeFontStyleDao(dbSession));
@ -75,12 +80,12 @@ public class ClockApplication extends Application {
}).callback(new PermissionUtils.SimpleCallback() { }).callback(new PermissionUtils.SimpleCallback() {
@Override @Override
public void onGranted() { public void onGranted() {
Log.d("app","supported permission...."); Timber.d("supported permission....");
} }
@Override @Override
public void onDenied() { public void onDenied() {
Log.d("app","supported permission denied..."); Timber.d("supported permission denied...");
} }
}).request(); }).request();
model = new SharePerferenceModel(); model = new SharePerferenceModel();
@ -114,4 +119,10 @@ public class ClockApplication extends Application {
public EntityManager getEntityManager(){ public EntityManager getEntityManager(){
return entityManager; return entityManager;
} }
private static class CrashReportingTree extends Timber.Tree {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
}
}
} }

View File

@ -14,4 +14,6 @@ public class Constants {
public final static String APP_MEMO="小提示: ←动画 →字体 ↑↓亮度 双指_字体大小 双击_切屏 长按_参数设置"; public final static String APP_MEMO="小提示: ←动画 →字体 ↑↓亮度 双指_字体大小 双击_切屏 长按_参数设置";
public static final Integer ACCESSIBILITY_SERVICE_REQUEST_CODE=101;
} }

View File

@ -4,7 +4,6 @@ package clock.socoolby.com.clock;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
@ -17,7 +16,6 @@ import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -67,6 +65,7 @@ import clock.socoolby.com.clock.model.SharePerferenceModel;
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum; import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum; import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
import clock.socoolby.com.clock.todo.TodoSyncServiceManager; import clock.socoolby.com.clock.todo.TodoSyncServiceManager;
import clock.socoolby.com.clock.utils.DialogUtils;
import clock.socoolby.com.clock.viewmodel.AlterViewModel; import clock.socoolby.com.clock.viewmodel.AlterViewModel;
import clock.socoolby.com.clock.viewmodel.DigitViewModel; import clock.socoolby.com.clock.viewmodel.DigitViewModel;
import clock.socoolby.com.clock.viewmodel.GlobalViewModel; import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
@ -105,8 +104,6 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
private SharePerferenceModel model; private SharePerferenceModel model;
//private PowerManager.WakeLock localWakeLock = null;
public WeatherResponse weatherAdape; public WeatherResponse weatherAdape;
private ClockStateMachine clockStateMachine; private ClockStateMachine clockStateMachine;
@ -136,8 +133,10 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
model = ((ClockApplication) getApplication()).getModel();
themeUIContainer = findViewById(R.id.main_background); themeUIContainer = findViewById(R.id.main_background);
tv_background_image = findViewById(R.id.tv_background_image); tv_background_image = findViewById(R.id.tv_background_image);
@ -146,7 +145,6 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
if (PermissionUtils.isGranted("android.permission.WAKE_LOCK", "android.permission.DEVICE_POWER")) { if (PermissionUtils.isGranted("android.permission.WAKE_LOCK", "android.permission.DEVICE_POWER")) {
PowerManager powerManager = (PowerManager) this.getSystemService(POWER_SERVICE); PowerManager powerManager = (PowerManager) this.getSystemService(POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK | powerManager.ON_AFTER_RELEASE, "Clock"); wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK | powerManager.ON_AFTER_RELEASE, "Clock");
//localWakeLock = powerManager.newWakeLock(32, "MyPower");
} else } else
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@ -160,24 +158,26 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
spiritsManager.initContiner(findViewById(R.id.spirits_container),getSupportFragmentManager(),R.id.fragment_spine_container); spiritsManager.initContiner(findViewById(R.id.spirits_container),getSupportFragmentManager(),R.id.fragment_spine_container);
testSetup(); testSetup();
//SqlScoutServer.create(this, getPackageName());
} }
private boolean isPowerManagerDisable() { private boolean isPowerManagerDisable() {
return wakeLock == null; return wakeLock == null;
} }
private void setUpProximityService() { private void setUpProximityService() {
if (isPowerManagerDisable()) if (isPowerManagerDisable()&&Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
return; return;
try { try {
if (isScreenLock()) { if (isScreenLock()) {
stopService(proximityServiceIntent); stopService(proximityServiceIntent);
} else { } else {
if (model.isTriggerScreen()) { if (model.isTriggerScreen()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(proximityServiceIntent);
}else
startService(proximityServiceIntent); startService(proximityServiceIntent);
} else { } else {
stopService(proximityServiceIntent); stopService(proximityServiceIntent);
@ -202,9 +202,8 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
} }
private void init() { private void init() {
model = ((ClockApplication) getApplication()).getModel();
businessService= ((ClockApplication) getApplication()).getBusinessService(); businessService= ((ClockApplication) getApplication()).getBusinessService();
Log.d(TAG, "start model:" + model.toString()); timber.log.Timber.d("start model:" + model.toString());
proximityServiceIntent = new Intent(this, ProximityService.class); proximityServiceIntent = new Intent(this, ProximityService.class);
@ -222,14 +221,15 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
alterManager = new AlterManager(model.getStartHourPowerTime(), model.getStopHourPowerTime(), globalViewModel, ClockApplication.getInstance().getEntityManager()); alterManager = new AlterManager(model.getStartHourPowerTime(), model.getStopHourPowerTime(), globalViewModel, ClockApplication.getInstance().getEntityManager());
todoSyncServiceManager = new TodoSyncServiceManager(this.getApplicationContext()); todoSyncServiceManager = new TodoSyncServiceManager(this.getApplicationContext());
globalViewModel.setTodoSyncServiceManager(todoSyncServiceManager);
clockStateMachine = new ClockStateMachine(alterManager, globalViewModel, digitViewModel, simulateViewModel, themeUIViewModel, alterViewModel,todoSyncServiceManager); clockStateMachine = new ClockStateMachine(alterManager, globalViewModel, digitViewModel, simulateViewModel, themeUIViewModel, alterViewModel,todoSyncServiceManager);
globalViewModel.setClockStateMachine(clockStateMachine);
setUpProximityService();
bindViewModel();
themeUIManager = new ThemeUIManager(ClockApplication.getInstance().getEntityManager(), model,fontManager); themeUIManager = new ThemeUIManager(ClockApplication.getInstance().getEntityManager(), model,fontManager);
globalViewModel.setThemeUIManager(themeUIManager);
bindViewModel();
spiritsManager=new SpiritsManager(globalViewModel,digitViewModel,simulateViewModel,themeUIViewModel,alterViewModel); spiritsManager=new SpiritsManager(globalViewModel,digitViewModel,simulateViewModel,themeUIViewModel,alterViewModel);
@ -286,16 +286,28 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
private void bindViewModel() { private void bindViewModel() {
globalViewModel.getUseSystemWallpaper().observe(this, new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {
if(aBoolean){
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
}else{
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
}
globalViewModel.checkSystemWallpaperSet();
}
});
globalViewModel.getClockInterfaceTypeEnum().observe(this, new Observer<ClockInterfaceTypeEnum>() { globalViewModel.getClockInterfaceTypeEnum().observe(this, new Observer<ClockInterfaceTypeEnum>() {
@Override @Override
public void onChanged(ClockInterfaceTypeEnum clockInterfaceTypeEnum) { public void onChanged(ClockInterfaceTypeEnum clockInterfaceTypeEnum) {
Log.d(TAG,"comming in clockInterfaceTypeEnum change observe type:"+clockInterfaceTypeEnum.name()); timber.log.Timber.d("comming in clockInterfaceTypeEnum change observe type:"+clockInterfaceTypeEnum.name());
switch (clockInterfaceTypeEnum) { switch (clockInterfaceTypeEnum) {
case Digit: case Digit:
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DigitClockFragment(clockStateMachine)).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DigitClockFragment()).commit();
break; break;
case Simulate: case Simulate:
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SimulateClockFragment(clockStateMachine)).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SimulateClockFragment()).commit();
break; break;
} }
clockStateMachine.setCurrentInterfaceType(clockInterfaceTypeEnum); clockStateMachine.setCurrentInterfaceType(clockInterfaceTypeEnum);
@ -315,7 +327,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
EventManger.addAlterListener(this,event->{ EventManger.addAlterListener(this,event->{
if(event.getValue()) { if(event.getValue()) {
closeAllConfigFragment(); closeAllConfigFragment();
AbstractAlterFragment alterFragment = new AlterTodoDefaultFragment(clockStateMachine,todoSyncServiceManager.getTodayTodoEntities()); AbstractAlterFragment alterFragment = new AlterTodoDefaultFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, alterFragment).addToBackStack(null).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, alterFragment).addToBackStack(null).commit();
}else }else
getSupportFragmentManager().popBackStack(); getSupportFragmentManager().popBackStack();
@ -435,7 +447,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
}); });
EventManger.addHourAnimatorListener(this,event->{ EventManger.addHourAnimatorListener(this,event->{
Log.d(TAG, "on hour animator changed: " + event.getValue()); timber.log.Timber.d("on hour animator changed: " + event.getValue());
if (event.getValue()) if (event.getValue())
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, HourAnimatorFactory.builder(globalViewModel.getHourAlterTypeName().getValue(), globalViewModel.getTime_hour().getValue())).addToBackStack(null).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, HourAnimatorFactory.builder(globalViewModel.getHourAlterTypeName().getValue(), globalViewModel.getTime_hour().getValue())).addToBackStack(null).commit();
else else
@ -443,18 +455,18 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
}); });
EventManger.addLongSleepWakeUpListener(this,event -> { EventManger.addLongSleepWakeUpListener(this,event -> {
Log.d(TAG, "on long sleep wake up: " + event.getValue()); timber.log.Timber.d("on long sleep wake up: " + event.getValue());
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, HourAnimatorFactory.builder(FishAnimator.NAME, event.getValue())).addToBackStack(null).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, HourAnimatorFactory.builder(FishAnimator.NAME, event.getValue())).addToBackStack(null).commit();
}); });
EventManger.addNewDayListener(this,event -> { EventManger.addNewDayListener(this,event -> {
Log.d(TAG, "new day comming: " + event.getValue().getDateString()); timber.log.Timber.d("new day comming: " + event.getValue().getDateString());
businessService.getWeather(model.getCity(), new RequestListener<WeatherResponse>() { businessService.getWeather(model.getCity(), new RequestListener<WeatherResponse>() {
@Override @Override
public void onResponse(WeatherResponse weather) { public void onResponse(WeatherResponse weather) {
if (weather == null) if (weather == null)
return; return;
Log.d(TAG, "set Weather ..."); timber.log.Timber.d("set Weather ...");
weatherAdape = weather; weatherAdape = weather;
if (weather.getTodayWeather() != null) if (weather.getTodayWeather() != null)
themeUIViewModel.getWeatherDescription().setValue(weather.getTodayWeather().weather + "/" + weather.getTodayWeather().temperature); themeUIViewModel.getWeatherDescription().setValue(weather.getTodayWeather().weather + "/" + weather.getTodayWeather().temperature);
@ -463,7 +475,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
@Override @Override
public void onRequestFailed(int error, String errorMessage) { public void onRequestFailed(int error, String errorMessage) {
Log.d(TAG, "get Weather false:"+errorMessage); timber.log.Timber.d("get Weather false:"+errorMessage);
} }
}); });
}); });
@ -477,6 +489,13 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
todoSyncServiceManager.stop(); todoSyncServiceManager.stop();
} }
}); });
globalViewModel.getTriggerScreen().observe(this, new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {
setUpProximityService();
}
});
} }
@ -538,7 +557,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
//Log.d(TAG,"onPause.."); //timber.log.Timber.d("onPause..");
if (!isPowerManagerDisable()) if (!isPowerManagerDisable())
wakeLock.release(); wakeLock.release();
if (backGroundAnimator != null) if (backGroundAnimator != null)
@ -570,7 +589,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
// 如果裁剪并压缩了以取压缩路径为准因为是先裁剪后压缩的 // 如果裁剪并压缩了以取压缩路径为准因为是先裁剪后压缩的
globalViewModel.setBackgroundImageUri(Uri.parse(selectList.get(0).getPath())); globalViewModel.setBackgroundImageUri(Uri.parse(selectList.get(0).getPath()));
globalViewModel.getBackgroundImageVisable().setValue(true); globalViewModel.setBackgroundImageVisable(true);
break; break;
case PictureConfig.TYPE_VIDEO: case PictureConfig.TYPE_VIDEO:
selectList = PictureSelector.obtainMultipleResult(data); selectList = PictureSelector.obtainMultipleResult(data);
@ -622,19 +641,11 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
return true; return true;
} }
if (!isFullScreen()) { if (!isFullScreen()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); DialogUtils.show(this,"温馨提示","确定要退出吗",ok->{
builder.setIcon(android.R.drawable.ic_dialog_info); if(ok){
builder.setTitle("温馨提示");
builder.setMessage("确定要退出吗");
builder.setCancelable(true);
builder.setPositiveButton("确定", (dialog, which) -> {
MainActivity.this.finish(); MainActivity.this.finish();
}
}); });
builder.setNegativeButton("取消", (dialog, which) -> {
dialog.dismiss();
});
builder.create().show();
} }
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
return true; return true;
@ -645,7 +656,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
} }
public void setup() { public void setup() {
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new SystemAppConfigFragment(model)).addToBackStack(null).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new SystemAppConfigFragment()).addToBackStack(null).commit();
} }
@Override @Override
@ -701,10 +712,10 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
return; return;
switch (globalViewModel.getClockInterfaceTypeEnum().getValue()) { switch (globalViewModel.getClockInterfaceTypeEnum().getValue()) {
case Digit: case Digit:
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new DigitClockConfigFragment(themeUIManager)).addToBackStack(null).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new DigitClockConfigFragment()).addToBackStack(null).commit();
break; break;
case Simulate: case Simulate:
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new SimulateClockConfigFragment(themeUIManager)).addToBackStack(null).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new SimulateClockConfigFragment()).addToBackStack(null).commit();
break; break;
} }
} }
@ -750,7 +761,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
if(isScreenLockWithPassword()) if(isScreenLockWithPassword())
return true; return true;
Log.d(TAG, "onFling"); timber.log.Timber.d("onFling");
int brightness = globalViewModel.getBrightness().getValue(); int brightness = globalViewModel.getBrightness().getValue();
@ -758,7 +769,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
calcFilingFlag(); calcFilingFlag();
if (e2.getY() - e1.getY() < -flingHeight) { // 从上至下 if (e2.getY() - e1.getY() < -flingHeight) { // 从上至下
Log.d(TAG, "change brightness +10"); timber.log.Timber.d("change brightness +10");
brightness = brightness + 10; brightness = brightness + 10;
if (brightness >= 255) { if (brightness >= 255) {
Toast.makeText(this, "最大亮度了", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "最大亮度了", Toast.LENGTH_SHORT).show();
@ -767,7 +778,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
globalViewModel.getBrightness().setValue(brightness); globalViewModel.getBrightness().setValue(brightness);
return true; return true;
} else if (e2.getY() - e1.getY() > flingHeight) { // 从下至上 } else if (e2.getY() - e1.getY() > flingHeight) { // 从下至上
Log.d(TAG, "change brightness -10"); timber.log.Timber.d("change brightness -10");
brightness = brightness - 10; brightness = brightness - 10;
if (brightness <= 0) { if (brightness <= 0) {
Toast.makeText(this, "最小亮度了", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "最小亮度了", Toast.LENGTH_SHORT).show();
@ -776,7 +787,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
globalViewModel.getBrightness().setValue(brightness); globalViewModel.getBrightness().setValue(brightness);
return true; return true;
} else if (e2.getX() - e1.getX() > flingWidth) { // 从左向右滑动左进右出 } else if (e2.getX() - e1.getX() > flingWidth) { // 从左向右滑动左进右出
Log.d(TAG, "left->right"); timber.log.Timber.d("left->right");
if (globalViewModel.getClockInterfaceTypeEnum().getValue() == ClockInterfaceTypeEnum.Simulate) { if (globalViewModel.getClockInterfaceTypeEnum().getValue() == ClockInterfaceTypeEnum.Simulate) {
simulateViewModel.setClockTypeName(ClockFactory.nextSimulateClockName(simulateViewModel.getClockTypeName().getValue())); simulateViewModel.setClockTypeName(ClockFactory.nextSimulateClockName(simulateViewModel.getClockTypeName().getValue()));
return true; return true;
@ -818,7 +829,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
public boolean onScaleBegin(ScaleGestureDetector detector) { public boolean onScaleBegin(ScaleGestureDetector detector) {
if(isScreenLockWithPassword()) if(isScreenLockWithPassword())
return false; return false;
Log.d(TAG, "onScaleBegin "); timber.log.Timber.d("onScaleBegin ");
scaleSpan = detector.getCurrentSpan(); scaleSpan = detector.getCurrentSpan();
currentFontSize=digitViewModel.getTimeFontStyleSize().getValue(); currentFontSize=digitViewModel.getTimeFontStyleSize().getValue();
//maxFontSize = fontManager.getMaxFontSize(model.isDisplaySecond()); //maxFontSize = fontManager.getMaxFontSize(model.isDisplaySecond());
@ -833,7 +844,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
currentFontSize = currentFontSize + step; currentFontSize = currentFontSize + step;
Log.d(TAG, "onScaleEnd span:" + span + "\t step:" + step + "\tcurrent text size" + currentFontSize); timber.log.Timber.d("onScaleEnd span:" + span + "\t step:" + step + "\tcurrent text size" + currentFontSize);
digitViewModel.setTimeFontStyleSize(currentFontSize); digitViewModel.setTimeFontStyleSize(currentFontSize);
@ -901,7 +912,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
display.getSize(outSize); display.getSize(outSize);
flingWidth=outSize.x/3; flingWidth=outSize.x/3;
flingHeight =outSize.y/3; flingHeight =outSize.y/3;
//Log.d(TAG,"calc filing flag flingWidth:"+flingWidth+"\tflingHeight"+flingHeight); //timber.log.Timber.d("calc filing flag flingWidth:"+flingWidth+"\tflingHeight"+flingHeight);
} }
@Override @Override

View File

@ -34,6 +34,7 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
private SharePerferenceModel model; private SharePerferenceModel model;
CheckBox triggerSystemWallpaper;
@Override @Override
@ -69,6 +70,16 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
} }
}); });
/*triggerSystemWallpaper = (CheckBox) findViewById(R.id.cb_trigger_system_wallpaper);
cb_trigger_screen.setChecked(model.isTriggerScreen());
cb_trigger_screen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
model.setTriggerScreen(isChecked);
}
});*/
Button btn_uninstall = (Button) findViewById(R.id.btn_uninstall); Button btn_uninstall = (Button) findViewById(R.id.btn_uninstall);
btn_uninstall.setOnClickListener(this); btn_uninstall.setOnClickListener(this);
Button btn_about = (Button) findViewById(R.id.btn_about); Button btn_about = (Button) findViewById(R.id.btn_about);

View File

@ -130,7 +130,7 @@ public class SpiritsManager implements DragFrameLayout.OnDragDropListener {
demo.setOnClickListener(new View.OnClickListener() { demo.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Log.d(TAG,"demo Button clicked"); timber.log.Timber.d("demo Button clicked");
} }
}); });
layout.addDragChildView(demo,10,20);*/ layout.addDragChildView(demo,10,20);*/
@ -143,16 +143,16 @@ public class SpiritsManager implements DragFrameLayout.OnDragDropListener {
@Override @Override
public void onDragStart(View view) { public void onDragStart(View view) {
Log.d(TAG,"onDragStart view:"+view.getId()); timber.log.Timber.d("onDragStart view:"+view.getId());
} }
@Override @Override
public void ontDraging(View view) { public void ontDraging(View view) {
Log.d(TAG,"onDraging view:"+view.getId()); timber.log.Timber.d("onDraging view:"+view.getId());
} }
@Override @Override
public void onDragEnd(View view,int left,int top) { public void onDragEnd(View view,int left,int top) {
Log.d(TAG,"onDragEnd view is demo:"+(view==demo)+"\t left padding:"+left+"\t top padding:"+top); timber.log.Timber.d("onDragEnd view is demo:"+(view==demo)+"\t left padding:"+left+"\t top padding:"+top);
} }
} }

View File

@ -145,7 +145,7 @@ public class ThemeUIManager{
} }
public void saveTempThemeUI(int type){ public void saveTempThemeUI(int type){
Log.d(TAG,"save temp ThemeUI type:"+type); timber.log.Timber.d("save temp ThemeUI type:"+type);
if(type==ClockInterfaceTypeEnum.Digit.code) if(type==ClockInterfaceTypeEnum.Digit.code)
this.tempThemeStr=makeSaveDigitThemeString(model.getDigitPerferenceModel()); this.tempThemeStr=makeSaveDigitThemeString(model.getDigitPerferenceModel());
else else
@ -153,7 +153,7 @@ public class ThemeUIManager{
} }
public void recoverTempThemeUI(int type)throws BasicException{ public void recoverTempThemeUI(int type)throws BasicException{
Log.d(TAG,"recover temp ThemeUI type"+type); timber.log.Timber.d("recover temp ThemeUI type"+type);
if(tempThemeStr==null) if(tempThemeStr==null)
return; return;
if(type==ClockInterfaceTypeEnum.Digit.code) { if(type==ClockInterfaceTypeEnum.Digit.code) {

View File

@ -61,7 +61,7 @@ public class EventManger {
public static void removeClockEventListener(EventListenerHandle handle){ public static void removeClockEventListener(EventListenerHandle handle){
if(liveEventBus==null) if(liveEventBus==null)
init(); init();
Log.d(TAG, "removeClockEventListener: "+handle.getEventType()); timber.log.Timber.d("removeClockEventListener: "+handle.getEventType());
liveEventBus.with(handle.getEventType(),handle.getValueClass()).removeObserver(handle.getHandle()); liveEventBus.with(handle.getEventType(),handle.getValueClass()).removeObserver(handle.getHandle());
} }

View File

@ -26,8 +26,7 @@ public abstract class AbstractAlterFragment extends Fragment {
int view_id; int view_id;
public AbstractAlterFragment(ClockStateMachine clockStateMachine, int view_id) { public AbstractAlterFragment( int view_id) {
this.clockStateMachine=clockStateMachine;
this.view_id=view_id; this.view_id=view_id;
} }
@ -36,6 +35,7 @@ public abstract class AbstractAlterFragment extends Fragment {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
globalViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); globalViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(AlterViewModel.class); alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(AlterViewModel.class);
clockStateMachine=globalViewModel.getClockStateMachine();
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package clock.socoolby.com.clock.fragment.alter; package clock.socoolby.com.clock.fragment.alter;
import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
@ -44,10 +45,14 @@ public class AlterTodoDefaultFragment extends AbstractAlterFragment {
TodoEntity currentTodoEntity; TodoEntity currentTodoEntity;
private OneAdapter todoAdapter; private OneAdapter todoAdapter;
public AlterTodoDefaultFragment() {
super(R.layout.fragment_alter_todo);
}
public AlterTodoDefaultFragment(ClockStateMachine clockStateMachine, List<TodoEntity> todayTodoList) { @Override
super(clockStateMachine, R.layout.fragment_alter_todo); public void onCreate(Bundle savedInstanceState) {
this.todayTodoList=todayTodoList; super.onCreate(savedInstanceState);
todayTodoList=globalViewModel.getTodoSyncServiceManager().getTodayTodoEntities();
currentTodoEntity=clockStateMachine.getCurrentTodoEntity(); currentTodoEntity=clockStateMachine.getCurrentTodoEntity();
} }

View File

@ -140,8 +140,8 @@ public class DigitClockConfigFragment extends Fragment {
@BindView(R.id.tv_time_text_basline_x) @BindView(R.id.tv_time_text_basline_x)
VerticalRangeSeekBar tvTimeTextBaslineX; VerticalRangeSeekBar tvTimeTextBaslineX;
public DigitClockConfigFragment(ThemeUIManager themeUIManager) { public DigitClockConfigFragment(){
this.themeUIManager = themeUIManager;
} }
@Override @Override
@ -150,6 +150,7 @@ public class DigitClockConfigFragment extends Fragment {
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class); digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class);
themeUIViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(ThemeUIViewModel.class); themeUIViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(ThemeUIViewModel.class);
themeUIManager=globalViewModel.getThemeUIManager();
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Digit.code); themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Digit.code);
globalViewModel.setAppConfig(true); globalViewModel.setAppConfig(true);
} }

View File

@ -34,8 +34,8 @@ public class DigitClockFragment extends Fragment {
public static final String TAG=DigitClockFragment.class.getName(); public static final String TAG=DigitClockFragment.class.getName();
public ClockStateMachine clockStateMachine; public ClockStateMachine clockStateMachine;
public DigitClockFragment(ClockStateMachine clockStateMachine) { public DigitClockFragment(){
this.clockStateMachine=clockStateMachine;
} }
DigitViewModel digitViewModel; DigitViewModel digitViewModel;
@ -50,6 +50,7 @@ public class DigitClockFragment extends Fragment {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
digitViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class); digitViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class);
globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
clockStateMachine=globalViewModel.getClockStateMachine();
} }
@Override @Override

View File

@ -26,8 +26,7 @@ public abstract class AbstractHandUpFragment extends Fragment {
int view_id; int view_id;
public AbstractHandUpFragment(ClockStateMachine clockStateMachine, int view_id) { public AbstractHandUpFragment(int view_id) {
this.clockStateMachine=clockStateMachine;
this.view_id=view_id; this.view_id=view_id;
} }
@ -36,6 +35,7 @@ public abstract class AbstractHandUpFragment extends Fragment {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
globalViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); globalViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(AlterViewModel.class); alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(AlterViewModel.class);
clockStateMachine=globalViewModel.getClockStateMachine();
} }
@Override @Override

View File

@ -5,8 +5,8 @@ import clock.socoolby.com.clock.state.ClockStateMachine;
public abstract class AbstractHandUpSelectFragment extends AbstractHandUpFragment { public abstract class AbstractHandUpSelectFragment extends AbstractHandUpFragment {
public AbstractHandUpSelectFragment(ClockStateMachine clockStateMachine, int view_id) { public AbstractHandUpSelectFragment( int view_id) {
super(clockStateMachine, view_id); super( view_id);
} }
protected void selected(){ protected void selected(){

View File

@ -26,8 +26,8 @@ public class HandUpDefaultFragment extends AbstractHandUpFragment {
private int handUPDialy=0; private int handUPDialy=0;
public HandUpDefaultFragment(ClockStateMachine clockStateMachine) { public HandUpDefaultFragment() {
super(clockStateMachine,R.layout.fragment_handup); super(R.layout.fragment_handup);
} }
@Override @Override

View File

@ -7,9 +7,9 @@ public final class HandUpFragmentFactory {
public static AbstractHandUpFragment build(String name, ClockStateMachine clockStateMachine){ public static AbstractHandUpFragment build(String name, ClockStateMachine clockStateMachine){
switch (name){ switch (name){
case HandUpSelect123Fragment.NAME: case HandUpSelect123Fragment.NAME:
return new HandUpSelect123Fragment(clockStateMachine); return new HandUpSelect123Fragment();
} }
return new HandUpDefaultFragment(clockStateMachine); return new HandUpDefaultFragment();
} }
} }

View File

@ -30,8 +30,8 @@ public class HandUpSelect123Fragment extends AbstractHandUpSelectFragment implem
EventListenerHandle heartBeatListenerHandle; EventListenerHandle heartBeatListenerHandle;
public HandUpSelect123Fragment(ClockStateMachine clockStateMachine) { public HandUpSelect123Fragment() {
super(clockStateMachine, R.layout.fragment_handup_select_123); super( R.layout.fragment_handup_select_123);
} }
@Override @Override
@ -42,7 +42,6 @@ public class HandUpSelect123Fragment extends AbstractHandUpSelectFragment implem
selectButton2.setOnClickListener(this); selectButton2.setOnClickListener(this);
selectButton3=rootView.findViewById(R.id.tv_select_button3); selectButton3=rootView.findViewById(R.id.tv_select_button3);
selectButton3.setOnClickListener(this); selectButton3.setOnClickListener(this);
} }
@ -66,7 +65,7 @@ public class HandUpSelect123Fragment extends AbstractHandUpSelectFragment implem
heartBeatListenerHandle=EventManger.addHeartbeatListener(new ClockEventListener<Boolean>() { heartBeatListenerHandle=EventManger.addHeartbeatListener(new ClockEventListener<Boolean>() {
@Override @Override
public void onEvent(ClockEvent<Boolean> event) { public void onEvent(ClockEvent<Boolean> event) {
Log.d(TAG, "onEvent: "+event.getEventType()+"\troundLoop:"+roundLoop); timber.log.Timber.d("onEvent: "+event.getEventType()+"\troundLoop:"+roundLoop);
if(roundLoop==0) { if(roundLoop==0) {
setButtonColor(rundomButton); setButtonColor(rundomButton);
EventManger.removeClockEventListener(heartBeatListenerHandle); EventManger.removeClockEventListener(heartBeatListenerHandle);

View File

@ -25,6 +25,11 @@ public class HourVideoFragment extends AbstractVideoFragment {
protected GlobalViewModel globalViewModel; protected GlobalViewModel globalViewModel;
public HourVideoFragment(){
super();
this.hour=0;
}
public HourVideoFragment(int hour) { public HourVideoFragment(int hour) {
super(); super();
this.hour=hour; this.hour=hour;

View File

@ -106,8 +106,8 @@ public class SimulateClockConfigFragment extends Fragment {
private ColorPickerPop colorPickerDialog; private ColorPickerPop colorPickerDialog;
public SimulateClockConfigFragment(ThemeUIManager themeUIManager) { public SimulateClockConfigFragment(){
this.themeUIManager = themeUIManager;
} }
@Override @Override
@ -116,6 +116,7 @@ public class SimulateClockConfigFragment extends Fragment {
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class); simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class);
themeUIViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(ThemeUIViewModel.class); themeUIViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(ThemeUIViewModel.class);
themeUIManager=globalViewModel.getThemeUIManager();
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Simulate.code); themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Simulate.code);
globalViewModel.setAppConfig(true); globalViewModel.setAppConfig(true);
} }

View File

@ -40,8 +40,7 @@ public class SimulateClockFragment extends Fragment {
ClockStateMachine clockStateMachine; ClockStateMachine clockStateMachine;
public SimulateClockFragment(ClockStateMachine clockStateMachine) { public SimulateClockFragment(){
this.clockStateMachine=clockStateMachine;
} }
@Override @Override
@ -50,6 +49,7 @@ public class SimulateClockFragment extends Fragment {
clockAnimator = new ClockAnimator(); clockAnimator = new ClockAnimator();
simulateViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class); simulateViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class);
globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
clockStateMachine=globalViewModel.getClockStateMachine();
} }
@Override @Override

View File

@ -50,7 +50,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
public void preDestory(){ public void preDestory(){
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "preDestory"); timber.log.Timber.d("preDestory");
if (!m_hasBuilt) if (!m_hasBuilt)
return; return;
@ -73,7 +73,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "onCreateView"); timber.log.Timber.d("onCreateView");
m_viewRooter = (ViewGroup) inflater.inflate(R.layout.fragment_spine, container,false); m_viewRooter = (ViewGroup) inflater.inflate(R.layout.fragment_spine, container,false);
return m_viewRooter; return m_viewRooter;
@ -83,7 +83,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "onViewCreated"); timber.log.Timber.d("onViewCreated");
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
buildGDX(); buildGDX();
@ -91,7 +91,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
public void buildGDX(){ public void buildGDX(){
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "buildGDX"); timber.log.Timber.d("buildGDX");
spineEffectView = SpineFactory.build(spineType); spineEffectView = SpineFactory.build(spineType);
m_viewRooter.addView(CreateGLAlpha(spineEffectView)); m_viewRooter.addView(CreateGLAlpha(spineEffectView));
@ -108,7 +108,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
public void onStart() { public void onStart() {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "onStart"); timber.log.Timber.d("onStart");
m_isStoping = false; m_isStoping = false;
super.onStart(); super.onStart();
@ -121,7 +121,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
public void onStop() { public void onStop() {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "onStop"); timber.log.Timber.d("onStop");
m_isStoping = true; m_isStoping = true;
spineEffectView.setCanDraw(false); spineEffectView.setCanDraw(false);
@ -132,7 +132,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
public void onResume() { public void onResume() {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "onResume"); timber.log.Timber.d("onResume");
super.onResume(); super.onResume();
@ -148,7 +148,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
public void onPause() { public void onPause() {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "onPause"); timber.log.Timber.d("onPause");
if (spineEffectView != null) { if (spineEffectView != null) {
spineEffectView.forceOver(); spineEffectView.forceOver();
@ -165,7 +165,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
@Override @Override
public void onConfigurationChanged(Configuration config) { public void onConfigurationChanged(Configuration config) {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "onConfigurationChanged"); timber.log.Timber.d("onConfigurationChanged");
super.onConfigurationChanged(config); super.onConfigurationChanged(config);
m_viewRooter.removeAllViews(); m_viewRooter.removeAllViews();
buildGDX(); buildGDX();
@ -175,7 +175,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
private View CreateGLAlpha(ApplicationListener application) { private View CreateGLAlpha(ApplicationListener application) {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "CreateGLAlpha"); timber.log.Timber.d("CreateGLAlpha");
// GLSurfaceView透明相关 // GLSurfaceView透明相关
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
@ -219,7 +219,7 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
public boolean keyDown(int i) { public boolean keyDown(int i) {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "keyDown"); timber.log.Timber.d("keyDown");
return false; return false;
} }
@ -238,19 +238,19 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
@Override @Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) { public boolean touchDown(int screenX, int screenY, int pointer, int button) {
Log.d(TAG, "touchDown screenX:"+screenX+"\t screenY:"+screenY+"\tpointer:"+pointer+"\tbutton:"+button); timber.log.Timber.d("touchDown screenX:"+screenX+"\t screenY:"+screenY+"\tpointer:"+pointer+"\tbutton:"+button);
if(spineEffectView.isContainsPoint(screenX,screenY)) { if(spineEffectView.isContainsPoint(screenX,screenY)) {
setInterruptTouch(true); setInterruptTouch(true);
touchSpine = spineEffectView; touchSpine = spineEffectView;
Log.d(TAG,"find spine in touch down"); timber.log.Timber.d("find spine in touch down");
} }
return false; return false;
} }
@Override @Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) { public boolean touchUp(int screenX, int screenY, int pointer, int button) {
Log.d(TAG, "touchUp screenX:"+screenX+"\t screenY:"+screenY+"\tpointer:"+pointer+"\tbutton:"+button); timber.log.Timber.d("touchUp screenX:"+screenX+"\t screenY:"+screenY+"\tpointer:"+pointer+"\tbutton:"+button);
if(touchSpine!=null) { if(touchSpine!=null) {
touchSpine.setAction(ActionEnum.IDLE); touchSpine.setAction(ActionEnum.IDLE);
setInterruptTouch(false); setInterruptTouch(false);
@ -261,24 +261,24 @@ public class LibgdxSpineFragment extends AndroidFragmentApplication implements I
@Override @Override
public boolean touchDragged(int screenX, int screenY, int pointer) { public boolean touchDragged(int screenX, int screenY, int pointer) {
Log.d(TAG, "touchDragged x:"+screenX+"\t y:"+screenY+"\ti2:"+pointer); timber.log.Timber.d("touchDragged x:"+screenX+"\t y:"+screenY+"\ti2:"+pointer);
if(touchSpine!=null) { if(touchSpine!=null) {
touchSpine.setPosition(screenX,screenY); touchSpine.setPosition(screenX,screenY);
touchSpine.setAction(ActionEnum.RUN); touchSpine.setAction(ActionEnum.RUN);
//Log.d(TAG, "touchDragged spine"); //timber.log.Timber.d("touchDragged spine");
} }
return false; return false;
} }
@Override @Override
public boolean mouseMoved(int x, int y) { public boolean mouseMoved(int x, int y) {
Log.d(TAG, "mouseMoved x:"+x+"\t y:"+y); timber.log.Timber.d("mouseMoved x:"+x+"\t y:"+y);
return false; return false;
} }
@Override @Override
public boolean scrolled(int amount) { public boolean scrolled(int amount) {
Log.d(TAG, "mouseMoved amount:"+amount); timber.log.Timber.d("mouseMoved amount:"+amount);
return false; return false;
} }
} }

View File

@ -2,12 +2,16 @@ package clock.socoolby.com.clock.fragment.system;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
@ -26,11 +30,16 @@ import clock.socoolby.com.clock.AboutActivity;
import clock.socoolby.com.clock.ActivateAdmin; import clock.socoolby.com.clock.ActivateAdmin;
import clock.socoolby.com.clock.ClockApplication; import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.Constants; import clock.socoolby.com.clock.Constants;
import clock.socoolby.com.clock.MainActivity;
import clock.socoolby.com.clock.R; import clock.socoolby.com.clock.R;
import clock.socoolby.com.clock.fragment.houranimator.HourAnimatorFactory; import clock.socoolby.com.clock.fragment.houranimator.HourAnimatorFactory;
import clock.socoolby.com.clock.fragment.houranimator.HourVideoFragment; import clock.socoolby.com.clock.fragment.houranimator.HourVideoFragment;
import clock.socoolby.com.clock.model.DateModel; import clock.socoolby.com.clock.model.DateModel;
import clock.socoolby.com.clock.model.SharePerferenceModel; import clock.socoolby.com.clock.model.SharePerferenceModel;
import clock.socoolby.com.clock.net.auth.AuthCallback;
import clock.socoolby.com.clock.todo.TodoSyncServiceManager;
import clock.socoolby.com.clock.todo.microsoft.MicrosoftTodoSyncServiceImpl;
import clock.socoolby.com.clock.utils.DialogUtils;
import clock.socoolby.com.clock.utils.FuncUnit; import clock.socoolby.com.clock.utils.FuncUnit;
import clock.socoolby.com.clock.viewmodel.AlterViewModel; import clock.socoolby.com.clock.viewmodel.AlterViewModel;
import clock.socoolby.com.clock.viewmodel.GlobalViewModel; import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
@ -80,10 +89,12 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
CheckBox cb_todo_sync_able; CheckBox cb_todo_sync_able;
CheckBox cb_trigger_system_wallpaper;
private SharePerferenceModel model; private SharePerferenceModel model;
public SystemAppConfigFragment(SharePerferenceModel model) { public SystemAppConfigFragment() {
this.model = model;
} }
@Override @Override
@ -92,6 +103,7 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
this.globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); this.globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(AlterViewModel.class); alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(AlterViewModel.class);
globalViewModel.setAppConfig(true); globalViewModel.setAppConfig(true);
model=ClockApplication.getInstance().getModel();
} }
@ -116,7 +128,6 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
rg_clock_hour_video=themeRootView.findViewById(R.id.rg_clock_hour_video); rg_clock_hour_video=themeRootView.findViewById(R.id.rg_clock_hour_video);
btn_clock_hour_video=themeRootView.findViewById(R.id.btn_clock_hour_video); btn_clock_hour_video=themeRootView.findViewById(R.id.btn_clock_hour_video);
cb_boot_start=themeRootView.findViewById(R.id.cb_boot_start); cb_boot_start=themeRootView.findViewById(R.id.cb_boot_start);
cb_tick = themeRootView.findViewById(R.id.cb_tick); cb_tick = themeRootView.findViewById(R.id.cb_tick);
@ -131,6 +142,8 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
cb_fullscreen_spirit=themeRootView.findViewById(R.id.cb_fullscreen_spirit); cb_fullscreen_spirit=themeRootView.findViewById(R.id.cb_fullscreen_spirit);
cb_todo_sync_able=themeRootView.findViewById(R.id.cb_todo_alter_able); cb_todo_sync_able=themeRootView.findViewById(R.id.cb_todo_alter_able);
cb_trigger_system_wallpaper=themeRootView.findViewById(R.id.cb_trigger_system_wallpaper);
loadDataFromModel(); loadDataFromModel();
btn_about.setOnClickListener(this); btn_about.setOnClickListener(this);
@ -140,6 +153,20 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
cb_trigger_screen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cb_trigger_screen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AccessibilityManager manager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (!manager.isEnabled()) {
DialogUtils.show(getContext(),"提醒","当前功能须要开启补助功能,是不前往。", ok->{
if(ok){
getActivity().startActivityForResult(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS), Constants.ACCESSIBILITY_SERVICE_REQUEST_CODE);
}
});
cb_trigger_screen.setChecked(false);
return;
}
}
}
model.setTriggerScreen(isChecked); model.setTriggerScreen(isChecked);
} }
}); });
@ -218,10 +245,37 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
} }
}); });
cb_trigger_system_wallpaper.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
model.setUseSystemWallpaper(isChecked);
}
});
cb_todo_sync_able.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cb_todo_sync_able.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
globalViewModel.setTodoSyncAble(isChecked); if(isChecked){
TodoSyncServiceManager todoSyncServiceManager=globalViewModel.getTodoSyncServiceManager();
todoSyncServiceManager.start();
todoSyncServiceManager.singIn(MicrosoftTodoSyncServiceImpl.NAME, getActivity(), new AuthCallback() {
@Override
public void onSuccess() {
globalViewModel.setTodoSyncAble(true);
}
@Override
public void onError(Exception exception) {
cb_todo_sync_able.setChecked(false);
}
@Override
public void onCancel() {
cb_todo_sync_able.setChecked(false);
}
});
}else
globalViewModel.setTodoSyncAble(false);
} }
}); });
@ -289,6 +343,8 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
cb_fullscreen_spirit.setChecked(model.isFullscreenSpiritAble()); cb_fullscreen_spirit.setChecked(model.isFullscreenSpiritAble());
cb_todo_sync_able.setChecked(model.isTodoSyncAble()); cb_todo_sync_able.setChecked(model.isTodoSyncAble());
cb_trigger_system_wallpaper.setChecked(model.isUseSystemWallpaper());
} }
private void saveToModel() { private void saveToModel() {

View File

@ -33,6 +33,7 @@ import clock.socoolby.com.clock.pop.WeatherPopup;
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum; import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum; import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
import clock.socoolby.com.clock.state.ClockTimeTypeEnum; import clock.socoolby.com.clock.state.ClockTimeTypeEnum;
import clock.socoolby.com.clock.utils.DialogUtils;
import clock.socoolby.com.clock.viewmodel.AlterViewModel; import clock.socoolby.com.clock.viewmodel.AlterViewModel;
import clock.socoolby.com.clock.viewmodel.DigitViewModel; import clock.socoolby.com.clock.viewmodel.DigitViewModel;
import clock.socoolby.com.clock.viewmodel.GlobalViewModel; import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
@ -40,6 +41,7 @@ import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel; import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel;
import clock.socoolby.com.clock.viewmodel.ViewModelFactory; import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
import clock.socoolby.com.clock.widget.textview.AutoScrollTextView; import clock.socoolby.com.clock.widget.textview.AutoScrollTextView;
import timber.log.Timber;
public abstract class AbstractThemeUIFragment extends Fragment implements View.OnClickListener { public abstract class AbstractThemeUIFragment extends Fragment implements View.OnClickListener {
@ -118,6 +120,17 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
tv_background_image_hand.setOnLongClickListener(new View.OnLongClickListener() { tv_background_image_hand.setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
if(model.isUseSystemWallpaper()){
DialogUtils.show(getActivity(), getString(R.string.system_wallpaper), getString(R.string.logut_system_wallpaper_mode), new DialogUtils.OkCancelSelectedLinstener() {
@Override
public void onReturn(boolean ok) {
if(ok) {
globalViewModel.setUseSystemWallpaper(false);
mainActivity.configBackGroundImage();
}
}
});
}else
mainActivity.configBackGroundImage(); mainActivity.configBackGroundImage();
return true; return true;
} }
@ -283,7 +296,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
timer.cancel(); timer.cancel();
} }
running=true; running=true;
Log.d("themeUiManager","autoFullScreen task created ..."); Timber.d("autoFullScreen task created ...");
timer.schedule(new TimerTask() { timer.schedule(new TimerTask() {
public void run() { public void run() {
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.FULLSCREEN); themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.FULLSCREEN);
@ -433,7 +446,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
hour=saveHandUpTime/60; hour=saveHandUpTime/60;
minute=saveHandUpTime-hour*60; minute=saveHandUpTime-hour*60;
} }
Log.d(TAG, "switch HandUpTime:" + saveHandUpTime+"\thour:"+hour+"\tminute:"+minute); timber.log.Timber.d("switch HandUpTime:" + saveHandUpTime+"\thour:"+hour+"\tminute:"+minute);
handUpTimePopup1.init(hour,minute,globalViewModel.getHandUpTypeName().getValue(),alterViewModel.getHandUpMusic().getValue(),alterViewModel.getHandUpMusicName().getValue()); handUpTimePopup1.init(hour,minute,globalViewModel.getHandUpTypeName().getValue(),alterViewModel.getHandUpMusic().getValue(),alterViewModel.getHandUpMusicName().getValue());
handUpTimePopup1.showNow(getFragmentManager(),null); handUpTimePopup1.showNow(getFragmentManager(),null);
} }
@ -570,6 +583,16 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
setDiscript(FamousQuotesManager.roundAutoQuotes()); setDiscript(FamousQuotesManager.roundAutoQuotes());
break; break;
case R.id.tv_background_color: case R.id.tv_background_color:
if(model.isUseSystemWallpaper()){
DialogUtils.show(getActivity(), getString(R.string.system_wallpaper), getString(R.string.logut_system_wallpaper_mode), new DialogUtils.OkCancelSelectedLinstener() {
@Override
public void onReturn(boolean ok) {
if(ok) {
globalViewModel.setUseSystemWallpaper(false);
}
}
});
}else {
if (colorPickerDialog == null) if (colorPickerDialog == null)
colorPickerDialog = new ColorPickerPop(mainActivity); colorPickerDialog = new ColorPickerPop(mainActivity);
@ -584,12 +607,28 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
} }
}); });
colorPickerDialog.show(model.getBackgroundColor()); colorPickerDialog.show(model.getBackgroundColor());
}
break; break;
case R.id.tv_background_image_hand: case R.id.tv_background_image_hand:
if(model.isUseSystemWallpaper()){
DialogUtils.show(getActivity(), getString(R.string.system_wallpaper), getString(R.string.logut_system_wallpaper_mode), new DialogUtils.OkCancelSelectedLinstener() {
@Override
public void onReturn(boolean ok) {
if(ok) {
globalViewModel.setUseSystemWallpaper(false);
if (globalViewModel.getBackgroundImageUri().getValue() == null)
mainActivity.configBackGroundImage();
else
globalViewModel.setBackgroundImageVisable(true);
}
}
});
}else {
if (globalViewModel.getBackgroundImageUri().getValue() == null) if (globalViewModel.getBackgroundImageUri().getValue() == null)
mainActivity.configBackGroundImage(); mainActivity.configBackGroundImage();
else else
globalViewModel.setBackgroundImageVisable(!globalViewModel.getBackgroundImageVisable().getValue()); globalViewModel.setBackgroundImageVisable(!globalViewModel.getBackgroundImageVisable().getValue());
}
break; break;
case R.id.tv_foreground_color: case R.id.tv_foreground_color:
globalViewModel.setForegroundColor(model.getForegroundColor1()); globalViewModel.setForegroundColor(model.getForegroundColor1());
@ -638,7 +677,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
private void switchMode(ClockThemeUITypeEnum mode) { private void switchMode(ClockThemeUITypeEnum mode) {
Log.d(TAG, "switch mode to:" + mode); timber.log.Timber.d("switch mode to:" + mode);
switch (mode) { switch (mode) {
case FULLSCREEN: case FULLSCREEN:
tv_date.setVisibility(View.GONE); tv_date.setVisibility(View.GONE);

View File

@ -13,8 +13,6 @@ import clock.socoolby.com.clock.Constants;
public class SharePerferenceModel extends AbstractPerferenceModel { public class SharePerferenceModel extends AbstractPerferenceModel {
private boolean dirty=false;
public static final int DEFAULT_COLOR=Color.rgb(255, 255, 255); public static final int DEFAULT_COLOR=Color.rgb(255, 255, 255);
protected boolean firstStart = true; protected boolean firstStart = true;
@ -34,7 +32,7 @@ public class SharePerferenceModel extends AbstractPerferenceModel {
protected boolean tickSound = false; protected boolean tickSound = false;
protected final static String KEY_IS_TICK_SOUND = "key_is_tick_sound"; protected final static String KEY_IS_TICK_SOUND = "key_is_tick_sound";
protected boolean triggerScreen = true; protected boolean triggerScreen = false;
protected final static String KEY_IS_TRIGGER_SCREEN = "key_is_trigger_screen"; protected final static String KEY_IS_TRIGGER_SCREEN = "key_is_trigger_screen";
protected boolean hourSystem12 = false; protected boolean hourSystem12 = false;
@ -96,6 +94,10 @@ public class SharePerferenceModel extends AbstractPerferenceModel {
protected boolean backgroundImageVisable=false; protected boolean backgroundImageVisable=false;
protected final static String KEY_USE_SYSTEM_WALLPAPER="key_use_system_wallpaper";
protected boolean useSystemWallpaper=false;
protected final static String KEY_FOREGROUND_COLOR="key_foreground_color"; protected final static String KEY_FOREGROUND_COLOR="key_foreground_color";
protected Integer foregroundColor=DEFAULT_COLOR; protected Integer foregroundColor=DEFAULT_COLOR;
@ -246,7 +248,7 @@ public class SharePerferenceModel extends AbstractPerferenceModel {
screenLockPassword=jsonObject.optInt(KEY_SCREEN_LOCK_PASSWORD,0); screenLockPassword=jsonObject.optInt(KEY_SCREEN_LOCK_PASSWORD,0);
tickSound = jsonObject.getBoolean(KEY_IS_TICK_SOUND); tickSound = jsonObject.getBoolean(KEY_IS_TICK_SOUND);
triggerScreen =jsonObject.optBoolean(KEY_IS_TRIGGER_SCREEN,true); triggerScreen =jsonObject.optBoolean(KEY_IS_TRIGGER_SCREEN,false);
mCity = jsonObject.optString(KEY_CITY,"jinhua"); mCity = jsonObject.optString(KEY_CITY,"jinhua");
mDescription = jsonObject.optString(KEY_DESCRPTION, ""); mDescription = jsonObject.optString(KEY_DESCRPTION, "");
startHourPowerTime = new DateModel(); startHourPowerTime = new DateModel();
@ -291,6 +293,8 @@ public class SharePerferenceModel extends AbstractPerferenceModel {
todoSyncAble=jsonObject.optBoolean(KEY_SYS_TODO_SYNC_ABLE,false); todoSyncAble=jsonObject.optBoolean(KEY_SYS_TODO_SYNC_ABLE,false);
useSystemWallpaper=jsonObject.optBoolean(KEY_USE_SYSTEM_WALLPAPER,false);
themeUILoad(jsonObject); themeUILoad(jsonObject);
} }
@ -344,6 +348,8 @@ public class SharePerferenceModel extends AbstractPerferenceModel {
jsonObject.put(KEY_SYS_TODO_SYNC_ABLE,todoSyncAble); jsonObject.put(KEY_SYS_TODO_SYNC_ABLE,todoSyncAble);
jsonObject.put(KEY_USE_SYSTEM_WALLPAPER,useSystemWallpaper);
themeUISave(jsonObject); themeUISave(jsonObject);
} }
@ -491,6 +497,15 @@ public class SharePerferenceModel extends AbstractPerferenceModel {
dirtySave(); dirtySave();
} }
public boolean isUseSystemWallpaper() {
return useSystemWallpaper;
}
public void setUseSystemWallpaper(boolean useSystemWallpaper) {
this.useSystemWallpaper = useSystemWallpaper;
dirtySave();
}
public boolean isBackgroundAnimatorRandomColor() { public boolean isBackgroundAnimatorRandomColor() {
return backgroundAnimatorRandomColor; return backgroundAnimatorRandomColor;
} }

View File

@ -74,19 +74,19 @@ public final class NetworkManager {
if (url == null || url.length() == 0 || requestObject == null) { if (url == null || url.length() == 0 || requestObject == null) {
return false; return false;
} }
Log.d(TAG, String.format("request URL:%s \nrequest Params:%s", request.getUrl(), requestObject.toString())); timber.log.Timber.d(String.format("request URL:%s \nrequest Params:%s", request.getUrl(), requestObject.toString()));
JsonObjectRequest jsonRequest = new JsonObjectRequest(url, requestObject, JsonObjectRequest jsonRequest = new JsonObjectRequest(url, requestObject,
new Response.Listener<JSONObject>() { new Response.Listener<JSONObject>() {
@Override @Override
public void onResponse(JSONObject response) { public void onResponse(JSONObject response) {
Log.d(TAG, "http response JsonString:" + response.toString()); timber.log.Timber.d("http response JsonString:" + response.toString());
listener.onResponse(response); listener.onResponse(response);
} }
}, },
new Response.ErrorListener() { new Response.ErrorListener() {
@Override @Override
public void onErrorResponse(VolleyError error) { public void onErrorResponse(VolleyError error) {
Log.d(TAG, "http request fail"); timber.log.Timber.d("http request fail");
listener.onRequestFailed(Constants.FAIL_CODE, error.toString()); listener.onRequestFailed(Constants.FAIL_CODE, error.toString());
} }
}) { }) {

View File

@ -9,6 +9,7 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -168,6 +169,7 @@ public class CalendarPopup extends FullScreenDialogFragment implements CalendarV
public void onEvent(ClockEvent<String> event) { public void onEvent(ClockEvent<String> event) {
initSyncTodoData(); initSyncTodoData();
todo_sync.setClickable(true); todo_sync.setClickable(true);
Toast.makeText(getContext(), "同步完成。。。", Toast.LENGTH_SHORT).show();
} }
}); });
@ -217,7 +219,7 @@ public class CalendarPopup extends FullScreenDialogFragment implements CalendarV
todoAdapter.clear(); todoAdapter.clear();
List<TodoEntity> dayEntityList=todoSyncServiceManager.getTodoEntities(calendar.getYear(),calendar.getMonth()-1,calendar.getDay()); List<TodoEntity> dayEntityList=todoSyncServiceManager.getTodoEntities(calendar.getYear(),calendar.getMonth()-1,calendar.getDay());
Log.d(TAG,"onCalendarSelect on month:"+calendar.getMonth()+"\t list size:"+dayEntityList.size()); timber.log.Timber.d("onCalendarSelect on month:"+calendar.getMonth()+"\t list size:"+dayEntityList.size());
if(dayEntityList.size()>0) if(dayEntityList.size()>0)
todoAdapter.setItems(dayEntityList); todoAdapter.setItems(dayEntityList);
} }
@ -236,13 +238,13 @@ public class CalendarPopup extends FullScreenDialogFragment implements CalendarV
protected void initSyncTodoData(){ protected void initSyncTodoData(){
Map<String, Calendar> map = new HashMap<>(); Map<String, Calendar> map = new HashMap<>();
Calendar todoCalendar; Calendar todoCalendar;
Log.d(TAG,"total todos :"+todoSyncServiceManager.getTodoEntities().size()); timber.log.Timber.d("total todos :"+todoSyncServiceManager.getTodoEntities().size());
for(TodoEntity todoEntity:todoSyncServiceManager.getTodoEntities()){ for(TodoEntity todoEntity:todoSyncServiceManager.getTodoEntities()){
//Log.d(TAG,"todo name:"+todoEntity.getSubject()+"create time:"+todoEntity.getCreateddatetime()); //timber.log.Timber.d("todo name:"+todoEntity.getSubject()+"create time:"+todoEntity.getCreateddatetime());
if(todoEntity.getCreateddatetime()!=null){ if(todoEntity.getCreateddatetime()!=null){
todoCalendar=getSchemeCalendar(todoEntity.getCreateddatetime(),0xFF40db25,todoEntity.getSubject()); todoCalendar=getSchemeCalendar(todoEntity.getCreateddatetime(),0xFF40db25,todoEntity.getSubject());
map.put(todoCalendar.toString(),todoCalendar); map.put(todoCalendar.toString(),todoCalendar);
//Log.d(TAG,"todo to show:"+todoCalendar.toString()); //timber.log.Timber.d("todo to show:"+todoCalendar.toString());
} }
} }
mCalendarView.setSchemeDate(map); mCalendarView.setSchemeDate(map);

View File

@ -135,7 +135,7 @@ public class TimeSetupPopup extends FullScreenDialogFragment implements MusicPic
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d(TAG,"onResume hour:"+hour+"\tminute:"+minute); timber.log.Timber.d("onResume hour:"+hour+"\tminute:"+minute);
mHourSeekbar.fillInside(); mHourSeekbar.fillInside();
mHourSeekbar.setCurProcess(hour); mHourSeekbar.setCurProcess(hour);
mMinuteSeekbar.setCurProcess(minute); mMinuteSeekbar.setCurProcess(minute);

View File

@ -0,0 +1,38 @@
package clock.socoolby.com.clock.screen;
import android.accessibilityservice.AccessibilityService;
import android.os.Build;
import android.view.accessibility.AccessibilityEvent;
import timber.log.Timber;
public class LockAccessibilityService extends AccessibilityService {
public static final String LOCK_COMMAND="Lock Screen";
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
Timber.v("onAccessibilityEvent(): "+event.getText().toString());
if(null!=event) {
if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED && !event.getText().isEmpty()&&event.getText().get(0).toString().equalsIgnoreCase(LOCK_COMMAND)) {
Timber.d("Received Lock Command");
lockDevice();
}
}
}
private void lockDevice() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
Timber.d("Locking device using AccessibilityService");
performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN);
} else {
// This should never be reached, but we'll log it just in case.
Timber.e("Locking device using AccessibilityService is only available for Android versions >= Pie");
}
}
@Override
public void onInterrupt() {
Timber.v("onInterrupt()");
}
}

View File

@ -1,40 +1,57 @@
package clock.socoolby.com.clock.utils; package clock.socoolby.com.clock.screen;
import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.Application;
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.os.PowerManager; import android.os.PowerManager;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.view.Window; import android.view.accessibility.AccessibilityEvent;
import android.view.WindowManager; import android.view.accessibility.AccessibilityManager;
import java.util.List; import java.util.List;
import clock.socoolby.com.clock.ActivateAdmin; import clock.socoolby.com.clock.ActivateAdmin;
import clock.socoolby.com.clock.ClockApplication; import clock.socoolby.com.clock.ClockApplication;
import timber.log.Timber;
public class ScreenManager { public class ScreenManager {
public static boolean isScreenOn() { public static boolean isScreenOn() {
PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(AppCompatActivity.POWER_SERVICE); PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(AppCompatActivity.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
return pm.isInteractive();
}
return pm.isScreenOn(); return pm.isScreenOn();
} }
public static void systemLock(Context context) { public static void systemLock(Context context) {
DevicePolicyManager policyManager; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
ComponentName componentName; AccessibilityManager manager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
policyManager = (DevicePolicyManager) context.getSystemService(AppCompatActivity.DEVICE_POLICY_SERVICE); if (manager.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
componentName = new ComponentName(context, ActivateAdmin.class); event.setPackageName(context.getPackageName());
event.setClassName(ScreenManager.class.getName());
event.setEnabled(true);
event.getText().add(LockAccessibilityService.LOCK_COMMAND);
Timber.v("Accessibility enabled. Firing AccessibilityEvent: $event");
manager.sendAccessibilityEvent(event);
} else {
Timber.v("Accessibility disabled. Can't fire AccessibilityEvent");
}
return;
}
DevicePolicyManager policyManager = (DevicePolicyManager) context.getSystemService(AppCompatActivity.DEVICE_POLICY_SERVICE);
ComponentName componentName= new ComponentName(context, ActivateAdmin.class);
if (!policyManager.isAdminActive(componentName)) { if (!policyManager.isAdminActive(componentName)) {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName);
//描述(additional explanation)
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "------ 用于锁定屏幕 ------");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
context.startActivity(intent); context.startActivity(intent);
} }
if (policyManager.isAdminActive(componentName)) { if (policyManager.isAdminActive(componentName)) {
@ -45,7 +62,7 @@ public class ScreenManager {
public static void systemUnLock() { public static void systemUnLock() {
PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(AppCompatActivity.POWER_SERVICE); PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(AppCompatActivity.POWER_SERVICE);
PowerManager.WakeLock mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK, "workclock:SimpleTimer"); PowerManager.WakeLock mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "workclock:SimpleTimer");
mWakelock.acquire(); mWakelock.acquire();
mWakelock.release(); mWakelock.release();
KeyguardManager keyguardManager = (KeyguardManager) ClockApplication.getContext().getSystemService(AppCompatActivity.KEYGUARD_SERVICE); KeyguardManager keyguardManager = (KeyguardManager) ClockApplication.getContext().getSystemService(AppCompatActivity.KEYGUARD_SERVICE);
@ -64,4 +81,5 @@ public class ScreenManager {
} }
return false; return false;
} }
} }

View File

@ -1,5 +1,8 @@
package clock.socoolby.com.clock.service; package clock.socoolby.com.clock.service;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service; import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -7,13 +10,15 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent; import android.hardware.SensorEvent;
import android.hardware.SensorEventListener; import android.hardware.SensorEventListener;
import android.hardware.SensorManager; import android.hardware.SensorManager;
import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.util.Log;
import androidx.annotation.RequiresApi;
import clock.socoolby.com.clock.ClockApplication; import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.MainActivity; import clock.socoolby.com.clock.MainActivity;
import clock.socoolby.com.clock.utils.FuncUnit; import clock.socoolby.com.clock.utils.FuncUnit;
import clock.socoolby.com.clock.utils.ScreenManager; import clock.socoolby.com.clock.screen.ScreenManager;
/** /**
* Alway zuo,never die. * Alway zuo,never die.
@ -23,23 +28,27 @@ import clock.socoolby.com.clock.utils.ScreenManager;
public class ProximityService extends Service { public class ProximityService extends Service {
private final static String TAG = ProximityService.class.getSimpleName(); private final static String TAG = ProximityService.class.getSimpleName();
public static final String CHANNEL_ID="workclock_channel";
protected boolean isRunning=false;
private SensorManager mSensorManager; private SensorManager mSensorManager;
private SensorEventListener mSensorListener = new SensorEventListener() { private SensorEventListener mSensorListener = new SensorEventListener() {
@Override @Override
public void onSensorChanged(SensorEvent sensorEvent) { public void onSensorChanged(SensorEvent sensorEvent) {
float[] its = sensorEvent.values; float[] its = sensorEvent.values;
Log.d(TAG, String.format("its %f %f %f len:,%d", its[0], its[1], its[2], its.length)); //timber.log.Timber.d(String.format("its %f %f %f len:,%d", its[0], its[1], its[2], its.length));
if (sensorEvent.sensor.getType() == Sensor.TYPE_PROXIMITY) { if (sensorEvent.sensor.getType() == Sensor.TYPE_PROXIMITY) {
if (FuncUnit.isForeground(ClockApplication.getContext(), MainActivity.class.getName())) { if (FuncUnit.isForeground(ClockApplication.getContext(), MainActivity.class.getName())) {
if (its[0] <= 3) { if (its[0] <= 3) {
Log.d(TAG,"Hand stay"); timber.log.Timber.d("Hand stay");
if (ScreenManager.isScreenOn()) { if (ScreenManager.isScreenOn()) {
ScreenManager.systemLock(ClockApplication.getInstance().getApplicationContext()); ScreenManager.systemLock(ClockApplication.getInstance().getApplicationContext());
} else { } else {
ScreenManager.systemUnLock(); ScreenManager.systemUnLock();
} }
} else { } else {
Log.d(TAG,"Hand leave..."); timber.log.Timber.d("Hand leave...");
} }
} }
} }
@ -57,7 +66,6 @@ public class ProximityService extends Service {
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
Sensor mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); Sensor mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
mSensorManager.registerListener(mSensorListener, mSensor, SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener(mSensorListener, mSensor, SensorManager.SENSOR_DELAY_FASTEST);
} }
@Override @Override
@ -67,7 +75,12 @@ public class ProximityService extends Service {
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
if(isRunning)
return super.onStartCommand(intent, flags, startId);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
initChanel();
}
isRunning=true;
return super.onStartCommand(intent, flags, startId); return super.onStartCommand(intent, flags, startId);
} }
@ -76,4 +89,16 @@ public class ProximityService extends Service {
mSensorManager.unregisterListener(mSensorListener); mSensorManager.unregisterListener(mSensorListener);
super.onDestroy(); super.onDestroy();
} }
@RequiresApi(api = Build.VERSION_CODES.O)
private void initChanel(){
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,"FallDetect",
NotificationManager.IMPORTANCE_HIGH);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.createNotificationChannel(channel);
Notification notification = new Notification.Builder(getApplicationContext(),CHANNEL_ID).build();
startForeground(3210, notification);
}
} }

View File

@ -81,13 +81,13 @@ public class ClockStateMachine implements Handler.Callback{
public void start(){ public void start(){
//Log.d(TAG,"create timer and timerTask................................."); //timber.log.Timber.d("create timer and timerTask.................................");
timer = new Timer(); timer = new Timer();
handler = new Handler(this); handler = new Handler(this);
timerTask = new TimerTask() { timerTask = new TimerTask() {
@Override @Override
public void run() { public void run() {
//Log.d(TAG, "timerTask move..."); //timber.log.Timber.d("timerTask move...");
handler.sendEmptyMessage(UPDATE_TIME); handler.sendEmptyMessage(UPDATE_TIME);
} }
}; };
@ -255,7 +255,7 @@ public class ClockStateMachine implements Handler.Callback{
beforeHour=globalViewModel.getTime_hour().getValue(); beforeHour=globalViewModel.getTime_hour().getValue();
if(beforeHour!=date.getHour()) { if(beforeHour!=date.getHour()) {
globalViewModel.setTime_hour(date.getHour()); globalViewModel.setTime_hour(date.getHour());
Log.d(TAG,"in state machine hour changed:"+beforeHour+"->"+date.getHour()); timber.log.Timber.d("in state machine hour changed:"+beforeHour+"->"+date.getHour());
if(isHourAnimatorAble()&&date.getMinute()==0) { if(isHourAnimatorAble()&&date.getMinute()==0) {
if (HourAnimatorFactory.isHourAnimator(globalViewModel.getHourAlterTypeName().getValue())) if (HourAnimatorFactory.isHourAnimator(globalViewModel.getHourAlterTypeName().getValue()))
EventManger.post(ClockEvent.buildHourAnimator(true)); EventManger.post(ClockEvent.buildHourAnimator(true));
@ -280,7 +280,7 @@ public class ClockStateMachine implements Handler.Callback{
DateModel currentDate=null; DateModel currentDate=null;
private void updateDay(DateModel date){ private void updateDay(DateModel date){
if(currentDate==null||currentDate.getDay()!=date.getDay()) { if(currentDate==null||currentDate.getDay()!=date.getDay()) {
Log.d(TAG,"updateDay."+date); timber.log.Timber.d("updateDay."+date);
currentDate=date; currentDate=date;
String dayString = date.getToday(); String dayString = date.getToday();
String dateString = date.getDateString(); String dateString = date.getDateString();
@ -319,7 +319,7 @@ public class ClockStateMachine implements Handler.Callback{
int today = date.getWeek(); int today = date.getWeek();
if (model.getTypeHourPower() != Constants.TALKING_NO_REPORT) { if (model.getTypeHourPower() != Constants.TALKING_NO_REPORT) {
//Log.d(TAG, String.format("reportTime Year:%d Month:%d Day:%d Hour:%d Minute:%d Today:%d", year, month, day, hour, minute, today)); //timber.log.Timber.d(String.format("reportTime Year:%d Month:%d Day:%d Hour:%d Minute:%d Today:%d", year, month, day, hour, minute, today));
if (!alterManager.isReport(hour, minute)) if (!alterManager.isReport(hour, minute))
return; return;
if ((minute == 30 || minute == 0) && model.getTypeHourPower() == Constants.TALKING_HALF_AN_HOUR && second == 0) { if ((minute == 30 || minute == 0) && model.getTypeHourPower() == Constants.TALKING_HALF_AN_HOUR && second == 0) {

View File

@ -84,7 +84,6 @@ public class TodoSyncServiceManager {
authCallback.onCancel(); authCallback.onCancel();
return; return;
} }
I_TodoSyncService syncService=syncServicesMap.get(serviceName); I_TodoSyncService syncService=syncServicesMap.get(serviceName);
if(!syncService.isSignIn()) if(!syncService.isSignIn())
syncService.signIn(activity,authCallback); syncService.signIn(activity,authCallback);
@ -123,7 +122,7 @@ public class TodoSyncServiceManager {
@Override @Override
public void onRequestFailed(int error, String errorMessage) { public void onRequestFailed(int error, String errorMessage) {
Log.d(TAG, errorMessage); timber.log.Timber.d(errorMessage);
} }
}; };
todoSyncService.list(requestListener); todoSyncService.list(requestListener);
@ -250,7 +249,7 @@ public class TodoSyncServiceManager {
private boolean isSameDay(Date base,Date toCheckday){ private boolean isSameDay(Date base,Date toCheckday){
if(toCheckday==null) if(toCheckday==null)
return false; return false;
//Log.d(TAG,"isSameDay from:"+ TypeUtils.dayFormat(base)+"\t to:"+TypeUtils.dayFormat(toCheckday)); //timber.log.Timber.d("isSameDay from:"+ TypeUtils.dayFormat(base)+"\t to:"+TypeUtils.dayFormat(toCheckday));
return TimeUtils.isSameDay(base,toCheckday); return TimeUtils.isSameDay(base,toCheckday);
} }

View File

@ -66,13 +66,13 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
} }
public void start(Context applicationContext, NetworkManager networkManager){ public void start(Context applicationContext, NetworkManager networkManager){
Log.d(TAG,"on start start..."); timber.log.Timber.d("on start start...");
/* Configure your sample app and save state for this activity */ /* Configure your sample app and save state for this activity */
serviceStarting =true; serviceStarting =true;
sampleApp = new PublicClientApplication( sampleApp = new PublicClientApplication(
applicationContext, applicationContext,
R.raw.auth_config); R.raw.auth_config);
Log.d(TAG,"create sampleApp..."); timber.log.Timber.d("create sampleApp...");
this.networkManager=networkManager; this.networkManager=networkManager;
/* Attempt to get a user and acquireTokenSilent /* Attempt to get a user and acquireTokenSilent
@ -83,15 +83,15 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
public void onAccountsLoaded(final List<IAccount> accounts) { public void onAccountsLoaded(final List<IAccount> accounts) {
if (!accounts.isEmpty()) { if (!accounts.isEmpty()) {
/* This sample doesn't support multi-account scenarios, use the first account */ /* This sample doesn't support multi-account scenarios, use the first account */
Log.d(TAG,"on accounts load"); timber.log.Timber.d("on accounts load");
sampleApp.acquireTokenSilentAsync(SCOPES, accounts.get(0), getAuthTokenCallback()); sampleApp.acquireTokenSilentAsync(SCOPES, accounts.get(0), getAuthTokenCallback());
} else { } else {
/* No accounts or >1 account */ /* No accounts or >1 account */
}
serviceStarting =false; serviceStarting =false;
} }
}
}); });
Log.d(TAG,"call getAccounts end"); timber.log.Timber.d("call getAccounts end");
} }
public void signIn(Activity activity,AuthCallback authCallback){ public void signIn(Activity activity,AuthCallback authCallback){
@ -134,7 +134,7 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
} }
public boolean isSignIn(){ public boolean isSignIn(){
Log.d(TAG,"call is sing in...serviceStarting:"+ serviceStarting); timber.log.Timber.d("call is sing in...serviceStarting:"+ serviceStarting);
return authResult != null&&authResult.getAccessToken() != null; return authResult != null&&authResult.getAccessToken() != null;
} }
@ -144,7 +144,7 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
protected void callGraphAPI(HttpMethod methodType, String graphUrl, RequestListener listener) { protected void callGraphAPI(HttpMethod methodType, String graphUrl, RequestListener listener) {
/* Make sure we have a token to send to graph */ /* Make sure we have a token to send to graph */
if (authResult.getAccessToken() == null) { if (authResult.getAccessToken() == null) {
Log.d(TAG, "call graph api please sign in first ..url: " +graphUrl); timber.log.Timber.d("call graph api please sign in first ..url: " +graphUrl);
return; return;
} }
@ -153,20 +153,20 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
try { try {
parameters.put("key", "value"); parameters.put("key", "value");
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, "Failed to put parameters: " + e.toString()); timber.log.Timber.d("Failed to put parameters: " + e.toString());
} }
JsonObjectRequest request = new JsonObjectRequest(methodType.value, graphUrl, JsonObjectRequest request = new JsonObjectRequest(methodType.value, graphUrl,
parameters,new Response.Listener<JSONObject>() { parameters,new Response.Listener<JSONObject>() {
@Override @Override
public void onResponse(JSONObject response) { public void onResponse(JSONObject response) {
/* Successfully called graph, process data and send to UI */ /* Successfully called graph, process data and send to UI */
Log.d(TAG, "Response: " + response.toString()); timber.log.Timber.d("Response: " + response.toString());
listener.onResponse(response); listener.onResponse(response);
} }
}, new Response.ErrorListener() { }, new Response.ErrorListener() {
@Override @Override
public void onErrorResponse(VolleyError error) { public void onErrorResponse(VolleyError error) {
Log.d(TAG, "Error: " + error.toString()); timber.log.Timber.d("Error: " + error.toString());
listener.onRequestFailed(0,error.toString()); listener.onRequestFailed(0,error.toString());
} }
}) { }) {
@ -182,8 +182,8 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
} }
protected void callGraphAPI(JsonObjectRequest request) { protected void callGraphAPI(JsonObjectRequest request) {
Log.d(TAG, "Starting volley request to graph"); timber.log.Timber.d("Starting volley request to graph");
Log.d(TAG, "Adding HTTP GET to Queue, Request: " + request.toString()); timber.log.Timber.d("Adding HTTP GET to Queue, Request: " + request.toString());
networkManager.sendRequest(3000,request); networkManager.sendRequest(3000,request);
} }
@ -198,7 +198,7 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
@Override @Override
public void onSuccess(IAuthenticationResult authenticationResult) { public void onSuccess(IAuthenticationResult authenticationResult) {
/* Successfully got a token, call graph now */ /* Successfully got a token, call graph now */
Log.d(TAG, "Successfully authenticated"); timber.log.Timber.d("Successfully authenticated");
/* Store the authResult */ /* Store the authResult */
authResult = authenticationResult; authResult = authenticationResult;
serviceStarting =false; serviceStarting =false;
@ -207,7 +207,7 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
@Override @Override
public void onError(MsalException exception) { public void onError(MsalException exception) {
/* Failed to acquireToken */ /* Failed to acquireToken */
Log.d(TAG, "Authentication failed: " + exception.toString()); timber.log.Timber.d("Authentication failed: " + exception.toString());
if (exception instanceof MsalClientException) { if (exception instanceof MsalClientException) {
/* Exception inside MSAL, more info inside MsalError.java */ /* Exception inside MSAL, more info inside MsalError.java */
@ -222,7 +222,7 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
@Override @Override
public void onCancel() { public void onCancel() {
/* User cancelled the authentication */ /* User cancelled the authentication */
Log.d(TAG, "User cancelled login."); timber.log.Timber.d("User cancelled login.");
serviceStarting =false; serviceStarting =false;
} }
}; };
@ -238,7 +238,7 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
@Override @Override
public void onSuccess(IAuthenticationResult authenticationResult) { public void onSuccess(IAuthenticationResult authenticationResult) {
/* Successfully got a token, call graph now */ /* Successfully got a token, call graph now */
Log.d(TAG, "Successfully authenticated"); timber.log.Timber.d("Successfully authenticated");
/* Store the authResult */ /* Store the authResult */
authResult = authenticationResult; authResult = authenticationResult;
@ -249,7 +249,7 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
@Override @Override
public void onError(MsalException exception) { public void onError(MsalException exception) {
/* Failed to acquireToken */ /* Failed to acquireToken */
Log.d(TAG, "Authentication failed: " + exception.toString()); timber.log.Timber.d("Authentication failed: " + exception.toString());
if (exception instanceof MsalClientException) { if (exception instanceof MsalClientException) {
/* Exception inside MSAL, more info inside MsalError.java */ /* Exception inside MSAL, more info inside MsalError.java */
@ -265,7 +265,7 @@ public class MicrosoftTodoSyncServiceImpl implements I_TodoSyncService {
@Override @Override
public void onCancel() { public void onCancel() {
/* User cancelled the authentication */ /* User cancelled the authentication */
Log.d(TAG, "User cancelled login."); timber.log.Timber.d("User cancelled login.");
authCallback.onCancel(); authCallback.onCancel();
} }
}; };

View File

@ -74,7 +74,7 @@ public class TypeUtils {
modifiedStrVal = strVal; modifiedStrVal = strVal;
} }
//Log.d(TAG,"string to deserialize date:"+modifiedStrVal); //timber.log.Timber.d("string to deserialize date:"+modifiedStrVal);
// Parse the well-formatted date string. // Parse the well-formatted date string.
final String datePattern; final String datePattern;

View File

@ -5,7 +5,6 @@ import android.content.res.AssetFileDescriptor;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.net.Uri; import android.net.Uri;
import android.util.Log;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -14,6 +13,7 @@ import java.util.Map;
import clock.socoolby.com.clock.ClockApplication; import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.R; import clock.socoolby.com.clock.R;
import clock.socoolby.com.clock.screen.ScreenManager;
public class Player { public class Player {
private final static String TAG = Player.class.getSimpleName(); private final static String TAG = Player.class.getSimpleName();
@ -105,10 +105,10 @@ public class Player {
} }
public void reportTime(Context activity, int year, int month, int day, int hour, int minute, int today) { public void reportTime(Context activity, int year, int month, int day, int hour, int minute, int today) {
Log.d(TAG,"go in report time playAble:"+playAble+"\tisReportime:"+isReporttime); timber.log.Timber.d("go in report time playAble:"+playAble+"\tisReportime:"+isReporttime);
if (!playAble||isReporttime) if (!playAble||isReporttime)
return; return;
Log.d(TAG, String.format("reportTime Year:%d Month:%d Day:%d Hour:%d Minute:%d Today:%d", year, month, day, hour, minute, today)); timber.log.Timber.d(String.format("reportTime Year:%d Month:%d Day:%d Hour:%d Minute:%d Today:%d", year, month, day, hour, minute, today));
LinkedList<Integer> playList = new LinkedList<Integer>(); LinkedList<Integer> playList = new LinkedList<Integer>();
playList.add(R.raw.todayis); playList.add(R.raw.todayis);
@ -169,7 +169,7 @@ public class Player {
} }
public void playTick(Context activity,int tick_type_id) { public void playTick(Context activity,int tick_type_id) {
Log.d(TAG,"go in Play tick playable:"+playAble+"\tisReportime:"+isReporttime); timber.log.Timber.d("go in Play tick playable:"+playAble+"\tisReportime:"+isReporttime);
if (!playAble||isReporttime) if (!playAble||isReporttime)
return; return;
if (!ScreenManager.isScreenOn() || ScreenManager.isApplicationBroughtToBackground(ClockApplication.getContext())) if (!ScreenManager.isScreenOn() || ScreenManager.isApplicationBroughtToBackground(ClockApplication.getContext()))
@ -181,7 +181,7 @@ public class Player {
private Map<Integer,AssetFileDescriptor> soundFileCache=new HashMap<>(); private Map<Integer,AssetFileDescriptor> soundFileCache=new HashMap<>();
public void playHandUp(Context activity){ public void playHandUp(Context activity){
Log.d(TAG,"go in Play hand up playable:"+playAble+"\tisReportime:"+isReporttime); timber.log.Timber.d("go in Play hand up playable:"+playAble+"\tisReportime:"+isReporttime);
if (!playAble||isReporttime) if (!playAble||isReporttime)
return; return;
if (!ScreenManager.isScreenOn() || ScreenManager.isApplicationBroughtToBackground(ClockApplication.getContext())) if (!ScreenManager.isScreenOn() || ScreenManager.isApplicationBroughtToBackground(ClockApplication.getContext()))
@ -275,7 +275,7 @@ public class Player {
} }
public void setPlayAble(boolean playAble) { public void setPlayAble(boolean playAble) {
Log.d(TAG,"set Play able:"+playAble); timber.log.Timber.d("set Play able:"+playAble);
this.playAble = playAble; this.playAble = playAble;
if(!playAble&&mediaPlayer!=null){ if(!playAble&&mediaPlayer!=null){
resert(); resert();

View File

@ -2,13 +2,18 @@ package clock.socoolby.com.clock.viewmodel;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import java.util.Date; import java.util.Date;
import clock.socoolby.com.clock.ThemeUIManager;
import clock.socoolby.com.clock.model.SharePerferenceModel; import clock.socoolby.com.clock.model.SharePerferenceModel;
import clock.socoolby.com.clock.state.ClockModeEnum; import clock.socoolby.com.clock.state.ClockModeEnum;
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum; import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
import clock.socoolby.com.clock.state.ClockStateMachine;
import clock.socoolby.com.clock.todo.TodoSyncServiceManager;
public class GlobalViewModel extends ViewModel { public class GlobalViewModel extends ViewModel {
@ -33,6 +38,8 @@ public class GlobalViewModel extends ViewModel {
private MutableLiveData<Boolean> autoFullScreen=new MutableLiveData<>(); private MutableLiveData<Boolean> autoFullScreen=new MutableLiveData<>();
private MutableLiveData<Boolean> useSystemWallpaper=new MutableLiveData<>();
//system //system
private Boolean tickSound=false; private Boolean tickSound=false;
@ -42,7 +49,7 @@ public class GlobalViewModel extends ViewModel {
private MutableLiveData<Integer> brightness=new MutableLiveData<>(); private MutableLiveData<Integer> brightness=new MutableLiveData<>();
//public MutableLiveData<Boolean> heartbeat=new MutableLiveData(); public MutableLiveData<Boolean> triggerScreen=new MutableLiveData();
public MutableLiveData<Boolean> todoSyncAble=new MutableLiveData(); public MutableLiveData<Boolean> todoSyncAble=new MutableLiveData();
@ -72,6 +79,12 @@ public class GlobalViewModel extends ViewModel {
SharePerferenceModel model; SharePerferenceModel model;
ThemeUIManager themeUIManager;
ClockStateMachine clockStateMachine;
TodoSyncServiceManager todoSyncServiceManager;
public GlobalViewModel(SharePerferenceModel model) { public GlobalViewModel(SharePerferenceModel model) {
this.model = model; this.model = model;
init(); init();
@ -81,10 +94,8 @@ public class GlobalViewModel extends ViewModel {
private void init(){ private void init(){
srceenLock.setValue(false); srceenLock.setValue(false);
brightness.setValue(100); brightness.setValue(100);
//heartbeat.setValue(true);
appConfig.setValue(false); appConfig.setValue(false);
clockModeEnum.setValue(ClockModeEnum.NORMAL); clockModeEnum.setValue(ClockModeEnum.NORMAL);
//timeHourAnimatorStarting.setValue(false);
} }
public void loadFromModel(){ public void loadFromModel(){
@ -113,6 +124,9 @@ public class GlobalViewModel extends ViewModel {
time_hour.setValue(new Date().getHours()); time_hour.setValue(new Date().getHours());
timeHourAnimatordialy.setValue(model.getTimeHourAlterDialy()); timeHourAnimatordialy.setValue(model.getTimeHourAlterDialy());
useSystemWallpaper.setValue(model.isUseSystemWallpaper());
triggerScreen.setValue(model.isTriggerScreen());
} }
public MutableLiveData<String> getCity() { public MutableLiveData<String> getCity() {
@ -155,6 +169,15 @@ public class GlobalViewModel extends ViewModel {
return clockInterfaceTypeEnum; return clockInterfaceTypeEnum;
} }
public MutableLiveData<Boolean> getTriggerScreen() {
return triggerScreen;
}
public void setTriggerScreen(Boolean triggerScreen) {
this.triggerScreen.setValue(triggerScreen);
model.setTriggerScreen(triggerScreen);
}
public MutableLiveData<ClockModeEnum> getClockModeEnum() { public MutableLiveData<ClockModeEnum> getClockModeEnum() {
return clockModeEnum; return clockModeEnum;
} }
@ -192,6 +215,25 @@ public class GlobalViewModel extends ViewModel {
return handUpAble; return handUpAble;
} }
public MutableLiveData<Boolean> getUseSystemWallpaper() {
return useSystemWallpaper;
}
public void setUseSystemWallpaper(Boolean useSystemWallpaper) {
this.useSystemWallpaper.setValue(useSystemWallpaper);
model.setUseSystemWallpaper(useSystemWallpaper);
}
public void checkSystemWallpaperSet(){
if(useSystemWallpaper.getValue()) {
backgroundColor.setValue(Color.TRANSPARENT);
backgroundImageVisable.setValue(false);
}else{
backgroundColor.setValue(model.getBackgroundColor());
backgroundImageVisable.setValue(model.isBackgroundImageVisable());
}
}
public void setHandUpTime(Integer handUpTime) { public void setHandUpTime(Integer handUpTime) {
this.handUpTime.setValue(handUpTime); this.handUpTime.setValue(handUpTime);
//model.setHandUpTime(handUpTime); //model.setHandUpTime(handUpTime);
@ -304,13 +346,6 @@ public class GlobalViewModel extends ViewModel {
model.setHandUpTypeName(handUpTypeName); model.setHandUpTypeName(handUpTypeName);
} }
/*public MutableLiveData<Boolean> getHeartbeat() {
return heartbeat;
}
public void setHeartbeat(Boolean heartbeat) {
this.heartbeat.setValue(heartbeat);
}*/
public MutableLiveData<String> getHourAlterTypeName() { public MutableLiveData<String> getHourAlterTypeName() {
return hourAlterTypeName; return hourAlterTypeName;
@ -370,4 +405,29 @@ public class GlobalViewModel extends ViewModel {
public MutableLiveData<Boolean> getTodoSyncAble(){ public MutableLiveData<Boolean> getTodoSyncAble(){
return todoSyncAble; return todoSyncAble;
} }
public ThemeUIManager getThemeUIManager() {
return themeUIManager;
}
public void setThemeUIManager(ThemeUIManager themeUIManager) {
this.themeUIManager = themeUIManager;
}
public ClockStateMachine getClockStateMachine() {
return clockStateMachine;
}
public void setClockStateMachine(ClockStateMachine clockStateMachine) {
this.clockStateMachine = clockStateMachine;
}
public TodoSyncServiceManager getTodoSyncServiceManager() {
return todoSyncServiceManager;
}
public void setTodoSyncServiceManager(TodoSyncServiceManager todoSyncServiceManager) {
this.todoSyncServiceManager = todoSyncServiceManager;
}
} }

View File

@ -154,7 +154,7 @@ public class FireworkAnimator extends AbstractCacheDifferenceAnimator<FireworkAn
Element temp=null; Element temp=null;
color=Util.roundColor(); color=Util.roundColor();
// 给每个火花设定一个随机的方向 0-360 // 给每个火花设定一个随机的方向 0-360
//Log.d(TAG, "Firework start mode = " + mode + " count = " + count); //timber.log.Timber.d("Firework start mode = " + mode + " count = " + count);
switch (mode) { switch (mode) {
case MAX: case MAX:
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {

View File

@ -178,11 +178,11 @@ public class SnakeAnimator extends AbstractAnimator<SnakeAnimator.Snake> {
case GameType.TOP: case GameType.TOP:
case GameType.BOTTOM: case GameType.BOTTOM:
if(distanceY==0&&Math.abs(distanceX)<4) { if(distanceY==0&&Math.abs(distanceX)<4) {
Log.d(TAG,"close to food for Y,dist :"+distanceX); timber.log.Timber.d("close to food for Y,dist :"+distanceX);
return; return;
} }
if(distanceX==0&&Math.abs(distanceY)==1){ if(distanceX==0&&Math.abs(distanceY)==1){
Log.d(TAG,"food is "+(distanceY>0?"left":"right")); timber.log.Timber.d("food is "+(distanceY>0?"left":"right"));
setSnakeDirection(distanceY>0?GameType.LEFT:GameType.RIGHT); setSnakeDirection(distanceY>0?GameType.LEFT:GameType.RIGHT);
return; return;
} }
@ -190,11 +190,11 @@ public class SnakeAnimator extends AbstractAnimator<SnakeAnimator.Snake> {
case GameType.LEFT: case GameType.LEFT:
case GameType.RIGHT: case GameType.RIGHT:
if(distanceX==0&&Math.abs(distanceY)<4) { if(distanceX==0&&Math.abs(distanceY)<4) {
Log.d(TAG,"close to food for X,dist :"+distanceY); timber.log.Timber.d("close to food for X,dist :"+distanceY);
return; return;
} }
if(distanceY==0&&Math.abs(distanceX)==1){ if(distanceY==0&&Math.abs(distanceX)==1){
Log.d(TAG,"food is "+(distanceX>0?"up":"down")); timber.log.Timber.d("food is "+(distanceX>0?"up":"down"));
setSnakeDirection(distanceX>0?GameType.TOP:GameType.BOTTOM); setSnakeDirection(distanceX>0?GameType.TOP:GameType.BOTTOM);
return; return;
} }

View File

@ -71,7 +71,7 @@ public class Wave3DAnimator extends AbstractAnimator<Wave3DAnimator.Wave> {
datas.add(pointCicle); datas.add(pointCicle);
} }
} }
Log.d(Tag,"initWave datas count:"+datas.size()); timber.log.Timber.d("initWave datas count:"+datas.size());
} }

View File

@ -179,7 +179,7 @@ public class EZLedAnimator extends AbstractAnimator<EZLedAnimator.EZLed> {
* @param text content * @param text content
*/ */
public void setText(CharSequence text) { public void setText(CharSequence text) {
Log.d(Tag,"setText:"+text); timber.log.Timber.d("setText:"+text);
this.contentType = CONTENT_TYPE_TEXT; this.contentType = CONTENT_TYPE_TEXT;
this.ledText = text; this.ledText = text;
measureTextBound(text.toString()); measureTextBound(text.toString());
@ -232,7 +232,7 @@ public class EZLedAnimator extends AbstractAnimator<EZLedAnimator.EZLed> {
startX=maxWidth; startX=maxWidth;
Float len=maxWidth*stepPercent; Float len=maxWidth*stepPercent;
startX=startX-len.intValue(); startX=startX-len.intValue();
Log.d(Tag,"move right to left startX:"+startX); timber.log.Timber.d("move right to left startX:"+startX);
if(startX<-mDrawableWidth) if(startX<-mDrawableWidth)
startX=maxWidth; startX=maxWidth;
} }
@ -248,7 +248,7 @@ public class EZLedAnimator extends AbstractAnimator<EZLedAnimator.EZLed> {
} }
mustRefush=false; mustRefush=false;
} }
Log.d(Tag,"onDraw bitmap is :"+bitmap); timber.log.Timber.d("onDraw bitmap is :"+bitmap);
float y=height* hightPercent -mDrawableHeight/2; float y=height* hightPercent -mDrawableHeight/2;
if (bitmap != null) { if (bitmap != null) {
if(bitmap.getWidth() > TEXTURE_MAX){ if(bitmap.getWidth() > TEXTURE_MAX){
@ -283,7 +283,7 @@ public class EZLedAnimator extends AbstractAnimator<EZLedAnimator.EZLed> {
*/ */
private Bitmap renderText(CharSequence text, Paint paint) { private Bitmap renderText(CharSequence text, Paint paint) {
Log.d(Tag,"renderText:"+text); timber.log.Timber.d("renderText:"+text);
Bitmap cacheMap = Bitmap.createBitmap(mDrawableWidth, mDrawableHeight, Bitmap.Config.ARGB_8888); Bitmap cacheMap = Bitmap.createBitmap(mDrawableWidth, mDrawableHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(cacheMap); Canvas canvas = new Canvas(cacheMap);
int yPos = (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2)); int yPos = (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2));
@ -296,7 +296,7 @@ public class EZLedAnimator extends AbstractAnimator<EZLedAnimator.EZLed> {
} }
private Bitmap generateDrawable(Bitmap bitmap) { private Bitmap generateDrawable(Bitmap bitmap) {
Log.d(Tag,"generateDrawable:"+bitmap); timber.log.Timber.d("generateDrawable:"+bitmap);
if (bitmap != null) { if (bitmap != null) {
release(); release();
measureBitmap(bitmap); measureBitmap(bitmap);
@ -311,7 +311,7 @@ public class EZLedAnimator extends AbstractAnimator<EZLedAnimator.EZLed> {
* @return led bitmap * @return led bitmap
*/ */
private Bitmap generateLedBitmap(Bitmap src) { private Bitmap generateLedBitmap(Bitmap src) {
Log.d(Tag,"generateLedBitmap:"+src); timber.log.Timber.d("generateLedBitmap:"+src);
Bitmap bitmap = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Bitmap.Config.ARGB_8888); Bitmap bitmap = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
for (Point point : circlePoint) { for (Point point : circlePoint) {
@ -351,7 +351,7 @@ public class EZLedAnimator extends AbstractAnimator<EZLedAnimator.EZLed> {
* Calculate the led point position * Calculate the led point position
*/ */
private void measurePoint(int width, int height) { private void measurePoint(int width, int height) {
Log.d(Tag,"measurePoint width:"+width+"height:"+height); timber.log.Timber.d("measurePoint width:"+width+"height:"+height);
int halfBound = ledRadius + ledSpace / 2; int halfBound = ledRadius + ledSpace / 2;
int x = halfBound; int x = halfBound;
int y = halfBound; int y = halfBound;

View File

@ -117,7 +117,7 @@ public class PathEffectTextAnimator extends AbstractAnimator<PathEffectTextAnima
public void onDraw(Canvas canvas, Paint mPaint) { public void onDraw(Canvas canvas, Paint mPaint) {
if (mPaths == null) if (mPaths == null)
return; return;
//Log.d(TAG,"paths size:"+mPaths.size()+"\tdatas size:"+mDatas.size()); //timber.log.Timber.d("paths size:"+mPaths.size()+"\tdatas size:"+mDatas.size());
//synchronized (mSvgLock) { //synchronized (mSvgLock) {
for (int i = 0; i < mPaths.size(); i++) for (int i = 0; i < mPaths.size(); i++)
canvas.drawPath(mPaths.get(i), mPathPaint); canvas.drawPath(mPaths.get(i), mPathPaint);

View File

@ -52,7 +52,7 @@ public class DragFrameLayout extends FrameLayout {
@Override @Override
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) { public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
super.onViewPositionChanged(changedView, left, top, dx, dy); super.onViewPositionChanged(changedView, left, top, dx, dy);
Log.d(TAG,"onViewPositionChanged left:"+left+"\ttop:"+top+"\tdx:"+dx+"\tdy:"+dy); timber.log.Timber.d("onViewPositionChanged left:"+left+"\ttop:"+top+"\tdx:"+dx+"\tdy:"+dy);
this.left=left; this.left=left;
this.top=top; this.top=top;
if (onDragDropListener != null) { if (onDragDropListener != null) {
@ -79,7 +79,7 @@ public class DragFrameLayout extends FrameLayout {
@Override @Override
public void onViewReleased(View releasedChild, float xvel, float yvel) { public void onViewReleased(View releasedChild, float xvel, float yvel) {
super.onViewReleased(releasedChild, xvel, yvel); super.onViewReleased(releasedChild, xvel, yvel);
Log.d(TAG," onViewReleased xvel:"+xvel+"yvel:"+yvel); timber.log.Timber.d(" onViewReleased xvel:"+xvel+"yvel:"+yvel);
if (onDragDropListener != null) { if (onDragDropListener != null) {
onDragDropListener.onDragEnd(releasedChild,left,top); onDragDropListener.onDragEnd(releasedChild,left,top);
} }

View File

@ -62,7 +62,7 @@ public abstract class AbstractLibgdxSpineEffectView implements ApplicationListe
public void forceOver() { public void forceOver() {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "forceOver"); timber.log.Timber.d("forceOver");
forceOver = true; forceOver = true;
@ -77,7 +77,7 @@ public abstract class AbstractLibgdxSpineEffectView implements ApplicationListe
public void closeforceOver() { public void closeforceOver() {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "closeforceOver"); timber.log.Timber.d("closeforceOver");
forceOver = false; forceOver = false;
@ -130,7 +130,7 @@ public abstract class AbstractLibgdxSpineEffectView implements ApplicationListe
public void create() { public void create() {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "create"); timber.log.Timber.d("create");
mBatch = new SpriteBatch(); mBatch = new SpriteBatch();
@ -189,7 +189,7 @@ public abstract class AbstractLibgdxSpineEffectView implements ApplicationListe
public void setCanDraw(boolean candraw) { public void setCanDraw(boolean candraw) {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "setCanDraw:"+candraw); timber.log.Timber.d("setCanDraw:"+candraw);
m_candraw = candraw; m_candraw = candraw;
@ -254,7 +254,7 @@ public abstract class AbstractLibgdxSpineEffectView implements ApplicationListe
public void dispose() { public void dispose() {
if (openDEBUGLog) if (openDEBUGLog)
Log.d(TAG, "dispose"); timber.log.Timber.d("dispose");
mBatch.dispose(); mBatch.dispose();

View File

@ -327,11 +327,11 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
startX += padding; startX += padding;
} }
startX += subscriptCharWidth; startX += subscriptCharWidth;
//Log.d(Tag,"view hight:"+getHeight()+"\t startY:"+startY+"\t text hight:"+textBodyHight+"small text hight:"+subscriptTextHight); //timber.log.Timber.d("view hight:"+getHeight()+"\t startY:"+startY+"\t text hight:"+textBodyHight+"small text hight:"+subscriptTextHight);
} }
} }
preString = textToDraw; preString = textToDraw;
//Log.d(Tag,"total draw time:"+(System.currentTimeMillis()-before)); //timber.log.Timber.d("total draw time:"+(System.currentTimeMillis()-before));
} }
private void drawBackground(Canvas canvas, float startX, float startY, int width, int height, Paint mBackgroundPaint) { private void drawBackground(Canvas canvas, float startX, float startY, int width, int height, Paint mBackgroundPaint) {
@ -353,7 +353,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
private void drawCharWithAnaimatorCheck(Canvas canvas, int i, String charStr, float startX, float startY, Paint mTextPaint) { private void drawCharWithAnaimatorCheck(Canvas canvas, int i, String charStr, float startX, float startY, Paint mTextPaint) {
charWidth = getCharWidth(charStr, mTextPaint); charWidth = getCharWidth(charStr, mTextPaint);
//Log.d(Tag,"view width:"+getWidth()+"\t heitht:"+getHeight()+"\t startx:"+startX+"\t startY:"+startY+"\t baseCharWidth:"+baseCharWidth+"\t text hight:"+textBodyHight+"\t text font hight:"+textFontHight); //timber.log.Timber.d("view width:"+getWidth()+"\t heitht:"+getHeight()+"\t startx:"+startX+"\t startY:"+startY+"\t baseCharWidth:"+baseCharWidth+"\t text hight:"+textBodyHight+"\t text font hight:"+textFontHight);
if (charBackgroundBorder) if (charBackgroundBorder)
if(charBackgroundBorderWithDoubble) { if(charBackgroundBorderWithDoubble) {
if (i == 0 || i == 3 || i == 6) if (i == 0 || i == 3 || i == 6)
@ -372,7 +372,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
} }
if (charAnimator != null) { if (charAnimator != null) {
charAnimator.drawCharAnimator(canvas, startX, startY , mTextPaint); charAnimator.drawCharAnimator(canvas, startX, startY , mTextPaint);
//Log.d(Tag,"charAnimator index i:"+i+"\tanimator percent:"); //timber.log.Timber.d("charAnimator index i:"+i+"\tanimator percent:");
if (charBackgroundBorder) if (charBackgroundBorder)
if(charBackgroundBorderWithDoubble) { if(charBackgroundBorderWithDoubble) {
if (i == 1 || i == 4 || i == 7) if (i == 1 || i == 4 || i == 7)

View File

@ -351,14 +351,14 @@ public class AndroidFragmentApplication extends Fragment implements AndroidAppli
@Override @Override
public void debug(String tag, String message) { public void debug(String tag, String message) {
if (logLevel >= LOG_DEBUG) { if (logLevel >= LOG_DEBUG) {
Log.d(tag, message); timber.log.Timber.d(message);
} }
} }
@Override @Override
public void debug(String tag, String message, Throwable exception) { public void debug(String tag, String message, Throwable exception) {
if (logLevel >= LOG_DEBUG) { if (logLevel >= LOG_DEBUG) {
Log.d(tag, message, exception); timber.log.Timber.d(message, exception);
} }
} }

View File

@ -52,7 +52,7 @@ public class AndroidInputThreePlus extends AndroidInput implements OnGenericMoti
@Override @Override
public boolean onGenericMotion (View view, MotionEvent event) { public boolean onGenericMotion (View view, MotionEvent event) {
Log.d(TAG,"onGenericMotion"+view.toString()); timber.log.Timber.d("onGenericMotion"+view.toString());
if (mouseHandler.onGenericMotion(event, this)) return true; if (mouseHandler.onGenericMotion(event, this)) return true;
for (int i = 0, n = genericMotionListeners.size(); i < n; i++) for (int i = 0, n = genericMotionListeners.size(); i < n; i++)
if (genericMotionListeners.get(i).onGenericMotion(view, event)) return true; if (genericMotionListeners.get(i).onGenericMotion(view, event)) return true;
@ -67,7 +67,7 @@ public class AndroidInputThreePlus extends AndroidInput implements OnGenericMoti
@Override @Override
public boolean onTouch (View view, MotionEvent event) { public boolean onTouch (View view, MotionEvent event) {
super.onTouch(view,event); super.onTouch(view,event);
//Log.d(TAG,"onTouch interrupt:"+interruptTouch+"\t event:"+event.toString()); //timber.log.Timber.d("onTouch interrupt:"+interruptTouch+"\t event:"+event.toString());
return interruptTouch; return interruptTouch;
} }

View File

@ -4,7 +4,6 @@
android:id="@+id/main_background" android:id="@+id/main_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#000"
tools:context="clock.socoolby.com.clock.MainActivity"> tools:context="clock.socoolby.com.clock.MainActivity">
<ImageView <ImageView

View File

@ -107,11 +107,26 @@
android:text="@string/trigger_screen_on_off" /> android:text="@string/trigger_screen_on_off" />
<TextView <TextView
android:id="@+id/tv_weather_title" android:id="@+id/tv_trigger_system_wallpaper_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/cb_trigger_screen" android:layout_below="@+id/cb_trigger_screen"
android:layout_marginTop="@dimen/setting_margin_top" android:layout_marginTop="@dimen/setting_margin_top"
android:text="@string/system_wallpaper" />
<CheckBox
android:id="@+id/cb_trigger_system_wallpaper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_trigger_system_wallpaper_title"
android:text="@string/system_wallpaper_on_off" />
<TextView
android:id="@+id/tv_weather_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cb_trigger_system_wallpaper"
android:layout_marginTop="@dimen/setting_margin_top"
android:text="@string/weather_citiyname" /> android:text="@string/weather_citiyname" />
<EditText <EditText

View File

@ -222,11 +222,26 @@
android:text="@string/fullscreen_spirit_on_off" /> android:text="@string/fullscreen_spirit_on_off" />
<TextView <TextView
android:id="@+id/tv_trigger_title" android:id="@+id/tv_trigger_system_wallpaper_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/cb_fullscreen_spirit" android:layout_below="@+id/cb_fullscreen_spirit"
android:layout_marginTop="@dimen/setting_margin_top" android:layout_marginTop="@dimen/setting_margin_top"
android:text="@string/system_wallpaper" />
<CheckBox
android:id="@+id/cb_trigger_system_wallpaper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_trigger_system_wallpaper_title"
android:text="@string/system_wallpaper_on_off" />
<TextView
android:id="@+id/tv_trigger_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cb_trigger_system_wallpaper"
android:layout_marginTop="@dimen/setting_margin_top"
android:text="@string/screen_trigger" /> android:text="@string/screen_trigger" />
<CheckBox <CheckBox

View File

@ -36,4 +36,8 @@
<string name="fullscreen_spirit_on_off">开启小宠物</string> <string name="fullscreen_spirit_on_off">开启小宠物</string>
<string name="todo_alter_title">Todo同步</string> <string name="todo_alter_title">Todo同步</string>
<string name="todo_alter_able">开启微软Todo同步</string> <string name="todo_alter_able">开启微软Todo同步</string>
<string name="accessibility_desc">本服务用于锁定屏幕,只有开启才有效</string>
<string name="system_wallpaper">壁纸设置</string>
<string name="system_wallpaper_on_off">使用系统壁纸</string>
<string name="logut_system_wallpaper_mode">正在使用系统壁纸,是否要关闭来进行下一步?</string>
</resources> </resources>

View File

@ -6,6 +6,7 @@
<color name="select_main_bg_color">#4E4988</color> <color name="select_main_bg_color">#4E4988</color>
<color name="duration">#666</color> <color name="duration">#666</color>
<color name="time">#303F9F</color> <color name="time">#303F9F</color>
<color name="translate">#00FFFFFF</color>
<!--CircleSeekbar --> <!--CircleSeekbar -->
<color name="def_wheel_color">#4E4988</color> <color name="def_wheel_color">#4E4988</color>
@ -14,4 +15,5 @@
<!--drop pop menu --> <!--drop pop menu -->
<color name="drop_pop_menu_bg_color">#a0000000</color> <color name="drop_pop_menu_bg_color">#a0000000</color>
</resources> </resources>

View File

@ -32,14 +32,17 @@
<string name="examples_text">examples_text</string> <string name="examples_text">examples_text</string>
<string name="save">save</string> <string name="save">save</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="exit">exit</string> <string name="exit">exit</string>
<string name="handup_title">HandpU</string> <string name="handup_title">Hand Up</string>
<string name="handup_overtime_counting">OverTime Counting</string> <string name="handup_overtime_counting">OverTime Counting</string>
<string name="tv_handup_deily">deily(second):</string> <string name="tv_handup_deily">deily(second):</string>
<string name="fullscreen_title">fullscreen</string> <string name="fullscreen_title">fullscreen</string>
<string name="fullscreen_spirit_on_off">spirit able</string> <string name="fullscreen_spirit_on_off">spirit able</string>
<string name="todo_alter_title">Todo同步</string> <string name="todo_alter_title">Todo同步</string>
<string name="todo_alter_able">开启微软Todo同步</string> <string name="todo_alter_able">开启微软Todo同步</string>
<string name="accessibility_desc">本服务用于锁定屏幕,只有开启才有效</string>
<string name="system_wallpaper">Wallpaper</string>
<string name="system_wallpaper_on_off">Use System Wallpaper</string>
<string name="logut_system_wallpaper_mode">Current in System Wallpaper Mode,do you logout?</string>
</resources> </resources>

View File

@ -1,13 +1,5 @@
<resources> <resources>
<!-- Base application theme. -->
<!--<styleCode name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
<!--&lt;!&ndash; Customize your theme here. &ndash;&gt;-->
<!--<item name="colorPrimary">@color/colorPrimary</item>-->
<!--<item name="colorPrimaryDark">@color/colorPrimaryDark</item>-->
<!--<item name="colorAccent">@color/colorAccent</item>-->
<!--</styleCode>-->
<declare-styleable name="Cricle_slide"> <declare-styleable name="Cricle_slide">
//设置最大进度 //设置最大进度
<attr name="max_progress" format="integer"></attr> <attr name="max_progress" format="integer"></attr>
@ -32,4 +24,8 @@
<item name="android:windowContentOverlay">@null</item>//是否有遮盖 <item name="android:windowContentOverlay">@null</item>//是否有遮盖
</style> </style>
<style name="Activity.Translucent" parent="Theme.AppCompat.Light.NoActionBar.FullScreen">
<item name="android:windowBackground">@color/translate</item>
</style>
</resources> </resources>

View File

@ -0,0 +1,7 @@
<accessibility-service
xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeNotificationStateChanged"
android:packageNames="clock.socoolby.com.clock"
android:accessibilityFeedbackType="feedbackGeneric"
android:notificationTimeout="100"
android:canRetrieveWindowContent="false" />