Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add json #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
tools:targetApi="n">

<activity android:name=".settings.SettingsHostActivity"></activity>
<activity
android:name=".suda_life.SudaLifeActivity"
android:label="苏大生活" />
Expand All @@ -33,7 +33,9 @@
android:windowSoftInputMode="adjustPan">
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />

<data
android:mimeType="application/octet-stream"
android:pathPattern=".*\\.wakeup_schedule" />
Expand Down
48 changes: 47 additions & 1 deletion app/src/main/java/com/suda/yzune/wakeupschedule/App.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
package com.suda.yzune.wakeupschedule

import android.annotation.TargetApi
import android.app.Activity
import android.app.Application
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.graphics.Typeface
import android.os.Build
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatDelegate
import androidx.multidex.MultiDex
import com.crashlytics.android.Crashlytics
import com.crashlytics.android.answers.Answers
import com.microsoft.appcenter.AppCenter
import com.microsoft.appcenter.analytics.Analytics
import com.microsoft.appcenter.crashes.Crashes
import com.suda.yzune.wakeupschedule.schedule_settings.ScheduleSettingsActivity
import com.suda.yzune.wakeupschedule.utils.PreferenceUtils
import es.dmoral.toasty.Toasty
import io.fabric.sdk.android.Fabric

class App : Application() {

var activityCount = 0

override fun onCreate() {
super.onCreate()
Toasty.Config.getInstance()
.setToastTypeface(Typeface.DEFAULT_BOLD)
.setTextSize(12)
.apply()
if (!BuildConfig.DEBUG) {
AppCenter.start(this, "74cb13b8-bd94-40ce-99b3-c102cbadf772",
Analytics::class.java, Crashes::class.java)
}
if (!BuildConfig.DEBUG && !Fabric.isInitialized()) {
Fabric.with(this, Crashlytics())
Fabric.with(this, Crashlytics(), Answers())
}
PreferenceUtils.init(applicationContext)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Expand All @@ -35,6 +50,37 @@ class App : Application() {
importance = NotificationManager.IMPORTANCE_LOW
createNotificationChannel(this, channelId, channelName, importance)
}
if (PreferenceUtils.getBooleanFromSP(applicationContext, "s_night_mode", false)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
}
registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
override fun onActivityPaused(activity: Activity?) {
}

override fun onActivityResumed(activity: Activity?) {
}

override fun onActivityStarted(activity: Activity?) {
activityCount++
}

override fun onActivityDestroyed(activity: Activity?) {
}

override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) {
}

override fun onActivityStopped(activity: Activity?) {
activityCount--
if (activity is ScheduleSettingsActivity && activityCount == 0) {
Toasty.info(applicationContext, "对小部件的编辑需要按「返回键」退出设置页面才能生效哦", Toast.LENGTH_LONG).show()
}
}

override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) {
}

})
}

@TargetApi(Build.VERSION_CODES.O)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.suda.yzune.wakeupschedule.apply_info

import com.chad.library.adapter.base.BaseItemDraggableAdapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.bean.HtmlCountBean

