Browse Source

update to kotlin 1.3.40, added theme choose option

* added missing dividers in settings
* added a black theme
* closes #15
pull/31/head
Jannik 3 years ago
parent
commit
98b3adbf3b
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 3
      app/build.gradle
  2. 4
      app/src/main/AndroidManifest.xml
  3. 1
      app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
  4. 55
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt
  5. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt
  6. 6
      app/src/main/res/layout/cardview_day.xml
  7. 47
      app/src/main/res/layout/fragment_settings.xml
  8. 4
      app/src/main/res/layout/linearlayout_lesson.xml
  9. 4
      app/src/main/res/values-de-rDE/strings.xml
  10. 4
      app/src/main/res/values/strings.xml
  11. 9
      app/src/main/res/values/styles.xml
  12. 2
      build.gradle

3
app/build.gradle

@ -13,7 +13,7 @@ android {
minSdkVersion 23
targetSdkVersion 28
versionCode 14
versionName "0.4.91"
versionName "0.4.92"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "build_time", buildTime()
setProperty("archivesBaseName", "projectlaogai-$versionName")
@ -25,7 +25,6 @@ android {
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
}

4
app/src/main/AndroidManifest.xml

@ -10,7 +10,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_laogai_icon"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme.Light">
<activity
android:name=".SplashActivity"
@ -26,7 +26,7 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/AppTheme.Light"
android:screenOrientation="portrait">
</activity>
</application>

1
app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt

@ -205,7 +205,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
SettingsFragment().selectCourse(this)
} else {
Aesthetic.config {
// activityTheme(R.style.AppTheme_Light)
colorPrimary(cColorPrimary)
colorPrimaryDark(cColorPrimary)
colorAccent(cColorAccent)

55
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt

@ -51,6 +51,7 @@ import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
import java.util.*
import android.util.TypedValue
import com.afollestad.materialdialogs.list.listItemsSingleChoice
/**
* The settings controller class
@ -61,6 +62,7 @@ class SettingsFragment : Fragment() {
private lateinit var linLayoutUser: LinearLayout
private lateinit var linLayoutCourse: LinearLayout
private lateinit var linLayoutAbout: LinearLayout
private lateinit var linLayoutTheme: LinearLayout
private lateinit var linLayoutPrimaryColor: LinearLayout
private lateinit var linLayoutAccentColor: LinearLayout
private lateinit var switchBuffet: Switch
@ -72,6 +74,7 @@ class SettingsFragment : Fragment() {
linLayoutUser = view.findViewById(R.id.linLayout_User)
linLayoutCourse = view.findViewById(R.id.linLayout_Course)
linLayoutAbout = view.findViewById(R.id.linLayout_About)
linLayoutTheme = view.findViewById(R.id.linLayout_Theme)
linLayoutPrimaryColor = view.findViewById(R.id.linLayout_PrimaryColor)
linLayoutAccentColor = view.findViewById(R.id.linLayout_AccentColor)
switchBuffet = view.findViewById(R.id.switch_buffet)
@ -85,17 +88,28 @@ class SettingsFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// initialize the settings gui
txtView_Course.text = cCourse.courseName
txtView_AboutDesc.text = resources.getString(R.string.about_version, BuildConfig.VERSION_NAME, getString(R.string.build_time))
switch_buffet.isChecked = cShowBuffet // init switch
val outValue = TypedValue()
activity!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
if (outValue.string == "dark") {
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
} else {
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryLight, activity!!.theme))
when(outValue.string) {
"light" -> {
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryLight, activity!!.theme))
txtView_SelectedTheme.text = resources.getString(R.string.themeLight)
}
"dark" -> {
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
txtView_SelectedTheme.text = resources.getString(R.string.themeDark)
}
"black" -> {
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
txtView_SelectedTheme.text = resources.getString(R.string.themeBlack)
}
}
}
/**
@ -104,19 +118,6 @@ class SettingsFragment : Fragment() {
private fun initActions() {
linLayoutUser.setOnClickListener {
// open a new dialog
// TODO move and save
// val outValue = TypedValue()
// activity!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
// if (outValue.string == "dark") {
// Aesthetic.config {
// activityTheme(R.style.AppTheme_Light)
// }
// } else {
// Aesthetic.config {
// activityTheme(R.style.AppTheme_Dark)
// }
// }
}
linLayoutCourse.setOnClickListener {
@ -132,6 +133,26 @@ class SettingsFragment : Fragment() {
.show()
}
linLayoutTheme.setOnClickListener {
val themes = listOf(
resources.getString(R.string.themeLight),
resources.getString(R.string.themeDark),
resources.getString(R.string.themeBlack)
)
MaterialDialog(context!!).show {
listItemsSingleChoice(items = themes) { _, index, _ ->
Aesthetic.config {
when (index) {
0 -> activityTheme(R.style.AppTheme_Light)
1 -> activityTheme(R.style.AppTheme_Dark)
2 -> activityTheme(R.style.AppTheme_Black)
else -> activityTheme(R.style.AppTheme_Light)
}
}
}
}
}
linLayoutPrimaryColor.setOnClickListener {
// open a new color chooser dialog
MaterialDialog(context!!)

2
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt

@ -94,7 +94,7 @@ class TimeTableFragment : Fragment() {
}
// hide the btnCardValue if the user is scrolling down
scrollViewTimetable.setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY ->
scrollViewTimetable.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
if (scrollY > oldScrollY) {
faBtnAddLesson.hide()
} else {

6
app/src/main/res/layout/cardview_day.xml

@ -2,8 +2,10 @@
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content" app:cardUseCompatPadding="true"
app:cardElevation="5dp" app:cardBackgroundColor="?themeSecondary"
android:layout_height="wrap_content"
app:cardUseCompatPadding="true"
app:cardElevation="5dp"
app:cardBackgroundColor="?themeSecondary"
>
<LinearLayout

47
app/src/main/res/layout/fragment_settings.xml

@ -66,7 +66,7 @@
android:id="@+id/divider2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:background="?dividerColor"
/>
<LinearLayout
android:orientation="vertical"
@ -91,7 +91,7 @@
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:background="?dividerColor"
/>
<LinearLayout
android:orientation="vertical"
@ -128,7 +128,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linLayout_Settings"
android:padding="7dp">
>
<TextView
android:text="@string/settings"
android:layout_width="match_parent"
@ -138,7 +138,28 @@
android:textSize="18sp"
android:textColor="?colorAccent"
android:textStyle="bold"
android:paddingTop="3dp"/>
android:paddingTop="3dp" android:layout_margin="7dp"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/linLayout_Theme"
android:layout_margin="7dp">
<TextView
android:text="@string/theme"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_Theme"
android:textSize="16sp" android:textStyle="bold"/>
<TextView
android:text="@string/themeLight"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_SelectedTheme"/>
</LinearLayout>
<View
android:id="@+id/divider3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?dividerColor"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
@ -146,7 +167,7 @@
android:gravity="center_vertical|end"
android:clickable="true"
android:id="@+id/linLayout_PrimaryColor"
android:focusable="true">
android:focusable="true" android:layout_margin="7dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
@ -178,6 +199,12 @@
android:background="?colorPrimary"/>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/divider4"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?dividerColor"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
@ -185,7 +212,7 @@
android:gravity="center_vertical|end"
android:clickable="true"
android:id="@+id/linLayout_AccentColor"
android:focusable="true">
android:focusable="true" android:layout_margin="7dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
@ -217,6 +244,12 @@
android:background="?colorAccent"/>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/divider5"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
/>
<Switch
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -224,7 +257,7 @@
android:textSize="16sp"
android:textStyle="bold"
android:text="@string/show_buffet"
/>
android:layout_margin="7dp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>

4
app/src/main/res/layout/linearlayout_lesson.xml

@ -30,6 +30,6 @@
android:id="@+id/divider_lesson"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?dividerColor"
/>
android:background="?dividerColor"/>
</LinearLayout>

4
app/src/main/res/values-de-rDE/strings.xml

@ -27,4 +27,8 @@
<string name="navigation_drawer_open">Navigationsleiste öffnen</string>
<string name="show_buffet">Buffet immer anzeigen</string>
<string name="select_course">Wähle deinen Studiengang aus</string>
<string name="theme">Design</string>
<string name="themeLight">Hell</string>
<string name="themeDark">Dunkel</string>
<string name="themeBlack">Schwarz</string>
</resources>

4
app/src/main/res/values/strings.xml

@ -42,6 +42,10 @@
<string name="about_dialog_heading">About</string>
<string name="about_dialog_text" translatable="false">"This software is made by @Seil0 and is published under the terms and conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018-2019 seil0@mosad.xyz "</string>
<string name="loading_timetable">loading timetable …</string>
<string name="theme">Theme</string>
<string name="themeLight">light</string>
<string name="themeDark">dark</string>
<string name="themeBlack">black</string>
<string name="save_key_course" translatable="false">org.mosad.seil0.projectlaogai.course</string>
<string name="save_key_courseTTLink" translatable="false">org.mosad.seil0.projectlaogai.courseTTLink</string>

9
app/src/main/res/values/styles.xml

@ -25,6 +25,15 @@
<item name="dividerColor">@color/dividerDark</item>
</style>
<style name="AppTheme.Black" parent="AppTheme">
<item name="themeName">black</item>
<item name="themePrimary">@color/themePrimaryDark</item>
<item name="themeSecondary">@color/themePrimaryDark</item>
<item name="android:textColor">@color/textPrimaryDark</item>
<item name="textPrimary">@color/textPrimaryDark</item>
<item name="dividerColor">@color/dividerDark</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>

2
build.gradle

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.31'
ext.kotlin_version = '1.3.40'
repositories {
google()
jcenter()

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close