Skip to content

Commit

Permalink
1.1.0 clean-up for release
Browse files Browse the repository at this point in the history
  • Loading branch information
phytal committed Aug 18, 2022
2 parents 872027f + 8c43376 commit 2397c45
Show file tree
Hide file tree
Showing 47 changed files with 297 additions and 750 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ plugins {
}

android {
compileSdkVersion 30
compileSdkVersion 32
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.phytal.sarona"
minSdkVersion 26
targetSdkVersion 30
versionCode 5
versionName "1.0.4"
targetSdkVersion 32
versionCode 7
versionName "1.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
kapt {
arguments {
Expand Down Expand Up @@ -47,19 +47,19 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.1'
implementation 'androidx.preference:preference-ktx:1.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

def room_version = "2.4.0-alpha04"
def room_version = "2.5.0-alpha02"

implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
android:theme="@style/Theme.Sarona.DayNight">
<activity
android:name=".ui.MainActivity"
android:windowSoftInputMode="adjustPan">
android:windowSoftInputMode="adjustPan"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/phytal/sarona/data/db/MpDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface MpDao {
@Query("SELECT * FROM mp_table")
fun getAllMps(): LiveData<List<MarkingPeriod>>

@Query("SELECT * FROM mp_table WHERE mp LIKE :mp+1 LIMIT 1")
@Query("SELECT * FROM mp_table WHERE mp LIKE :mp LIMIT 1")
fun getMp(mp: Int): LiveData<MarkingPeriod>

@Query("SELECT * FROM mp_table WHERE current IS 1 LIMIT 1")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.phytal.sarona.data.network.response

import com.phytal.sarona.data.db.entities.MarkingPeriod

data class OtherMpResponse (
val otherMps: List<MarkingPeriod>
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package com.phytal.sarona.internal.helpers

import android.os.Build
import androidx.appcompat.app.AppCompatDelegate
import com.phytal.sarona.R

object ThemeHelper {
private const val LIGHT_MODE = "Light"
private const val DARK_MODE = "Dark"
const val DEFAULT_MODE = "Default"
private const val LIGHT_MODE = R.id.menu_light.toString()
private const val DARK_MODE = R.id.menu_dark.toString()
const val DEFAULT_MODE = R.id.menu_system_default.toString()
fun applyTheme(themePref: String) {
when (themePref) {
LIGHT_MODE -> {
Expand Down
145 changes: 52 additions & 93 deletions app/src/main/java/com/phytal/sarona/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.net.Uri
import android.os.Bundle
import android.view.MenuItem
import android.view.View
import android.widget.AdapterView
import android.widget.Toast
import androidx.annotation.MenuRes
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -22,11 +24,11 @@ import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import com.google.android.material.transition.MaterialFadeThrough
import com.phytal.sarona.R
import com.phytal.sarona.data.db.entities.Course
import com.phytal.sarona.databinding.ActivityMainBinding
import com.phytal.sarona.ui.courses.CoursesFragment
import com.phytal.sarona.ui.nav.*
import com.phytal.sarona.ui.welcome.LoginFragmentDirections
import com.phytal.sarona.util.contentView
import java.util.*


class MainActivity : AppCompatActivity(), Toolbar.OnMenuItemClickListener,
Expand Down Expand Up @@ -64,17 +66,6 @@ class MainActivity : AppCompatActivity(), Toolbar.OnMenuItemClickListener,
bottomNavDrawer.apply {
addOnSlideAction(HalfClockwiseRotateSlideAction(binding.bottomAppBarChevron))
addOnSlideAction(AlphaSlideAction(binding.bottomAppBarTitle, true))
addOnStateChangedAction(ChangeSettingsMenuStateAction { showSettings ->
// Toggle between the current destination's BAB menu and the menu which should
// be displayed when the BottomNavigationDrawer is open.
binding.bottomAppBar.replaceMenu(
if (showSettings) {
R.menu.bottom_app_bar_settings_menu
} else {
R.menu.bottom_app_bar_menu
}
)
})

addOnSandwichSlideAction(HalfCounterClockwiseRotateSlideAction(binding.bottomAppBarChevron))
addNavigationListener(this@MainActivity)
Expand Down Expand Up @@ -124,7 +115,30 @@ class MainActivity : AppCompatActivity(), Toolbar.OnMenuItemClickListener,
}

override fun onNavMenuItemClicked(item: NavigationModelItem.NavMenuItem) {
navigateToHome(item.titleRes, item.destination)
if (item.destination == Destinations.ABOUT) {
val url = "https://linktr.ee/simplegrade"
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(browserIntent)
}
else if (item.destination == Destinations.LOGOUT) {
val loginSharedPref = this.getSharedPreferences(
getString(R.string.login_preference_file_key),
Context.MODE_PRIVATE
)

if (loginSharedPref != null) {
with(loginSharedPref.edit()) {
clear()
apply()
}
}
val directions =
LoginFragmentDirections.actionGlobalLoginFragment()
findNavController(R.id.nav_host_fragment).navigate(directions)
Toast.makeText(this, "Successfully logged out!", Toast.LENGTH_LONG).show()
}
else
navigateToHome(item.titleRes, item.destination)
}

private fun navigateToHome(@StringRes titleRes: Int, destination: Destinations) {
Expand All @@ -136,8 +150,7 @@ class MainActivity : AppCompatActivity(), Toolbar.OnMenuItemClickListener,
}
val directions = when (destination) {
Destinations.CLASSES -> R.id.nav_courses
Destinations.GPA -> R.id.nav_gpa
Destinations.GRADES -> R.id.nav_grades
else -> R.id.nav_courses
}
findNavController(R.id.nav_host_fragment).navigate(directions)
}
Expand All @@ -163,12 +176,6 @@ class MainActivity : AppCompatActivity(), Toolbar.OnMenuItemClickListener,
R.id.nav_courses -> {
setBottomAppBarForHome(R.menu.bottom_app_bar_menu)
}
R.id.nav_grades -> {
setBottomAppBarForHome(R.menu.bottom_app_bar_menu)
}
R.id.nav_gpa -> {
setBottomAppBarForHome(R.menu.bottom_app_bar_menu)
}
}
}

Expand All @@ -182,83 +189,35 @@ class MainActivity : AppCompatActivity(), Toolbar.OnMenuItemClickListener,
return true
}

private fun showDarkThemeMenu() {
private fun onDarkThemeMenuItemSelected(itemId: Int): Boolean {
val sharedPref = this.getSharedPreferences(
getString(R.string.user_preference_file_key),
Context.MODE_PRIVATE
)
MenuBottomSheetDialogFragment(object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>,
view: View?,
position: Int,
id: Long
) {
if (parent.tag == position)
return
parent.tag = position
val selectedItem = parent.getItemAtPosition(position).toString()
if (selectedItem == "Dark" || selectedItem == "Light" || selectedItem == "Default") {
val nightMode = when (selectedItem) {
"Light" -> AppCompatDelegate.MODE_NIGHT_NO
"Dark" -> AppCompatDelegate.MODE_NIGHT_YES
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}

if (sharedPref != null) {
with(sharedPref.edit()) {
putString(
getString(R.string.saved_theme_key),
selectedItem
)
apply()
}
}
delegate.localNightMode = nightMode
val prev = supportFragmentManager.findFragmentByTag("settings_menu")
if (prev != null) {
val df: MenuBottomSheetDialogFragment =
prev as MenuBottomSheetDialogFragment
df.dismiss()
}
}
}

override fun onNothingSelected(parent: AdapterView<*>?) {}
}, object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>,
view: View?,
position: Int,
id: Long
) {
if (parent.tag == position)
return
parent.tag = position
val selectedItem = parent.getItemAtPosition(position).toString()
if (selectedItem == "English" || selectedItem == "Español" || selectedItem == "Français" || selectedItem == "한곡어" || selectedItem == "中文") {
// TODO: Change Language

if (sharedPref != null) {
with(sharedPref.edit()) {
putString(
getString(R.string.saved_language_key),
selectedItem
)
apply()
}
}
val nightMode = when (itemId) {
R.id.menu_light -> AppCompatDelegate.MODE_NIGHT_NO
R.id.menu_dark -> AppCompatDelegate.MODE_NIGHT_YES
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}

val prev = supportFragmentManager.findFragmentByTag("settings_menu")
if (prev != null) {
val df: MenuBottomSheetDialogFragment =
prev as MenuBottomSheetDialogFragment
df.dismiss()
}
}
if (sharedPref != null) {
with(sharedPref.edit()) {
putString(
getString(R.string.saved_theme_key),
itemId.toString()
)
apply()
}
}

delegate.localNightMode = nightMode
return true
}

override fun onNothingSelected(parent: AdapterView<*>?) {}
}).show(supportFragmentManager, "settings_menu")
private fun showDarkThemeMenu() {
MenuBottomSheetDialogFragment(R.menu.dark_theme_bottom_sheet_menu) {
onDarkThemeMenuItemSelected(it.itemId)
}.show(supportFragmentManager, null)
}
}
Loading

0 comments on commit 2397c45

Please sign in to comment.