Commit 747216ec authored by wanglei's avatar wanglei

...

parent 48342092
......@@ -4,10 +4,13 @@ import android.content.Intent
import android.net.Uri
import android.os.Build
import com.test.easy.easycleanerjunk.databinding.ActivitySettingBinding
import com.test.easy.easycleanerjunk.fcm.FCMUtil.subscribeToTopic
import com.test.easy.easycleanerjunk.fcm.FCMUtil.unsubscribeFromTopic
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.ConfigHelper.allNotification
import com.test.easy.easycleanerjunk.helps.ConfigHelper.fcmNotification
import com.test.easy.easycleanerjunk.helps.ConfigHelper.remainNotification
import com.test.easy.easycleanerjunk.service.PermanentNotificationService
import com.test.easy.easycleanerjunk.view.RateStarPop
......@@ -22,19 +25,29 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
override fun initListener() {
binding.ivBack.setOnClickListener {
// AdmobUtils.showInterstitialAd(this) {
finishToMain()
// }
}
// binding.switchRemainNotification.setOnCheckedChangeListener { buttonView, isChecked ->
// remainNotification = isChecked
// if (isChecked) {
// startNotification()
// } else {
// val serviceIntent = Intent(this, NotificationService::class.java)
// stopService(serviceIntent)
// }
// }
binding.switchRemainNotification.isChecked = remainNotification
binding.switchFcmNotification.isChecked = fcmNotification
binding.switchRemainNotification.setOnCheckedChangeListener { buttonView, isChecked ->
remainNotification = isChecked
if (isChecked) {
startNotification()
} else {
val serviceIntent = Intent(this, PermanentNotificationService::class.java)
stopService(serviceIntent)
}
}
binding.switchFcmNotification.setOnCheckedChangeListener { buttonView, isChecked ->
fcmNotification = isChecked
if (isChecked) {
subscribeToTopic(ConfigHelper.packageName)
} else {
unsubscribeFromTopic(ConfigHelper.packageName)
}
}
binding.cardPrivacy.setOnClickListener {
val intent = Intent(
......@@ -44,7 +57,16 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
startActivity(intent)
}
binding.idLlScore.setOnClickListener {
RateStarPop.show(this,true)
RateStarPop.show(this, true)
}
}
private fun startNotification() {
val intent = Intent(this, PermanentNotificationService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent)
} else {
startService(intent)
}
}
......
......@@ -72,7 +72,7 @@ object ConfigHelper {
field = value
SPUtils.getInstance().put("remainNotification", value, true)
}
var allNotification = true
var fcmNotification = true
get() {
return SPUtils.getInstance().getBoolean("fcmNotification", field)
}
......
......@@ -34,6 +34,68 @@
tools:ignore="HardcodedText" />
</FrameLayout>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="20dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:text="Notification toolbar"
android:textColor="@color/black"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch_remain_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="15dp"
android:layout_marginBottom="5dp"
android:thumb="@drawable/bg_switch_thumb_ffffff"
app:thumbTint="@color/white"
app:track="@drawable/bg_switch_track"
app:trackTint="@color/color_switch_track_selector" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="20dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:text="All Notification message"
android:textColor="@color/black"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch_fcm_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="15dp"
android:layout_marginBottom="5dp"
android:thumb="@drawable/bg_switch_thumb_ffffff"
app:thumbTint="@color/white"
app:track="@drawable/bg_switch_track"
app:trackTint="@color/color_switch_track_selector" />
</androidx.cardview.widget.CardView>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/id_ll_score"
android:layout_width="match_parent"
......@@ -55,7 +117,8 @@
android:text="Score"
android:textColor="#000000"
android:textSize="15sp"
android:textStyle="bold" />
android:textStyle="bold"
tools:ignore="HardcodedText" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
......@@ -85,7 +148,8 @@
android:text="Privacy Policy"
android:textColor="#000000"
android:textSize="15sp"
android:textStyle="bold" />
android:textStyle="bold"
tools:ignore="HardcodedText" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment