diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9a0ba454..471873ad 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -17,7 +17,7 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
tools:targetApi="n">
-
+
@@ -33,7 +33,9 @@
android:windowSoftInputMode="adjustPan">
+
+
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/App.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/App.kt
index bb9dc9a7..03fe4760 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/App.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/App.kt
@@ -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) {
@@ -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)
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/apply_info/ApplyInfoAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/apply_info/ApplyInfoAdapter.kt
index 6a95116f..b892b3a4 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/apply_info/ApplyInfoAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/apply_info/ApplyInfoAdapter.kt
@@ -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) :
- BaseItemDraggableAdapter(layoutResId, data) {
+ BaseQuickAdapter(layoutResId, data) {
override fun convert(helper: BaseViewHolder, item: HtmlCountBean) {
helper.setText(R.id.tv_school, item.school)
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseActivity.kt
index 6a819cee..9863674c 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseActivity.kt
@@ -1,6 +1,6 @@
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
@@ -8,13 +8,10 @@ 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
@@ -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 -> {
@@ -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)
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseBlurTitleActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseBlurTitleActivity.kt
index a42ace9a..71d73ba0 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseBlurTitleActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseBlurTitleActivity.kt
@@ -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() {
@@ -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
@@ -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()
}
@@ -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
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseListActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseListActivity.kt
index 0901db13..44e1fc94 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseListActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseListActivity.kt
@@ -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
@@ -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) {
@@ -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()
}
@@ -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()
+ }
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseListFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseListFragment.kt
new file mode 100644
index 00000000..0527d7c6
--- /dev/null
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseListFragment.kt
@@ -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
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseTitleActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseTitleActivity.kt
index ab9a0411..58318db8 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseTitleActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/base_view/BaseTitleActivity.kt
@@ -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()
}
@@ -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
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseActivity.kt
index bd5d2eed..5aac7dfa 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseActivity.kt
@@ -3,6 +3,7 @@ package com.suda.yzune.wakeupschedule.course_add
import android.animation.ArgbEvaluator
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
+import android.app.Dialog
import android.appwidget.AppWidgetManager
import android.graphics.Color
import android.graphics.Typeface
@@ -25,6 +26,7 @@ import com.suda.yzune.wakeupschedule.base_view.BaseListActivity
import com.suda.yzune.wakeupschedule.bean.CourseBaseBean
import com.suda.yzune.wakeupschedule.bean.CourseEditBean
import com.suda.yzune.wakeupschedule.utils.CourseUtils
+import com.suda.yzune.wakeupschedule.widget.EditDetailFragment
import com.suda.yzune.wakeupschedule.widget.colorpicker.ColorPickerFragment
import es.dmoral.toasty.Toasty
import kotlinx.coroutines.Dispatchers
@@ -89,7 +91,7 @@ class AddCourseActivity : BaseListActivity(), ColorPickerFragment.ColorPickerDia
viewModel.tableId = intent.extras!!.getInt("tableId")
viewModel.maxWeek = intent.extras!!.getInt("maxWeek")
viewModel.nodes = intent.extras!!.getInt("nodes")
- initAdapter(AddCourseAdapter(R.layout.item_add_course_detail, viewModel.initData(viewModel.maxWeek)), viewModel.initBaseData())
+ initAdapter(AddCourseAdapter(R.layout.item_add_course_detail, viewModel.initData(viewModel.maxWeek)), viewModel.baseBean)
} else {
viewModel.tableId = intent.extras!!.getInt("tableId")
viewModel.maxWeek = intent.extras!!.getInt("maxWeek")
@@ -161,6 +163,56 @@ class AddCourseActivity : BaseListActivity(), ColorPickerFragment.ColorPickerDia
selectWeekDialog.isCancelable = false
selectWeekDialog.show(supportFragmentManager, "selectWeek")
}
+ R.id.ll_teacher -> {
+ launch {
+ val textView = adapter.getViewByPosition(mRecyclerView, position + 1, R.id.et_teacher) as TextView
+ if (viewModel.teacherList == null) {
+ viewModel.teacherList = viewModel.getExistedTeachers()
+ }
+ EditDetailFragment.newInstance("授课老师", viewModel.teacherList!!, viewModel.editList[position].teacher
+ ?: "").apply {
+ listener = object : EditDetailFragment.OnSaveClickedListener {
+ override fun save(editText: EditText, dialog: Dialog) {
+ val teacher = editText.text.toString()
+ textView.text = teacher
+ viewModel.editList[position].teacher = teacher
+ val flag = viewModel.teacherList!!.any {
+ it == teacher
+ }
+ if (!flag) {
+ viewModel.teacherList!!.add(teacher)
+ }
+ dialog.dismiss()
+ }
+ }
+ }.show(supportFragmentManager, null)
+ }
+ }
+ R.id.ll_room -> {
+ launch {
+ val textView = adapter.getViewByPosition(mRecyclerView, position + 1, R.id.et_room) as TextView
+ if (viewModel.roomList == null) {
+ viewModel.roomList = viewModel.getExistedRooms()
+ }
+ EditDetailFragment.newInstance("上课地点", viewModel.roomList!!, viewModel.editList[position].room
+ ?: "").apply {
+ listener = object : EditDetailFragment.OnSaveClickedListener {
+ override fun save(editText: EditText, dialog: Dialog) {
+ val room = editText.text.toString()
+ textView.text = room
+ viewModel.editList[position].room = room
+ val flag = viewModel.roomList!!.any {
+ it == room
+ }
+ if (!flag) {
+ viewModel.roomList!!.add(room)
+ }
+ dialog.dismiss()
+ }
+ }
+ }.show(supportFragmentManager, null)
+ }
+ }
}
}
mRecyclerView.adapter = adapter
@@ -227,17 +279,31 @@ class AddCourseActivity : BaseListActivity(), ColorPickerFragment.ColorPickerDia
colorAnim.start()
}
tvBtn.setOnClickListener {
- adapter.addData(CourseEditBean(
- teacher = viewModel.editList[0].teacher,
- room = viewModel.editList[0].room,
- tableId = viewModel.tableId,
- weekList = MutableLiveData>().apply {
- this.value = ArrayList().apply {
- for (i in 1..viewModel.maxWeek) {
- this.add(i)
+ if (viewModel.editList.isEmpty()) {
+ adapter.addData(CourseEditBean(
+ teacher = "",
+ room = "",
+ tableId = viewModel.tableId,
+ weekList = MutableLiveData>().apply {
+ this.value = ArrayList().apply {
+ for (i in 1..viewModel.maxWeek) {
+ this.add(i)
+ }
}
- }
- }))
+ }))
+ } else {
+ adapter.addData(CourseEditBean(
+ teacher = viewModel.editList[0].teacher,
+ room = viewModel.editList[0].room,
+ tableId = viewModel.tableId,
+ weekList = MutableLiveData>().apply {
+ this.value = ArrayList().apply {
+ for (i in 1..viewModel.maxWeek) {
+ this.add(i)
+ }
+ }
+ }))
+ }
}
return view
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseAdapter.kt
index ff3f36be..5561d98f 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseAdapter.kt
@@ -3,14 +3,14 @@ package com.suda.yzune.wakeupschedule.course_add
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
-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.CourseEditBean
import com.suda.yzune.wakeupschedule.utils.CourseUtils
class AddCourseAdapter(layoutResId: Int, data: MutableList) :
- BaseItemDraggableAdapter(layoutResId, data) {
+ BaseQuickAdapter(layoutResId, data) {
private var mListener: OnItemEditTextChangedListener? = null
@@ -31,35 +31,8 @@ class AddCourseAdapter(layoutResId: Int, data: MutableList) :
helper.addOnClickListener(R.id.ib_delete)
helper.addOnClickListener(R.id.ll_weeks)
helper.addOnClickListener(R.id.ll_time)
- val etRoom = helper.getView(R.id.et_room)
- val etTeacher = helper.getView(R.id.et_teacher)
- etRoom.addTextChangedListener(object : TextWatcher {
- override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
-
- }
-
- override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
-
- }
-
- override fun afterTextChanged(s: Editable) {
- mListener?.onEditTextAfterTextChanged(s, helper.layoutPosition - 1, "room")
- }
- })
-
- etTeacher.addTextChangedListener(object : TextWatcher {
- override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
-
- }
-
- override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
-
- }
-
- override fun afterTextChanged(s: Editable) {
- mListener?.onEditTextAfterTextChanged(s, helper.layoutPosition - 1, "teacher")
- }
- })
+ helper.addOnClickListener(R.id.ll_teacher)
+ helper.addOnClickListener(R.id.ll_room)
}
interface OnItemEditTextChangedListener {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseViewModel.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseViewModel.kt
index 615830b2..9388f0ce 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseViewModel.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/AddCourseViewModel.kt
@@ -13,8 +13,13 @@ import com.suda.yzune.wakeupschedule.utils.ViewUtils
class AddCourseViewModel(application: Application) : AndroidViewModel(application) {
- lateinit var editList: MutableList
- lateinit var baseBean: CourseBaseBean
+ val editList = mutableListOf()
+ val baseBean: CourseBaseBean by lazy {
+ CourseBaseBean(-1, "", "", tableId)
+ }
+
+ var teacherList: ArrayList? = null
+ var roomList: ArrayList? = null
private val dataBase = AppDatabase.getDatabase(application)
private val baseDao = dataBase.courseBaseDao()
@@ -93,7 +98,7 @@ class AddCourseViewModel(application: Application) : AndroidViewModel(applicatio
}
fun initData(maxWeek: Int): MutableList {
- editList = mutableListOf(CourseEditBean(
+ editList.add(CourseEditBean(
tableId = tableId,
weekList = MutableLiveData>().apply {
this.value = ArrayList().apply {
@@ -106,7 +111,6 @@ class AddCourseViewModel(application: Application) : AndroidViewModel(applicatio
}
suspend fun initData(id: Int, tableId: Int): List {
- editList = mutableListOf()
return detailDao.getDetailByIdOfTableInThread(id, tableId)
}
@@ -114,17 +118,19 @@ class AddCourseViewModel(application: Application) : AndroidViewModel(applicatio
return baseDao.getLastIdOfTableInThread(tableId)
}
- fun initBaseData(): CourseBaseBean {
- baseBean = CourseBaseBean(-1, "", "", tableId)
- return baseBean
- }
-
suspend fun initBaseData(id: Int): CourseBaseBean {
- baseBean = CourseBaseBean(-1, "", "", tableId)
return baseDao.getCourseByIdOfTableInThread(id, tableId)
}
suspend fun getScheduleWidgetIds(): List {
return widgetDao.getWidgetsByBaseTypeInThread(0)
}
+
+ suspend fun getExistedTeachers(): ArrayList {
+ return ArrayList(detailDao.getExistedTeachers(tableId))
+ }
+
+ suspend fun getExistedRooms(): ArrayList {
+ return ArrayList(detailDao.getExistedRooms(tableId))
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectTimeFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectTimeFragment.kt
index a81a2081..2cb7d8ae 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectTimeFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectTimeFragment.kt
@@ -15,8 +15,8 @@ class SelectTimeFragment : BaseDialogFragment() {
get() = R.layout.fragment_select_time
var position = -1
- private val dayList = listOf("周一", "周二", "周三", "周四", "周五", "周六", "周日")
- private val nodeList = arrayListOf()
+ private val dayList = arrayOf("周一", "周二", "周三", "周四", "周五", "周六", "周日")
+ private val nodeList = arrayOfNulls(30)
private lateinit var viewModel: AddCourseViewModel
private lateinit var course: CourseEditBean
var day = 1
@@ -33,10 +33,10 @@ class SelectTimeFragment : BaseDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- initNodeList(viewModel.nodes)
- wp_day.data = dayList
- wp_start.data = nodeList
- wp_end.data = nodeList
+ initNodeList()
+ wp_day.displayedValues = dayList
+ wp_start.displayedValues = nodeList
+ wp_end.displayedValues = nodeList
course = viewModel.editList[position]
day = course.time.value!!.day
start = if (course.time.value!!.startNode > viewModel.nodes) viewModel.nodes else course.time.value!!.startNode
@@ -44,31 +44,41 @@ class SelectTimeFragment : BaseDialogFragment() {
initEvent()
}
- private fun initNodeList(max: Int) {
- for (i in 1..max) {
- nodeList.add("第 $i 节")
+ private fun initNodeList() {
+ for (i in 1..30) {
+ nodeList[i - 1] = "第 $i 节"
}
}
private fun initEvent() {
- wp_day.selectedItemPosition = day - 1
- wp_start.selectedItemPosition = start - 1
- wp_end.selectedItemPosition = end - 1
+ wp_day.minValue = 0
+ wp_day.maxValue = dayList.size - 1
+ wp_day.value = day - 1
- wp_day.setOnItemSelectedListener { _, _, position ->
- day = position + 1
+ wp_start.minValue = 0
+ wp_start.maxValue = viewModel.nodes - 1
+ wp_start.value = start - 1
+
+ wp_end.minValue = 0
+ wp_end.maxValue = viewModel.nodes - 1
+ wp_end.value = end - 1
+
+ wp_day.setOnValueChangedListener { _, _, newVal ->
+ day = newVal + 1
}
- wp_start.setOnItemSelectedListener { _, _, position ->
- start = position + 1
+
+ wp_start.setOnValueChangedListener { _, _, newVal ->
+ start = newVal + 1
if (end < start) {
- wp_end.selectedItemPosition = start - 1
+ wp_end.smoothScrollToValue(start - 1, false)
end = start
}
}
- wp_end.setOnItemSelectedListener { _, _, position ->
- end = position + 1
+
+ wp_end.setOnValueChangedListener { _, _, newVal ->
+ end = newVal + 1
if (end < start) {
- wp_end.selectedItemPosition = start - 1
+ wp_end.smoothScrollToValue(start - 1, false)
end = start
}
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectWeekAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectWeekAdapter.kt
index f8bb1b48..4fbc6907 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectWeekAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectWeekAdapter.kt
@@ -5,6 +5,8 @@ import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.suda.yzune.wakeupschedule.R
+import org.jetbrains.anko.colorAttr
+import org.jetbrains.anko.textColor
class SelectWeekAdapter(layoutResId: Int, max: Int, private val intData: List) :
BaseQuickAdapter(layoutResId, (1..max).toList()) {
@@ -15,8 +17,9 @@ class SelectWeekAdapter(layoutResId: Int, max: Int, private val intData: List(R.id.tv_num).background = null
+ val v = helper.getView(R.id.tv_num)
+ v.setTextColor(v.colorAttr(R.attr.colorOnSurface))
+ v.background = null
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectWeekFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectWeekFragment.kt
index 265f3fdd..aadc73dc 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectWeekFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/course_add/SelectWeekFragment.kt
@@ -19,6 +19,7 @@ import com.suda.yzune.wakeupschedule.widget.SelectedRecyclerView
import es.dmoral.toasty.Toasty
import kotlinx.android.synthetic.main.fragment_select_week.*
import org.jetbrains.anko.backgroundResource
+import org.jetbrains.anko.colorAttr
import org.jetbrains.anko.support.v4.dip
import org.jetbrains.anko.textColor
@@ -31,6 +32,7 @@ class SelectWeekFragment : BaseDialogFragment() {
private lateinit var viewModel: AddCourseViewModel
private val liveData = MutableLiveData>()
private val result = ArrayList()
+ private var colorSurface: Int = Color.BLACK
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -38,13 +40,14 @@ class SelectWeekFragment : BaseDialogFragment() {
position = it.getInt("position")
}
viewModel = ViewModelProviders.of(activity!!).get(AddCourseViewModel::class.java)
+ colorSurface = context!!.colorAttr(R.attr.colorOnSurface)
liveData.observe(this, Observer {
if (it?.size == viewModel.maxWeek) {
tv_all.setTextColor(Color.WHITE)
tv_all.background = ContextCompat.getDrawable(context!!, R.drawable.select_textview_bg)
}
if (it?.size != viewModel.maxWeek) {
- tv_all.setTextColor(Color.BLACK)
+ tv_all.setTextColor(colorSurface)
tv_all.background = null
}
val flag = viewModel.judgeType(it!!)
@@ -53,7 +56,7 @@ class SelectWeekFragment : BaseDialogFragment() {
tv_type1.background = ContextCompat.getDrawable(context!!, R.drawable.select_textview_bg)
}
if (flag != 1) {
- tv_type1.setTextColor(Color.BLACK)
+ tv_type1.setTextColor(colorSurface)
tv_type1.background = null
}
if (flag == 2) {
@@ -61,7 +64,7 @@ class SelectWeekFragment : BaseDialogFragment() {
tv_type2.background = ContextCompat.getDrawable(context!!, R.drawable.select_textview_bg)
}
if (flag != 2) {
- tv_type2.setTextColor(Color.BLACK)
+ tv_type2.setTextColor(colorSurface)
tv_type2.background = null
}
})
@@ -94,7 +97,7 @@ class SelectWeekFragment : BaseDialogFragment() {
result.remove(pos + 1)
adapter.getViewByPosition(pos, R.id.tv_num)?.background = null
(adapter.getViewByPosition(pos, R.id.tv_num) as TextView).textColor =
- Color.BLACK
+ colorSurface
}
liveData.value = result
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/dao/CourseDetailDao.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/dao/CourseDetailDao.kt
index a2f38b05..aee331c3 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/dao/CourseDetailDao.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/dao/CourseDetailDao.kt
@@ -30,4 +30,10 @@ interface CourseDetailDao {
@Query("select * from coursedetailbean where id = :id and day = :day and startNode = :startNode and startWeek = :startWeek and type = :type and tableId = :tableId")
fun getDetailByKeys(id: Int, day: Int, startNode: Int, startWeek: Int, type: Int, tableId: Int): List
+
+ @Query("select distinct teacher from coursedetailbean where tableId = :tableId order by length(teacher)")
+ suspend fun getExistedTeachers(tableId: Int) : List
+
+ @Query("select distinct room from coursedetailbean where tableId = :tableId order by length(room)")
+ suspend fun getExistedRooms(tableId: Int): List
}
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/dao/TableDao.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/dao/TableDao.kt
index 7b4b52ff..2ab76c8b 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/dao/TableDao.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/dao/TableDao.kt
@@ -29,7 +29,7 @@ interface TableDao {
fun setNewDefaultTable(newId: Int)
@Query("select * from tablebean where id = :tableId")
- fun getTableByIdInThread(tableId: Int): TableBean
+ fun getTableByIdInThread(tableId: Int): TableBean?
@Query("select * from tablebean where id = :tableId")
fun getTableById(tableId: Int): LiveData
@@ -40,12 +40,18 @@ interface TableDao {
@Query("select id from tablebean where type = 1")
fun getDefaultTableId(): LiveData
+ @Query("select id from tablebean where type = 1")
+ fun getDefaultTableIdInThread(): Int
+
@Query("select * from tablebean where type = 1")
fun getDefaultTableInThread(): TableBean
@Query("select id, tableName, background, maxWeek, nodes, type from tablebean")
fun getTableSelectList(): LiveData>
+ @Query("select id, tableName, background, maxWeek, nodes, type from tablebean")
+ fun getTableSelectListInThread(): List
+
@Query("delete from tablebean where id = :id")
fun deleteTable(id: Int)
}
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/intro/IntroYoungActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/intro/IntroYoungActivity.kt
index 7af26048..74596538 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/intro/IntroYoungActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/intro/IntroYoungActivity.kt
@@ -2,8 +2,8 @@ package com.suda.yzune.wakeupschedule.intro
import android.os.Bundle
import android.widget.TextView
+import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
-import com.suda.yzune.wakeupschedule.GlideApp
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.base_view.BaseBlurTitleActivity
import com.suda.yzune.wakeupschedule.utils.CourseUtils
@@ -19,7 +19,7 @@ class IntroYoungActivity : BaseBlurTitleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- GlideApp.with(this)
+ Glide.with(this)
.load("https://ws1.sinaimg.cn/large/006tNbRwgy1fxto1a67fej305c05cwen.jpg")
.error(R.drawable.net_work_error)
.transition(DrawableTransitionOptions.withCrossFade())
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/main/MainFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/main/MainFragment.kt
index 1f3f7b22..eabca352 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/main/MainFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/main/MainFragment.kt
@@ -310,7 +310,7 @@ class MainFragment : BaseFragment() {
}
}
- val textView = TipTextView(context!!)
+ val textView = TipTextView(table.courseTextColor, table.itemTextSize, context!!)
val lp = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
@@ -332,10 +332,11 @@ class MainFragment : BaseFragment() {
}
textView.layoutParams = lp
- textView.textSize = table.itemTextSize.toFloat()
- textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
- textView.setPadding(dip(4), dip(4), dip(4), dip(4))
- textView.setTextColor(table.courseTextColor)
+ textView.padding = dip(4)
+// textView.textSize = table.itemTextSize.toFloat()
+// textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
+// textView.setPadding(dip(4), dip(4), dip(4), dip(4))
+// textView.setTextColor(table.courseTextColor)
textView.background = ContextCompat.getDrawable(activity!!.applicationContext, R.drawable.course_item_bg)
val myGrad = textView.background as GradientDrawable
@@ -431,7 +432,7 @@ class MainFragment : BaseFragment() {
if (table.showTime && viewModel.timeList.isNotEmpty()) {
strBuilder.insert(0, viewModel.timeList[c.startNode - 1].startTime + "\n")
}
- textView.text = strBuilder
+ textView.text = strBuilder.toString()
textView.setOnClickListener {
try {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/AfterImportTipFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/AfterImportTipFragment.kt
index 9a915a86..ab4305e7 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/AfterImportTipFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/AfterImportTipFragment.kt
@@ -5,11 +5,11 @@ import android.view.View
import androidx.fragment.app.BaseDialogFragment
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.utils.ViewUtils
-import kotlinx.android.synthetic.main.fragment_after_import_tip.*
+import kotlinx.android.synthetic.main.fragment_tip.*
class AfterImportTipFragment : BaseDialogFragment() {
override val layoutId: Int
- get() = R.layout.fragment_after_import_tip
+ get() = R.layout.fragment_tip
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
isCancelable = false
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/CourseDetailFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/CourseDetailFragment.kt
index d0864c4a..32adfb1a 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/CourseDetailFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/CourseDetailFragment.kt
@@ -27,7 +27,7 @@ import org.jetbrains.anko.find
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.support.v4.dip
-class CourseDetailFragment : BaseDialogFragment(), CoroutineScope {
+class CourseDetailFragment : BaseDialogFragment() {
override val layoutId: Int
get() = R.layout.fragment_course_detail
@@ -76,25 +76,13 @@ class CourseDetailFragment : BaseDialogFragment(), CoroutineScope {
}
private fun initView() {
- tv_item.setTextColor(Color.BLACK)
tv_item.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
- et_weeks.setTextColor(Color.BLACK)
- et_time.setTextColor(Color.BLACK)
- et_teacher.setTextColor(Color.BLACK)
- et_room.setTextColor(Color.BLACK)
-
- et_teacher.isEnabled = false
- et_teacher.isFocusable = false
- et_teacher.isFocusableInTouchMode = false
- et_room.isEnabled = false
- et_room.isFocusable = false
- et_room.isFocusableInTouchMode = false
}
private fun showData() {
tv_item.text = course.courseName
- et_teacher.setText(course.teacher)
- et_room.setText(course.room)
+ et_teacher.text = course.teacher
+ et_room.text = course.room
val type = when (course.type) {
1 -> "单周"
2 -> "双周"
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/DonateFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/DonateFragment.kt
index 2655c21a..9686ebfa 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/DonateFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/DonateFragment.kt
@@ -37,6 +37,17 @@ class DonateFragment : BaseDialogFragment() {
dismiss()
}
+ tv_weibo.setOnClickListener {
+ try {
+ val intent = Intent(Intent.ACTION_VIEW)
+ intent.addCategory("android.intent.category.DEFAULT")
+ intent.data = Uri.parse("sinaweibo://userinfo?uid=6970231444")
+ activity!!.startActivity(intent)
+ } catch (e: Exception) {
+ Toasty.info(context!!.applicationContext, "没有检测到微博客户端o(╥﹏╥)o").show()
+ }
+ }
+
tv_star.setOnClickListener {
try {
val uri = Uri.parse("market://details?id=com.suda.yzune.wakeupschedule")
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ExportSettingsFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ExportSettingsFragment.kt
index 285cd887..1c0bfad8 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ExportSettingsFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ExportSettingsFragment.kt
@@ -1,8 +1,10 @@
package com.suda.yzune.wakeupschedule.schedule
+import android.content.Intent
import android.os.Bundle
import android.os.Environment
import android.view.View
+import androidx.core.app.ShareCompat
import androidx.fragment.app.BaseDialogFragment
import androidx.lifecycle.ViewModelProviders
import com.suda.yzune.wakeupschedule.R
@@ -64,12 +66,19 @@ class ExportSettingsFragment : BaseDialogFragment() {
}
}
if (task != null) {
- Share2.Builder(activity)
- .setContentType(ShareContentType.FILE)
- .setShareFileUri(FileUtil.getFileUri(activity, null, File(task)))
- .setTitle("导出并分享课程文件")
- .build()
- .shareBySystem()
+ val shareIntent = ShareCompat.IntentBuilder.from(activity)
+ .setChooserTitle("导出并分享课程文件")
+ .setStream(FileUtil.getFileUri(activity, null, File(task)))
+ .setType("*/*")
+ .createChooserIntent()
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ startActivity(shareIntent)
+// Share2.Builder(activity)
+// .setContentType(ShareContentType.FILE)
+// .setShareFileUri(FileUtil.getFileUri(activity, null, File(task)))
+// .setTitle("导出并分享课程文件")
+// .build()
+// .shareBySystem()
dismiss()
} else {
Toasty.error(activity!!.applicationContext, "出现异常>_<").show()
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ImportChooseFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ImportChooseFragment.kt
index 6308652e..6a78f21f 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ImportChooseFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ImportChooseFragment.kt
@@ -4,6 +4,7 @@ import android.Manifest
import android.content.pm.PackageManager
import android.os.Bundle
import android.view.View
+import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.BaseDialogFragment
@@ -11,6 +12,7 @@ import androidx.lifecycle.ViewModelProviders
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.schedule_import.LoginWebActivity
import com.suda.yzune.wakeupschedule.schedule_import.SchoolListActivity
+import com.suda.yzune.wakeupschedule.schedule_import.SchoolListBean
import kotlinx.android.synthetic.main.fragment_import_choose.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
@@ -21,6 +23,7 @@ class ImportChooseFragment : BaseDialogFragment() {
get() = R.layout.fragment_import_choose
private lateinit var viewModel: ScheduleViewModel
+ private lateinit var importSchool: SchoolListBean
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -29,6 +32,7 @@ class ImportChooseFragment : BaseDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
+ importSchool = viewModel.getImportSchoolBean()
initEvent()
}
@@ -67,21 +71,26 @@ class ImportChooseFragment : BaseDialogFragment() {
}
}
- tv_suda.setOnClickListener {
+ tv_school.text = "${importSchool.name}导入"
+ tv_school.setOnClickListener {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
activity!!.startActivityForResult(
32,
- "type" to "苏州大学",
- "tableId" to viewModel.table.id
+ "type" to importSchool.name,
+ "tableId" to viewModel.table.id,
+ "url" to importSchool.url
)
dismiss()
}
tv_more.setOnClickListener {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
activity!!.startActivityForResult(32)
dismiss()
}
tv_feedback.setOnClickListener {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
activity!!.startActivity("type" to "apply")
dismiss()
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleActivity.kt
index bb98ed03..c1426867 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleActivity.kt
@@ -6,7 +6,6 @@ import android.app.Dialog
import android.appwidget.AppWidgetManager
import android.content.Intent
import android.content.pm.PackageManager
-import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.os.Parcel
@@ -21,14 +20,11 @@ import androidx.core.content.ContextCompat
import androidx.core.view.GravityCompat
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
+import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
-import com.getkeepsafe.taptargetview.TapTarget
-import com.getkeepsafe.taptargetview.TapTargetSequence
import com.google.android.material.navigation.NavigationView
import com.google.gson.Gson
-import com.google.gson.JsonSyntaxException
import com.google.gson.reflect.TypeToken
-import com.suda.yzune.wakeupschedule.GlideApp
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.UpdateFragment
import com.suda.yzune.wakeupschedule.apply_info.ApplyInfoActivity
@@ -81,9 +77,8 @@ class ScheduleActivity : BaseActivity() {
private lateinit var drawerLayout: androidx.drawerlayout.widget.DrawerLayout
override fun onCreate(savedInstanceState: Bundle?) {
- viewModel = ViewModelProviders.of(this).get(ScheduleViewModel::class.java)
-
super.onCreate(savedInstanceState)
+ viewModel = ViewModelProviders.of(this).get(ScheduleViewModel::class.java)
if (PreferenceUtils.getBooleanFromSP(applicationContext, "hide_main_nav_bar", false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
}
@@ -153,7 +148,7 @@ class ScheduleActivity : BaseActivity() {
if (updateInfo.id > getVersionCode(this@ScheduleActivity.applicationContext)) {
UpdateFragment.newInstance(updateInfo).show(supportFragmentManager, "updateDialog")
}
- } catch (e: JsonSyntaxException) {
+ } catch (e: Exception) {
}
}
@@ -183,25 +178,27 @@ class ScheduleActivity : BaseActivity() {
if (viewModel.table.background != "") {
val x = (ViewUtils.getRealSize(this).x * 0.5).toInt()
val y = (ViewUtils.getRealSize(this).y * 0.5).toInt()
- GlideApp.with(this.applicationContext)
+ Glide.with(this)
.load(viewModel.table.background)
.override(x, y)
.transition(DrawableTransitionOptions.withCrossFade())
+ .error(R.drawable.main_background_2019)
.into(bgImageView)
- GlideApp.with(this.applicationContext)
+ Glide.with(this)
.load(viewModel.table.background)
.override((x * 0.8).toInt(), (y * 0.8).toInt())
.transition(DrawableTransitionOptions.withCrossFade())
+ .error(R.drawable.main_background_2019)
.into(navigationView.getHeaderView(0).find(R.id.iv_header))
} else {
val x = (ViewUtils.getRealSize(this).x * 0.5).toInt()
val y = (ViewUtils.getRealSize(this).y * 0.5).toInt()
- GlideApp.with(this.applicationContext)
+ Glide.with(this)
.load(R.drawable.main_background_2019)
.override(x, y)
.transition(DrawableTransitionOptions.withCrossFade())
.into(bgImageView)
- GlideApp.with(this.applicationContext)
+ Glide.with(this)
.load(R.drawable.main_background_2019)
.override((x * 0.8).toInt(), (y * 0.8).toInt())
.transition(DrawableTransitionOptions.withCrossFade())
@@ -270,7 +267,7 @@ class ScheduleActivity : BaseActivity() {
}
list.forEach {
when (it.detailType) {
- 0 -> AppWidgetUtils.refreshScheduleWidget(applicationContext, appWidgetManager, it.id, table)
+ // 0 -> AppWidgetUtils.refreshScheduleWidget(applicationContext, appWidgetManager, it.id, table)
1 -> AppWidgetUtils.refreshTodayWidget(applicationContext, appWidgetManager, it.id, table)
}
}
@@ -294,7 +291,7 @@ class ScheduleActivity : BaseActivity() {
}
override fun onFinish(editText: EditText, dialog: Dialog) {
- if (!editText.text.toString().isEmpty()) {
+ if (editText.text.toString().isNotEmpty()) {
launch {
val task = async(Dispatchers.IO) {
try {
@@ -327,91 +324,6 @@ class ScheduleActivity : BaseActivity() {
}
fun initIntro() {
- TapTargetSequence(this)
- .targets(
- TapTarget.forView(addImageButton, "这是手动添加课程的按钮", "新版本中添加课程变得友好很多哦,试试看\n点击白色区域告诉我你get到了")
- .outerCircleColor(R.color.red)
- .outerCircleAlpha(0.96f)
- .targetCircleColorInt(Color.WHITE)
- .titleTextSize(16)
- .titleTextColorInt(Color.WHITE)
- .descriptionTextSize(12)
- .textColorInt(Color.WHITE)
- .dimColorInt(Color.BLACK)
- .drawShadow(true)
- .cancelable(false)
- .tintTarget(true)
- .transparentTarget(false)
- .targetRadius(60),
- TapTarget.forView(importImageButton, "这是导入课程的按钮", "现在已经支持采用正方教务系统的学校的课程自动导入了!\n还有别人分享给你的文件也要从这里导入哦~\n点击白色区域告诉我你get到了")
- .outerCircleColor(R.color.lightBlue)
- .outerCircleAlpha(0.96f)
- .targetCircleColorInt(Color.WHITE)
- .titleTextSize(16)
- .titleTextColorInt(Color.WHITE)
- .descriptionTextSize(12)
- .textColorInt(Color.WHITE)
- .dimColorInt(Color.BLACK)
- .drawShadow(true)
- .cancelable(false)
- .tintTarget(true)
- .transparentTarget(false)
- .targetRadius(60),
- TapTarget.forView(shareImageButton, "点击此处可分享或导出", "可以导出成多种格式呢\n点击白色区域告诉我你get到了")
- .outerCircleColor(R.color.deepOrange)
- .outerCircleAlpha(0.96f)
- .targetCircleColorInt(Color.WHITE)
- .titleTextSize(16)
- .titleTextColorInt(Color.WHITE)
- .descriptionTextSize(12)
- .textColorInt(Color.WHITE)
- .dimColorInt(Color.BLACK)
- .drawShadow(true)
- .cancelable(false)
- .tintTarget(true)
- .transparentTarget(false)
- .targetRadius(60),
- TapTarget.forView(moreImageButton, "点这里发现更多", "比如可以分享课表给别人哦~\n多点去探索吧\n点击白色区域告诉我你get到了")
- .outerCircleColor(R.color.blue)
- .outerCircleAlpha(0.96f)
- .targetCircleColorInt(Color.WHITE)
- .titleTextSize(16)
- .titleTextColorInt(Color.WHITE)
- .descriptionTextSize(12)
- .textColorInt(Color.WHITE)
- .dimColorInt(Color.BLACK)
- .drawShadow(true)
- .cancelable(false)
- .tintTarget(true)
- .transparentTarget(false)
- .targetRadius(60),
- TapTarget.forView(weekdayTextView, "点击此处可快速回到当前周", "主界面左右滑动可以切换周数\n点击这里就可以快速回到当前周啦\n点击白色区域告诉我你get到了")
- .outerCircleColor(R.color.deepOrange)
- .outerCircleAlpha(0.96f)
- .targetCircleColorInt(Color.WHITE)
- .titleTextSize(16)
- .titleTextColorInt(Color.WHITE)
- .descriptionTextSize(12)
- .textColorInt(Color.WHITE)
- .dimColorInt(Color.BLACK)
- .drawShadow(true)
- .cancelable(false)
- .tintTarget(true)
- .transparentTarget(false)
- .targetRadius(60)
- ).listener(object : TapTargetSequence.Listener {
- override fun onSequenceCanceled(lastTarget: TapTarget?) {
-
- }
-
- override fun onSequenceFinish() {
- PreferenceUtils.saveBooleanToSP(this@ScheduleActivity.applicationContext, "has_intro", true)
- }
-
- override fun onSequenceStep(lastTarget: TapTarget?, targetClicked: Boolean) {
- }
-
- }).start()
}
override fun onStart() {
@@ -420,7 +332,6 @@ class ScheduleActivity : BaseActivity() {
}
private fun initNavView() {
- navigationView.itemIconTintList = null
navigationView.menu.findItem(R.id.nav_suda).isVisible = PreferenceUtils.getBooleanFromSP(this, "suda_life", true)
navigationView.setNavigationItemSelectedListener {
when (it.itemId) {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleActivityUI.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleActivityUI.kt
index 1d3d4a0a..01a84420 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleActivityUI.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleActivityUI.kt
@@ -9,6 +9,7 @@ import android.widget.ImageView
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import androidx.core.content.res.ResourcesCompat
import com.suda.yzune.wakeupschedule.R
+import com.suda.yzune.wakeupschedule.utils.ViewUtils
import org.jetbrains.anko.*
import org.jetbrains.anko.constraint.layout.constraintLayout
import org.jetbrains.anko.design.navigationView
@@ -160,17 +161,18 @@ class ScheduleActivityUI : AnkoComponent {
navigationView {
id = R.id.anko_nv
- backgroundColorResource = R.color.backgroundColor
+ backgroundColor = colorAttr(R.attr.colorSurface)
fitsSystemWindows = false
inflateHeaderView(R.layout.nav_header)
inflateMenu(R.menu.main_navigation_menu)
+ itemIconTintList = ViewUtils.createColorStateList(colorAttr(R.attr.colorOnBackground))
}.lparams(matchParent, matchParent) {
gravity = Gravity.START
}
navigationView {
id = R.id.anko_nv_end
- backgroundColorResource = R.color.backgroundColor
+ backgroundColor = colorAttr(R.attr.colorSurface)
fitsSystemWindows = false
recyclerView {
id = R.id.anko_rv_table_name
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleFragment.kt
index aad8c9c8..19147645 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleFragment.kt
@@ -1,7 +1,6 @@
package com.suda.yzune.wakeupschedule.schedule
import android.graphics.Color
-import android.graphics.Typeface
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.view.LayoutInflater
@@ -20,6 +19,7 @@ import com.suda.yzune.wakeupschedule.utils.CourseUtils
import com.suda.yzune.wakeupschedule.utils.ViewUtils
import com.suda.yzune.wakeupschedule.widget.TipTextView
import es.dmoral.toasty.Toasty
+import org.jetbrains.anko.padding
import org.jetbrains.anko.support.v4.dip
import org.jetbrains.anko.support.v4.find
import kotlin.math.roundToInt
@@ -72,20 +72,11 @@ class ScheduleFragment : BaseFragment() {
if (viewModel.table.sundayFirst) {
for (i in 0..6) {
textView = find(R.id.anko_tv_title0_1 + i)
- if (weekDay == 7 && i == 0) {
- textView.onShineEffect(viewModel.table.textColor)
- }
- if (weekDay == i) {
- textView.onShineEffect(viewModel.table.textColor)
- }
textView.text = viewModel.daysArray[i] + "\n${weekDate[i + 1]}"
}
} else {
for (i in 0..6) {
textView = find(R.id.anko_tv_title1 + i)
- if (i == weekDay - 1) {
- textView.onShineEffect(viewModel.table.textColor)
- }
textView.text = viewModel.daysArray[i + 1] + "\n${weekDate[i + 1]}"
}
}
@@ -127,10 +118,6 @@ class ScheduleFragment : BaseFragment() {
}
}
- private fun TextView.onShineEffect(colorInt: Int) {
- //this.setShadowLayer(12f, 0f, 0f, Color.WHITE)
- }
-
companion object {
@JvmStatic
fun newInstance(arg0: Int) =
@@ -166,11 +153,16 @@ class ScheduleFragment : BaseFragment() {
}
}
- val textView = TipTextView(context!!)
-
- if (day == weekDay) {
- textView.onShineEffect(viewModel.table.courseTextColor)
+ if (c.step <= 0) {
+ c.step = 1
+ Toasty.error(context!!, "检测到课程数据有误,请仔细核对").show()
}
+ if (c.startNode <= 0) {
+ c.startNode = 1
+ Toasty.error(context!!, "检测到课程数据有误,请仔细核对").show()
+ }
+
+ val textView = TipTextView(table.courseTextColor, table.itemTextSize, context!!)
val lp = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
@@ -192,10 +184,11 @@ class ScheduleFragment : BaseFragment() {
}
textView.layoutParams = lp
- textView.textSize = table.itemTextSize.toFloat()
- textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
- textView.setPadding(dip(4), dip(4), dip(4), dip(4))
- textView.setTextColor(table.courseTextColor)
+ textView.padding = dip(4)
+// textView.textSize = table.itemTextSize.toFloat()
+// textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
+// textView.setPadding(dip(4), dip(4), dip(4), dip(4))
+// textView.setTextColor(table.courseTextColor)
textView.background = ContextCompat.getDrawable(activity!!, R.drawable.course_item_bg)
val myGrad = textView.background as GradientDrawable
@@ -291,7 +284,7 @@ class ScheduleFragment : BaseFragment() {
if (table.showTime && viewModel.timeList.isNotEmpty()) {
strBuilder.insert(0, viewModel.timeList[c.startNode - 1].startTime + "\n")
}
- textView.text = strBuilder
+ textView.text = strBuilder.toString()
textView.setOnClickListener {
try {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/SchedulePagerAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/SchedulePagerAdapter.kt
index 83f95338..f831e290 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/SchedulePagerAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/SchedulePagerAdapter.kt
@@ -1,10 +1,12 @@
package com.suda.yzune.wakeupschedule.schedule
+import android.os.Bundle
+import android.os.Parcelable
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.viewpager.widget.PagerAdapter
-class SchedulePagerAdapter(var maxWeek: Int, manager: FragmentManager) : FragmentStatePagerAdapter(manager) {
+class SchedulePagerAdapter(var maxWeek: Int, manager: FragmentManager) : FragmentStatePagerAdapter(manager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
override fun getItem(position: Int): ScheduleFragment {
return ScheduleFragment.newInstance(position + 1)
@@ -17,4 +19,9 @@ class SchedulePagerAdapter(var maxWeek: Int, manager: FragmentManager) : Fragmen
override fun getItemPosition(`object`: Any): Int {
return PagerAdapter.POSITION_NONE
}
+
+ override fun saveState(): Parcelable? {
+ return null
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleViewModel.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleViewModel.kt
index fe85d3df..dab28763 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleViewModel.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/ScheduleViewModel.kt
@@ -1,26 +1,28 @@
package com.suda.yzune.wakeupschedule.schedule
import android.app.Application
+import android.util.Log
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.SavedStateHandle
+import biweekly.Biweekly
+import biweekly.ICalVersion
+import biweekly.ICalendar
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.suda.yzune.wakeupschedule.AppDatabase
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.bean.*
+import com.suda.yzune.wakeupschedule.schedule_import.SchoolListBean
import com.suda.yzune.wakeupschedule.utils.CourseUtils
import com.suda.yzune.wakeupschedule.utils.ICalUtils
import com.suda.yzune.wakeupschedule.utils.PreferenceUtils
-import net.fortuna.ical4j.data.CalendarOutputter
-import net.fortuna.ical4j.model.property.CalScale
-import net.fortuna.ical4j.model.property.ProdId
-import net.fortuna.ical4j.model.property.Version
import java.io.File
-import java.io.FileOutputStream
import java.text.SimpleDateFormat
import java.util.*
+
class ScheduleViewModel(application: Application) : AndroidViewModel(application) {
private val dataBase = AppDatabase.getDatabase(application)
@@ -46,6 +48,17 @@ class ScheduleViewModel(application: Application) : AndroidViewModel(application
return tableDao.getTableSelectList()
}
+ fun getImportSchoolBean(): SchoolListBean {
+ val json = PreferenceUtils.getStringFromSP(getApplication(), "import_school", null)
+ ?: return SchoolListBean("S", "苏州大学", "")
+ val gson = Gson()
+ return try {
+ gson.fromJson(json, object : TypeToken() {}.type)
+ } catch (e: Exception) {
+ SchoolListBean("S", "苏州大学", "")
+ }
+ }
+
fun getMultiCourse(week: Int, day: Int, startNode: Int): List {
return allCourseList[day - 1].value!!.filter {
it.inWeek(week) && it.startNode == startNode
@@ -166,13 +179,12 @@ class ScheduleViewModel(application: Application) : AndroidViewModel(application
if (!dir.exists()) {
dir.mkdir()
}
- var fos: FileOutputStream? = null
-
//val week = CourseUtils.countWeekForExport(table.startDate, table.sundayFirst)
- val calendar = net.fortuna.ical4j.model.Calendar()
- calendar.properties.add(ProdId("-//WakeUpSchedule //iCal4j 2.0//EN"))
- calendar.properties.add(Version.VERSION_2_0)
- calendar.properties.add(CalScale.GREGORIAN)
+ val ical = ICalendar()
+ ical.setProductId("-//YZune//WakeUpSchedule//EN")
+// calendar.properties.add(ProdId("-//WakeUpSchedule //iCal4j 2.0//EN"))
+// calendar.properties.add(Version.VERSION_2_0)
+// calendar.properties.add(CalScale.GREGORIAN)
val startTimeMap = ICalUtils.getClassTime(timeList, true)
val endTimeMap = ICalUtils.getClassTime(timeList, false)
val sdf = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)
@@ -180,25 +192,21 @@ class ScheduleViewModel(application: Application) : AndroidViewModel(application
allCourseList.forEach {
it.value?.forEach { course ->
try {
- val events = ICalUtils.getClassEvents(startTimeMap, endTimeMap, table.maxWeek, course, date)
- calendar.components.addAll(events)
+ ICalUtils.getClassEvents(ical, startTimeMap, endTimeMap, table.maxWeek, course, date)
} catch (ignored: Exception) {
}
}
}
- calendar.validate()
+ val warnings = ical.validate(ICalVersion.V2_0)
+ Log.d("日历", warnings.toString())
val tableName = if (table.tableName == "") {
"我的课表"
} else {
table.tableName
}
val file = File(myDir, "日历-$tableName.ics")
- fos = FileOutputStream(file)
- val calOut = CalendarOutputter()
- calOut.output(calendar, fos)
- fos.close()
-
+ Biweekly.write(ical).go(file)
return file.path
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/TableNameAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/TableNameAdapter.kt
index f5aa0da9..66fea6a9 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/TableNameAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule/TableNameAdapter.kt
@@ -1,16 +1,16 @@
package com.suda.yzune.wakeupschedule.schedule
import android.widget.ImageView
-import com.chad.library.adapter.base.BaseItemDraggableAdapter
+import com.bumptech.glide.Glide
+import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
-import com.suda.yzune.wakeupschedule.GlideApp
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.bean.TableSelectBean
import jp.wasabeef.glide.transformations.RoundedCornersTransformation
import org.jetbrains.anko.dip
class TableNameAdapter(layoutResId: Int, data: List) :
- BaseItemDraggableAdapter(layoutResId, data) {
+ BaseQuickAdapter(layoutResId, data) {
override fun convert(helper: BaseViewHolder, item: TableSelectBean) {
if (item.type == 1) {
@@ -26,13 +26,13 @@ class TableNameAdapter(layoutResId: Int, data: List) :
}
val imageView = helper.getView(R.id.iv_table_bg)
if (item.background != "") {
- GlideApp.with(mContext.applicationContext)
+ Glide.with(mContext)
.load(item.background)
.override(200, 300)
.transform(RoundedCornersTransformation(mContext.dip(4), 0, RoundedCornersTransformation.CornerType.ALL))
.into(imageView)
} else {
- GlideApp.with(mContext.applicationContext)
+ Glide.with(mContext)
.load(R.drawable.main_background_2019)
.override(200, 300)
.transform(RoundedCornersTransformation(mContext.dip(4), 0, RoundedCornersTransformation.CornerType.ALL))
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/ScheduleAppWidget.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/ScheduleAppWidget.kt
index 170a195e..8f44f071 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/ScheduleAppWidget.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/ScheduleAppWidget.kt
@@ -25,9 +25,19 @@ class ScheduleAppWidget : AppWidgetProvider() {
val widgetDao = dataBase.appWidgetDao()
val tableDao = dataBase.tableDao()
job = GlobalScope.launch(Dispatchers.IO) {
- val table = tableDao.getDefaultTableInThread()
for (appWidget in widgetDao.getWidgetsByTypesInThread(0, 0)) {
- AppWidgetUtils.refreshScheduleWidget(context, AppWidgetManager.getInstance(context), appWidget.id, table, true)
+ try {
+ val table = if (appWidget.info.isEmpty()) {
+ tableDao.getDefaultTableInThread()
+ } else {
+ tableDao.getTableByIdInThread(appWidget.info.toInt())
+ }
+ if (table != null) {
+ AppWidgetUtils.refreshScheduleWidget(context, AppWidgetManager.getInstance(context), appWidget.id, table, true)
+ }
+ } catch (ignore: Exception) {
+
+ }
}
job?.cancel()
}
@@ -37,9 +47,19 @@ class ScheduleAppWidget : AppWidgetProvider() {
val widgetDao = dataBase.appWidgetDao()
val tableDao = dataBase.tableDao()
job = GlobalScope.launch(Dispatchers.IO) {
- val table = tableDao.getDefaultTableInThread()
for (appWidget in widgetDao.getWidgetsByTypesInThread(0, 0)) {
- AppWidgetUtils.refreshScheduleWidget(context, AppWidgetManager.getInstance(context), appWidget.id, table)
+ try {
+ val table = if (appWidget.info.isEmpty()) {
+ tableDao.getDefaultTableInThread()
+ } else {
+ tableDao.getTableByIdInThread(appWidget.info.toInt())
+ }
+ if (table != null) {
+ AppWidgetUtils.refreshScheduleWidget(context, AppWidgetManager.getInstance(context), appWidget.id, table)
+ }
+ } catch (ignore: Exception) {
+
+ }
}
job?.cancel()
}
@@ -54,9 +74,19 @@ class ScheduleAppWidget : AppWidgetProvider() {
val widgetDao = dataBase.appWidgetDao()
val tableDao = dataBase.tableDao()
job = GlobalScope.launch(Dispatchers.IO) {
- val table = tableDao.getDefaultTableInThread()
for (appWidget in widgetDao.getWidgetsByTypesInThread(0, 0)) {
- AppWidgetUtils.refreshScheduleWidget(context, appWidgetManager, appWidget.id, table)
+ try {
+ val table = if (appWidget.info.isEmpty()) {
+ tableDao.getDefaultTableInThread()
+ } else {
+ tableDao.getTableByIdInThread(appWidget.info.toInt())
+ }
+ if (table != null) {
+ AppWidgetUtils.refreshScheduleWidget(context, AppWidgetManager.getInstance(context), appWidget.id, table)
+ }
+ } catch (ignore: Exception) {
+
+ }
}
job?.cancel()
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/ScheduleAppWidgetService.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/ScheduleAppWidgetService.kt
index dbc44579..8a30fbb7 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/ScheduleAppWidgetService.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/ScheduleAppWidgetService.kt
@@ -3,7 +3,6 @@ package com.suda.yzune.wakeupschedule.schedule_appwidget
import android.content.Context
import android.content.Intent
import android.graphics.Color
-import android.graphics.Typeface
import android.graphics.drawable.GradientDrawable
import android.view.View
import android.widget.*
@@ -18,25 +17,30 @@ import com.suda.yzune.wakeupschedule.utils.CourseUtils.countWeek
import com.suda.yzune.wakeupschedule.utils.ViewUtils
import com.suda.yzune.wakeupschedule.widget.TipTextView
import org.jetbrains.anko.dip
+import org.jetbrains.anko.padding
import java.text.ParseException
import kotlin.math.roundToInt
class ScheduleAppWidgetService : RemoteViewsService() {
override fun onGetViewFactory(intent: Intent?): RemoteViewsFactory {
- return if (intent != null) {
- val i = intent.data?.schemeSpecificPart?.toInt()
- return if (i == 1) {
- ScheduleRemoteViewsFactory(true)
+ if (intent != null) {
+ val list = intent.data?.schemeSpecificPart?.split(",")
+ ?: return ScheduleRemoteViewsFactory()
+ if (list.size < 2) {
+ return ScheduleRemoteViewsFactory(nextWeek = (list[0] == "1"))
+ }
+ return if (list[0] == "1") {
+ ScheduleRemoteViewsFactory(list[1].toInt(), true)
} else {
- ScheduleRemoteViewsFactory(false)
+ ScheduleRemoteViewsFactory(list[1].toInt(), false)
}
} else {
- ScheduleRemoteViewsFactory()
+ return ScheduleRemoteViewsFactory()
}
}
- private inner class ScheduleRemoteViewsFactory(val nextWeek: Boolean = false) : RemoteViewsFactory {
+ private inner class ScheduleRemoteViewsFactory(val tableId: Int = -1, val nextWeek: Boolean = false) : RemoteViewsFactory {
private lateinit var table: TableBean
private var week = 0
private var widgetItemHeight = 0
@@ -50,11 +54,19 @@ class ScheduleAppWidgetService : RemoteViewsService() {
private val weekDay = CourseUtils.getWeekdayInt()
override fun onCreate() {
- table = tableDao.getDefaultTableInThread()
+ table = if (tableId == -1) {
+ tableDao.getDefaultTableInThread()
+ } else {
+ tableDao.getTableByIdInThread(tableId) ?: tableDao.getDefaultTableInThread()
+ }
}
override fun onDataSetChanged() {
- table = tableDao.getDefaultTableInThread()
+ table = if (tableId == -1) {
+ tableDao.getDefaultTableInThread()
+ } else {
+ tableDao.getTableByIdInThread(tableId) ?: tableDao.getDefaultTableInThread()
+ }
widgetItemHeight = dip(table.widgetItemHeight)
marTop = resources.getDimensionPixelSize(R.dimen.weekItemMarTop)
val alphaInt = (255 * (table.widgetItemAlpha.toFloat() / 100)).roundToInt()
@@ -104,10 +116,6 @@ class ScheduleAppWidgetService : RemoteViewsService() {
return false
}
- private fun TextView.onShineEffect(colorInt: Int) {
- //this.setShadowLayer(24f, 0f, 0f, Color.WHITE)
- }
-
fun initView(view: View, weekPanel0: View) {
val weekPanel7 = view.findViewById(R.id.anko_ll_week_panel_7)
val weekPanel6 = view.findViewById(R.id.anko_ll_week_panel_6)
@@ -164,7 +172,8 @@ class ScheduleAppWidgetService : RemoteViewsService() {
initWeekPanel(weekPanel0, context, view, list, i)
}
val scrollView = view.findViewById(R.id.anko_sv_schedule)
- ViewUtils.layoutView(scrollView, dip(375), dip(375))
+ val info = ViewUtils.getScreenInfo(applicationContext)
+ ViewUtils.layoutView(scrollView, info[0], info[1])
views.setBitmap(R.id.iv_schedule, "setImageBitmap", ViewUtils.getViewBitmap(scrollView))
scrollView.removeAllViews()
weekPanel0.removeAllViews()
@@ -180,11 +189,7 @@ class ScheduleAppWidgetService : RemoteViewsService() {
for (i in data.indices) {
val strBuilder = StringBuilder()
val c = data[i]
- val tv = TipTextView(context)
-
- if (day == weekDay) {
- tv.onShineEffect(table.widgetCourseTextColor)
- }
+ val tv = TipTextView(table.widgetCourseTextColor, table.widgetItemTextSize, context)
val lp = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
@@ -196,11 +201,12 @@ class ScheduleAppWidgetService : RemoteViewsService() {
lp.setMargins(0, (c.startNode - 1) * (widgetItemHeight + marTop) + marTop, 0, 0)
}
tv.layoutParams = lp
+ tv.padding = dip(4)
//tv.gravity = Gravity.CENTER_VERTICAL
- tv.textSize = table.widgetItemTextSize.toFloat()
- tv.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
- tv.setPadding(8, 8, 8, 8)
- tv.setTextColor(table.widgetCourseTextColor)
+// tv.textSize = table.widgetItemTextSize.toFloat()
+// tv.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
+// tv.setPadding(8, 8, 8, 8)
+// tv.setTextColor(table.widgetCourseTextColor)
tv.background = ContextCompat.getDrawable(context.applicationContext, R.drawable.course_item_bg)
val myGrad = tv.background as GradientDrawable
@@ -288,7 +294,7 @@ class ScheduleAppWidgetService : RemoteViewsService() {
strBuilder.insert(0, timeList[c.startNode - 1].startTime + "\n")
}
- tv.text = strBuilder
+ tv.text = strBuilder.toString()
if (day == 7) {
if (table.sundayFirst) {
weekPanel0.addView(tv)
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WeekScheduleAppWidgetConfigActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WeekScheduleAppWidgetConfigActivity.kt
index cabb64b0..38918c1a 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WeekScheduleAppWidgetConfigActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WeekScheduleAppWidgetConfigActivity.kt
@@ -4,14 +4,18 @@ import android.app.Activity
import android.appwidget.AppWidgetManager
import android.content.Intent
import android.os.Bundle
+import android.view.View
import android.widget.TextView
import androidx.lifecycle.ViewModelProviders
+import androidx.recyclerview.widget.LinearLayoutManager
+import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
-import com.suda.yzune.wakeupschedule.GlideApp
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.base_view.BaseBlurTitleActivity
import com.suda.yzune.wakeupschedule.bean.AppWidgetBean
+import com.suda.yzune.wakeupschedule.bean.TableSelectBean
import com.suda.yzune.wakeupschedule.utils.AppWidgetUtils
+import es.dmoral.toasty.Toasty
import kotlinx.android.synthetic.main.activity_week_schedule_app_widget_config.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -29,6 +33,7 @@ class WeekScheduleAppWidgetConfigActivity : BaseBlurTitleActivity() {
private lateinit var viewModel: WeekScheduleAppWidgetConfigViewModel
private var mAppWidgetId = 0
+ private var isTodayType = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -42,45 +47,58 @@ class WeekScheduleAppWidgetConfigActivity : BaseBlurTitleActivity() {
AppWidgetManager.INVALID_APPWIDGET_ID)
}
- GlideApp.with(this)
- .load("https://ws2.sinaimg.cn/large/0069RVTdgy1fv5ypjuqs1j30u01hcdlt.jpg")
- .transition(DrawableTransitionOptions.withCrossFade())
- .into(iv_tip)
+ val appWidgetManager = AppWidgetManager.getInstance(applicationContext)
+ //Log.d("包名", appWidgetManager.getAppWidgetInfo(mAppWidgetId).provider.shortClassName)
+ val what = appWidgetManager.getAppWidgetInfo(mAppWidgetId).provider.shortClassName
+ isTodayType = (what == ".today_appwidget.TodayCourseAppWidget" || what == "com.suda.yzune.wakeupschedule.today_appwidget.TodayCourseAppWidget")
+ if (isTodayType) {
+ Glide.with(this)
+ .load("https://ws2.sinaimg.cn/large/0069RVTdgy1fv5ypjuqs1j30u01hcdlt.jpg")
+ .transition(DrawableTransitionOptions.withCrossFade())
+ .into(iv_tip)
+ } else {
+ tv_got_it.visibility = View.GONE
+ iv_tip.visibility = View.GONE
+ val list = ArrayList()
+ val adapter = WidgetTableListAdapter(R.layout.item_table_list, list)
+ adapter.setOnItemClickListener { _, _, position ->
+ launch {
+ val table = withContext(Dispatchers.IO) {
+ viewModel.insertWeekAppWidgetData(AppWidgetBean(mAppWidgetId, 0, 0, "${list[position].id}"))
+ viewModel.getTableById(list[position].id)
+ }
+ if (table == null) {
+ Toasty.error(applicationContext, "该课表读取错误>_<").show()
+ finish()
+ } else {
+ AppWidgetUtils.refreshScheduleWidget(applicationContext, appWidgetManager, mAppWidgetId, table)
+ val resultValue = Intent()
+ resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId)
+ setResult(Activity.RESULT_OK, resultValue)
+ finish()
+ }
+ }
+ }
+ adapter.bindToRecyclerView(rv_table_list)
+ rv_table_list.layoutManager = LinearLayoutManager(this)
+ launch {
+ list.clear()
+ list.addAll(withContext(Dispatchers.IO) {
+ viewModel.getTableList()
+ })
+ adapter.notifyDataSetChanged()
+ }
+ }
+
tv_got_it.setOnClickListener {
launch {
- val appWidgetManager = AppWidgetManager.getInstance(applicationContext)
//Log.d("包名", appWidgetManager.getAppWidgetInfo(mAppWidgetId).provider.shortClassName)
- when (appWidgetManager.getAppWidgetInfo(mAppWidgetId).provider.shortClassName) {
- ".schedule_appwidget.ScheduleAppWidget" -> {
- val table = withContext(Dispatchers.IO) {
- viewModel.insertWeekAppWidgetData(AppWidgetBean(mAppWidgetId, 0, 0, ""))
- viewModel.getDefaultTable()
- }
- AppWidgetUtils.refreshScheduleWidget(applicationContext, appWidgetManager, mAppWidgetId, table)
- }
- ".today_appwidget.TodayCourseAppWidget" -> {
- val table = withContext(Dispatchers.IO) {
- viewModel.insertWeekAppWidgetData(AppWidgetBean(mAppWidgetId, 0, 1, ""))
- viewModel.getDefaultTable()
- }
- AppWidgetUtils.refreshTodayWidget(applicationContext, appWidgetManager, mAppWidgetId, table)
- }
- "com.suda.yzune.wakeupschedule.schedule_appwidget.ScheduleAppWidget" -> {
- val table = withContext(Dispatchers.IO) {
- viewModel.insertWeekAppWidgetData(AppWidgetBean(mAppWidgetId, 0, 0, ""))
- viewModel.getDefaultTable()
- }
- AppWidgetUtils.refreshScheduleWidget(applicationContext, appWidgetManager, mAppWidgetId, table)
- }
- "com.suda.yzune.wakeupschedule.today_appwidget.TodayCourseAppWidget" -> {
- val table = withContext(Dispatchers.IO) {
- viewModel.insertWeekAppWidgetData(AppWidgetBean(mAppWidgetId, 0, 1, ""))
- viewModel.getDefaultTable()
- }
- AppWidgetUtils.refreshTodayWidget(applicationContext, appWidgetManager, mAppWidgetId, table)
- }
+ val table = withContext(Dispatchers.IO) {
+ viewModel.insertWeekAppWidgetData(AppWidgetBean(mAppWidgetId, 0, 1, ""))
+ viewModel.getDefaultTable()
}
+ AppWidgetUtils.refreshTodayWidget(applicationContext, appWidgetManager, mAppWidgetId, table)
val resultValue = Intent()
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId)
setResult(Activity.RESULT_OK, resultValue)
@@ -90,6 +108,11 @@ class WeekScheduleAppWidgetConfigActivity : BaseBlurTitleActivity() {
}
override fun onBackPressed() {
- ll_root.longSnackbar("请阅读文字后点击“我知道啦”")
+ ll_root.longSnackbar(
+ if (isTodayType) {
+ "请阅读文字后点击“我知道啦”"
+ } else {
+ "请从列表中选择需要放置的课表"
+ })
}
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WeekScheduleAppWidgetConfigViewModel.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WeekScheduleAppWidgetConfigViewModel.kt
index 3cb41006..c997c8fd 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WeekScheduleAppWidgetConfigViewModel.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WeekScheduleAppWidgetConfigViewModel.kt
@@ -5,6 +5,7 @@ import androidx.lifecycle.AndroidViewModel
import com.suda.yzune.wakeupschedule.AppDatabase
import com.suda.yzune.wakeupschedule.bean.AppWidgetBean
import com.suda.yzune.wakeupschedule.bean.TableBean
+import com.suda.yzune.wakeupschedule.bean.TableSelectBean
class WeekScheduleAppWidgetConfigViewModel(application: Application) : AndroidViewModel(application) {
private val dataBase = AppDatabase.getDatabase(application)
@@ -15,7 +16,15 @@ class WeekScheduleAppWidgetConfigViewModel(application: Application) : AndroidVi
return tableDao.getDefaultTableInThread()
}
+ suspend fun getTableById(id: Int): TableBean? {
+ return tableDao.getTableByIdInThread(id)
+ }
+
suspend fun insertWeekAppWidgetData(appWidget: AppWidgetBean) {
widgetDao.insertAppWidget(appWidget)
}
+
+ suspend fun getTableList(): List {
+ return tableDao.getTableSelectListInThread()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WidgetTableListAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WidgetTableListAdapter.kt
index 4b389571..2c96fdbd 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WidgetTableListAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_appwidget/WidgetTableListAdapter.kt
@@ -1,14 +1,14 @@
package com.suda.yzune.wakeupschedule.schedule_appwidget
import android.widget.ImageView
-import com.chad.library.adapter.base.BaseItemDraggableAdapter
+import com.bumptech.glide.Glide
+import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
-import com.suda.yzune.wakeupschedule.GlideApp
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.bean.TableSelectBean
class WidgetTableListAdapter(layoutResId: Int, data: List) :
- BaseItemDraggableAdapter(layoutResId, data) {
+ BaseQuickAdapter(layoutResId, data) {
override fun convert(helper: BaseViewHolder, item: TableSelectBean) {
helper.setVisible(R.id.ib_share, false)
@@ -22,12 +22,12 @@ class WidgetTableListAdapter(layoutResId: Int, data: List) :
}
val imageView = helper.getView(R.id.iv_pic)
if (item.background != "") {
- GlideApp.with(mContext.applicationContext)
+ Glide.with(mContext)
.load(item.background)
.override(400, 600)
.into(imageView)
} else {
- GlideApp.with(mContext.applicationContext)
+ Glide.with(mContext)
.load(R.drawable.main_background_2019)
.override(400, 600)
.into(imageView)
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ExcelImportFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ExcelImportFragment.kt
index c5da5af1..c2a5b091 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ExcelImportFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ExcelImportFragment.kt
@@ -7,7 +7,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModelProviders
import com.nbsp.materialfilepicker.MaterialFilePicker
-
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.base_view.BaseFragment
import com.suda.yzune.wakeupschedule.utils.CourseUtils
@@ -46,6 +45,11 @@ class ExcelImportFragment : BaseFragment() {
.withPath(basePath)
.withFilter(Pattern.compile(".*\\.xlsx$")) // Filtering files and directories by file name using regexp
.start()
+// val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
+// addCategory(Intent.CATEGORY_OPENABLE)
+// type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+// }
+// startActivityForResult(intent, 2)
}
ib_back.setOnClickListener {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/HUST/MobileHub.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/HUST/MobileHub.kt
index 0d677c9a..ac72fa94 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/HUST/MobileHub.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/HUST/MobileHub.kt
@@ -1,10 +1,9 @@
package com.suda.yzune.wakeupschedule.schedule_import.HUST
import okhttp3.*
-import java.lang.Exception
import java.math.BigInteger
-class MobileHub (private var user: String, private var password: String){
+class MobileHub(private var user: String, private var password: String) {
private val loginUrl = "https://pass.hust.edu.cn/cas/login?service=http%3A%2F%2Fhub.m.hust.edu.cn%2Fcj%2Findex.jsp"
private val getScheduleUrl = "http://hub.m.hust.edu.cn/kcb/todate/namecourse.action"
@@ -31,8 +30,8 @@ class MobileHub (private var user: String, private var password: String){
}
})
.build()
- private lateinit var modulus : String
- private lateinit var execution : String
+ private lateinit var modulus: String
+ private lateinit var execution: String
lateinit var courseHTML: String
@@ -57,7 +56,7 @@ class MobileHub (private var user: String, private var password: String){
execution = matchResult.groupValues.last()
}
- fun login() : Boolean{
+ fun login(): Boolean {
refreshSession()
val cipher = Cipher(HUST_RSA_EXPONENT, BigInteger(modulus, 16))
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/HtmlImportFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/HtmlImportFragment.kt
index 808735d4..3cc03aa3 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/HtmlImportFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/HtmlImportFragment.kt
@@ -189,6 +189,7 @@ class HtmlImportFragment : BaseFragment() {
3 -> viewModel.parseQZ(html, "青岛农业大学")
4 -> viewModel.parseQZ(html, "锦州医科大学")
5 -> viewModel.parseQZ(html, "山东科技大学")
+ 6 -> viewModel.parseQZ(html, "佛山科学技术学院")
else -> "没有贵校的信息哦>_<"
}
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ImportService.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ImportService.kt
index 869c8c7e..a28c6124 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ImportService.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ImportService.kt
@@ -10,7 +10,7 @@ interface ImportService {
@POST("/default2.aspx")
@FormUrlEncoded
- @Headers("Host: xk-old.suda.edu.cn", "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko")
+ @Headers("Host: xk.suda.edu.cn", "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko")
fun login(@Field("txtUserName") xh: String,
@Field("Textbox2") pwd: String,
@Field("txtSecretCode") code: String,
@@ -26,7 +26,7 @@ interface ImportService {
@POST("/")
@FormUrlEncoded
- @Headers("Host: xk-old.suda.edu.cn", "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko")
+ @Headers("Host: xk.suda.edu.cn", "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko")
fun login(@Field("TextBox1") xh: String,
@Field("TextBox2") pwd: String,
@Field("TextBox3") code: String,
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ImportViewModel.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ImportViewModel.kt
index 13f69eb3..42296209 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ImportViewModel.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/ImportViewModel.kt
@@ -18,7 +18,6 @@ import com.suda.yzune.wakeupschedule.utils.CourseUtils.intList2WeekBeanList
import com.suda.yzune.wakeupschedule.utils.CourseUtils.isContainName
import com.suda.yzune.wakeupschedule.utils.MyRetrofitUtils
import com.suda.yzune.wakeupschedule.utils.ViewUtils
-import kotlinx.coroutines.selects.select
import org.json.JSONArray
import org.json.JSONObject
import org.jsoup.Connection
@@ -29,14 +28,10 @@ import org.xmlpull.v1.XmlPullParser
import retrofit2.Retrofit
import java.io.*
import java.net.URLEncoder
-import java.text.SimpleDateFormat
-import java.util.*
import java.util.regex.Pattern
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipInputStream
-import kotlin.collections.ArrayList
-import kotlin.collections.HashMap
class ImportViewModel(application: Application) : AndroidViewModel(application) {
@@ -75,22 +70,22 @@ class ImportViewModel(application: Application) : AndroidViewModel(application)
val urpList = arrayOf("渤海大学", "烟台大学", "山西工程技术学院", "安徽财经大学", "河北工程大学", "中国农业大学",
"上海海洋大学", "齐鲁师范学院", "山西农业大学", "中国石油大学(北京)", "内蒙古科技大学", "湖南理工学院",
"内蒙古大学", "齐齐哈尔大学", "河南理工大学", "西南石油大学", "河北大学", "北京邮电大学", "东北财经大学",
- "天津工业大学", "山东农业大学", "河海大学", "URP 系统")
- val ZFSchoolList = arrayOf("渭南师范学院", "西安科技大学", "湖南城市学院", "武汉东湖学院", "沈阳师范大学", "厦门工学院", "北京联合大学", "浙江工业大学之江学院", "西安外事学院", "福建农林大学金山学院", "辽宁工业大学", "重庆邮电大学移通学院", "河南工程学院", "黑龙江外国语学院", "四川大学锦城学院", "郑州大学西亚斯国际学院", "安徽大学", "杭州医学院", "河北科技师范学院", "徐州幼儿师范高等专科学校", "海南师范大学", "华北电力大学科技学校", "山东师范大学", "广东海洋大学", "郑州航空工业管理学院", "河北经贸大学", "福建师范大学", "安徽工业大学", "潍坊学院", "大连工业大学艺术与信息工程学院", "华南农业大学", "大连大学", "成都理工大学工程技术学院", "云南财经大学", "重庆三峡学院", "杭州电子科技大学", "北京信息科技大学",
+ "天津工业大学", "河海大学", "URP 系统")
+ val ZFSchoolList = arrayOf("西安建筑科技大学", "湖南农业大学", "渭南师范学院", "西安科技大学", "湖南城市学院", "武汉东湖学院", "沈阳师范大学", "厦门工学院", "北京联合大学", "浙江工业大学之江学院", "西安外事学院", "福建农林大学金山学院", "辽宁工业大学", "重庆邮电大学移通学院", "河南工程学院", "黑龙江外国语学院", "四川大学锦城学院", "郑州大学西亚斯国际学院", "安徽大学", "杭州医学院", "河北科技师范学院", "徐州幼儿师范高等专科学校", "海南师范大学", "华北电力大学科技学校", "山东师范大学", "广东海洋大学", "郑州航空工业管理学院", "河北经贸大学", "福建师范大学", "安徽工业大学", "潍坊学院", "大连工业大学艺术与信息工程学院", "华南农业大学", "大连大学", "成都理工大学工程技术学院", "云南财经大学", "重庆三峡学院", "杭州电子科技大学", "北京信息科技大学",
"绍兴文理学院", "广东环境保护工程职业学院", "西华大学", "西安理工大学", "绍兴文理学院元培学院", "北京工业大学")
- val ZFSchoolList1 = arrayOf("华中农业大学", "茂名职业技术学院", "福建农林大学", "浙江万里学院", "重庆交通职业学院")
- val newZFSchoolList = arrayOf("常州机电职业技术学院", "保定学院", "河北环境工程学院", "安徽信息工程学院", "延安大学", "浙江财经大学", "中国医科大学", "苏州农业职业技术学院", "无锡太湖学院", "山东青年政治学院", "河南财经政法大学", "青岛科技大学", "三江学院", "西昌学院", "滨州医学院", "青岛滨海学院", "天津体育学院", "中国矿业大学徐海学院", "武昌首义学院", "四川轻化工大学", "安徽农业大学", "湖北工程学院新技术学院", "贺州学院", "河北政法职业学院", "浙江工商大学", "淮南师范学院", "广西大学", "湖北中医药大学", "南京城市职业学院", "北京化工大学", "信阳师范学院", "西南政法大学", "广西大学行健文理学院", "江西中医药大学", "嘉兴学院南湖学院", "湖北师范大学", "南宁职业技术学院", "济南大学", "西安邮电大学", "浙江工业大学", "徐州医科大学", "温州医科大学", "浙江农林大学", "中国地质大学(武汉)", "厦门理工学院", "浙江师范大学行知学院", "硅湖职业技术学院", "西南民族大学", "山东理工大学", "江苏工程职业技术学院",
+ val ZFSchoolList1 = arrayOf("广东科学技术职业学院", "茂名职业技术学院", "福建农林大学", "浙江万里学院", "重庆交通职业学院")
+ val newZFSchoolList = arrayOf("山东农业大学", "辽宁机电职业技术学院", "华中农业大学", "常州机电职业技术学院", "保定学院", "河北环境工程学院", "安徽信息工程学院", "延安大学", "浙江财经大学", "中国医科大学", "苏州农业职业技术学院", "无锡太湖学院", "山东青年政治学院", "河南财经政法大学", "青岛科技大学", "三江学院", "西昌学院", "滨州医学院", "青岛滨海学院", "天津体育学院", "中国矿业大学徐海学院", "武昌首义学院", "四川轻化工大学", "安徽农业大学", "湖北工程学院新技术学院", "贺州学院", "河北政法职业学院", "浙江工商大学", "淮南师范学院", "广西大学", "湖北中医药大学", "南京城市职业学院", "北京化工大学", "信阳师范学院", "西南政法大学", "广西大学行健文理学院", "江西中医药大学", "嘉兴学院南湖学院", "湖北师范大学", "南宁职业技术学院", "济南大学", "西安邮电大学", "浙江工业大学", "徐州医科大学", "温州医科大学", "浙江农林大学", "中国地质大学(武汉)", "厦门理工学院", "浙江师范大学行知学院", "硅湖职业技术学院", "西南民族大学", "山东理工大学", "江苏工程职业技术学院",
"南京工业大学", "德州学院", "南京特殊教育师范学院", "济南工程职业技术学院", "吉林建筑大学", "宁波工程学院", "西南大学", "河北师范大学",
"贵州财经大学", "江苏建筑职业技术学院", "武汉纺织大学", "浙江师范大学",
"山东政法大学", "石家庄学院", "中国矿业大学", "武汉轻工大学", "黄冈师范学院", "广州大学", "南京师范大学中北学院",
"湖北经济学院", "华中师范大学", "华南理工大学", "潍坊职业学院")
val gzChengFangList = arrayOf("南方医科大学", "广东工业大学", "五邑大学", "湖北医药学院")
val qzCrazyList = arrayOf("河北金融学院", "桂林理工大学博文管理学院", "佛山科学技术学院", "华南农业大学珠江学院", "重庆大学城市科技学院")
- val qzAbnormalNodeList = arrayOf("北京林业大学", "青岛农业大学", "广东金融学院")
+ val qzAbnormalNodeList = arrayOf("长沙理工大学", "江西农业大学南昌商学院", "北京林业大学", "青岛农业大学", "广东金融学院")
val qzGuangwaiList = arrayOf("哈尔滨工程大学", "北京理工大学", "北京理工大学珠海学院", "江苏师范大学", "广东外语外贸大学", "海南大学", "广州医科大学", "长沙医学院")
val qzLessNodeSchoolList = arrayOf("大庆师范学院", "吉林师范大学", "锦州医科大学", "中国药科大学", "广西师范学院", "南宁师范大学", "天津中医药大学", "山东大学威海校区",
"吉首大学", "南京理工大学", "天津医科大学", "重庆交通大学", "沈阳工程学院", "韶关学院")
- val qzMoreNodeSchoolList = arrayOf("电子科技大学中山学院", "中国石油大学胜利学院", "江苏科技大学", "山东大学(威海)", "南昌大学", "湖南工业大学", "南方科技大学", "山东财经大学", "湘潭大学", "哈尔滨商业大学", "山东科技大学", "华东理工大学", "中南大学", "湖南商学院", "威海职业学院", "大连外国语大学",
+ val qzMoreNodeSchoolList = arrayOf("湖南工商大学", "电子科技大学中山学院", "中国石油大学胜利学院", "江苏科技大学", "山东大学(威海)", "南昌大学", "湖南工业大学", "南方科技大学", "山东财经大学", "湘潭大学", "哈尔滨商业大学", "山东科技大学", "华东理工大学", "中南大学", "湖南商学院", "威海职业学院", "大连外国语大学",
"中南林业科技大学", "东北林业大学", "齐鲁工业大学", "四川美术学院", "广东财经大学", "南昌航空大学", "皖西学院", "中南财经政法大学", "临沂大学")
var selectedYear = ""
var selectedTerm = ""
@@ -101,10 +96,10 @@ class ImportViewModel(application: Application) : AndroidViewModel(application)
private val detailList = arrayListOf()
private val retryList = arrayListOf()
- private val retrofit = Retrofit.Builder().baseUrl("http://xk-old.suda.edu.cn/").build()
+ private val retrofit = Retrofit.Builder().baseUrl("http://xk.suda.edu.cn/").build()
private val importService = retrofit.create(ImportService::class.java)
private var loginCookieStr = ""
- private val viewStateLoginCode = "dDwtMTE5ODQzMDQ1NDt0PDtsPGk8MT47PjtsPHQ8O2w8aTw0PjtpPDc+O2k8OT47PjtsPHQ8cDw7cDxsPHZhbHVlOz47bDxcZTs+Pj47Oz47dDxwPDtwPGw8b25jbGljazs+O2w8d2luZG93LmNsb3NlKClcOzs+Pj47Oz47dDx0PDs7bDxpPDI+Oz4+Ozs+Oz4+Oz4+Oz5527rVtbyXbkyZdrm5O4U8rQ4EHA=="
+ private val viewStateLoginCode = "gL9F+JHumK2sqbV6zwQemFSg4zth6L+4YJUeYQOsGmGYGgicF/OqcZ/3Ocj2R8yHlucjhxo/qkiMTckoHKd1YfTaVtAxBVg5vqINlJUEHgUsbYYrCCMI6PRc83d5awHsV3aHev7t543cfjmKx/YhUT/xj+K2h1OQqFLYYZND8u58U+zuIxTfpVopvsko0oo0JpZkNXtiBfbdJ0lc5OVaUCFBK8E="
private var viewStatePostCode = ""
suspend fun getNewId(): Int {
@@ -123,6 +118,80 @@ class ImportViewModel(application: Application) : AndroidViewModel(application)
}
}
+ suspend fun loginTsinghua(username: String, password: String): String {
+ //login
+ val LEARN_PREFIX = "https://learn2018.tsinghua.edu.cn"
+ baseList.clear()
+ detailList.clear()
+ var cookies: Map?
+ val ticket = Jsoup.connect("https://id.tsinghua.edu.cn/do/off/ui/auth/login/post/bb5df85216504820be7bba2b0ae1535b/0?/login.do")
+ .data("i_user", username).data("i_pass", password).data("atOnce", true.toString())
+ .timeout(10000).post()
+ .body().select("a").attr("href").split('=').last()
+ val loginResponse = Jsoup.connect("$LEARN_PREFIX/b/j_spring_security_thauth_roaming_entry?ticket=$ticket")
+ .execute().let {
+ cookies = it.cookies()
+ it.statusCode() in 200..299
+ }
+ if (!loginResponse) throw Exception("Incorrect username or password.")
+ //getSemesterIdList
+ val semesterIdArray = JSONArray(Jsoup.connect("$LEARN_PREFIX/b/wlxt/kc/v_wlkc_xs_xktjb_coassb/queryxnxq")
+ .cookies(cookies).execute().body()).let {
+ Array(it.length()) { i: Int -> it.getString(i) }
+ }
+ //getCurrentSemester
+ var currentSemester = JSONObject(Jsoup.connect("$LEARN_PREFIX/b/kc/zhjw_v_code_xnxq/getCurrentAndNextSemester")
+ .cookies(cookies).execute().body())
+ .getJSONObject("result").getString("id")
+ if (currentSemester.split("-").last() == "3" && semesterIdArray.indexOf(currentSemester) > 0)
+ currentSemester = semesterIdArray[semesterIdArray.indexOf(currentSemester) - 1]
+ //getCourseList
+ val courseList = JSONObject(Jsoup.connect("$LEARN_PREFIX/b/wlxt/kc/v_wlkc_xs_xkb_kcb_extend/student/loadCourseBySemesterId/$currentSemester")
+ .cookies(cookies).execute().body())
+ .getJSONArray("resultList")
+ val courseDetailList = Array>(courseList.length()) { i ->
+ JSONArray(Jsoup.connect("$LEARN_PREFIX/b/kc/v_wlkc_xk_sjddb/detail?id=${courseList.getJSONObject(i).getString("wlkcid")}")
+ .cookies(cookies).execute().body()).let {
+ Array(it.length()) { idx ->
+ it.getString(idx)
+ }
+ }
+ }
+ for (i in 0 until courseList.length()) {
+ baseList.add(CourseBaseBean(i,
+ courseName = courseList.getJSONObject(i).getString("kcm"),
+ color = "#${Integer.toHexString(ViewUtils.getCustomizedColor(getApplication(), i % 9))}",
+ tableId = importId
+ ))
+ for (element in courseDetailList[i]) {
+ val matcher = Pattern.compile("星期([一二三四五六七日])第([1-6])节\\((.*?)\\),(.*)")
+ .matcher(element)
+ if (matcher.find()) {
+ val matchRs = matcher.toMatchResult()
+
+ detailList.add(CourseDetailBean(i,
+ day = "一二三四五六七日".indexOf(matchRs.group(1)) + 1,
+ room = matchRs.group(4),
+ teacher = courseList.getJSONObject(i).getString("jsm"),
+ tableId = importId,
+ startNode = when (matchRs.group(2).toInt()) {
+ 1 -> 1; 2 -> 3;3 -> 6;4 -> 8;5 -> 10;6 -> 12
+ else -> 0
+ },
+ step = when (matchRs.group(2).toInt()) {
+ 2, 6 -> 3
+ else -> 2
+ },
+ startWeek = if (matchRs.group(3).contains("后")) 9 else 1,
+ endWeek = if (matchRs.group(3).contains("前")) 8 else 16,
+ type = 0
+ ))
+ }
+ }
+ }
+ return write2DB()
+ }
+
suspend fun parseZFNewer(html: String): String {
baseList.clear()
detailList.clear()
@@ -426,77 +495,77 @@ class ImportViewModel(application: Application) : AndroidViewModel(application)
val hashMapCourse = HashMap>()
- for ((courseId, i) in lis.withIndex()) {
-
- var courseName: String
- var ps: Elements
- var textTeacher: String
- try {
- courseName = i.selectFirst("strong").html().trim()
- ps = i.select("p")
- textTeacher = ps[0].html().replace(" ", "").split(":").lastOrNull() ?: ""
- } catch(e: Exception) {
- continue
- }
+ for ((courseId, i) in lis.withIndex()) {
- val course = CourseBaseBean(
- id = courseId,
- courseName = courseName,
- color = "#${Integer.toHexString(ViewUtils.getCustomizedColor(getApplication(), baseList.size % 9))}",
- tableId = importId
- )
-
- baseList.add(course)
+ var courseName: String
+ var ps: Elements
+ var textTeacher: String
+ try {
+ courseName = i.selectFirst("strong").html().trim()
+ ps = i.select("p")
+ textTeacher = ps[0].html().replace(" ", "").split(":").lastOrNull() ?: ""
+ } catch (e: Exception) {
+ continue
+ }
+ val course = CourseBaseBean(
+ id = courseId,
+ courseName = courseName,
+ color = "#${Integer.toHexString(ViewUtils.getCustomizedColor(getApplication(), baseList.size % 9))}",
+ tableId = importId
+ )
+ baseList.add(course)
- if(hashMapCourse.containsKey(courseName)) {
- hashMapCourse[courseName]!!.forEach { if(!it.teacher!!.split(',').contains(textTeacher)) it.teacher = "${it.teacher},$textTeacher" }
- continue
- }
- hashMapCourse[courseName] = ArrayList()
- // 周次、星期、节次、地点
- val segments = i.select("div[class=\"grid demo-grid\"]:has(div[class=\"col-0\"])")
- for(segment in segments) {
- var infos: List
- var nodes: List
- var week: List
+ if (hashMapCourse.containsKey(courseName)) {
+ hashMapCourse[courseName]!!.forEach { if (!it.teacher!!.split(',').contains(textTeacher)) it.teacher = "${it.teacher},$textTeacher" }
+ continue
+ }
- try {
- infos = segment.select("div[class~=col-]").map { it.html().trim() }
- nodes = infos[2].substring(1, infos[2].length - 1).split('-').map { it.toInt() }
- week = infos[0].split('-').map {it.toInt()}
+ hashMapCourse[courseName] = ArrayList()
- assert(infos.count() == 4 && nodes.count() == 2 && week.count() == 2)
- } catch (e: Exception) {
- continue
- }
+ // 周次、星期、节次、地点
+ val segments = i.select("div[class=\"grid demo-grid\"]:has(div[class=\"col-0\"])")
+ for (segment in segments) {
+ var infos: List
+ var nodes: List
+ var week: List
- val detail = CourseDetailBean(
- id = courseId,
- teacher = textTeacher,
- startWeek = week[0],
- endWeek = week[1],
- room = infos[3],
- day = hashMapDay[infos[1].substring("星期".length, infos[1].length)]!!,
- startNode = nodes[0],
- step = nodes[1] - nodes[0] + 1,
- tableId = importId,
- type = 0
- )
+ try {
+ infos = segment.select("div[class~=col-]").map { it.html().trim() }
+ nodes = infos[2].substring(1, infos[2].length - 1).split('-').map { it.toInt() }
+ week = infos[0].split('-').map { it.toInt() }
- hashMapCourse[courseName]!!.add(detail)
- detailList.add(detail)
+ assert(infos.count() == 4 && nodes.count() == 2 && week.count() == 2)
+ } catch (e: Exception) {
+ continue
}
+ val detail = CourseDetailBean(
+ id = courseId,
+ teacher = textTeacher,
+ startWeek = week[0],
+ endWeek = week[1],
+ room = infos[3],
+ day = hashMapDay[infos[1].substring("星期".length, infos[1].length)]!!,
+ startNode = nodes[0],
+ step = nodes[1] - nodes[0] + 1,
+ tableId = importId,
+ type = 0
+ )
+
+ hashMapCourse[courseName]!!.add(detail)
+ detailList.add(detail)
}
+ }
- return write2DB()
- }
+
+ return write2DB()
+ }
private val nodeHashMap = SparseArray?>()
@@ -545,7 +614,7 @@ class ImportViewModel(application: Application) : AndroidViewModel(application)
suspend fun getPrepare(id: String): String {
val response = importService.getPrepare(
- xh = id, referer = "http://xk-old.suda.edu.cn/xskbcx.aspx?xh=$id",
+ xh = id, referer = "http://xk.suda.edu.cn/xskbcx.aspx?xh=$id",
cookies = loginCookieStr
).execute()
if (response.isSuccessful) {
@@ -569,7 +638,7 @@ class ImportViewModel(application: Application) : AndroidViewModel(application)
event_argument = "",
view_state = viewStatePostCode,
cookies = loginCookieStr,
- referer = "http://xk-old.suda.edu.cn/xskbcx.aspx?xh=" + id + "&xm=" + URLEncoder.encode(name, "gb2312") + "&gnmkdm=N121603",
+ referer = "http://xk.suda.edu.cn/xskbcx.aspx?xh=" + id + "&xm=" + URLEncoder.encode(name, "gb2312") + "&gnmkdm=N121603",
xnd = year,
xqd = term
).execute()
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/LoginWebActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/LoginWebActivity.kt
index d1e0983b..5db96dba 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/LoginWebActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/LoginWebActivity.kt
@@ -7,14 +7,18 @@ import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Log
import android.widget.Toast
+import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModelProviders
+import com.crashlytics.android.answers.Answers
+import com.crashlytics.android.answers.SearchEvent
import com.nbsp.materialfilepicker.ui.FilePickerActivity
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.SplashActivity
import com.suda.yzune.wakeupschedule.base_view.BaseActivity
import es.dmoral.toasty.Toasty
+import io.fabric.sdk.android.Fabric
import kotlinx.android.synthetic.main.fragment_login_web.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -32,55 +36,67 @@ class LoginWebActivity : BaseActivity() {
viewModel = ViewModelProviders.of(this).get(ImportViewModel::class.java)
+ val type = intent.getStringExtra("type")
+
+ if (Fabric.isInitialized()) {
+ Answers.getInstance().logSearch(SearchEvent().putQuery(type))
+ }
when {
- intent.getStringExtra("type") == "苏州大学" -> {
+ type == "苏州大学" -> {
val fragment = LoginWebFragment.newInstance("苏州大学")
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fl_fragment, fragment, "sudaLogin")
transaction.commit()
showImportSettingDialog()
}
- intent.getStringExtra("type") == "上海大学" -> {
+ type == "清华大学" -> {
+ val fragment = LoginWebFragment.newInstance("清华大学")
+ val transaction = supportFragmentManager.beginTransaction()
+ transaction.add(R.id.fl_fragment, fragment, "tsinghuaLogin")
+ transaction.commit()
+ showImportSettingDialog()
+ }
+ type == "上海大学" -> {
val fragment = LoginWebFragment.newInstance("上海大学")
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fl_fragment, fragment, "shanghaiLogin")
transaction.commit()
showImportSettingDialog()
}
- intent.getStringExtra("type") == "吉林大学" -> {
+ type == "吉林大学" -> {
val fragment = LoginWebFragment.newInstance("吉林大学")
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fl_fragment, fragment, "JLU")
transaction.commit()
showImportSettingDialog()
}
- intent.getStringExtra("type") == "华中科技大学" -> {
+ type == "华中科技大学" -> {
val fragment = LoginWebFragment.newInstance("华中科技大学")
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fl_fragment, fragment, "HUST")
transaction.commit()
showImportSettingDialog()
}
- intent.getStringExtra("type") == "apply" -> {
+ type == "apply" -> {
val fragment = SchoolInfoFragment.newInstance()
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fl_fragment, fragment, "schoolInfo")
transaction.commit()
}
- intent.getStringExtra("type") == "file" -> {
+ type == "file" -> {
val fragment = FileImportFragment()
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fl_fragment, fragment, "fileImport")
transaction.commit()
}
- intent.getStringExtra("type") == "excel" -> {
+ type == "excel" -> {
val fragment = ExcelImportFragment()
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fl_fragment, fragment, "excelImport")
transaction.commit()
showImportSettingDialog()
}
- intent.getStringExtra("type") == "html" -> {
+ type == "html" -> {
val fragment = HtmlImportFragment()
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fl_fragment, fragment, "htmlImport")
@@ -100,7 +116,8 @@ class LoginWebActivity : BaseActivity() {
}
}
else -> {
- val fragment = WebViewLoginFragment.newInstance(intent.getStringExtra("type"), intent.getStringExtra("url"))
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
+ val fragment = WebViewLoginFragment.newInstance(type, intent.getStringExtra("url"))
val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.fl_fragment, fragment, "webLogin")
transaction.commit()
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/LoginWebFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/LoginWebFragment.kt
index 7e731217..446073f0 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/LoginWebFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/LoginWebFragment.kt
@@ -52,15 +52,20 @@ class LoginWebFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
+ tv_title.text = type
if (type != "苏州大学") {
- tv_vpn.visibility = View.GONE
input_code.visibility = View.INVISIBLE
rl_code.visibility = View.INVISIBLE
+ tv_tip.visibility = View.GONE
} else {
refreshCode()
+ tv_tip.setOnClickListener {
+ CourseUtils.openUrl(context!!, "https://yzune.github.io/2018/08/13/%E4%BD%BF%E7%94%A8FortiClient%E8%BF%9E%E6%8E%A5%E6%A0%A1%E5%9B%AD%E7%BD%91/")
+ }
}
if (type == "上海大学") {
btg_ports.visibility = View.VISIBLE
+ tv_thanks.text = "感谢 @Deep Sea\n能导入贵校课程离不开他无私贡献代码"
btg_ports.addOnButtonCheckedListener { group, checkedId, isChecked ->
if (isChecked) {
shanghaiPort = checkedId - R.id.btn_port1
@@ -70,8 +75,17 @@ class LoginWebFragment : BaseFragment() {
}
}
}
- if(type == "华中科技大学") {
+ if (type == "清华大学") {
+ input_id.hint = "用户名"
+ tv_thanks.text = "感谢 @RikaSugisawa\n能导入贵校课程离不开他无私贡献代码"
+ et_id.inputType = InputType.TYPE_CLASS_TEXT
+ }
+ if (type == "吉林大学") {
+ tv_thanks.text = "感谢 @颩欥殘膤\n能导入贵校课程离不开他无私贡献代码"
+ }
+ if (type == "华中科技大学") {
et_id.inputType = InputType.TYPE_CLASS_TEXT
+ tv_thanks.text = "感谢 @Lyt99\n能导入贵校课程离不开他无私贡献代码"
}
initEvent()
}
@@ -95,10 +109,6 @@ class LoginWebFragment : BaseFragment() {
fab_login.setImageDrawable(textDrawable)
- tv_vpn.setOnClickListener {
- CourseUtils.openUrl(context!!, "https://yzune.github.io/2018/08/13/%E4%BD%BF%E7%94%A8FortiClient%E8%BF%9E%E6%8E%A5%E6%A0%A1%E5%9B%AD%E7%BD%91/")
- }
-
iv_code.setOnClickListener {
refreshCode()
}
@@ -175,6 +185,28 @@ class LoginWebFragment : BaseFragment() {
}
}
}
+ if (type == "清华大学") {
+ launch {
+ val task = withContext(Dispatchers.IO) {
+ try {
+ viewModel.loginTsinghua(et_id.text.toString(),
+ et_pwd.text.toString())
+ } catch (e: Exception) {
+ e.message
+ }
+ }
+ when (task) {
+ "ok" -> {
+ Toasty.success(activity!!.applicationContext, "导入成功(゚▽゚)/请在右侧栏切换后查看", Toast.LENGTH_LONG).show()
+ activity!!.setResult(RESULT_OK)
+ activity!!.finish()
+ }
+ else -> {
+ Toasty.error(activity!!.applicationContext, "发生异常>_<\n$task", Toast.LENGTH_LONG).show()
+ }
+ }
+ }
+ }
if (type == "上海大学") {
launch {
val task = withContext(Dispatchers.IO) {
@@ -228,7 +260,7 @@ class LoginWebFragment : BaseFragment() {
val task = withContext(Dispatchers.IO) {
val hub = MobileHub(et_id.text.toString(), et_pwd.text.toString())
try {
- if(!hub.login()) {
+ if (!hub.login()) {
"no login"
} else {
hub.getCourseSchedule()
@@ -249,7 +281,7 @@ class LoginWebFragment : BaseFragment() {
Toasty.error(activity!!.applicationContext, "学号或密码错误,请检查后再输入", Toast.LENGTH_LONG).show()
}
else -> {
- if(task?.contains("failed to connect") == true) {
+ if (task?.contains("failed to connect") == true) {
Toasty.error(activity!!.applicationContext, "无法访问HUB系统,请检查是否连接校园网", Toast.LENGTH_LONG).show()
} else {
Toasty.error(activity!!.applicationContext, "发生异常>_<\n$task", Toast.LENGTH_LONG).show()
@@ -376,15 +408,23 @@ class LoginWebFragment : BaseFragment() {
private fun cardC2Dialog(years: List) {
ll_dialog.visibility = View.VISIBLE
- val terms = listOf("1", "2", "3")
- wp_term.data = terms
- wp_years.data = years
- wp_years.setOnItemSelectedListener { _, data, _ ->
- year = data as String
+ val terms = arrayOf("1", "2", "3")
+ wp_term.displayedValues = terms
+ wp_term.value = 0
+ wp_term.minValue = 0
+ wp_term.maxValue = terms.size - 1
+
+ wp_years.displayedValues = years.toTypedArray()
+ wp_years.value = 0
+ wp_years.minValue = 0
+ wp_years.maxValue = years.size - 1
+
+ wp_years.setOnValueChangedListener { _, _, newVal ->
+ year = years[newVal]
Log.d("选中", "选中学年$year")
}
- wp_term.setOnItemSelectedListener { _, data, _ ->
- term = data as String
+ wp_term.setOnValueChangedListener { _, _, newVal ->
+ term = terms[newVal]
Log.d("选中", "选中学期$term")
}
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/SchoolImportListAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/SchoolImportListAdapter.kt
index 90a57829..42be302c 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/SchoolImportListAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/SchoolImportListAdapter.kt
@@ -5,14 +5,14 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
-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.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersAdapter
import org.jetbrains.anko.find
class SchoolImportListAdapter(layoutResId: Int, data: MutableList) :
- BaseItemDraggableAdapter(layoutResId, data),
+ BaseQuickAdapter(layoutResId, data),
StickyRecyclerHeadersAdapter {
override fun getHeaderId(position: Int): Long {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/SchoolListActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/SchoolListActivity.kt
index b9d28ec4..164e46d6 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/SchoolListActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/SchoolListActivity.kt
@@ -2,7 +2,6 @@ package com.suda.yzune.wakeupschedule.schedule_import
import android.app.Activity
import android.content.Intent
-import android.graphics.Color
import android.graphics.Typeface
import android.os.Bundle
import android.text.Editable
@@ -15,15 +14,19 @@ import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.TextView
import androidx.core.content.res.ResourcesCompat
-import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bigkoo.quicksidebar.listener.OnQuickSideBarTouchListener
+import com.google.gson.Gson
import com.suda.yzune.wakeupschedule.AppDatabase
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.base_view.BaseTitleActivity
+import com.suda.yzune.wakeupschedule.utils.PreferenceUtils
import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration
import kotlinx.android.synthetic.main.activity_school_list.*
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
import org.jetbrains.anko.*
import org.jetbrains.anko.design.longSnackbar
@@ -51,16 +54,17 @@ class SchoolListActivity : BaseTitleActivity(), OnQuickSideBarTouchListener {
override 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()
}
@@ -134,10 +138,10 @@ class SchoolListActivity : BaseTitleActivity(), OnQuickSideBarTouchListener {
}
}
- 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
}
@@ -152,6 +156,7 @@ class SchoolListActivity : BaseTitleActivity(), OnQuickSideBarTouchListener {
private fun initSchoolList() {
val dataBase = AppDatabase.getDatabase(application)
val tableDao = dataBase.tableDao()
+ val gson = Gson()
schools.add(SchoolListBean("S", "苏州大学"))
schools.add(SchoolListBean("S", "上海大学"))
@@ -169,6 +174,7 @@ class SchoolListActivity : BaseTitleActivity(), OnQuickSideBarTouchListener {
schools.add(SchoolListBean("H", "华东理工大学", "http://inquiry.ecust.edu.cn/jsxsd/"))
schools.add(SchoolListBean("Z", "中南大学", "https://csujwc.its.csu.edu.cn/"))
schools.add(SchoolListBean("H", "湖南商学院", "http://jwgl.hnuc.edu.cn/"))
+ schools.add(SchoolListBean("H", "湖南工商大学", "http://jwgl.hnuc.edu.cn/"))
schools.add(SchoolListBean("S", "山东大学威海校区", "https://portal.wh.sdu.edu.cn/"))
schools.add(SchoolListBean("J", "江苏师范大学", "http://sdjw.jsnu.edu.cn/"))
schools.add(SchoolListBean("J", "吉首大学", "http://jwxt.jsu.edu.cn/"))
@@ -217,7 +223,7 @@ class SchoolListActivity : BaseTitleActivity(), OnQuickSideBarTouchListener {
schools.add(SchoolListBean("N", "南京师范大学中北学院", "http://222.192.5.246/"))
schools.add(SchoolListBean("H", "湖北经济学院", ""))
schools.add(SchoolListBean("H", "华中师范大学", "http://xk.ccnu.edu.cn/xtgl/"))
- schools.add(SchoolListBean("H", "华南理工大学", "http://xsjw2018.scuteo.com/driotlogin"))
+ schools.add(SchoolListBean("H", "华南理工大学", "http://xsjw2018.scuteo.com"))
schools.add(SchoolListBean("G", "广东环境保护工程职业学院", "http://113.107.254.7/"))
schools.add(SchoolListBean("X", "西华大学", "http://jwc.xhu.edu.cn/"))
schools.add(SchoolListBean("X", "西安理工大学", "http://202.200.112.200/"))
@@ -284,17 +290,17 @@ class SchoolListActivity : BaseTitleActivity(), OnQuickSideBarTouchListener {
schools.add(SchoolListBean("Z", "浙江工业大学", "http://www.gdjw.zjut.edu.cn/"))
schools.add(SchoolListBean("D", "东北财经大学", "http://202.199.165.159/"))
schools.add(SchoolListBean("T", "天津工业大学", "http://jwpt.tjpu.edu.cn/"))
- schools.add(SchoolListBean("S", "山东农业大学", "http://jw.sdau.edu.cn/"))
+ schools.add(SchoolListBean("S", "山东农业大学", "http://xjw.sdau.edu.cn/jwglxt/"))
schools.add(SchoolListBean("H", "河海大学", "http://202.119.113.135/"))
schools.add(SchoolListBean("X", "西安邮电大学", "http://www.zfjw.xupt.edu.cn/jwglxt/"))
schools.add(SchoolListBean("B", "北京邮电大学", "https://jwxt.bupt.edu.cn/"))
- schools.add(SchoolListBean("H", "湖南科技大学", "http://kdjw.hnust.cn/kdjw"))
+ schools.add(SchoolListBean("H", "湖南科技大学", "http://kdjw.hnust.cn:8080/kdjw"))
schools.add(SchoolListBean("B", "北京大学", "http://elective.pku.edu.cn"))
- schools.add(SchoolListBean("J", "济南大学", "http://jwgl7.ujn.edu.cn/jwglxt"))
+ schools.add(SchoolListBean("J", "济南大学", "http://jwgl4.ujn.edu.cn/jwglxt"))
schools.add(SchoolListBean("H", "河北大学", "http://zhjw.hbu.edu.cn/"))
schools.add(SchoolListBean("X", "西南石油大学", "http://jwxt.swpu.edu.cn/"))
- schools.add(SchoolListBean("H", "湖南科技大学潇湘学院", "http://xxjw.hnust.cn/xxjw/"))
+ schools.add(SchoolListBean("H", "湖南科技大学潇湘学院", "http://xxjw.hnust.cn:8080/xxjw/"))
schools.add(SchoolListBean("Z", "郑州大学西亚斯国际学院", "http://218.198.176.111/default2.aspx"))
schools.add(SchoolListBean("H", "河南理工大学", ""))
schools.add(SchoolListBean("Q", "齐齐哈尔大学", ""))
@@ -335,12 +341,11 @@ class SchoolListActivity : BaseTitleActivity(), OnQuickSideBarTouchListener {
schools.add(SchoolListBean("X", "信阳师范学院", "http://jwc.xynu.edu.cn/jxzhxxfwpt.htm"))
schools.add(SchoolListBean("A", "安徽建筑大学", "http://219.231.0.156/"))
schools.add(SchoolListBean("B", "北京化工大学", "http://jwglxt.buct.edu.cn/"))
- schools.add(SchoolListBean("Z", "北京化工大学", "http://jwglxt.buct.edu.cn/"))
schools.add(SchoolListBean("Z", "浙江工业大学之江学院", "http://jwgl.zzjc.edu.cn/default2.aspx"))
schools.add(SchoolListBean("B", "北京联合大学", ""))
schools.add(SchoolListBean("N", "南京城市职业学院", "http://jw.ncc.edu.cn/jwglxt/xtgl/"))
schools.add(SchoolListBean("H", "湖北中医药大学", "http://jwxt.hbtcm.edu.cn/jwglxt/xtgl"))
- schools.add(SchoolListBean("H", "华中农业大学", ""))
+ schools.add(SchoolListBean("H", "华中农业大学", "http://jwgl.hzau.edu.cn/xtgl/login_slogin.html"))
schools.add(SchoolListBean("G", "广西大学", "http://jwxt2018.gxu.edu.cn/jwglxt/xtgl/"))
schools.add(SchoolListBean("H", "淮南师范学院", "http://211.70.176.173/jwglxt/xtgl/"))
schools.add(SchoolListBean("Z", "浙江工商大学", "http://124.160.64.163/jwglxt/xtgl/"))
@@ -375,6 +380,17 @@ class SchoolListActivity : BaseTitleActivity(), OnQuickSideBarTouchListener {
schools.add(SchoolListBean("W", "渭南师范学院", "http://218.195.46.9"))
schools.add(SchoolListBean("H", "华中科技大学", ""))
+ schools.add(SchoolListBean("G", "广东科学技术职业学院", ""))
+ schools.add(SchoolListBean("M", "闽南师范大学", "http://222.205.160.107/jwglxt/xtgl/login_slogin.html"))
+
+ schools.add(SchoolListBean("Q", "清华大学", ""))
+
+ schools.add(SchoolListBean("X", "西安建筑科技大学", "http://xk.xauat.edu.cn/default2.aspx#a"))
+ schools.add(SchoolListBean("J", "江西农业大学南昌商学院", "http://223.83.249.67:8080/jsxsd/"))
+
+ schools.add(SchoolListBean("C", "长沙理工大学", "http://xk.csust.edu.cn/"))
+ schools.add(SchoolListBean("L", "辽宁机电职业技术学院", "http://jwgl.lnjdp.com/"))
+
schools.sortWith(compareBy({ it.sortKey }, { it.name }))
schools.add(0, SchoolListBean("★", "URP 系统"))
@@ -393,14 +409,18 @@ class SchoolListActivity : BaseTitleActivity(), OnQuickSideBarTouchListener {
setResult(Activity.RESULT_OK, Intent().apply { putExtra("name", showList[position].name) })
finish()
} else {
- tableDao.getDefaultTableId().observe(this, Observer {
+ launch {
+ PreferenceUtils.saveStringToSP(applicationContext, "import_school", gson.toJson(showList[position]))
+ val tableId = withContext(Dispatchers.IO) {
+ tableDao.getDefaultTableIdInThread()
+ }
startActivity(
"type" to showList[position].name,
- "tableId" to it,
+ "tableId" to tableId,
"url" to showList[position].url
)
finish()
- })
+ }
}
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/WebViewLoginFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/WebViewLoginFragment.kt
index 503e7367..68e7cb93 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/WebViewLoginFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_import/WebViewLoginFragment.kt
@@ -27,6 +27,7 @@ import org.jetbrains.anko.design.longSnackbar
import org.jetbrains.anko.find
import org.jetbrains.anko.startActivity
+
class WebViewLoginFragment : BaseFragment() {
private val GET_FRAME_CONTENT_STR = "document.getElementById('iframeautoheight').contentWindow.document.body.innerHTML"
@@ -94,19 +95,19 @@ class WebViewLoginFragment : BaseFragment() {
cg_old_qz.visibility = View.GONE
}
- wv_course.settings.javaScriptEnabled = true
+ wv_course!!.settings.javaScriptEnabled = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- wv_course.settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
+ wv_course!!.settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
}
- wv_course.addJavascriptInterface(InJavaScriptLocalObj(), "local_obj")
- wv_course.webViewClient = object : WebViewClient() {
+ wv_course!!.addJavascriptInterface(InJavaScriptLocalObj(), "local_obj")
+ wv_course!!.webViewClient = object : WebViewClient() {
override fun onReceivedSslError(view: WebView, handler: SslErrorHandler, error: SslError) {
handler.proceed() //接受所有网站的证书
}
}
- wv_course.webChromeClient = object : WebChromeClient() {
+ wv_course!!.webChromeClient = object : WebChromeClient() {
override fun onProgressChanged(view: WebView?, newProgress: Int) {
super.onProgressChanged(view, newProgress)
if (newProgress == 100) {
@@ -118,17 +119,17 @@ class WebViewLoginFragment : BaseFragment() {
}
}
}
- //设置自适应屏幕,两者合用
- wv_course.settings.useWideViewPort = true //将图片调整到适合WebView的大小
- wv_course.settings.loadWithOverviewMode = true // 缩放至屏幕的大小
+ // 设置自适应屏幕,两者合用
+ wv_course!!.settings.useWideViewPort = true //将图片调整到适合WebView的大小
+ wv_course!!.settings.loadWithOverviewMode = true // 缩放至屏幕的大小
// 缩放操作
- wv_course.settings.setSupportZoom(true) //支持缩放,默认为true。是下面那个的前提。
- wv_course.settings.builtInZoomControls = true //设置内置的缩放控件。若为false,则该WebView不可缩放
- wv_course.settings.displayZoomControls = false //隐藏原生的缩放控件wvCourse.settings
- wv_course.settings.javaScriptCanOpenWindowsAutomatically = true
- wv_course.settings.domStorageEnabled = true
- wv_course.settings.userAgentString = wv_course.settings.userAgentString.replace("Mobile", "eliboM").replace("Android", "diordnA")
- wv_course.settings.textZoom = 100
+ wv_course!!.settings.setSupportZoom(true) //支持缩放,默认为true。是下面那个的前提。
+ wv_course!!.settings.builtInZoomControls = true //设置内置的缩放控件。若为false,则该WebView不可缩放
+ wv_course!!.settings.displayZoomControls = false //隐藏原生的缩放控件wvCourse.settings
+ wv_course!!.settings.javaScriptCanOpenWindowsAutomatically = true
+ wv_course!!.settings.domStorageEnabled = true
+ wv_course!!.settings.userAgentString = wv_course!!.settings.userAgentString.replace("Mobile", "eliboM").replace("Android", "diordnA")
+ wv_course!!.settings.textZoom = 100
initEvent()
}
@@ -236,19 +237,19 @@ class WebViewLoginFragment : BaseFragment() {
fab_import.setOnClickListener {
if (type !in viewModel.oldQZList1 && type !in viewModel.urpList && type !in viewModel.gzChengFangList && !viewModel.isUrp) {
- wv_course.loadUrl(js)
+ wv_course!!.loadUrl(js)
}
if (type in viewModel.oldQZList1) {
if (!isRefer) {
val referUrl = when (type) {
"湖南科技大学" -> "http://kdjw.hnust.cn/kdjw/tkglAction.do?method=goListKbByXs&istsxx=no"
- else -> if (wv_course.url.endsWith('/')) wv_course.url + "tkglAction.do?method=goListKbByXs&istsxx=no" else wv_course.url + "/tkglAction.do?method=goListKbByXs&istsxx=no"
+ else -> if (wv_course!!.url.endsWith('/')) wv_course!!.url + "tkglAction.do?method=goListKbByXs&istsxx=no" else wv_course!!.url + "/tkglAction.do?method=goListKbByXs&istsxx=no"
}
- wv_course.loadUrl(referUrl)
+ wv_course!!.loadUrl(referUrl)
it.longSnackbar("请在看到网页加载完成后,再点一次右下角按钮")
isRefer = true
} else {
- wv_course.loadUrl(js)
+ wv_course!!.loadUrl(js)
}
}
if (type in viewModel.gzChengFangList) {
@@ -258,35 +259,41 @@ class WebViewLoginFragment : BaseFragment() {
"南方医科大学" -> "http://zhjw.smu.edu.cn/xsgrkbcx!getXsgrbkList.action"
"五邑大学" -> "http://jxgl.wyu.edu.cn/xsgrkbcx!getXsgrbkList.action"
"湖北医药学院" -> "http://jw.hbmu.edu.cn/xsgrkbcx!getXsgrbkList.action"
- else -> if (wv_course.url.endsWith('/')) wv_course.url + "xsgrkbcx!getXsgrbkList.action" else wv_course.url + "/xsgrkbcx!getXsgrbkList.action"
+ else -> if (wv_course!!.url.endsWith('/')) wv_course!!.url + "xsgrkbcx!getXsgrbkList.action" else wv_course!!.url + "/xsgrkbcx!getXsgrbkList.action"
}
- wv_course.loadUrl(referUrl)
+ wv_course!!.loadUrl(referUrl)
it.longSnackbar("请重新选择一下学期再点按钮导入,要记得选择全部周,记得点查询按钮")
isRefer = true
} else {
- wv_course.loadUrl(js)
+ wv_course!!.loadUrl(js)
}
}
if (type in viewModel.urpList || viewModel.isUrp) {
if (!isRefer) {
- val referUrl = if (wv_course.url.endsWith('/')) wv_course.url.substringBeforeLast('/').substringBeforeLast('/') + "/xkAction.do?actionType=6" else wv_course.url.substringBeforeLast('/') + "/xkAction.do?actionType=6"
- wv_course.loadUrl(referUrl)
+ val referUrl = if (wv_course!!.url.endsWith('/')) wv_course!!.url.substringBeforeLast('/').substringBeforeLast('/') + "/xkAction.do?actionType=6" else wv_course!!.url.substringBeforeLast('/') + "/xkAction.do?actionType=6"
+ wv_course!!.loadUrl(referUrl)
it.longSnackbar("请在看到网页加载完成后,再点一次右下角按钮")
isRefer = true
} else {
- wv_course.loadUrl(js)
+ wv_course!!.loadUrl(js)
}
}
}
+
+ btn_back.setOnClickListener {
+ if (wv_course.canGoBack()) {
+ wv_course.goBack()
+ }
+ }
}
private fun startVisit() {
- wv_course.visibility = View.VISIBLE
+ wv_course!!.visibility = View.VISIBLE
ll_error.visibility = View.GONE
val url = if (et_url.text.toString().startsWith("http://") || et_url.text.toString().startsWith("https://"))
et_url.text.toString() else "http://" + et_url.text.toString()
if (URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)) {
- wv_course.loadUrl(url)
+ wv_course!!.loadUrl(url)
PreferenceUtils.saveStringToSP(activity!!.applicationContext, "school_url", url)
} else {
Toasty.error(context!!.applicationContext, "请输入正确的网址╭(╯^╰)╮").show()
@@ -387,12 +394,12 @@ class WebViewLoginFragment : BaseFragment() {
}
override fun onDestroyView() {
- wv_course.webViewClient = null
- wv_course.webChromeClient = null
- wv_course.clearCache(true)
- wv_course.clearHistory()
- wv_course.removeAllViews()
- wv_course.destroy()
+ wv_course?.webViewClient = null
+ wv_course?.webChromeClient = null
+ wv_course?.clearCache(true)
+ wv_course?.clearHistory()
+ wv_course?.removeAllViews()
+ wv_course?.destroy()
super.onDestroyView()
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/CourseListAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/CourseListAdapter.kt
index e4219f56..546c2d55 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/CourseListAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/CourseListAdapter.kt
@@ -1,12 +1,12 @@
package com.suda.yzune.wakeupschedule.schedule_manage
-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.CourseBaseBean
class CourseListAdapter(layoutResId: Int, data: List) :
- BaseItemDraggableAdapter(layoutResId, data) {
+ BaseQuickAdapter(layoutResId, data) {
override fun convert(helper: BaseViewHolder, item: CourseBaseBean) {
helper.setText(R.id.tv_course_name, item.courseName)
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/ScheduleManageFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/ScheduleManageFragment.kt
index 8f81bf29..50d60216 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/ScheduleManageFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/ScheduleManageFragment.kt
@@ -64,10 +64,14 @@ class ScheduleManageFragment : BaseFragment() {
}
R.id.ib_edit -> {
launch {
- val task = async(Dispatchers.IO) {
+ val task = withContext(Dispatchers.IO) {
viewModel.getTableById(data[position].id)
}
- startActivity("tableData" to task.await())
+ if (task != null) {
+ startActivity("tableData" to task)
+ } else {
+ Toasty.error(context!!.applicationContext, "读取课表异常>_<")
+ }
}
}
R.id.ib_delete -> {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/ScheduleManageViewModel.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/ScheduleManageViewModel.kt
index 4d116309..bcdb53a1 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/ScheduleManageViewModel.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/ScheduleManageViewModel.kt
@@ -27,7 +27,7 @@ class ScheduleManageViewModel(application: Application) : AndroidViewModel(appli
return baseDao.getCourseBaseBeanOfTable(tableId)
}
- suspend fun getTableById(id: Int): TableBean {
+ suspend fun getTableById(id: Int): TableBean? {
return tableDao.getTableByIdInThread(id)
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/TableListAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/TableListAdapter.kt
index 632a23a1..ee6ca3c0 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/TableListAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_manage/TableListAdapter.kt
@@ -2,14 +2,14 @@ package com.suda.yzune.wakeupschedule.schedule_manage
import android.view.View
import android.widget.ImageView
-import com.chad.library.adapter.base.BaseItemDraggableAdapter
+import com.bumptech.glide.Glide
+import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
-import com.suda.yzune.wakeupschedule.GlideApp
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.bean.TableSelectBean
class TableListAdapter(layoutResId: Int, data: List) :
- BaseItemDraggableAdapter(layoutResId, data) {
+ BaseQuickAdapter(layoutResId, data) {
override fun convert(helper: BaseViewHolder, item: TableSelectBean) {
if (item.type == 1) {
@@ -25,12 +25,12 @@ class TableListAdapter(layoutResId: Int, data: List) :
}
val imageView = helper.getView(R.id.iv_pic)
if (item.background != "") {
- GlideApp.with(mContext.applicationContext)
+ Glide.with(mContext)
.load(item.background)
.override(400, 600)
.into(imageView)
} else {
- GlideApp.with(mContext.applicationContext)
+ Glide.with(mContext)
.load(R.drawable.main_background_2019)
.override(400, 600)
.into(imageView)
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_settings/ScheduleSettingsActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_settings/ScheduleSettingsActivity.kt
index b6eddb48..1f804470 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_settings/ScheduleSettingsActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/schedule_settings/ScheduleSettingsActivity.kt
@@ -6,7 +6,6 @@ import android.app.Dialog
import android.appwidget.AppWidgetManager
import android.content.ActivityNotFoundException
import android.content.Intent
-import android.content.pm.ActivityInfo
import android.content.pm.PackageManager
import android.os.Bundle
import android.os.Parcel
@@ -19,6 +18,7 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.lifecycle.ViewModelProviders
+import com.drakeet.multitype.MultiTypeAdapter
import com.suda.yzune.wakeupschedule.BuildConfig
import com.suda.yzune.wakeupschedule.DonateActivity
import com.suda.yzune.wakeupschedule.R
@@ -36,7 +36,6 @@ import es.dmoral.toasty.Toasty
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import me.drakeet.multitype.MultiTypeAdapter
import org.jetbrains.anko.design.longSnackbar
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
@@ -65,7 +64,7 @@ class ScheduleSettingsActivity : BaseListActivity(), ColorPickerFragment.ColorPi
val iconFont = ResourcesCompat.getFont(this, R.font.iconfont)
tvButton.typeface = iconFont
tvButton.textSize = 20f
- tvButton.text = "\uE6C2"
+ tvButton.text = getString(R.string.icon_heart)
if (BuildConfig.CHANNEL == "google" || BuildConfig.CHANNEL == "huawei") {
tvButton.setOnClickListener {
val dialog = DonateFragment.newInstance()
@@ -79,11 +78,6 @@ class ScheduleSettingsActivity : BaseListActivity(), ColorPickerFragment.ColorPi
return tvButton
}
- override fun onPause() {
- super.onPause()
- Toasty.info(applicationContext, "对小部件的编辑需要按「返回键」退出设置页面才能生效哦", Toast.LENGTH_LONG).show()
- }
-
private lateinit var viewModel: ScheduleSettingsViewModel
private val mAdapter: MultiTypeAdapter = MultiTypeAdapter()
private val REQUEST_CODE_CHOOSE_BG = 23
@@ -147,10 +141,10 @@ class ScheduleSettingsActivity : BaseListActivity(), ColorPickerFragment.ColorPi
private fun onItemsCreated(items: MutableList) {
items.add(CategoryItem("课程数据", true))
items.add(HorizontalItem("课表名称", viewModel.table.tableName, listOf("名称", "名字", "名", "课表")))
+ items.add(HorizontalItem("上课时间", "点击此处更改", listOf("时间")))
items.add(HorizontalItem("学期开始日期", viewModel.table.startDate, listOf("学期", "周", "日期", "开学", "开始", "时间")))
- items.add(SeekBarItem("一天课程节数", viewModel.table.nodes, 4, 30, "节", listOf("节数", "数量", "数")))
- items.add(SeekBarItem("学期周数", viewModel.table.maxWeek, 10, 30, "周", listOf("学期", "周", "时间")))
- items.add(HorizontalItem("上课时间", "", listOf("时间")))
+ items.add(SeekBarItem("一天课程节数", viewModel.table.nodes, 1, 30, "节", listOf("节数", "数量", "数")))
+ items.add(SeekBarItem("学期周数", viewModel.table.maxWeek, 1, 30, "周", listOf("学期", "周", "时间")))
items.add(SwitchItem("周日为每周第一天", viewModel.table.sundayFirst, listOf("周日", "第一天", "起始", "星期天", "天")))
items.add(SwitchItem("显示周六", viewModel.table.showSat, listOf("周六", "显示", "星期六", "六")))
items.add(SwitchItem("显示周日", viewModel.table.showSun, listOf("周日", "显示", "星期日", "日", "星期天", "周天")))
@@ -255,15 +249,6 @@ class ScheduleSettingsActivity : BaseListActivity(), ColorPickerFragment.ColorPi
} catch (e: ActivityNotFoundException) {
e.printStackTrace()
}
-// Matisse.from(this)
-// .choose(MimeType.ofImage())
-// .countable(true)
-// .maxSelectable(1)
-// .gridExpectedSize(resources.getDimensionPixelSize(R.dimen.grid_expected_size))
-// .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
-// .thumbnailScale(0.85f)
-// .imageEngine(GlideAppEngine())
-// .forResult(REQUEST_CODE_CHOOSE_BG)
}
}
"界面文字颜色" -> {
@@ -336,16 +321,6 @@ class ScheduleSettingsActivity : BaseListActivity(), ColorPickerFragment.ColorPi
} catch (e: ActivityNotFoundException) {
e.printStackTrace()
}
-// Matisse.from(this)
-// .choose(MimeType.ofImage())
-// .countable(true)
-// .maxSelectable(1)
-// .gridExpectedSize(resources.getDimensionPixelSize(R.dimen.grid_expected_size))
-// .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
-// .thumbnailScale(0.85f)
-// .imageEngine(GlideAppEngine())
-// .forResult(REQUEST_CODE_CHOOSE_BG)
-
} else {
// permission denied, boo! Disable the
// functionality that depends on this permission.
@@ -379,7 +354,11 @@ class ScheduleSettingsActivity : BaseListActivity(), ColorPickerFragment.ColorPi
val appWidgetManager = AppWidgetManager.getInstance(applicationContext)
list.forEach {
when (it.detailType) {
- 0 -> AppWidgetUtils.refreshScheduleWidget(applicationContext, appWidgetManager, it.id, viewModel.table)
+ 0 -> {
+ if (it.info == viewModel.table.id.toString()) {
+ AppWidgetUtils.refreshScheduleWidget(applicationContext, appWidgetManager, it.id, viewModel.table)
+ }
+ }
1 -> AppWidgetUtils.refreshTodayWidget(applicationContext, appWidgetManager, it.id, viewModel.table, false)
}
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/AdvancedSettingsActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/AdvancedSettingsActivity.kt
index 0094caae..a4c34e3f 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/AdvancedSettingsActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/AdvancedSettingsActivity.kt
@@ -7,6 +7,7 @@ import android.os.Build
import android.os.Bundle
import android.widget.TextView
import androidx.core.content.ContextCompat
+import com.drakeet.multitype.MultiTypeAdapter
import com.suda.yzune.wakeupschedule.AppDatabase
import com.suda.yzune.wakeupschedule.BuildConfig
import com.suda.yzune.wakeupschedule.DonateActivity
@@ -30,7 +31,6 @@ import es.dmoral.toasty.Toasty
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
-import me.drakeet.multitype.MultiTypeAdapter
import org.jetbrains.anko.design.longSnackbar
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.textColorResource
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SelectTimeDetailFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SelectTimeDetailFragment.kt
index 6f3c003e..3eba80d2 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SelectTimeDetailFragment.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SelectTimeDetailFragment.kt
@@ -36,8 +36,16 @@ class SelectTimeDetailFragment : BaseDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- wp_start.data = viewModel.timeSelectList
- wp_end.data = viewModel.timeSelectList
+ val valueArray = viewModel.timeSelectList.toTypedArray()
+
+ wp_start.displayedValues = valueArray
+ wp_start.minValue = 0
+ wp_start.maxValue = valueArray.size - 1
+
+ wp_end.displayedValues = valueArray
+ wp_end.minValue = 0
+ wp_end.maxValue = valueArray.size - 1
+
if (viewModel.timeTableList[tablePosition].sameLen) {
tv_title.text = "请选择开始时间"
wp_end.visibility = View.GONE
@@ -59,20 +67,21 @@ class SelectTimeDetailFragment : BaseDialogFragment() {
if (endIndex == -1) {
endIndex = 0
}
- wp_start.selectedItemPosition = startIndex
- wp_end.selectedItemPosition = endIndex
- wp_start.setOnItemSelectedListener { _, _, position ->
- startIndex = position
+ wp_start.value = startIndex
+ wp_end.value = endIndex
+
+ wp_start.setOnValueChangedListener { _, _, newVal ->
+ startIndex = newVal
if (endIndex < startIndex) {
- wp_end.selectedItemPosition = startIndex
+ wp_end.smoothScrollToValue(startIndex, false)
endIndex = startIndex
}
}
- wp_end.setOnItemSelectedListener { _, _, position ->
- endIndex = position
+ wp_end.setOnValueChangedListener { _, _, newVal ->
+ endIndex = newVal
if (endIndex < startIndex) {
- wp_end.selectedItemPosition = startIndex
+ wp_end.smoothScrollToValue(startIndex, false)
endIndex = startIndex
}
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsActivity.kt
index dc24707b..b56c7928 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsActivity.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsActivity.kt
@@ -3,6 +3,8 @@ package com.suda.yzune.wakeupschedule.settings
import android.content.Intent
import android.os.Bundle
import android.widget.TextView
+import androidx.appcompat.app.AppCompatDelegate
+import com.drakeet.multitype.MultiTypeAdapter
import com.suda.yzune.wakeupschedule.AppDatabase
import com.suda.yzune.wakeupschedule.BuildConfig
import com.suda.yzune.wakeupschedule.DonateActivity
@@ -23,7 +25,6 @@ import com.suda.yzune.wakeupschedule.utils.PreferenceUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import me.drakeet.multitype.MultiTypeAdapter
import org.jetbrains.anko.design.longSnackbar
import org.jetbrains.anko.design.snackbar
import org.jetbrains.anko.startActivity
@@ -70,6 +71,7 @@ class SettingsActivity : BaseListActivity() {
items.add(SwitchItem("显示日视图背景", PreferenceUtils.getBooleanFromSP(applicationContext, "s_colorful_day_widget", false)))
items.add(SwitchItem("显示侧栏「苏大生活」", PreferenceUtils.getBooleanFromSP(applicationContext, "suda_life", true)))
items.add(HorizontalItem("设置当前课表", ""))
+ items.add(SwitchItem("使用暗黑模式", PreferenceUtils.getBooleanFromSP(applicationContext, "s_night_mode", false)))
items.add(CategoryItem("高级", false))
when (BuildConfig.CHANNEL) {
@@ -100,6 +102,14 @@ class SettingsActivity : BaseListActivity() {
PreferenceUtils.saveBooleanToSP(applicationContext, "suda_life", isChecked)
mRecyclerView.snackbar("重启App后生效哦")
}
+ "使用暗黑模式" -> {
+ PreferenceUtils.saveBooleanToSP(applicationContext, "s_night_mode", isChecked)
+ if (isChecked) {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
+ } else {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
+ }
+ }
}
item.checked = isChecked
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsFragment.kt
new file mode 100644
index 00000000..d5b02640
--- /dev/null
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsFragment.kt
@@ -0,0 +1,66 @@
+package com.suda.yzune.wakeupschedule.settings
+
+import android.os.Bundle
+import android.view.View
+import androidx.recyclerview.widget.LinearLayoutManager
+import com.drakeet.multitype.MultiTypeAdapter
+import com.suda.yzune.wakeupschedule.base_view.BaseListFragment
+import com.suda.yzune.wakeupschedule.settings.bean.CategoryItem
+import com.suda.yzune.wakeupschedule.settings.bean.HorizontalItem
+import com.suda.yzune.wakeupschedule.settings.bean.SwitchItem
+import com.suda.yzune.wakeupschedule.settings.bean.VerticalItem
+import com.suda.yzune.wakeupschedule.settings.view_binder.CategoryItemViewBinder
+import com.suda.yzune.wakeupschedule.settings.view_binder.HorizontalItemViewBinder
+import com.suda.yzune.wakeupschedule.settings.view_binder.SwitchItemViewBinder
+import com.suda.yzune.wakeupschedule.settings.view_binder.VerticalItemViewBinder
+
+class SettingsFragment : BaseListFragment() {
+
+ private val mAdapter: MultiTypeAdapter = MultiTypeAdapter()
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ onAdapterCreated(mAdapter)
+ val items = mutableListOf()
+ onItemsCreated(items)
+ mAdapter.items = items
+ mRecyclerView.layoutManager = LinearLayoutManager(context)
+ mRecyclerView.adapter = mAdapter
+ }
+
+
+ private fun onItemsCreated(items: MutableList) {
+ items.add(VerticalItem("课程数据"))
+ items.add(VerticalItem("外观"))
+ items.add(VerticalItem("桌面小部件"))
+ items.add(VerticalItem("提醒"))
+ items.add(VerticalItem("备份"))
+ items.add(VerticalItem("关于"))
+ }
+
+ private fun onAdapterCreated(adapter: MultiTypeAdapter) {
+ adapter.register(CategoryItem::class, CategoryItemViewBinder())
+ adapter.register(HorizontalItem::class, HorizontalItemViewBinder { onHorizontalItemClick(it) })
+ adapter.register(VerticalItem::class, VerticalItemViewBinder({ onVerticalItemClick(it) }, { false }))
+ adapter.register(SwitchItem::class, SwitchItemViewBinder { item, isCheck -> onSwitchItemCheckChange(item, isCheck) })
+ }
+
+ private fun onSwitchItemCheckChange(item: SwitchItem, isChecked: Boolean) {
+ when (item.title) {
+
+ }
+ item.checked = isChecked
+ }
+
+ private fun onHorizontalItemClick(item: HorizontalItem) {
+ when (item.title) {
+
+ }
+ }
+
+ private fun onVerticalItemClick(item: VerticalItem) {
+ when (item.title) {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsHostActivity.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsHostActivity.kt
new file mode 100644
index 00000000..25e25ffe
--- /dev/null
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/SettingsHostActivity.kt
@@ -0,0 +1,37 @@
+package com.suda.yzune.wakeupschedule.settings
+
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import androidx.lifecycle.ViewModelProviders
+import androidx.navigation.NavArgument
+import androidx.navigation.NavController
+import androidx.navigation.NavType
+import androidx.navigation.Navigation
+import androidx.navigation.fragment.NavHostFragment
+import com.suda.yzune.wakeupschedule.R
+import com.suda.yzune.wakeupschedule.base_view.BaseTitleActivity
+
+class SettingsHostActivity : BaseTitleActivity() {
+
+ override val layoutId: Int
+ get() = R.layout.activity_settings_host
+
+ private lateinit var navController: NavController
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ initView()
+ }
+
+ private fun initView() {
+ val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_fragment) as NavHostFragment
+ val navGraph = navHostFragment.navController.navInflater.inflate(R.navigation.nav_settings)
+ val fragDestination = navGraph.findNode(R.id.settingsFragment)!!
+ navHostFragment.navController.graph = navGraph
+// navController = Navigation.findNavController(this, R.id.nav_fragment)
+// navController.addOnDestinationChangedListener { _, destination, _ ->
+// mainTitle.text = destination.label
+// }
+ }
+
+}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeSettingsAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeSettingsAdapter.kt
index d697e01e..25590c00 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeSettingsAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeSettingsAdapter.kt
@@ -1,13 +1,13 @@
package com.suda.yzune.wakeupschedule.settings
-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.TimeDetailBean
import kotlinx.android.parcel.RawValue
class TimeSettingsAdapter(private val layoutResId: Int, val list: @RawValue List) :
- BaseItemDraggableAdapter(layoutResId, list) {
+ BaseQuickAdapter(layoutResId, list) {
override fun convert(helper: BaseViewHolder, item: TimeDetailBean) {
val name = "第 ${item.node} 节"
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeSettingsViewModel.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeSettingsViewModel.kt
index ac57278c..db41b430 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeSettingsViewModel.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeSettingsViewModel.kt
@@ -84,7 +84,7 @@ class TimeSettingsViewModel(application: Application) : AndroidViewModel(applica
}
fun initTimeSelectList() {
- for (i in 6..24) {
+ for (i in 6..23) {
for (j in 0..55 step 5) {
val h = if (i < 10) "0$i" else i.toString()
val m = if (j < 10) "0$j" else j.toString()
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeTableAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeTableAdapter.kt
index e020b980..dce6d72d 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeTableAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/TimeTableAdapter.kt
@@ -1,12 +1,12 @@
package com.suda.yzune.wakeupschedule.settings
-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.TimeTableBean
class TimeTableAdapter(layoutResId: Int, data: List, var selectedId: Int) :
- BaseItemDraggableAdapter(layoutResId, data) {
+ BaseQuickAdapter(layoutResId, data) {
override fun convert(helper: BaseViewHolder, item: TimeTableBean) {
if (item.id == 1) {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/bean/VerticalItem.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/bean/VerticalItem.kt
index ec4ee1ac..fd9474c2 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/bean/VerticalItem.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/bean/VerticalItem.kt
@@ -2,6 +2,6 @@ package com.suda.yzune.wakeupschedule.settings.bean
data class VerticalItem(
val title: String,
- val description: String,
+ val description: String = "",
val isSpanned: Boolean = false,
val keys: List? = null) : BaseItem(keys)
\ No newline at end of file
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/CategoryItemViewBinder.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/CategoryItemViewBinder.kt
index b711e87c..994472f2 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/CategoryItemViewBinder.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/CategoryItemViewBinder.kt
@@ -8,11 +8,11 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.content.ContextCompat
+import com.drakeet.multitype.ItemViewBinder
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.settings.bean.CategoryItem
import com.suda.yzune.wakeupschedule.utils.PreferenceUtils
import com.suda.yzune.wakeupschedule.utils.ViewUtils
-import me.drakeet.multitype.ItemViewBinder
import org.jetbrains.anko.*
class CategoryItemViewBinder : ItemViewBinder() {
@@ -30,9 +30,9 @@ class CategoryItemViewBinder : ItemViewBinder Unit) : ItemViewBinder() {
@@ -29,7 +29,6 @@ class HorizontalItemViewBinder constructor(private val onHorizontalItemClickList
textView {
id = R.id.anko_text_view
- textColor = Color.BLACK
textSize = 16f
gravity = Gravity.CENTER_VERTICAL
lines = 1
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/SeekBarItemViewBinder.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/SeekBarItemViewBinder.kt
index 56a1114d..632850eb 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/SeekBarItemViewBinder.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/SeekBarItemViewBinder.kt
@@ -7,10 +7,10 @@ import android.widget.TextView
import androidx.appcompat.widget.AppCompatSeekBar
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
+import com.drakeet.multitype.ItemViewBinder
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.settings.bean.SeekBarItem
import com.suda.yzune.wakeupschedule.utils.PreferenceUtils
-import me.drakeet.multitype.ItemViewBinder
import org.jetbrains.anko.*
import org.jetbrains.anko.custom.ankoView
@@ -26,7 +26,6 @@ class SeekBarItemViewBinder constructor(private val onSeekValueChange: (SeekBarI
linearLayout {
textView {
id = R.id.anko_text_view
- textColor = Color.BLACK
textSize = 16f
gravity = Gravity.CENTER_VERTICAL
}.lparams(0, matchParent) {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/SwitchItemViewBinder.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/SwitchItemViewBinder.kt
index 9c9dd62d..8d28f394 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/SwitchItemViewBinder.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/SwitchItemViewBinder.kt
@@ -10,10 +10,10 @@ import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.widget.AppCompatCheckBox
import androidx.core.content.ContextCompat
+import com.drakeet.multitype.ItemViewBinder
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.settings.bean.SwitchItem
import com.suda.yzune.wakeupschedule.utils.PreferenceUtils
-import me.drakeet.multitype.ItemViewBinder
import org.jetbrains.anko.*
import org.jetbrains.anko.custom.ankoView
@@ -32,7 +32,6 @@ class SwitchItemViewBinder constructor(private val onCheckItemCheckChange: (Swit
lparams(matchParent, dip(64))
textView {
id = R.id.anko_text_view
- textColor = Color.BLACK
textSize = 16f
}.lparams(0, wrapContent) {
gravity = Gravity.CENTER_VERTICAL
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/VerticalItemViewBinder.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/VerticalItemViewBinder.kt
index 1ce3ce47..afba88d4 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/VerticalItemViewBinder.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/settings/view_binder/VerticalItemViewBinder.kt
@@ -7,10 +7,10 @@ import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
+import com.drakeet.multitype.ItemViewBinder
import com.suda.yzune.wakeupschedule.R
import com.suda.yzune.wakeupschedule.settings.bean.VerticalItem
import com.suda.yzune.wakeupschedule.utils.ViewUtils
-import me.drakeet.multitype.ItemViewBinder
import org.jetbrains.anko.*
class VerticalItemViewBinder constructor(
@@ -26,14 +26,14 @@ class VerticalItemViewBinder constructor(
val outValue = TypedValue()
context.theme.resolveAttribute(R.attr.selectableItemBackground, outValue, true)
backgroundResource = outValue.resourceId
+ topPadding = dip(16)
+ bottomPadding = dip(16)
lparams(matchParent, wrapContent)
textView {
id = R.id.anko_text_view
- textColor = Color.BLACK
textSize = 16f
}.lparams(wrapContent, wrapContent) {
- topMargin = dip(16)
marginStart = dip(16)
marginEnd = dip(16)
}
@@ -42,7 +42,6 @@ class VerticalItemViewBinder constructor(
textSize = 12f
}.lparams(wrapContent, wrapContent) {
topMargin = dip(4)
- bottomMargin = dip(16)
marginStart = dip(16)
marginEnd = dip(16)
}
@@ -53,13 +52,18 @@ class VerticalItemViewBinder constructor(
override fun onBindViewHolder(holder: ViewHolder, item: VerticalItem) {
holder.tvTitle.text = item.title
- if (item.isSpanned) {
- holder.tvDescription.text = ViewUtils.getHtmlSpannedString(item.description)
- } else {
- holder.tvDescription.text = item.description
- }
holder.llVerticalItem.setOnClickListener { onVerticalItemClickListener.invoke(item) }
holder.llVerticalItem.setOnLongClickListener { onVerticalItemLongClickListener.invoke(item) }
+ if (item.description.isEmpty()) {
+ holder.tvDescription.visibility = View.GONE
+ } else {
+ holder.tvDescription.visibility = View.VISIBLE
+ if (item.isSpanned) {
+ holder.tvDescription.text = ViewUtils.getHtmlSpannedString(item.description)
+ } else {
+ holder.tvDescription.text = item.description
+ }
+ }
}
class ViewHolder(itemView: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(itemView) {
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/suda_life/RoomAdapter.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/suda_life/RoomAdapter.kt
index 848696d5..013ff70c 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/suda_life/RoomAdapter.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/suda_life/RoomAdapter.kt
@@ -1,13 +1,13 @@
package com.suda.yzune.wakeupschedule.suda_life
-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.SudaRoomData
import com.suda.yzune.wakeupschedule.widget.RoomView
class RoomAdapter(layoutResId: Int, data: MutableList) :
- BaseItemDraggableAdapter(layoutResId, data) {
+ BaseQuickAdapter(layoutResId, data) {
override fun convert(helper: BaseViewHolder, item: SudaRoomData) {
helper.getView(R.id.room_view).list = item.kfj.split(',')
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/today_appwidget/TodayColorfulService.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/today_appwidget/TodayColorfulService.kt
index ee95a618..42282aae 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/today_appwidget/TodayColorfulService.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/today_appwidget/TodayColorfulService.kt
@@ -8,9 +8,9 @@ import android.graphics.drawable.GradientDrawable
import android.text.TextUtils
import android.view.Gravity
import android.view.View
+import android.widget.LinearLayout
import android.widget.RemoteViews
import android.widget.RemoteViewsService
-import android.widget.ScrollView
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import com.suda.yzune.wakeupschedule.AppDatabase
@@ -78,17 +78,23 @@ class TodayColorfulService : RemoteViewsService() {
}
override fun getCount(): Int {
- return 1
+ return if (courseList.isEmpty()) {
+ 1
+ } else {
+ courseList.size
+ }
}
override fun getViewAt(position: Int): RemoteViews {
return if (courseList.isNotEmpty()) {
val mRemoteViews = RemoteViews(applicationContext.packageName, R.layout.item_schedule_widget)
- val view = initView(applicationContext)
- val scrollView = view.find(R.id.anko_sv_schedule)
- ViewUtils.layoutView(scrollView, dip(1000), dip(500))
- mRemoteViews.setBitmap(R.id.iv_schedule, "setImageBitmap", ViewUtils.getViewBitmap(scrollView))
- scrollView.removeAllViews()
+ val view = initView(applicationContext, position)
+ val contentView = view.find(R.id.anko_layout)
+ val info = ViewUtils.getScreenInfo(applicationContext)
+ ViewUtils.layoutView(contentView, info[0], info[1])
+ val bitmap = ViewUtils.getViewBitmap(contentView, true, dip(2))
+ mRemoteViews.setBitmap(R.id.iv_schedule, "setImageBitmap", bitmap)
+ contentView.removeAllViews()
mRemoteViews
} else {
val mRemoteViews = RemoteViews(applicationContext.packageName, R.layout.item_today_course_empty)
@@ -97,9 +103,9 @@ class TodayColorfulService : RemoteViewsService() {
}
}
- private fun initView(context: Context): View {
+ private fun initView(context: Context, position: Int): View {
val iconFont = ResourcesCompat.getFont(context, R.font.iconfont)
- val dp = 5
+ val dp = 2
val alphaInt = (255 * (table.widgetItemAlpha.toFloat() / 100)).roundToInt()
var alphaStr = if (alphaInt != 0) {
Integer.toHexString(alphaInt)
@@ -110,135 +116,131 @@ class TodayColorfulService : RemoteViewsService() {
alphaStr = "0$alphaStr"
}
return context.UI {
- scrollView {
- id = R.id.anko_sv_schedule
- overScrollMode = View.OVER_SCROLL_NEVER
- isVerticalScrollBarEnabled = false
- verticalLayout {
- for (c in courseList) {
- linearLayout {
- topPadding = dip(dp * 4)
- bottomPadding = dip(dp * 4)
- leftPadding = dip(dp * 4)
- rightPadding = dip(dp * 4)
- background = ContextCompat.getDrawable(context.applicationContext, R.drawable.course_item_bg_today)
- val myGrad = background as GradientDrawable
+
+ verticalLayout {
+ id = R.id.anko_layout
+ val c = courseList[position]
+ linearLayout {
+ topPadding = dip(dp * 4)
+ bottomPadding = dip(dp * 4)
+ leftPadding = dip(dp * 4)
+ rightPadding = dip(dp * 4)
+ background = ContextCompat.getDrawable(context.applicationContext, R.drawable.course_item_bg_today)
+ val myGrad = background as GradientDrawable
// myGrad.cornerRadius = dip(dp * 4).toFloat()
- myGrad.setStroke(dip(dp), table.widgetStrokeColor)
- when {
- c.color.length == 7 -> myGrad.setColor(Color.parseColor("#$alphaStr${c.color.substring(1, 7)}"))
- c.color.isEmpty() -> {
- myGrad.setColor(Color.parseColor("#${alphaStr}fa6278"))
- }
- else -> myGrad.setColor(Color.parseColor("#$alphaStr${c.color.substring(3, 9)}"))
- }
+ myGrad.setStroke(dip(dp), table.widgetStrokeColor)
+ when {
+ c.color.length == 7 -> myGrad.setColor(Color.parseColor("#$alphaStr${c.color.substring(1, 7)}"))
+ c.color.isEmpty() -> {
+ myGrad.setColor(Color.parseColor("#${alphaStr}fa6278"))
+ }
+ else -> myGrad.setColor(Color.parseColor("#$alphaStr${c.color.substring(3, 9)}"))
+ }
- verticalLayout {
- gravity = Gravity.CENTER
- // 开始节
- textView(c.startNode.toString()) {
- alpha = 0.8f
- textColor = table.widgetCourseTextColor
- textSize = sp(12).toFloat()
- typeface = Typeface.DEFAULT_BOLD
- }.lparams(wrapContent, wrapContent) {
- bottomMargin = dip(dp * 2)
- }
- // 结束节
- textView("${c.startNode + c.step - 1}") {
- alpha = 0.8f
- textColor = table.widgetCourseTextColor
- textSize = sp(12).toFloat()
- typeface = Typeface.DEFAULT_BOLD
- }.lparams(wrapContent, wrapContent) {
- topMargin = dip(dp * 2)
- }
+ verticalLayout {
+ gravity = Gravity.CENTER
+ // 开始节
+ textView(c.startNode.toString()) {
+ alpha = 0.8f
+ textColor = table.widgetCourseTextColor
+ textSize = 12f
+ typeface = Typeface.DEFAULT_BOLD
+ }.lparams(wrapContent, wrapContent) {
+ bottomMargin = dip(dp * 2)
+ }
+ // 结束节
+ textView("${c.startNode + c.step - 1}") {
+ alpha = 0.8f
+ textColor = table.widgetCourseTextColor
+ textSize = 12f
+ typeface = Typeface.DEFAULT_BOLD
+ }.lparams(wrapContent, wrapContent) {
+ topMargin = dip(dp * 2)
+ }
- }.lparams(dip(dp * 10), matchParent)
+ }.lparams(dip(dp * 10), matchParent)
- verticalLayout {
- gravity = Gravity.CENTER
+ verticalLayout {
+ gravity = Gravity.CENTER
- textView(timeList[c.startNode - 1].startTime) {
- alpha = 0.8f
- textColor = table.widgetCourseTextColor
- textSize = sp(12).toFloat()
- }.lparams(wrapContent, wrapContent) {
- margin = dip(dp * 2)
- }
+ textView(timeList[c.startNode - 1].startTime) {
+ alpha = 0.8f
+ textColor = table.widgetCourseTextColor
+ textSize = 12f
+ }.lparams(wrapContent, wrapContent) {
+ margin = dip(dp * 2)
+ }
- textView(timeList[c.startNode + c.step - 2].endTime) {
- alpha = 0.8f
- textColor = table.widgetCourseTextColor
- textSize = sp(12).toFloat()
- }.lparams(wrapContent, wrapContent) {
- margin = dip(dp * 2)
- }
+ textView(timeList[c.startNode + c.step - 2].endTime) {
+ alpha = 0.8f
+ textColor = table.widgetCourseTextColor
+ textSize = 12f
+ }.lparams(wrapContent, wrapContent) {
+ margin = dip(dp * 2)
+ }
+
+ }.lparams(wrapContent, matchParent)
+
+ verticalLayout {
+ gravity = Gravity.CENTER_VERTICAL
- }.lparams(wrapContent, matchParent)
-
- verticalLayout {
- gravity = Gravity.CENTER_VERTICAL
-
- textView(c.courseName) {
- textColor = table.widgetCourseTextColor
- textSize = sp(14).toFloat()
- typeface = Typeface.DEFAULT_BOLD
- }.lparams(matchParent, wrapContent)
-
- if (c.room != "" || c.teacher != "") {
- linearLayout {
- if (c.room != "") {
- textView("\uE6B2") {
- alpha = 0.8f
- textColor = table.widgetCourseTextColor
- textSize = sp(12).toFloat()
- typeface = iconFont
- }.lparams(wrapContent, wrapContent)
-
- textView(c.room) {
- alpha = 0.8f
- textColor = table.widgetCourseTextColor
- maxLines = 1
- textSize = sp(12).toFloat()
- }.lparams(wrapContent, wrapContent) {
- marginStart = dip(dp * 2)
- marginEnd = dip(dp * 8)
- }
- }
- if (c.teacher != "") {
- textView("\uE6EB") {
- alpha = 0.8f
- textColor = table.widgetCourseTextColor
- textSize = sp(12).toFloat()
- typeface = iconFont
- }.lparams(wrapContent, wrapContent)
-
- textView(c.teacher) {
- alpha = 0.8f
- textColor = table.widgetCourseTextColor
- maxLines = 1
- ellipsize = TextUtils.TruncateAt.END
- textSize = sp(12).toFloat()
- }.lparams(wrapContent, wrapContent) {
- marginStart = dip(dp * 2)
- }
- }
- }.lparams(matchParent, wrapContent) {
- topMargin = dip(dp * 4)
+ textView(c.courseName) {
+ textColor = table.widgetCourseTextColor
+ textSize = 14f
+ typeface = Typeface.DEFAULT_BOLD
+ }.lparams(matchParent, wrapContent)
+
+ if (c.room != "" || c.teacher != "") {
+ linearLayout {
+ if (c.room != "") {
+ textView("\uE6B2") {
+ alpha = 0.8f
+ textColor = table.widgetCourseTextColor
+ textSize = 12f
+ typeface = iconFont
+ }.lparams(wrapContent, wrapContent)
+
+ textView(c.room) {
+ alpha = 0.8f
+ textColor = table.widgetCourseTextColor
+ maxLines = 1
+ textSize = 12f
+ }.lparams(wrapContent, wrapContent) {
+ marginStart = dip(dp * 2)
+ marginEnd = dip(dp * 8)
}
}
+ if (c.teacher != "") {
+ textView("\uE6EB") {
+ alpha = 0.8f
+ textColor = table.widgetCourseTextColor
+ textSize = 12f
+ typeface = iconFont
+ }.lparams(wrapContent, wrapContent)
- }.lparams(wrapContent, matchParent) {
- marginStart = dip(dp)
+ textView(c.teacher) {
+ alpha = 0.8f
+ textColor = table.widgetCourseTextColor
+ maxLines = 1
+ ellipsize = TextUtils.TruncateAt.END
+ textSize = 12f
+ }.lparams(wrapContent, wrapContent) {
+ marginStart = dip(dp * 2)
+ }
+ }
+ }.lparams(matchParent, wrapContent) {
+ topMargin = dip(dp * 4)
}
-
- }.lparams(matchParent, wrapContent) {
- bottomMargin = dip(dp * 2)
}
+
+ }.lparams(wrapContent, matchParent) {
+ marginStart = dip(dp)
}
- }
+
+ }.lparams(matchParent, wrapContent)
+
}
+
}.view
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/utils/AppWidgetUtils.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/utils/AppWidgetUtils.kt
index 5ddb961b..f986f47e 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/utils/AppWidgetUtils.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/utils/AppWidgetUtils.kt
@@ -37,14 +37,17 @@ object AppWidgetUtils {
mRemoteViews.setTextViewTextSize(R.id.tv_date, TypedValue.COMPLEX_UNIT_SP, tableBean.widgetItemTextSize.toFloat() + 2)
mRemoteViews.setTextViewTextSize(R.id.tv_week, TypedValue.COMPLEX_UNIT_SP, tableBean.widgetItemTextSize.toFloat())
mRemoteViews.setTextViewText(R.id.tv_date, date)
+ if (tableBean.tableName.isEmpty()) {
+ tableBean.tableName = "我的课表"
+ }
if (week > 0) {
if (nextWeek) {
- mRemoteViews.setTextViewText(R.id.tv_week, "第${week}周")
+ mRemoteViews.setTextViewText(R.id.tv_week, "${tableBean.tableName} | 第${week}周")
} else {
- mRemoteViews.setTextViewText(R.id.tv_week, "第${week}周 $weekDay")
+ mRemoteViews.setTextViewText(R.id.tv_week, "${tableBean.tableName} | 第${week}周 $weekDay")
}
} else {
- mRemoteViews.setTextViewText(R.id.tv_week, "还没有开学哦")
+ mRemoteViews.setTextViewText(R.id.tv_week, "${tableBean.tableName} | 还没有开学哦")
week = 1
}
@@ -73,6 +76,7 @@ object AppWidgetUtils {
mRemoteViews.setInt(R.id.iv_back, "setColorFilter", tableBean.widgetTextColor)
val weekDate = CourseUtils.getDateStringFromWeek(CourseUtils.countWeek(tableBean.startDate, tableBean.sundayFirst), week, tableBean.sundayFirst)
mRemoteViews.setTextColor(R.id.tv_title0, tableBean.widgetTextColor)
+ mRemoteViews.setTextViewTextSize(R.id.tv_title0, TypedValue.COMPLEX_UNIT_SP, tableBean.widgetItemTextSize.toFloat())
mRemoteViews.setTextViewText(R.id.tv_title0, weekDate[0] + "\n月")
if (nextWeek) {
mRemoteViews.setTextViewText(R.id.tv_date, "下周")
@@ -110,18 +114,18 @@ object AppWidgetUtils {
}
val lvIntent = Intent(context, ScheduleAppWidgetService::class.java)
lvIntent.data = if (nextWeek) {
- Uri.fromParts("content", "1", null)
+ Uri.fromParts("content", "1,${tableBean.id}", null)
} else {
- Uri.fromParts("content", "0", null)
+ Uri.fromParts("content", "0,${tableBean.id}", null)
}
mRemoteViews.setRemoteAdapter(R.id.lv_schedule, lvIntent)
val intent = Intent(context, SplashActivity::class.java)
val pIntent = PendingIntent.getActivity(context, 0, intent, 0)
mRemoteViews.setOnClickPendingIntent(R.id.tv_date, pIntent)
- val i = Intent(context, ScheduleAppWidget::class.java)
- i.action = "WAKEUP_NEXT_WEEK"
- val pi = PendingIntent.getBroadcast(context, 1, i, PendingIntent.FLAG_UPDATE_CURRENT)
+ val nextIntent = Intent(context, ScheduleAppWidget::class.java)
+ nextIntent.action = "WAKEUP_NEXT_WEEK"
+ val pi = PendingIntent.getBroadcast(context, 1, nextIntent, PendingIntent.FLAG_UPDATE_CURRENT)
mRemoteViews.setOnClickPendingIntent(R.id.iv_next, pi)
val backIntent = Intent(context, ScheduleAppWidget::class.java)
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/utils/ICalUtils.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/utils/ICalUtils.kt
index 1a2d886d..54b7e51a 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/utils/ICalUtils.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/utils/ICalUtils.kt
@@ -1,28 +1,22 @@
package com.suda.yzune.wakeupschedule.utils
+import biweekly.ICalendar
+import biweekly.component.VEvent
+import biweekly.property.Uid
+import biweekly.util.Frequency
+import biweekly.util.Recurrence
import com.suda.yzune.wakeupschedule.bean.CourseBean
import com.suda.yzune.wakeupschedule.bean.TimeDetailBean
-import net.fortuna.ical4j.model.*
-import net.fortuna.ical4j.model.component.VAlarm
-import net.fortuna.ical4j.model.component.VEvent
-import net.fortuna.ical4j.model.parameter.Value
-import net.fortuna.ical4j.model.property.*
-import net.fortuna.ical4j.util.UidGenerator
import java.util.*
-import java.util.Calendar
-import java.util.Date
-import net.fortuna.ical4j.model.property.Summary
-import net.fortuna.ical4j.model.Dur
object ICalUtils {
- fun getClassEvents(startTimeMap: ArrayList,
+ fun getClassEvents(ical: ICalendar, startTimeMap: ArrayList,
endTimeMap: ArrayList,
maxWeek: Int,
course: CourseBean,
- termStart: Date): List {
- val result = arrayListOf()
+ termStart: Date) {
var i = 1
while (i <= maxWeek) {
if (course.inWeek(i)) {
@@ -31,14 +25,12 @@ object ICalUtils {
j--
val event = getClassEvent(startTimeMap, endTimeMap, course, 1, i, j, termStart)
if (event != null) {
- event.validate()
- result.add(event)
+ ical.addEvent(event)
}
i += j - i
}
i++
}
- return result
}
private fun getClassEvent(startTimeMap: ArrayList,
@@ -53,9 +45,11 @@ object ICalUtils {
val dayAfter = (endWeek - currentWeek) * 7 + course.day
// repeat every week until endDate
- val recur = Recur(Recur.WEEKLY, DateTime(CourseUtils.getDateAfter(termStart, dayAfter)))
- recur.interval = 1
- val rule = RRule(recur)
+ val recur = Recurrence.Builder(Frequency.WEEKLY).interval(1)
+ .until(CourseUtils.getDateAfter(termStart, dayAfter))
+ .build()
+// Recur(Recur.WEEKLY, DateTime(CourseUtils.getDateAfter(termStart, dayAfter)))
+// val rule = RRule(recur)
val startTime = startTimeMap[course.startNode - 1]
val endTime = endTimeMap[course.startNode + course.step - 2]
@@ -65,38 +59,23 @@ object ICalUtils {
dailyStart.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY))
dailyStart.set(Calendar.MINUTE, startTime.get(Calendar.MINUTE))
dailyStart.set(Calendar.DAY_OF_WEEK, weekDayConvert(course.day))
- val start = DateTime(dailyStart.time)
val dailyEnd = Calendar.getInstance()
dailyEnd.time = CourseUtils.getDateBefore(termStart, dayBefore)
dailyEnd.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY))
dailyEnd.set(Calendar.MINUTE, endTime.get(Calendar.MINUTE))
dailyEnd.set(Calendar.DAY_OF_WEEK, weekDayConvert(course.day))
- val end = DateTime(dailyEnd.time)
-
- val paraList = ParameterList()
- paraList.add(ParameterFactoryImpl.getInstance().createParameter(Value.PERIOD.name, Value.PERIOD.value))
-
- val periodList = PeriodList()
- periodList.add(Period(start, end))
- val rdate = RDate(paraList, periodList)
// create event, repeat weekly
- val event = VEvent(start, end, course.courseName)
+ val event = VEvent()
+ event.setUid("WakeUpSchedule-" + Uid.random().value)
+ event.setSummary(course.courseName)
+ event.setDateStart(dailyStart.time)
+ event.setDateEnd(dailyEnd.time)
+ event.setRecurrenceRule(recur)
+ event.setLocation("${course.room} ${course.teacher}")
+ event.setDescription("${course.getNodeString()}\n${course.room}\n${course.teacher}")
- // set event
- // event.properties.add(Uid(UidGenerator("WakeUpSchedule").generateUid().value))
- event.properties.add(Uid("WakeUpSchedule" + course.courseName.hashCode().toString()))
- event.properties.add(Location("${course.room} ${course.teacher}"))
- // event.alarms.add(VAlarm(Dur(0, 0, -30, 0)))
- val valarm = VAlarm(Dur(0, 0, -30, 0))
- valarm.properties.add(Summary(course.courseName))
- valarm.properties.add(Action.DISPLAY)
- // 将VAlarm加入VEvent
- event.alarms.add(valarm)
- event.properties.add(Description("${course.getNodeString()}\n${course.room}\n${course.teacher}"))
- event.properties.add(rdate)
- event.properties.add(rule)
return event
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/utils/PreferenceUtils.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/utils/PreferenceUtils.kt
index 6b1368be..8d6dacb8 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/utils/PreferenceUtils.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/utils/PreferenceUtils.kt
@@ -21,7 +21,7 @@ object PreferenceUtils {
editor.apply()
}
- fun getStringFromSP(context: Context, key: String, defaultString: String): String? {
+ fun getStringFromSP(context: Context, key: String, defaultString: String?): String? {
init(context)
return sp!!.getString(key, defaultString)
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/utils/ViewUtils.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/utils/ViewUtils.kt
index ebbf0deb..d66fd7db 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/utils/ViewUtils.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/utils/ViewUtils.kt
@@ -11,8 +11,8 @@ import android.text.Spanned
import android.util.DisplayMetrics
import android.view.Gravity
import android.view.View
+import android.view.ViewGroup
import android.view.WindowManager
-import android.widget.ScrollView
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.text.HtmlCompat
import com.suda.yzune.wakeupschedule.R
@@ -21,6 +21,7 @@ import org.jetbrains.anko.constraint.layout.constraintLayout
import java.io.File
import java.io.FileOutputStream
+
object ViewUtils {
fun judgeColorIsLight(color: Int): Boolean {
@@ -30,6 +31,15 @@ object ViewUtils {
return (0.213 * red + 0.715 * green + 0.072 * blue > 255 / 2)
}
+ fun getScreenInfo(context: Context): Array {
+ val displayMetrics = DisplayMetrics()
+ val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
+ wm.defaultDisplay.getMetrics(displayMetrics)
+ val height = displayMetrics.heightPixels
+ val width = displayMetrics.widthPixels
+ return arrayOf(width, height)
+ }
+
fun createScheduleView(context: Context, tColor: Int = Color.BLACK, day: Int = -1): View {
return context.UI {
constraintLayout {
@@ -235,6 +245,17 @@ object ViewUtils {
return vh
}
+ fun createColorStateList(color: Int): ColorStateList {
+ val colors = intArrayOf(color, color, color, color, color, color)
+ val states = arrayOfNulls(6)
+ states[0] = intArrayOf(android.R.attr.state_pressed, android.R.attr.state_enabled)
+ states[1] = intArrayOf(android.R.attr.state_enabled, android.R.attr.state_focused)
+ states[2] = intArrayOf(android.R.attr.state_enabled)
+ states[3] = intArrayOf(android.R.attr.state_focused)
+ states[4] = intArrayOf(android.R.attr.state_window_focused)
+ states[5] = intArrayOf()
+ return ColorStateList(states, colors)
+ }
fun createColorStateList(normal: Int, pressed: Int, focused: Int, unable: Int): ColorStateList {
val colors = intArrayOf(pressed, focused, normal, focused, unable, normal)
@@ -280,18 +301,18 @@ object ViewUtils {
//activity.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file1.getAbsolutePath())));
}
- fun getViewBitmap(scrollView: ScrollView): Bitmap {
+ fun getViewBitmap(viewGroup: ViewGroup, low: Boolean = false, marginBottom: Int = 0): Bitmap {
var h = 0
val bitmap: Bitmap
// 获取scrollView实际高度,这里很重要
- for (i in 0 until scrollView.childCount) {
- h += scrollView.getChildAt(i).height
+ for (i in 0 until viewGroup.childCount) {
+ h += viewGroup.getChildAt(i).height + marginBottom
}
// 创建对应大小的bitmap
- bitmap = Bitmap.createBitmap(scrollView.width, h,
- Bitmap.Config.ARGB_8888)
+ bitmap = Bitmap.createBitmap(viewGroup.width, h,
+ if (low) Bitmap.Config.ARGB_4444 else Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
- scrollView.draw(canvas)
+ viewGroup.draw(canvas)
return bitmap
}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/widget/EditDetailFragment.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/widget/EditDetailFragment.kt
new file mode 100644
index 00000000..13b0aeed
--- /dev/null
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/widget/EditDetailFragment.kt
@@ -0,0 +1,80 @@
+package com.suda.yzune.wakeupschedule.widget
+
+
+import android.app.Dialog
+import android.os.Bundle
+import android.view.View
+import android.widget.EditText
+import androidx.fragment.app.BaseDialogFragment
+import com.google.android.material.chip.Chip
+import com.suda.yzune.wakeupschedule.R
+import kotlinx.android.synthetic.main.fragment_edit_detail.*
+import org.jetbrains.anko.find
+
+class EditDetailFragment : BaseDialogFragment() {
+
+ private val detailData: ArrayList? by lazy {
+ arguments?.getStringArrayList("data")
+ }
+
+ private val title: String by lazy {
+ arguments?.getString("title") ?: "编辑"
+ }
+
+ private val value: String by lazy {
+ arguments?.getString("value") ?: ""
+ }
+
+ var listener: OnSaveClickedListener? = null
+
+ override val layoutId: Int
+ get() = R.layout.fragment_edit_detail
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ tv_title.text = title
+ et_detail.setText(value)
+ val hasData = detailData?.any {
+ it.isNotBlank()
+ } ?: false
+ if (!hasData) {
+ sv_details.visibility = View.GONE
+ et_detail.hint = "请输入…"
+ }
+ detailData?.forEach {
+ if (it.isEmpty()) return@forEach
+ val chip = layoutInflater.inflate(R.layout.chip_group_item_choice, cg_details, false) as Chip
+ chip.text = it
+ cg_details.addView(chip)
+ }
+ cg_details.setOnCheckedChangeListener { group, checkedId ->
+ if (checkedId < 0) return@setOnCheckedChangeListener
+ val t = group.find(checkedId).text
+ et_detail.setText(t)
+ }
+ tv_save.setOnClickListener {
+ listener?.save(et_detail, dialog!!)
+ }
+ }
+
+ interface OnSaveClickedListener {
+ fun save(editText: EditText, dialog: Dialog)
+ }
+
+ override fun onDetach() {
+ super.onDetach()
+ listener = null
+ }
+
+ companion object {
+ @JvmStatic
+ fun newInstance(title: String, data: ArrayList, str: String) =
+ EditDetailFragment().apply {
+ arguments = Bundle().apply {
+ putString("title", title)
+ putStringArrayList("data", data)
+ putString("value", str)
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/suda/yzune/wakeupschedule/widget/TipTextView.kt b/app/src/main/java/com/suda/yzune/wakeupschedule/widget/TipTextView.kt
index c82b6422..4079d97e 100644
--- a/app/src/main/java/com/suda/yzune/wakeupschedule/widget/TipTextView.kt
+++ b/app/src/main/java/com/suda/yzune/wakeupschedule/widget/TipTextView.kt
@@ -1,18 +1,24 @@
package com.suda.yzune.wakeupschedule.widget
+import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
-import android.graphics.Paint.Style
+import android.graphics.Paint
import android.graphics.Path
+import android.graphics.Typeface
+import android.text.Layout
+import android.text.StaticLayout
+import android.text.TextPaint
import android.util.AttributeSet
-import androidx.appcompat.widget.AppCompatTextView
-
+import android.util.TypedValue
+import android.view.View
import org.jetbrains.anko.dip
-class TipTextView : AppCompatTextView {
+@SuppressLint("ViewConstructor")
+class TipTextView(mColor: Int, mSize: Int, context: Context) : View(context) {
- private val path = Path()
+ var text: String = ""
var tipVisibility = 0
set(value) {
@@ -20,17 +26,18 @@ class TipTextView : AppCompatTextView {
invalidate()
}
- constructor(context: Context) : super(context) {
- init(null)
+ private val mTextPaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
+ textSize = mSize * resources.displayMetrics.scaledDensity
+ typeface = Typeface.DEFAULT_BOLD
+ color = mColor
}
-
- constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
- init(attrs)
- }
-
- constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
- init(attrs)
+ private val mPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
+ color = mColor
+ isDither = true
+ style = Paint.Style.FILL_AND_STROKE
}
+ private val path = Path()
+ private var mStaticLayout: StaticLayout? = null
fun init(attrs: AttributeSet?) {
if (attrs != null) {
@@ -38,19 +45,45 @@ class TipTextView : AppCompatTextView {
}
}
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
+ // Tell the parent layout how big this view would like to be
+ // but still respect any requirements (measure specs) that are passed down.
+
+ // determine the width
+ val width = MeasureSpec.getSize(widthMeasureSpec)
+
+ // determine the height
+ val height = MeasureSpec.getSize(heightMeasureSpec)
+
+ // Required call: set width and height
+ setMeasuredDimension(width, height)
+ }
+
+
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
+ if (mStaticLayout == null) {
+ mStaticLayout = StaticLayout(
+ text,
+ mTextPaint,
+ width - paddingRight - paddingLeft,
+ Layout.Alignment.ALIGN_NORMAL,
+ 1.0f,
+ 0f,
+ false
+ )
+ }
if (tipVisibility == 1) {
- paint.isAntiAlias = true
- paint.isDither = true
- paint.style = Style.FILL_AND_STROKE
-
path.moveTo(width - dip(12).toFloat(), height - dip(6).toFloat()) // 此点为多边形的起点
path.lineTo(width - dip(6).toFloat(), height - dip(6).toFloat())
path.lineTo(width - dip(6).toFloat(), height - dip(12).toFloat())
path.close() // 使这些点构成封闭的多边形
- canvas.drawPath(path, paint)
+ canvas.drawPath(path, mPaint)
}
+ canvas.save()
+ canvas.translate(paddingLeft.toFloat(), paddingTop.toFloat())
+ mStaticLayout!!.draw(canvas)
+ canvas.restore()
}
companion object {
diff --git a/app/src/main/res/drawable/card_bg.xml b/app/src/main/res/drawable/card_bg.xml
index 7592ea46..966a913c 100644
--- a/app/src/main/res/drawable/card_bg.xml
+++ b/app/src/main/res/drawable/card_bg.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/course_item_bg_today.xml b/app/src/main/res/drawable/course_item_bg_today.xml
index 3040f52b..bc0fb609 100644
--- a/app/src/main/res/drawable/course_item_bg_today.xml
+++ b/app/src/main/res/drawable/course_item_bg_today.xml
@@ -1,7 +1,7 @@
-
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/splash.xml b/app/src/main/res/drawable/splash.xml
index c0118323..ca2a632d 100644
--- a/app/src/main/res/drawable/splash.xml
+++ b/app/src/main/res/drawable/splash.xml
@@ -2,7 +2,7 @@
-
-
+
-
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
index 9d86a963..333838cf 100644
--- a/app/src/main/res/layout/activity_about.xml
+++ b/app/src/main/res/layout/activity_about.xml
@@ -93,6 +93,15 @@
android:textIsSelectable="true"
android:textSize="12sp" />
+
+
diff --git a/app/src/main/res/layout/activity_donate.xml b/app/src/main/res/layout/activity_donate.xml
index 657f0a89..845b83e6 100644
--- a/app/src/main/res/layout/activity_donate.xml
+++ b/app/src/main/res/layout/activity_donate.xml
@@ -1,6 +1,7 @@
-
+ android:textSize="12sp" />
-
+ android:textStyle="bold"
+ android:textSize="12sp" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_login_web.xml b/app/src/main/res/layout/activity_login_web.xml
index 3a55c36d..a2954ddf 100644
--- a/app/src/main/res/layout/activity_login_web.xml
+++ b/app/src/main/res/layout/activity_login_web.xml
@@ -3,7 +3,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fl_fragment"
android:layout_width="match_parent"
- android:background="@color/backgroundColor"
android:layout_height="match_parent"
tools:context=".schedule_import.LoginWebActivity">
diff --git a/app/src/main/res/layout/activity_schedule_manage.xml b/app/src/main/res/layout/activity_schedule_manage.xml
index d5495b75..df849f84 100644
--- a/app/src/main/res/layout/activity_schedule_manage.xml
+++ b/app/src/main/res/layout/activity_schedule_manage.xml
@@ -5,7 +5,6 @@
android:id="@+id/ll_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/backgroundColor"
android:orientation="vertical"
tools:context=".schedule_manage.ScheduleManageActivity">
diff --git a/app/src/main/res/layout/activity_school_list.xml b/app/src/main/res/layout/activity_school_list.xml
index c665749e..5eaf033c 100644
--- a/app/src/main/res/layout/activity_school_list.xml
+++ b/app/src/main/res/layout/activity_school_list.xml
@@ -5,7 +5,6 @@
android:id="@+id/ll_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@android:color/white"
android:orientation="vertical"
tools:context=".schedule_import.SchoolListActivity">
@@ -34,7 +33,7 @@
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
app:sidebarItemHeight="24dp"
- app:sidebarTextColor="@android:color/black"
+ app:sidebarTextColor="?attr/colorOnBackground"
app:sidebarTextColorChoose="@color/colorPrimary"
app:sidebarTextSize="11sp"
app:sidebarTextSizeChoose="14sp" />
diff --git a/app/src/main/res/layout/activity_settings_host.xml b/app/src/main/res/layout/activity_settings_host.xml
new file mode 100644
index 00000000..b6918c7e
--- /dev/null
+++ b/app/src/main/res/layout/activity_settings_host.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_time_settings.xml b/app/src/main/res/layout/activity_time_settings.xml
index 6f2b654b..8aa81108 100644
--- a/app/src/main/res/layout/activity_time_settings.xml
+++ b/app/src/main/res/layout/activity_time_settings.xml
@@ -6,7 +6,6 @@
android:id="@+id/ll_root"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
- android:background="@color/backgroundColor"
tools:context="com.suda.yzune.wakeupschedule.settings.TimeSettingsActivity">
-
@@ -37,6 +35,20 @@
android:id="@+id/iv_tip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="16dp" />
+ android:layout_margin="16dp"
+ tools:visibility="gone" />
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/adapter_school_name_head.xml b/app/src/main/res/layout/adapter_school_name_head.xml
index 92fc29ac..0520dcf2 100644
--- a/app/src/main/res/layout/adapter_school_name_head.xml
+++ b/app/src/main/res/layout/adapter_school_name_head.xml
@@ -1,8 +1,7 @@
+ android:layout_height="48dp">
+
+
diff --git a/app/src/main/res/layout/fragment_add_course_tip.xml b/app/src/main/res/layout/fragment_add_course_tip.xml
index 4cd6553f..21c37dc1 100644
--- a/app/src/main/res/layout/fragment_add_course_tip.xml
+++ b/app/src/main/res/layout/fragment_add_course_tip.xml
@@ -4,7 +4,6 @@
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:background="@android:color/white"
android:orientation="vertical"
tools:context=".course_add.AddCourseTipFragment">
@@ -29,8 +28,7 @@
android:layout_marginTop="-16dp"
android:layout_marginBottom="8dp"
android:gravity="center"
- android:text="温馨提示"
- android:textColor="@android:color/black" />
+ android:text="温馨提示" />
+ android:text="可容纳人数:90"
+ android:textColor="@android:color/black" />
+ android:text="当前滞留人数:"
+ android:textColor="@android:color/black" />
+ android:text="拥挤度:0%"
+ android:textColor="@android:color/black" />
@@ -138,13 +141,15 @@
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
- android:text="可容纳人数:80" />
+ android:text="可容纳人数:80"
+ android:textColor="@android:color/black" />
+ android:text="当前滞留人数:"
+ android:textColor="@android:color/black" />
+ android:text="拥挤度:0%"
+ android:textColor="@android:color/black" />
diff --git a/app/src/main/res/layout/fragment_before_feedback.xml b/app/src/main/res/layout/fragment_before_feedback.xml
index 3c55b161..27ff9aed 100644
--- a/app/src/main/res/layout/fragment_before_feedback.xml
+++ b/app/src/main/res/layout/fragment_before_feedback.xml
@@ -4,7 +4,6 @@
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:background="@android:color/white"
android:orientation="vertical"
tools:context=".schedule.BeforeFeedbackFragment">
@@ -19,7 +18,7 @@
android:fontFamily="@font/iconfont"
android:gravity="center"
android:includeFontPadding="false"
- android:text=""
+ android:text="@string/icon_close"
android:textSize="20sp" />
@@ -31,7 +30,6 @@
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="温馨提示"
- android:textColor="@android:color/black"
android:textStyle="bold" />
+
+
diff --git a/app/src/main/res/layout/fragment_color_picker.xml b/app/src/main/res/layout/fragment_color_picker.xml
index f7abdc58..f139d757 100644
--- a/app/src/main/res/layout/fragment_color_picker.xml
+++ b/app/src/main/res/layout/fragment_color_picker.xml
@@ -5,7 +5,6 @@
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:background="@android:color/white"
android:orientation="vertical"
tools:context=".widget.colorpicker.ColorPickerFragment">
@@ -15,7 +14,6 @@
android:layout_marginTop="24dp"
android:gravity="center"
android:text="选择颜色"
- android:textColor="@android:color/black"
android:textStyle="bold" />
diff --git a/app/src/main/res/layout/fragment_donate.xml b/app/src/main/res/layout/fragment_donate.xml
index 90941f88..3b409bf9 100644
--- a/app/src/main/res/layout/fragment_donate.xml
+++ b/app/src/main/res/layout/fragment_donate.xml
@@ -4,7 +4,6 @@
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:background="@android:color/white"
android:orientation="vertical"
tools:context=".schedule.DonateFragment">
@@ -31,7 +30,6 @@
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="ヾ(=・ω・=)o"
- android:textColor="@android:color/black"
android:textStyle="bold" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_excel_import.xml b/app/src/main/res/layout/fragment_excel_import.xml
index f15a7756..a2499258 100644
--- a/app/src/main/res/layout/fragment_excel_import.xml
+++ b/app/src/main/res/layout/fragment_excel_import.xml
@@ -9,13 +9,11 @@
+ android:layout_height="24dp" />
+ android:layout_height="48dp">
+ android:src="@drawable/ic_back"
+ android:tint="?attr/colorOnSurface" />
-
-
@@ -83,34 +76,30 @@
android:textColor="@color/colorAccent"
android:textSize="12sp" />
-
-
diff --git a/app/src/main/res/layout/fragment_export_settings.xml b/app/src/main/res/layout/fragment_export_settings.xml
index 2662ce2c..aca907a3 100644
--- a/app/src/main/res/layout/fragment_export_settings.xml
+++ b/app/src/main/res/layout/fragment_export_settings.xml
@@ -12,7 +12,6 @@
android:layout_marginTop="24dp"
android:gravity="center"
android:text="导出课程"
- android:textColor="@android:color/black"
android:textStyle="bold" />
+ android:layout_height="24dp" />
+ android:layout_height="48dp">
+ android:src="@drawable/ic_back"
+ android:tint="?attr/colorOnSurface" />
-
-
@@ -72,64 +65,56 @@
android:text="如果是从QQ或Tim或者微信收到分享的导出文件,请点击对应的按钮。如果存放在其他路径,请自行选择。"
android:textSize="12sp" />
-
-
-
-
diff --git a/app/src/main/res/layout/fragment_html_import.xml b/app/src/main/res/layout/fragment_html_import.xml
index 686aa7e4..5b8c9b2d 100644
--- a/app/src/main/res/layout/fragment_html_import.xml
+++ b/app/src/main/res/layout/fragment_html_import.xml
@@ -10,13 +10,11 @@
+ android:layout_height="24dp" />
+ android:layout_height="48dp">
+ android:src="@drawable/ic_back"
+ android:tint="?attr/colorOnSurface" />
-
-
@@ -76,107 +69,94 @@
android:text="1. 学校已在适配列表中\n2. 是受支持的教务类型\n为了确保成功,请仔细阅读教程进行操作\n滑到底部点击最下方的圆形按钮确认导入"
android:textSize="12sp" />
-
-
-
-
-
-
@@ -205,7 +185,7 @@
android:checkable="true"
android:text="UTF-8"
android:textAlignment="center"
- android:textColor="@android:color/white"
+ android:textColor="?attr/colorSurface"
app:chipBackgroundColor="@color/pink" />
@@ -251,7 +231,7 @@
android:layout_height="wrap_content"
android:checkable="true"
android:text="强智 1"
- android:textColor="@android:color/white"
+ android:textColor="?attr/colorSurface"
app:chipBackgroundColor="@color/red" />
@@ -328,7 +308,7 @@
android:layout_height="wrap_content"
android:checkable="true"
android:text="正方 1"
- android:textColor="@android:color/white"
+ android:textColor="?attr/colorSurface"
app:chipBackgroundColor="@color/red" />
diff --git a/app/src/main/res/layout/fragment_import_choose.xml b/app/src/main/res/layout/fragment_import_choose.xml
index 3e6382ec..c61d3ff5 100644
--- a/app/src/main/res/layout/fragment_import_choose.xml
+++ b/app/src/main/res/layout/fragment_import_choose.xml
@@ -28,7 +28,6 @@
android:layout_marginTop="-16dp"
android:gravity="center"
android:text="导入课程"
- android:textColor="@android:color/black"
android:textStyle="bold" />
diff --git a/app/src/main/res/layout/fragment_import_setting.xml b/app/src/main/res/layout/fragment_import_setting.xml
index 6818fd34..f3abaad3 100644
--- a/app/src/main/res/layout/fragment_import_setting.xml
+++ b/app/src/main/res/layout/fragment_import_setting.xml
@@ -14,7 +14,6 @@
android:layout_marginTop="24dp"
android:gravity="center"
android:text="导入课程"
- android:textColor="@android:color/black"
android:textStyle="bold" />
+
+
+ app:layout_behavior="@string/fab_transformation_sheet_behavior"
+ tools:visibility="visible">
-
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+ android:layout_marginTop="8dp"
+ android:layout_weight="1"
+ android:text="确定"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@id/btn_cancel"
+ app:layout_constraintTop_toBottomOf="@id/wp_term" />
+
+
diff --git a/app/src/main/res/layout/fragment_modify_table_name.xml b/app/src/main/res/layout/fragment_modify_table_name.xml
index fd88474a..b82d33cd 100644
--- a/app/src/main/res/layout/fragment_modify_table_name.xml
+++ b/app/src/main/res/layout/fragment_modify_table_name.xml
@@ -14,7 +14,6 @@
android:layout_marginTop="24dp"
android:gravity="center"
android:text="课表名字"
- android:textColor="@android:color/black"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
diff --git a/app/src/main/res/layout/fragment_schedule_manage.xml b/app/src/main/res/layout/fragment_schedule_manage.xml
index ca1a9173..398faf21 100644
--- a/app/src/main/res/layout/fragment_schedule_manage.xml
+++ b/app/src/main/res/layout/fragment_schedule_manage.xml
@@ -4,7 +4,6 @@
android:id="@+id/rv_table_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/backgroundColor"
tools:context=".schedule_manage.ScheduleManageFragment"
tools:listitem="@layout/item_table_list">
diff --git a/app/src/main/res/layout/fragment_school_info.xml b/app/src/main/res/layout/fragment_school_info.xml
index 92e75d6b..c27d6c65 100644
--- a/app/src/main/res/layout/fragment_school_info.xml
+++ b/app/src/main/res/layout/fragment_school_info.xml
@@ -4,20 +4,17 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@android:color/white"
android:orientation="vertical"
tools:context=".schedule_import.SchoolInfoFragment">
+ android:layout_height="24dp" />
+ android:layout_height="48dp">
+ android:src="@drawable/ic_back"
+ android:tint="?attr/colorOnBackground" />
-
-
@@ -167,17 +159,15 @@
android:singleLine="true"
android:textSize="14sp" />
-
diff --git a/app/src/main/res/layout/fragment_select_time.xml b/app/src/main/res/layout/fragment_select_time.xml
index 69eb4bb8..e9574c4e 100644
--- a/app/src/main/res/layout/fragment_select_time.xml
+++ b/app/src/main/res/layout/fragment_select_time.xml
@@ -1,4 +1,5 @@
-
+ android:layout_weight="1"
+ app:npv_RespondChangeOnDetached="false"
+ app:npv_ShownCount="5"
+ app:npv_TextColorNormal="?attr/colorOnBackground"
+ app:npv_TextSizeNormal="14sp"
+ app:npv_TextSizeSelected="14sp"
+ app:npv_WrapSelectorWheel="true" />
-
+ android:layout_weight="1"
+ app:npv_RespondChangeOnDetached="false"
+ app:npv_ShownCount="5"
+ app:npv_TextColorNormal="?attr/colorOnBackground"
+ app:npv_TextSizeNormal="14sp"
+ app:npv_TextSizeSelected="14sp"
+ app:npv_WrapSelectorWheel="false" />
-
+ android:layout_weight="1"
+ app:npv_RespondChangeOnDetached="false"
+ app:npv_ShownCount="5"
+ app:npv_TextColorNormal="?attr/colorOnBackground"
+ app:npv_TextSizeNormal="14sp"
+ app:npv_TextSizeSelected="14sp"
+ app:npv_WrapSelectorWheel="false" />
diff --git a/app/src/main/res/layout/fragment_select_time_detail.xml b/app/src/main/res/layout/fragment_select_time_detail.xml
index 4a3017cc..8101487f 100644
--- a/app/src/main/res/layout/fragment_select_time_detail.xml
+++ b/app/src/main/res/layout/fragment_select_time_detail.xml
@@ -1,4 +1,5 @@
-
+ android:layout_weight="1"
+ app:npv_RespondChangeOnDetached="false"
+ app:npv_ShownCount="5"
+ app:npv_TextColorNormal="?attr/colorOnBackground"
+ app:npv_TextSizeNormal="14sp"
+ app:npv_TextSizeSelected="14sp"
+ app:npv_WrapSelectorWheel="false" />
-
+ android:layout_weight="1"
+ app:npv_RespondChangeOnDetached="false"
+ app:npv_ShownCount="5"
+ app:npv_TextColorNormal="?attr/colorOnBackground"
+ app:npv_TextSizeNormal="14sp"
+ app:npv_TextSizeSelected="14sp"
+ app:npv_WrapSelectorWheel="false" />
diff --git a/app/src/main/res/layout/fragment_select_week.xml b/app/src/main/res/layout/fragment_select_week.xml
index 2533126b..667eb896 100644
--- a/app/src/main/res/layout/fragment_select_week.xml
+++ b/app/src/main/res/layout/fragment_select_week.xml
@@ -12,15 +12,14 @@
android:layout_marginTop="24dp"
android:gravity="center"
android:text="请选择周数"
- android:textColor="@android:color/black"
android:textStyle="bold" />
+ android:text="全周" />
+ android:text="单周" />
+ android:text="双周" />
diff --git a/app/src/main/res/layout/fragment_tip.xml b/app/src/main/res/layout/fragment_tip.xml
new file mode 100644
index 00000000..39bd4e72
--- /dev/null
+++ b/app/src/main/res/layout/fragment_tip.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_update.xml b/app/src/main/res/layout/fragment_update.xml
index 2b6b4ede..c9174cde 100644
--- a/app/src/main/res/layout/fragment_update.xml
+++ b/app/src/main/res/layout/fragment_update.xml
@@ -1,26 +1,24 @@
@@ -28,20 +26,19 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:layout_marginBottom="8dp"
android:layout_marginTop="-16dp"
+ android:layout_marginBottom="8dp"
android:gravity="center"
android:text="有可用更新哦"
- android:textColor="@android:color/black"
android:textStyle="bold" />
@@ -50,9 +47,9 @@
android:id="@+id/tv_new_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
+ android:layout_marginEnd="16dp"
android:lineSpacingExtra="8dp"
android:text="最新版本:"
android:textSize="12sp" />
@@ -60,9 +57,9 @@
+ android:text="去看看"
+ android:textStyle="bold" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_web_view_login.xml b/app/src/main/res/layout/fragment_web_view_login.xml
index b1e74da8..78fbfc78 100644
--- a/app/src/main/res/layout/fragment_web_view_login.xml
+++ b/app/src/main/res/layout/fragment_web_view_login.xml
@@ -4,20 +4,17 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/backgroundColor"
android:orientation="vertical"
tools:context=".schedule_import.WebViewLoginFragment">
+ android:layout_height="24dp" />
+ android:layout_height="48dp">
+ android:layout_height="0dp"
+ android:layout_weight="1">
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_add_course_base.xml b/app/src/main/res/layout/item_add_course_base.xml
index 3b56aad9..c485301e 100644
--- a/app/src/main/res/layout/item_add_course_base.xml
+++ b/app/src/main/res/layout/item_add_course_base.xml
@@ -2,8 +2,7 @@
+ android:layout_height="wrap_content">
+ android:textStyle="bold" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_add_course_detail.xml b/app/src/main/res/layout/item_add_course_detail.xml
index 8731aa38..0ad6b9f3 100644
--- a/app/src/main/res/layout/item_add_course_detail.xml
+++ b/app/src/main/res/layout/item_add_course_detail.xml
@@ -1,9 +1,9 @@
+ android:layout_marginBottom="16dp">
+ android:textSize="14sp"
+ app:autoSizeMaxTextSize="14sp"
+ app:autoSizeMinTextSize="10sp"
+ app:autoSizeStepGranularity="1sp"
+ app:autoSizeTextType="uniform" />
-
-
-
+ android:background="?android:attr/selectableItemBackground">
-
+
-
+
+
+
+
+ android:layout_below="@id/ll_teacher"
+ android:background="?android:attr/selectableItemBackground">
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_table_add_main.xml b/app/src/main/res/layout/item_table_add_main.xml
index c98b2673..1655c031 100644
--- a/app/src/main/res/layout/item_table_add_main.xml
+++ b/app/src/main/res/layout/item_table_add_main.xml
@@ -2,7 +2,6 @@
@@ -16,7 +15,7 @@
android:gravity="center"
android:includeFontPadding="false"
android:scaleType="centerCrop"
- android:text=""
+ android:text="@string/icon_add"
android:textSize="20sp" />
+ android:layout_marginEnd="16dp" />
diff --git a/app/src/main/res/layout/today_course_app_widget_1.xml b/app/src/main/res/layout/today_course_app_widget_1.xml
new file mode 100644
index 00000000..19b4a0da
--- /dev/null
+++ b/app/src/main/res/layout/today_course_app_widget_1.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/navigation/nav_settings.xml b/app/src/main/res/navigation/nav_settings.xml
new file mode 100644
index 00000000..be051555
--- /dev/null
+++ b/app/src/main/res/navigation/nav_settings.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-v19/styles.xml b/app/src/main/res/values-v19/styles.xml
index e661079f..c56493c5 100644
--- a/app/src/main/res/values-v19/styles.xml
+++ b/app/src/main/res/values-v19/styles.xml
@@ -1,7 +1,7 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 48f194e9..944ba858 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,8 +1,29 @@
-
- - 只可以选择一个文件哦
- - You can only select up to %1$d media files
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
登录教务系统
学号
密码
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 8906abd8..9a0169fe 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
-
@@ -116,7 +73,6 @@
- 16dp
- 16dp
- 1
- - @android:color/black
- 16sp
diff --git a/app/src/main/res/xml/schedule_app_widget_info.xml b/app/src/main/res/xml/schedule_app_widget_info.xml
index 98abd921..7cb59dee 100644
--- a/app/src/main/res/xml/schedule_app_widget_info.xml
+++ b/app/src/main/res/xml/schedule_app_widget_info.xml
@@ -4,7 +4,7 @@
android:initialKeyguardLayout="@layout/schedule_app_widget"
android:initialLayout="@layout/schedule_app_widget"
android:minWidth="250dp"
- android:minHeight="180dp"
+ android:minHeight="110dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="10800000"
android:widgetCategory="home_screen" />
\ No newline at end of file