Version bump 2.0.3 - course card attributes on the right now expand to up to 200dp, necessary declarations for notifications are now only made when a notification is requested

This commit is contained in:
Deniz Düzgören
2019-06-04 09:27:54 +02:00
parent d4cef4f25d
commit 3ba38c2dfe
6 changed files with 43 additions and 33 deletions
@@ -57,12 +57,6 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
private lateinit var foodElements: Elements
private lateinit var doc: Document
private lateinit var docFood: Document
private var manager = mContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
private val channelId = "general"
private var channelName = mContext.getString(R.string.general)
private val importance = NotificationManager.IMPORTANCE_DEFAULT
private lateinit var channel: NotificationChannel
private lateinit var notification: Notification
private val prefs = PreferenceManager.getDefaultSharedPreferences(mContext) as SharedPreferences
private val edit = prefs.edit() as SharedPreferences.Editor
private lateinit var pullToRefresh: SwipeRefreshLayout
@@ -235,13 +229,6 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
}
}
if (jobservice) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
channel = NotificationChannel(channelId, channelName, importance)
channel.enableLights(true)
channel.lightColor = Color.BLUE
manager.createNotificationChannel(channel)
}
val openApp = Intent(mContext, Main::class.java)
openApp.flags = Intent.FLAG_ACTIVITY_NEW_TASK
openApp.flags += Intent.FLAG_ACTIVITY_CLEAR_TASK
@@ -252,8 +239,21 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
notificationLayout.setTextViewText(R.id.notification_textview, notifText)
if (notifText.isNotEmpty()) {
val manager = mContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val channelId = "general"
val channelName = mContext.getString(R.string.general)
val importance = NotificationManager.IMPORTANCE_DEFAULT
lateinit var channel: NotificationChannel
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notification = NotificationCompat.Builder(mContext) // TODO switch out the deprecated notification delivery method
channel = NotificationChannel(channelId, channelName, importance)
channel.enableLights(true)
channel.lightColor = Color.BLUE
manager.createNotificationChannel(channel)
}
val notification = when (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
true -> NotificationCompat.Builder(mContext) // TODO switch out the deprecated notification delivery method
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setSmallIcon(R.drawable.ic_avh)
@@ -261,8 +261,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
.setContentIntent(openAppPending)
.setAutoCancel(true)
.build()
} else {
notification = NotificationCompat.Builder(mContext)
false -> NotificationCompat.Builder(mContext)
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setSmallIcon(R.drawable.ic_avh)
@@ -28,8 +28,8 @@ import java.util.*
class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
lateinit var context: Context
lateinit var prefs: SharedPreferences
private lateinit var context: Context
private lateinit var prefs: SharedPreferences
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -47,14 +47,10 @@ class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
setTaskDescription(taskDesc)
context = this
prefs = PreferenceManager.getDefaultSharedPreferences(context) as SharedPreferences
val edit = prefs.edit()
val fab = findViewById<ExtendedFloatingActionButton>(R.id.efab)
val start = Intent(this, Main::class.java)
val name = findViewById<EditText>(R.id.txtName)
val grade = findViewById<EditText>(R.id.txtClasses)
val courses = findViewById<EditText>(R.id.txtCourses)
@@ -110,9 +106,7 @@ class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
}, 400)
animOut.setAnimationListener(object: Animation.AnimationListener {
override fun onAnimationStart(arg0: Animation) {}
override fun onAnimationRepeat(arg0: Animation) {}
override fun onAnimationEnd(arg0: Animation) {
colour.visibility = View.GONE
}
@@ -7,6 +7,7 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.Configuration
import android.graphics.BitmapFactory
import android.net.ConnectivityManager
import android.net.NetworkInfo
@@ -90,6 +91,21 @@ class Main : AppCompatActivity(R.layout.activity_main) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
window.navigationBarColor = ContextCompat.getColor(this, R.color.background)
}
// else -> {
// when (context.resources.configuration.uiMode) {
// Configuration.UI_MODE_NIGHT_YES, Configuration.UI_MODE_NIGHT_UNDEFINED -> {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
// window.navigationBarColor = ContextCompat.getColor(this, R.color.background)
// }
// }
// Configuration.UI_MODE_NIGHT_NO -> {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
// window.navigationBarColor = ContextCompat.getColor(this, R.color.background)
// }
// }
// } // TODO theming based on system settings for Android Q
}
val bm = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
+7 -6
View File
@@ -33,14 +33,15 @@
<TextView
android:id="@+id/date"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:textAlignment="textEnd"
android:textColor="@color/textcolor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_max="200dp"/>
<TextView
android:id="@+id/time"
@@ -48,10 +49,10 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textAlignment="textEnd"
android:textColor="@color/textcolor"
app:layout_constraintEnd_toEndOf="@+id/date"
app:layout_constraintStart_toStartOf="@+id/date"
app:layout_constraintTop_toBottomOf="@+id/date"
android:textColor="@color/textcolor" />
app:layout_constraintWidth_max="200dp" />
<TextView
android:id="@+id/course"
@@ -75,8 +76,8 @@
android:textColor="@color/textcolor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/time"
app:layout_constraintStart_toStartOf="@+id/time"
app:layout_constraintTop_toBottomOf="@+id/time" />
app:layout_constraintTop_toBottomOf="@+id/time"
app:layout_constraintWidth_max="200dp" />
<TextView
android:id="@+id/additional"
+1 -1
View File
@@ -43,7 +43,7 @@
<item name="colorControlNormal">#000000</item>
</style>
<style name="EditTextTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="EditTextTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorControlNormal">@color/hintcolor</item>
<item name="colorControlActivated">@color/accent</item>
<item name="colorControlHighlight">@color/accent</item>