class ApplyInfoAdapter(layoutResId: Int, data: List<HtmlCountBean>) :
BaseItemDraggableAdapter<HtmlCountBean, BaseViewHolder>(layoutResId, data) {
BaseQuickAdapter<HtmlCountBean, BaseViewHolder>(layoutResId, data) {

override fun convert(helper: BaseViewHolder, item: HtmlCountBean) {
helper.setText(R.id.tv_school, item.school)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package com.suda.yzune.wakeupschedule.base_view

import android.content.Intent
import android.content.res.Configuration
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.Window
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.SplashActivity
import com.suda.yzune.wakeupschedule.utils.PreferenceUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import org.jetbrains.anko.configuration
import kotlin.coroutines.CoroutineContext


Expand All @@ -25,12 +22,6 @@ abstract class BaseActivity : AppCompatActivity(), CoroutineScope {
get() = job + Dispatchers.Main

override fun onCreate(savedInstanceState: Bundle?) {
if (savedInstanceState != null) {
val intent = Intent(this, SplashActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
finish()
}
supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
Expand All @@ -51,10 +42,20 @@ abstract class BaseActivity : AppCompatActivity(), CoroutineScope {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.navigationBarColor = PreferenceUtils.getIntFromSP(applicationContext, "nav_bar_color", ContextCompat.getColor(applicationContext, R.color.colorAccent))
when (configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_NO -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
}
} // Night mode is not active, we're using the light theme
Configuration.UI_MODE_NIGHT_YES -> {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
} // Night mode is active, we're using dark theme
}
job = Job()
savedInstanceState?.remove("android:support:fragments")
super.onCreate(savedInstanceState)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import android.widget.LinearLayout
import android.widget.TextView
import androidx.annotation.LayoutRes
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.ContextCompat
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.utils.ViewUtils
import org.jetbrains.anko.*
import org.jetbrains.anko.appcompat.v7.tintedImageButton
import org.jetbrains.anko.constraint.layout.constraintLayout

abstract class BaseBlurTitleActivity : BaseActivity() {
Expand All @@ -34,7 +37,7 @@ abstract class BaseBlurTitleActivity : BaseActivity() {
private fun createView(): View {
return UI {
constraintLayout {
backgroundColorResource = R.color.backgroundColor
backgroundColor = colorAttr(R.attr.colorSurface)
scrollView {
overScrollMode = View.OVER_SCROLL_NEVER
isVerticalScrollBarEnabled = false
Expand All @@ -52,13 +55,14 @@ abstract class BaseBlurTitleActivity : BaseActivity() {
linearLayout {
id = R.id.anko_layout
topPadding = getStatusBarHeight()
backgroundColor = Color.WHITE
backgroundColor = colorAttr(R.attr.colorSurface)
val outValue = TypedValue()
context.theme.resolveAttribute(R.attr.selectableItemBackgroundBorderless, outValue, true)

imageButton(R.drawable.ic_back) {
tintedImageButton(R.drawable.ic_back) {
backgroundResource = outValue.resourceId
padding = dip(8)
setColorFilter(colorAttr(R.attr.colorOnBackground))
setOnClickListener {
onBackPressed()
}
Expand All @@ -85,14 +89,14 @@ abstract class BaseBlurTitleActivity : BaseActivity() {
endToEnd = ConstraintSet.PARENT_ID
}

view {
backgroundColorResource = R.color.grey
alpha = 0.5f
}.lparams(matchParent, dip(1)) {
topToBottom = R.id.anko_layout
startToStart = ConstraintSet.PARENT_ID
endToEnd = ConstraintSet.PARENT_ID
}
// view {
// backgroundColorResource = R.color.grey
// alpha = 0.5f
// }.lparams(matchParent, dip(1)) {
// topToBottom = R.id.anko_layout
// startToStart = ConstraintSet.PARENT_ID
// endToEnd = ConstraintSet.PARENT_ID
// }
}
}.view

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.suda.yzune.wakeupschedule.base_view

import android.graphics.Color
import android.graphics.Typeface
import android.os.Bundle
import android.text.TextWatcher
Expand Down Expand Up @@ -38,7 +37,6 @@ abstract class BaseListActivity : BaseActivity() {
private fun createView(): View {
return UI {
constraintLayout {
backgroundColorResource = R.color.backgroundColor
mRecyclerView = recyclerView {
overScrollMode = OVER_SCROLL_NEVER
}.lparams(matchParent, matchParent) {
Expand All @@ -51,13 +49,14 @@ abstract class BaseListActivity : BaseActivity() {
linearLayout {
id = R.id.anko_layout
topPadding = getStatusBarHeight()
backgroundColor = Color.WHITE
backgroundColor = colorAttr(R.attr.colorSurface)
val outValue = TypedValue()
context.theme.resolveAttribute(R.attr.selectableItemBackgroundBorderless, outValue, true)

imageButton(R.drawable.ic_back) {
backgroundResource = outValue.resourceId
padding = dip(8)
setColorFilter(colorAttr(R.attr.colorOnBackground))
setOnClickListener {
onBackPressed()
}
Expand Down Expand Up @@ -126,15 +125,21 @@ abstract class BaseListActivity : BaseActivity() {
endToEnd = ConstraintSet.PARENT_ID
}

view {
backgroundColorResource = R.color.grey
alpha = 0.5f
}.lparams(matchParent, dip(1)) {
topToBottom = R.id.anko_layout
startToStart = ConstraintSet.PARENT_ID
endToEnd = ConstraintSet.PARENT_ID
}
// view {
// backgroundColorResource = R.color.grey
// alpha = 0.5f
// }.lparams(matchParent, dip(1)) {
// topToBottom = R.id.anko_layout
// startToStart = ConstraintSet.PARENT_ID
// endToEnd = ConstraintSet.PARENT_ID
// }
}
}.view
}

override fun onDestroy() {
searchView.removeTextChangedListener(textWatcher)
textWatcher = null
super.onDestroy()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.suda.yzune.wakeupschedule.base_view

import android.graphics.Color
import android.graphics.Typeface
import android.os.Bundle
import android.util.TypedValue
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.res.ResourcesCompat
import androidx.recyclerview.widget.RecyclerView
import com.suda.yzune.wakeupschedule.R
import org.jetbrains.anko.*
import org.jetbrains.anko.constraint.layout.constraintLayout
import org.jetbrains.anko.recyclerview.v7.recyclerView
import org.jetbrains.anko.support.v4.UI

abstract class BaseListFragment : BaseFragment() {

protected lateinit var mRecyclerView: RecyclerView

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return UI {

constraintLayout {
mRecyclerView = recyclerView {
overScrollMode = View.OVER_SCROLL_NEVER
}.lparams(matchParent, matchParent) {
topToTop = ConstraintSet.PARENT_ID
bottomToTop = ConstraintSet.PARENT_ID
startToStart = ConstraintSet.PARENT_ID
endToEnd = ConstraintSet.PARENT_ID
}
}
}.view
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ abstract class BaseTitleActivity : BaseActivity() {
open fun createTitleBar(): View {
return UI {
verticalLayout {
backgroundColorResource = R.color.backgroundColor
backgroundColor = colorAttr(R.attr.colorSurface)
linearLayout {
topPadding = getStatusBarHeight()
backgroundColor = Color.WHITE
backgroundColor = colorAttr(R.attr.colorSurface)
val outValue = TypedValue()
context.theme.resolveAttribute(R.attr.selectableItemBackgroundBorderless, outValue, true)

imageButton(R.drawable.ic_back) {
backgroundResource = outValue.resourceId
padding = dip(8)
setColorFilter(colorAttr(R.attr.colorOnBackground))
setOnClickListener {
onBackPressed()
}
Expand All @@ -65,10 +66,10 @@ abstract class BaseTitleActivity : BaseActivity() {

}

view {
backgroundColorResource = R.color.grey
alpha = 0.5f
}.lparams(wrapContent, dip(1))
// view {
// backgroundColorResource = R.color.grey
// alpha = 0.5f
// }.lparams(wrapContent, dip(1))
}
}.view
}
Expand Down
Loading