Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  login: use constant id for showcase view singleshot
  Update NavigationView
  use FragmentContainerView
  update deps and androidx.fragments
  update material components to 1.1.0
  add missing tag name
  • Loading branch information
shalzz committed Apr 20, 2020
2 parents 4444447 + a9efdfc commit 61bf4ec
Show file tree
Hide file tree
Showing 23 changed files with 168 additions and 186 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
id: create_release
uses: actions/create-release@master
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ steps.changelog.outputs.body }}
draft: false
Expand Down
59 changes: 32 additions & 27 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import com.lordcodes.turtle.shellRun
import org.jetbrains.kotlin.config.KotlinCompilerVersion

plugins {
id("com.android.application")
Expand Down Expand Up @@ -138,6 +137,10 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

sourceSets {
val commonTestDir = "src/commonTest/java"

Expand Down Expand Up @@ -182,38 +185,40 @@ kapt {
dependencies {
val DAGGER_VERSION = "2.24"
val ESPRESSO_VERSION = "3.1.0"
val RETROFIT_VERSION = "2.6.2"
val MOSHI_VERSION = "1.8.0"
val ROOM_VERSION = "2.2.1"
val NAV_VERSION = "1.0.0"
val RETROFIT_VERSION = "2.8.1"
val MOSHI_VERSION = "1.9.2"
val ROOM_VERSION = "2.2.5"
val NAV_VERSION = "2.2.0"

// TODO: re-evaluate when RxJava is completely replaced with kotlin co-routines
implementation("androidx.multidex:multidex:2.0.1")

coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.0.4")
implementation(kotlin("stdlib-jdk7", KotlinCompilerVersion.VERSION))
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.0.5")
implementation(kotlin("stdlib-jdk7"))
implementation(kotlin("stdlib-jdk8"))

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5")

implementation("androidx.core:core-ktx:1.1.0")
implementation("android.arch.navigation:navigation-fragment-ktx:$NAV_VERSION")
implementation("android.arch.navigation:navigation-ui-ktx:$NAV_VERSION")
implementation("androidx.core:core-ktx:1.2.0")
implementation("androidx.navigation:navigation-fragment-ktx:$NAV_VERSION")
implementation("androidx.navigation:navigation-ui-ktx:$NAV_VERSION")

implementation("com.google.firebase:firebase-core:17.2.1")
implementation("com.google.firebase:firebase-analytics:17.2.1")
implementation("com.google.firebase:firebase-core:17.3.0")
implementation("com.google.firebase:firebase-analytics:17.3.0")
implementation("com.github.shalzz:helpstack-android:1.4.6")
// implementation("com.github.shalzz:helpstack:1.4.1-debug")

implementation("com.google.android.gms:play-services-oss-licenses:17.0.0")
implementation("com.google.android.material:material:1.0.0")

implementation("androidx.core:core:1.0.2")
implementation("androidx.appcompat:appcompat:1.0.2")
implementation("androidx.fragment:fragment:1.0.0")
implementation("androidx.recyclerview:recyclerview:1.0.0")
implementation("androidx.preference:preference:1.0.0")
implementation("androidx.annotation:annotation:1.0.2")
implementation("com.google.android.material:material:1.1.0")

implementation("androidx.core:core:1.2.0")
implementation("androidx.appcompat:appcompat:1.1.0")
implementation("androidx.fragment:fragment:1.2.4")
implementation("androidx.fragment:fragment-ktx:1.2.4")
implementation("androidx.recyclerview:recyclerview:1.1.0")
implementation("androidx.preference:preference:1.1.1")
implementation("androidx.annotation:annotation:1.1.0")
implementation("androidx.constraintlayout:constraintlayout:1.1.3")
implementation("androidx.constraintlayout:constraintlayout-solver:1.1.3")

Expand All @@ -228,8 +233,8 @@ dependencies {

implementation("com.jakewharton.timber:timber:4.7.1")

implementation("io.reactivex.rxjava2:rxandroid:2.0.2")
implementation("io.reactivex.rxjava2:rxjava:2.1.14")
implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
implementation("io.reactivex.rxjava2:rxjava:2.2.19")

implementation("com.squareup.retrofit2:retrofit:$RETROFIT_VERSION")
implementation("com.squareup.retrofit2:converter-moshi:$RETROFIT_VERSION")
Expand All @@ -255,17 +260,17 @@ dependencies {
testImplementation("androidx.room:room-testing:$ROOM_VERSION")
androidTestImplementation("androidx.room:room-testing:$ROOM_VERSION")

val jUnit = "androidx.test.ext:junit:1.0.0"
val jUnit = "androidx.test.ext:junit:1.1.1"
val truth = "androidx.test.ext:truth:1.0.0"
val mockito = "org.mockito:mockito-core:3.1.0"
val mockito = "org.mockito:mockito-core:3.3.3"

// Unit tests dependencies
testImplementation(jUnit)
testImplementation(truth)
testImplementation(mockito)
testImplementation("androidx.test:core:1.2.0")
testImplementation("org.robolectric:robolectric:4.3.1")
testImplementation("org.robolectric:shadows-multidex:4.0")
testImplementation("org.robolectric:shadows-multidex:4.3.1")

// Instrumentation test dependencies
androidTestImplementation(jUnit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ constructor(@ApplicationContext context: Context) {
*/
fun removeUser() {
val editor = mPref.edit()
editor.remove(MainActivity.PREFERENCE_ACTIVATED_FRAGMENT)
editor.putBoolean("LOGGEDIN", false)
editor.remove("USERNAME")
editor.remove("TOKEN")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ import android.animation.ValueAnimator
import android.app.Activity
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.*
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
Expand Down Expand Up @@ -59,6 +53,8 @@ import kotlinx.android.synthetic.main.fragment_attendance.*
import kotlinx.android.synthetic.main.fragment_attendance.view.*
import javax.inject.Inject
import javax.inject.Named
import kotlin.math.abs
import kotlin.math.min

class AttendanceListFragment : Fragment(), AttendanceMvpView,
ExpandableListAdapter.SubjectItemExpandedListener {
Expand Down Expand Up @@ -102,7 +98,7 @@ class AttendanceListFragment : Fragment(), AttendanceMvpView,
useGridLayout = resources.getBoolean(R.bool.use_grid_layout)
mExpandCollapseDuration = resources.getInteger(R.integer.expand_collapse_duration)

mActivity = activity!!
mActivity = requireActivity()
(mActivity as MainActivity).activityComponent().inject(this)
mPresenter.attachView(this)
setHasOptionsMenu(true)
Expand Down Expand Up @@ -158,10 +154,10 @@ class AttendanceListFragment : Fragment(), AttendanceMvpView,
(mActivity as MainActivity).setTitle(R.string.navigation_item_1)
}

override fun onCreateOptionsMenu(menu: Menu?, menuInflater: MenuInflater?) {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater!!.inflate(R.menu.attendance, menu)
val searchItem = menu!!.findItem(R.id.menu_search)
inflater.inflate(R.menu.attendance, menu)
val searchItem = menu.findItem(R.id.menu_search)

val searchView = searchItem.actionView as SearchView
searchView.queryHint = resources.getString(R.string.hint_search)
Expand All @@ -184,8 +180,8 @@ class AttendanceListFragment : Fragment(), AttendanceMvpView,
})
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
if (item!!.itemId == R.id.menu_refresh) {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.menu_refresh) {
// We make sure that the SwipeRefreshLayout is displaying it's refreshing indicator
if (!layoutSwipeRefresh.isRefreshing) {
layoutSwipeRefresh.isRefreshing = true
Expand All @@ -197,7 +193,7 @@ class AttendanceListFragment : Fragment(), AttendanceMvpView,
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, item.title.toString())
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Search")
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "menu")
mTracker.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle)
mTracker.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle)
}
return super.onOptionsItemSelected(item)
}
Expand All @@ -217,8 +213,8 @@ class AttendanceListFragment : Fragment(), AttendanceMvpView,
}
// Calculate some values to help with the animation.
val endingHeight = view.height
val distance = Math.abs(endingHeight - startingHeight)
val baseHeight = Math.min(endingHeight, startingHeight)
val distance = abs(endingHeight - startingHeight)
val baseHeight = min(endingHeight, startingHeight)
val isExpanded = endingHeight > startingHeight

// Set the views back to the start state of the animation
Expand Down Expand Up @@ -267,7 +263,6 @@ class AttendanceListFragment : Fragment(), AttendanceMvpView,

override fun getViewForCallId(callId: Long): View? {
if (!useGridLayout) {
assert(mLinearLayoutManager != null)
val firstPosition = mLinearLayoutManager!!.findFirstVisibleItemPosition()
val lastPosition = mLinearLayoutManager!!.findLastVisibleItemPosition()

Expand All @@ -284,7 +279,6 @@ class AttendanceListFragment : Fragment(), AttendanceMvpView,
} else {
val firstPosition = intArrayOf(0, 0)
val lastPosition = intArrayOf(0, 0)
assert(mGridLayoutManager != null)
mGridLayoutManager!!.findFirstVisibleItemPositions(firstPosition)
mGridLayoutManager!!.findLastVisibleItemPositions(lastPosition)

Expand Down Expand Up @@ -329,7 +323,7 @@ class AttendanceListFragment : Fragment(), AttendanceMvpView,
if (recyclerView.getChildAt(2) != null) {
val target = ViewTarget(recyclerView.getChildAt(2))

ShowcaseView.Builder(activity!!)
ShowcaseView.Builder(mActivity)
.setStyle(R.style.ShowcaseTheme)
.setTarget(target)
.singleShot(2222)
Expand Down Expand Up @@ -358,7 +352,7 @@ class AttendanceListFragment : Fragment(), AttendanceMvpView,
override fun showRetryError(message: String) {
stopRefreshing()
Snackbar.make(recyclerView, message, Snackbar.LENGTH_LONG)
.setAction("Retry") { v -> mPresenter.syncAttendance() }
.setAction("Retry") { mPresenter.syncAttendance() }
.show()
}

Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/com/shalzz/attendance/ui/day/DayFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class DayFragment : Fragment(), DayMvpView {
* The [androidx.swiperefreshlayout.widget.SwipeRefreshLayout] that detects swipe gestures and
* triggers callbacks in the app.
*/
var mSwipeRefreshLayout: MultiSwipeRefreshLayout? = null
var mRecyclerView: RecyclerView? = null
private var mSwipeRefreshLayout: MultiSwipeRefreshLayout? = null
private var mRecyclerView: RecyclerView? = null
private lateinit var mDate: Date
private lateinit var mEmptyView: EmptyView

Expand All @@ -93,8 +93,8 @@ class DayFragment : Fragment(), DayMvpView {
setHasOptionsMenu(true)
mDayPresenter.attachView(this)

mDate = if (arguments!!.getSerializable(ARG_DATE) != null)
arguments!!.getSerializable(ARG_DATE) as Date
mDate = if (arguments?.getSerializable(ARG_DATE) != null)
requireArguments().getSerializable(ARG_DATE) as Date
else
Date()

Expand Down Expand Up @@ -124,12 +124,12 @@ class DayFragment : Fragment(), DayMvpView {
return mView
}

override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
inflater!!.inflate(R.menu.day, menu)
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.day, menu)
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
if (item!!.itemId == R.id.menu_refresh) {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.menu_refresh) {
// We make sure that the SwipeRefreshLayout is displaying it's refreshing indicator
if (!mSwipeRefreshLayout!!.isRefreshing) {
mSwipeRefreshLayout!!.isRefreshing = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,12 @@ class CaptchaDialogFragment(listener: CaptchaDialogListener, dataAPI: DataAPI, c
fun onDialogPositiveClick(dialog: MaterialDialog, captcha: String, cookie: String)
}

override fun onAttach(context: Context?) {
super.onAttach(context)
mContext = context!!
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val inflater = activity!!.layoutInflater
val inflater = requireActivity().layoutInflater
val mView = inflater.inflate(R.layout.captcha_dialog, null)

return MaterialDialog.Builder(context!!)
mContext = requireContext()
return MaterialDialog.Builder(mContext)
.positiveText(R.string.login_button)
.negativeText(android.R.string.cancel)
.customView(mView, false)
Expand Down Expand Up @@ -103,7 +99,7 @@ class CaptchaDialogFragment(listener: CaptchaDialogListener, dataAPI: DataAPI, c

// logs in when user press done on keyboard.
materialDialog.captchaEditText.setOnEditorActionListener(
TextView.OnEditorActionListener { view, actionId, event ->
TextView.OnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
positiveButton.performClick()
return@OnEditorActionListener true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import android.app.Activity
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
Expand All @@ -32,7 +31,6 @@ import android.widget.ArrayAdapter
import androidx.fragment.app.Fragment
import com.afollestad.materialdialogs.MaterialDialog
import com.bugsnag.android.Bugsnag
import com.github.amlcurran.showcaseview.OnShowcaseEventListener
import com.github.amlcurran.showcaseview.ShowcaseView
import com.github.amlcurran.showcaseview.targets.ViewTarget
import com.google.android.gms.common.ConnectionResult
Expand All @@ -43,10 +41,8 @@ import com.shalzz.attendance.data.local.PreferencesHelper
import com.shalzz.attendance.data.model.College
import com.shalzz.attendance.data.model.entity.User
import com.shalzz.attendance.data.remote.DataAPI
import com.shalzz.attendance.ui.attendance.AttendanceListFragment
import com.shalzz.attendance.utils.Utils
import com.shalzz.attendance.utils.Utils.Analytics
import kotlinx.android.synthetic.main.drawer.*
import kotlinx.android.synthetic.main.fragment_login.*
import kotlinx.android.synthetic.main.fragment_login.view.*
import timber.log.Timber
Expand Down Expand Up @@ -131,7 +127,7 @@ class LoginFragment : Fragment(), LoginMvpView, AdapterView.OnItemSelectedListen
val sv = ShowcaseView.Builder(mActivity)
.setStyle(R.style.ShowcaseTheme)
.setTarget(target)
.singleShot(R.id.menu_help.toLong())
.singleShot(4444)
.blockAllTouches()
.setContentTitle(getString(R.string.sv_login_activity_faq))
.setContentText(getString(R.string.sv_login_activity_faq_content))
Expand All @@ -144,7 +140,7 @@ class LoginFragment : Fragment(), LoginMvpView, AdapterView.OnItemSelectedListen
ShowcaseView.Builder(mActivity)
.setStyle(R.style.ShowcaseTheme)
.setTarget(secondTarget)
.singleShot(R.id.spCollege.toLong())
.singleShot(5555)
.setContentTitle(getString(R.string.sv_login_activity_spinner))
.setContentText(getString(R.string.sv_login_activity_spinner_content))
.build()
Expand Down Expand Up @@ -262,7 +258,7 @@ class LoginFragment : Fragment(), LoginMvpView, AdapterView.OnItemSelectedListen
override fun showCaptchaDialog() {
dismissProgressDialog()
val dialog = CaptchaDialogFragment(this, mDataApi, college!!.id)
dialog.show(fragmentManager, "captcha-dialog")
dialog.show(parentFragmentManager, "captcha-dialog")
}

override fun updateCollegeList(data: List<College>) {
Expand Down
Loading

0 comments on commit 61bf4ec

Please sign in to comment.