diff --git a/.idea/sqlandroid.xml b/.idea/sqlandroid.xml new file mode 100644 index 0000000..ebc2259 --- /dev/null +++ b/.idea/sqlandroid.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/tignioj/freezeapp/backend/viewmodel/HomeViewModel.java b/app/src/main/java/com/tignioj/freezeapp/backend/viewmodel/HomeViewModel.java index 66fb53e..e631eb9 100644 --- a/app/src/main/java/com/tignioj/freezeapp/backend/viewmodel/HomeViewModel.java +++ b/app/src/main/java/com/tignioj/freezeapp/backend/viewmodel/HomeViewModel.java @@ -177,9 +177,9 @@ public FreezeTasker getFreezeTaskerById(long id) { public void updateFreezeTasks(FreezeTasker... freezeTaskerFromDb) { freezeTaskerRepository.insertFreezeTasker(freezeTaskerFromDb); - } + public LiveData> findAppCategorysLiveWithPattern(String pattern) { return appsCategoryRepository.findAppCategorysLiveWithPattern(pattern); } diff --git a/app/src/main/java/com/tignioj/freezeapp/receiver/ScreenReceiver.java b/app/src/main/java/com/tignioj/freezeapp/receiver/ScreenReceiver.java index 75ef06c..9a1a5c8 100644 --- a/app/src/main/java/com/tignioj/freezeapp/receiver/ScreenReceiver.java +++ b/app/src/main/java/com/tignioj/freezeapp/receiver/ScreenReceiver.java @@ -13,7 +13,7 @@ public class ScreenReceiver extends BroadcastReceiver { public static void lockNow(Context context) { Log.d(MyConfig.LOG_TAG_FREEZE_SERVICE, "lock_now"); - DeviceMethod.getInstance(context).lockNow(); +// DeviceMethod.getInstance(context).lockNow(); } @Override diff --git a/app/src/main/java/com/tignioj/freezeapp/service/FreezeService.java b/app/src/main/java/com/tignioj/freezeapp/service/FreezeService.java index 7060852..1dab2fb 100644 --- a/app/src/main/java/com/tignioj/freezeapp/service/FreezeService.java +++ b/app/src/main/java/com/tignioj/freezeapp/service/FreezeService.java @@ -151,6 +151,8 @@ public synchronized void onChanged(ConcurrentHashMap strings) { builder.setContentText(content.toString()); if (start != null) { builder.setContentTitle(start + "-" + end); + } else { + builder.setContentTitle(null); } startForeground(NOTIFICATION_ID, builder.build()); } diff --git a/app/src/main/java/com/tignioj/freezeapp/ui/home/applist/AppListAdapter.java b/app/src/main/java/com/tignioj/freezeapp/ui/home/applist/AppListAdapter.java index fc29dee..6ea4993 100644 --- a/app/src/main/java/com/tignioj/freezeapp/ui/home/applist/AppListAdapter.java +++ b/app/src/main/java/com/tignioj/freezeapp/ui/home/applist/AppListAdapter.java @@ -1,6 +1,7 @@ package com.tignioj.freezeapp.ui.home.applist; import android.content.Context; +import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; diff --git a/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/FreezeTimerEditFragment.java b/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/FreezeTimerEditFragment.java index 3737e36..138593a 100644 --- a/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/FreezeTimerEditFragment.java +++ b/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/FreezeTimerEditFragment.java @@ -15,10 +15,12 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Spinner; +import android.widget.Switch; import android.widget.TimePicker; import android.widget.Toast; @@ -50,6 +52,7 @@ public class FreezeTimerEditFragment extends Fragment { private RadioButton radioButtonFreeze, radioButtonUnFreeze; private CheckBox checkBoxEditTimerIsLockScreen; private EditText editTextDescription; + private Switch switchEnableSIngleTask; private HomeViewModel homeViewModel; @@ -135,6 +138,11 @@ public void onClick(View v) { } }); + switchEnableSIngleTask = inflate.findViewById(R.id.switchEnableSIngleTask); + switchEnableSIngleTask.setChecked(freezeTaskerFromDb.isEnable()); + + + radioGroupUnFreezeOrUnfreeze = inflate.findViewById(R.id.radioButtonUnFreezeOrUnfreeze); radioButtonFreeze = inflate.findViewById(R.id.radioButtonFreeze); radioButtonUnFreeze = inflate.findViewById(R.id.radioButtonUnfreeze); @@ -185,6 +193,9 @@ public void onClick(View v) { } freezeTaskerFromDb.setLockScreen(checkBoxEditTimerIsLockScreen.isChecked()); + + freezeTaskerFromDb.setEnable(switchEnableSIngleTask.isChecked()); + // homeViewModel.insertFreezeTasks(freezeTaskerFromDb); homeViewModel.updateFreezeTasks(freezeTaskerFromDb); diff --git a/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/TimerAdapter.java b/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/TimerAdapter.java index c318f85..48744c7 100644 --- a/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/TimerAdapter.java +++ b/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/TimerAdapter.java @@ -33,6 +33,7 @@ import com.tignioj.freezeapp.utils.MyDateUtils; import java.text.SimpleDateFormat; +import java.util.ArrayList; public class TimerAdapter extends ListAdapter { @@ -77,7 +78,7 @@ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) @Override public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) { - FreezeTasker item = getItem(position); + final FreezeTasker item = getItem(position); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); String formatStart = sdf.format(item.getStartTime()); @@ -110,12 +111,18 @@ public void onBindViewHolder(@NonNull final MyViewHolder holder, final int posit // }); holder.aSwitchEnable.setChecked(item.isEnable()); + + holder.aSwitchEnable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - final FreezeTasker currentDeleteItem = getItem(position); - currentDeleteItem.setEnable(isChecked); - timerFragment.homeViewModel.updateFreezeTasks(currentDeleteItem); + FreezeTasker item1 = getItem(holder.getAdapterPosition()); + Log.d("switchChange1", item1.getDescription()); + if (item1.isEnable() != isChecked) { + item1.setEnable(isChecked); + timerFragment.homeViewModel.updateFreezeTasks(item1); + } + } }); diff --git a/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/TimerFragment.java b/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/TimerFragment.java index 2b336e7..b0ff1e3 100644 --- a/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/TimerFragment.java +++ b/app/src/main/java/com/tignioj/freezeapp/ui/home/timer/TimerFragment.java @@ -65,13 +65,16 @@ public void onClick(View v) { - final SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext()); + SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext()); boolean enableAll = mPrefs.getBoolean(MyConfig.PERSONAL_SHP_CONFIG_KEY_ENABLE_ALL_TASKS, true); aSwitchEnableAll = inflate.findViewById(R.id.switch_eanble_all_task); aSwitchEnableAll.setChecked(enableAll); + + aSwitchEnableAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext()); homeViewModel.updateFreezeTasksAllEnable(isChecked); SharedPreferences.Editor edit = mPrefs.edit(); edit.putBoolean(MyConfig.PERSONAL_SHP_CONFIG_KEY_ENABLE_ALL_TASKS, isChecked); diff --git a/app/src/main/res/layout/fragment_edit_timer.xml b/app/src/main/res/layout/fragment_edit_timer.xml index 9a445ab..0353fcf 100644 --- a/app/src/main/res/layout/fragment_edit_timer.xml +++ b/app/src/main/res/layout/fragment_edit_timer.xml @@ -218,5 +218,15 @@ app:layout_constraintStart_toEndOf="@+id/button_addTimer_Back" app:layout_constraintTop_toTopOf="@+id/button_addTimer_Back" /> + + \ No newline at end of file