Archived
Unified app translation with iOS version, added "Follow system" theming option to API 28
This commit is contained in:
@@ -70,7 +70,7 @@ internal class Main : AppCompatActivity(R.layout.app_bar_main) {
|
|||||||
else -> { // launch the app
|
else -> { // launch the app
|
||||||
|
|
||||||
if (!prefs.getBoolean("colourTransferred", false)) {
|
if (!prefs.getBoolean("colourTransferred", false)) {
|
||||||
HelperFunctions.transferOldColourIntsToString(prefs)
|
HelperFunctions.transferOldColourIntsToString(prefs, context)
|
||||||
edit.putBoolean("colourTransferred", true).apply()
|
edit.putBoolean("colourTransferred", true).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ internal object HelperFunctions {
|
|||||||
"Theatre", "Geography", "History", "Politics", "Philosophy", "Religion", "Maths", "Biology", "Chemistry",
|
"Theatre", "Geography", "History", "Politics", "Philosophy", "Religion", "Maths", "Biology", "Chemistry",
|
||||||
"Physics", "CompSci", "PhysEd", "GLL", "WAT", "Forder", "WP")
|
"Physics", "CompSci", "PhysEd", "GLL", "WAT", "Forder", "WP")
|
||||||
|
|
||||||
val colourNames = arrayOf("default", "red", "orange", "yellow", "green", "teal", "cyan", "blue", "purple", "pink",
|
|
||||||
"brown", "grey", "salmon", "tangerine", "banana", "flora", "spindrift", "sky", "orchid",
|
|
||||||
"lavender", "carnation", "brown2", "pureWhite", "pureBlack")
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A lower-cased list of all phrases used to describe that a course has been cancelled. Expand
|
* A lower-cased list of all phrases used to describe that a course has been cancelled. Expand
|
||||||
* this if necessary. No further code changes required if this is expanded
|
* this if necessary. No further code changes required if this is expanded
|
||||||
@@ -84,8 +80,16 @@ internal object HelperFunctions {
|
|||||||
|
|
||||||
const val notificationChannelId = "general"
|
const val notificationChannelId = "general"
|
||||||
|
|
||||||
fun getColourArray(c: Context): Array<Colour> {
|
/**
|
||||||
val titles = c.resources.getStringArray(R.array.colour_names)
|
* This function returns an array that contains all data relevant to tinting individual entries
|
||||||
|
* on the substitution plan
|
||||||
|
*
|
||||||
|
* @param context a context reference to resolve the R.array reference
|
||||||
|
*
|
||||||
|
* @return the array of type Colour
|
||||||
|
*/
|
||||||
|
fun getColourArray(context: Context): Array<Colour> {
|
||||||
|
val titles = context.resources.getStringArray(R.array.colour_names)
|
||||||
return arrayOf(
|
return arrayOf(
|
||||||
Colour(titles[0], "default", 0, 0),
|
Colour(titles[0], "default", 0, 0),
|
||||||
Colour(titles[1], "red", 0, R.color.bgRed),
|
Colour(titles[1], "red", 0, R.color.bgRed),
|
||||||
@@ -216,13 +220,13 @@ internal object HelperFunctions {
|
|||||||
*
|
*
|
||||||
* @param prefs a reference to the app's SharedPreferences
|
* @param prefs a reference to the app's SharedPreferences
|
||||||
*/
|
*/
|
||||||
fun transferOldColourIntsToString(prefs: SharedPreferences) {
|
fun transferOldColourIntsToString(prefs: SharedPreferences, context: Context) {
|
||||||
var colour = ""
|
var colour = ""
|
||||||
val edit = prefs.edit()
|
val edit = prefs.edit()
|
||||||
for (course in languageIndependentCourses) {
|
for (course in languageIndependentCourses) {
|
||||||
for (i in colourIntegers.indices) {
|
for (i in colourIntegers.indices) {
|
||||||
if (prefs.getInt("bg$course", 0) == colourIntegers[i]) {
|
if (prefs.getInt("bg$course", 0) == colourIntegers[i]) {
|
||||||
colour = colourNames[i]
|
colour = getColourArray(context)[i].titleNoLang
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
colour = ""
|
colour = ""
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package com.denizd.substitutionplan.data
|
package com.denizd.substitutionplan.data
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.util.Log
|
|
||||||
import android.webkit.CookieManager
|
import android.webkit.CookieManager
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.webkit.WebViewClient
|
import android.webkit.WebViewClient
|
||||||
import java.lang.IllegalStateException
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that extends WebViewClient to provide a function that checks the website's cookies to
|
* Class that extends WebViewClient to provide a function that checks the website's cookies to
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Set spinners (+ listeners)
|
// Set spinners (+ listeners)
|
||||||
val darkModeList = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
|
val darkModeList = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||||
R.array.themes_pre_q
|
R.array.themes_pre_q
|
||||||
} else {
|
} else {
|
||||||
R.array.themes
|
R.array.themes
|
||||||
@@ -178,7 +178,7 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
window?.navigationBarColor = ContextCompat.getColor(mContext, R.color.colorBackground)
|
window?.navigationBarColor = ContextCompat.getColor(mContext, R.color.colorBackground)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
2 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) // only accessible on API 29+
|
2 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) // only accessible on API 28+
|
||||||
else -> {
|
else -> {
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
|
||||||
@@ -415,7 +415,7 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
)
|
)
|
||||||
dialogButton.setOnClickListener {
|
dialogButton.setOnClickListener {
|
||||||
when (dialogEditText.text.toString()) {
|
when (dialogEditText.text.toString()) {
|
||||||
"_STATISTICS" -> {
|
"_statistics" -> {
|
||||||
val alertDialogDev = AlertDialog.Builder(mContext)
|
val alertDialogDev = AlertDialog.Builder(mContext)
|
||||||
val devDialogView = View.inflate(mContext, R.layout.diagnostics_dialog, null)
|
val devDialogView = View.inflate(mContext, R.layout.diagnostics_dialog, null)
|
||||||
val devDialogText = devDialogView.findViewById<TextView>(R.id.dialogtext)
|
val devDialogText = devDialogView.findViewById<TextView>(R.id.dialogtext)
|
||||||
@@ -438,20 +438,20 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
alertDialogDev.setView(devDialogView)
|
alertDialogDev.setView(devDialogView)
|
||||||
alertDialogDev.show()
|
alertDialogDev.show()
|
||||||
}
|
}
|
||||||
"_LOGIN" -> {
|
"_login" -> {
|
||||||
prefs.edit().putBoolean("successful_login", false).apply()
|
prefs.edit().putBoolean("successful_login", false).apply()
|
||||||
makeToast("Login flag cleared")
|
makeToast("Login flag cleared")
|
||||||
}
|
}
|
||||||
"_FIRSTTIME" -> {
|
"_firsttime" -> {
|
||||||
prefs.edit().putBoolean("firstTime", true).apply()
|
prefs.edit().putBoolean("firstTime", true).apply()
|
||||||
makeToast("First time flag cleared")
|
makeToast("First time flag cleared")
|
||||||
}
|
}
|
||||||
"_TESTURLS" -> {
|
"_testurls" -> {
|
||||||
val currentTest = !prefs.getBoolean("testUrls", false)
|
val currentTest = !prefs.getBoolean("testUrls", false)
|
||||||
prefs.edit().putBoolean("testUrls", currentTest).apply()
|
prefs.edit().putBoolean("testUrls", currentTest).apply()
|
||||||
makeToast("Test URLs set to $currentTest")
|
makeToast("Test URLs set to $currentTest")
|
||||||
}
|
}
|
||||||
"_DEVCHANNEL" -> {
|
"_devchannel" -> {
|
||||||
val subbed = if (prefs.getBoolean("subscribedToFBDebugChannel", false)) {
|
val subbed = if (prefs.getBoolean("subscribedToFBDebugChannel", false)) {
|
||||||
unsubscribeFromTopic(Topic.DEVELOPMENT)
|
unsubscribeFromTopic(Topic.DEVELOPMENT)
|
||||||
"Unsubscribed from"
|
"Unsubscribed from"
|
||||||
@@ -462,7 +462,7 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
prefs.edit().putBoolean("subscribedToFBDebugChannel", !prefs.getBoolean("subscribedToFBDebugChannel", false)).apply()
|
prefs.edit().putBoolean("subscribedToFBDebugChannel", !prefs.getBoolean("subscribedToFBDebugChannel", false)).apply()
|
||||||
makeToast("$subbed Firebase development channel")
|
makeToast("$subbed Firebase development channel")
|
||||||
}
|
}
|
||||||
"_IOSCHANNEL" -> {
|
"_ioschannel" -> {
|
||||||
val subbed = if (prefs.getBoolean("subscribedToiOSChannel", false)) {
|
val subbed = if (prefs.getBoolean("subscribedToiOSChannel", false)) {
|
||||||
unsubscribeFromTopic(Topic.IOS)
|
unsubscribeFromTopic(Topic.IOS)
|
||||||
"Unsubscribed from"
|
"Unsubscribed from"
|
||||||
@@ -473,8 +473,8 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
prefs.edit().putBoolean("subscribedToiOSChannel", !prefs.getBoolean("subscribedToiOSChannel", false)).apply()
|
prefs.edit().putBoolean("subscribedToiOSChannel", !prefs.getBoolean("subscribedToiOSChannel", false)).apply()
|
||||||
makeToast("$subbed iOS channel")
|
makeToast("$subbed iOS channel")
|
||||||
}
|
}
|
||||||
"_WRITE" -> HelperFunctions.writePrefsToXml(prefs, mContext, activity!!)
|
"_write" -> HelperFunctions.writePrefsToXml(prefs, mContext, activity!!)
|
||||||
"_READ" -> HelperFunctions.readPrefsFromXml(prefs, mContext, activity!!)
|
"_read" -> HelperFunctions.readPrefsFromXml(prefs, mContext, activity!!)
|
||||||
else -> makeToast(getString(R.string.invalid_code))
|
else -> makeToast(getString(R.string.invalid_code))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
<string name="enable_course_notifications_title">Enable course notifications</string>
|
<string name="enable_course_notifications_title">Enable course notifications</string>
|
||||||
<string name="enable_course_notifications_desc">This does not affect broadcasts</string>
|
<string name="enable_course_notifications_desc">This does not affect broadcasts</string>
|
||||||
|
|
||||||
<string name="personalise">Personalise</string>
|
<string name="personalise">Personalize</string>
|
||||||
<string name="misc">Miscellaneous</string>
|
<string name="misc">Miscellaneous</string>
|
||||||
<string name="default_plan_title">Set personalised plan as default</string>
|
<string name="default_plan_title">Set personalized plan as default</string>
|
||||||
<string name="default_plan_desc">Defaults to general plan otherwise</string>
|
<string name="default_plan_desc">Defaults to general plan otherwise</string>
|
||||||
<string name="visit_website_title">Visit the school\'s website</string>
|
<string name="visit_website_title">Visit the school\'s website</string>
|
||||||
<string name="visit_website_desc">In case you need to</string>
|
<string name="visit_website_desc">In case you need to</string>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
<string name="greeting_title">Enable greeting</string>
|
<string name="greeting_title">Enable greeting</string>
|
||||||
<string name="greeting_desc">If you want me to be nice :)</string>
|
<string name="greeting_desc">If you want me to be nice :)</string>
|
||||||
|
|
||||||
<string name="licences_title">Licences</string>
|
<string name="licences_title">Licenses</string>
|
||||||
<string name="licences_desc">What went into making this app</string>
|
<string name="licences_desc">What went into making this app</string>
|
||||||
<string name="version">Version Number</string>
|
<string name="version">Version Number</string>
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
<string name="grade_help_dialog_title">How to enter your grade</string>
|
<string name="grade_help_dialog_title">How to enter your grade</string>
|
||||||
<string name="grade_help_dialog_text">Enter your current grade to have it appear in your personal plan and be notified about any information.\n\nNote:\n\nIn junior phase, put the number and letter together, as in \"5a\".\n\nIn E-Phase, separate them by a space, as in \"18 a\".\n\nIn Q1/Q2, only put in the number, as in \"17\".\n\nEntering multiple grades is not recommended.</string>
|
<string name="grade_help_dialog_text">Enter your current grade to have it appear in your personal plan and be notified about any information.\n\nNote:\n\nIn junior phase, put the number and letter together, as in \"5a\".\n\nIn E-Phase, separate them by a space, as in \"18 a\".\n\nIn Q1/Q2, only put in the number, as in \"17\".\n\nEntering multiple grades is not recommended.</string>
|
||||||
<string name="courses_help_dialog_title">How to enter your courses</string>
|
<string name="courses_help_dialog_title">How to enter your courses</string>
|
||||||
<string name="courses_help_dialog_text">You need to enter the course abbreviation for every course you want in your personal plan and want to be notified about. You can find them on your time table.\n\nHere\'s a few examples:\n\nMathematics in 5th grade (juniors) would be MAT.\n\nAdvanced English in E-Phase (seniors) for the English profile may be ENP1.\n\nBasic Biology in Q1 could be bio1.\n\nIn most cases, entering courses while in junior phase is redundant.\nSeparate multiple courses by spaces, commas are optional.\nCapitalisation is required.</string>
|
<string name="courses_help_dialog_text">You need to enter the course abbreviation for every course you want in your personal plan and want to be notified about. You can find them on your time table.\n\nHere\'s a few examples:\n\nMathematics in 5th grade (juniors) would be MAT.\n\nAdvanced English in E-Phase (seniors) for the English profile may be ENP1.\n\nBasic Biology in Q1 could be bio1.\n\nIn most cases, entering courses while in junior phase is redundant.\nSeparate multiple courses by spaces, commas are optional.\nCapitalization is required.</string>
|
||||||
<string name="experimental_menu_dialog_title">Testing Menu</string>
|
<string name="experimental_menu_dialog_title">Testing Menu</string>
|
||||||
<string name="statistics_dialog_title">Statistics Menu</string>
|
<string name="statistics_dialog_title">Statistics Menu</string>
|
||||||
<string name="experimental_menu_dialog_text">This menu is intended for testing only.</string>
|
<string name="experimental_menu_dialog_text">This menu is intended for testing only.</string>
|
||||||
@@ -61,8 +61,8 @@
|
|||||||
<string name="invalid_code">Invalid code</string>
|
<string name="invalid_code">Invalid code</string>
|
||||||
<string name="no_personal_substitutions">No substitutions for you</string>
|
<string name="no_personal_substitutions">No substitutions for you</string>
|
||||||
|
|
||||||
<string name="customise_colours_title">Customise colours</string>
|
<string name="customise_colours_title">Customize colors</string>
|
||||||
<string name="customise_colours_desc">Customise every subject individually</string>
|
<string name="customise_colours_desc">Customize every subject individually</string>
|
||||||
|
|
||||||
<string name="course_deu">German (+ as a second language)</string>
|
<string name="course_deu">German (+ as a second language)</string>
|
||||||
<string name="course_mat">Mathematics</string>
|
<string name="course_mat">Mathematics</string>
|
||||||
@@ -126,7 +126,7 @@
|
|||||||
<item>Hi %s!</item>
|
<item>Hi %s!</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string name="pick_ringtone_title">Customise notification ringtone</string>
|
<string name="pick_ringtone_title">Customize notification ringtone</string>
|
||||||
<string name="pick_ringtone_desc">Currently: %s</string>
|
<string name="pick_ringtone_desc">Currently: %s</string>
|
||||||
<string name="pick_ringtone_dialog_title">Pick a notification ringtone</string>
|
<string name="pick_ringtone_dialog_title">Pick a notification ringtone</string>
|
||||||
<string name="pick_ringtone_desc_o">Redirects to device settings</string>
|
<string name="pick_ringtone_desc_o">Redirects to device settings</string>
|
||||||
@@ -172,7 +172,7 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
<string name="ordering_system_hint">Ordering system</string>
|
<string name="ordering_system_hint">Ordering system</string>
|
||||||
<string name="ordering_systems_dialog_title">Information on ordering systems</string>
|
<string name="ordering_systems_dialog_title">Information on ordering systems</string>
|
||||||
<string name="ordering_systems_dialog_text">You may pick between two ordering systems that dictate the order in which the items on the substitution plan will appear in.\n\nThe default \'app-specific\' is an algorithm implemented in this app that provides a consistently-sorted substitution plan ordered just like the substitution plan on the website used to; sorted by classes, then by time.\n\n\'Website original\' offers the items on the substitution plan just like they\'re presented on the school website, but since these are not guaranteed to be consistent, \'app-specific\' is picked by default.</string>
|
<string name="ordering_systems_dialog_text">You may pick between two ordering systems that decide the order in which the items on the substitution plan will appear in.\n\nThe default \'app-specific\' is an algorithm implemented in this app that provides a consistently-sorted substitution plan ordered just like the substitution plan on the website used to; sorted by classes, then by time.\n\n\'Website original\' offers the items on the substitution plan just like they\'re presented on the school website, but since these are not guaranteed to be consistent, \'app-specific\' is picked by default.</string>
|
||||||
<string name="error_please_try_again">An error occurred, please try again</string>
|
<string name="error_please_try_again">An error occurred, please try again</string>
|
||||||
<string name="thanks_for_using">Thanks for using the app!</string>
|
<string name="thanks_for_using">Thanks for using the app!</string>
|
||||||
<string name="congratulations_for_nothing">Congratulations! You have achieved nothing.</string>
|
<string name="congratulations_for_nothing">Congratulations! You have achieved nothing.</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user