Skip to content

Commit

Permalink
Merge pull request #13 from PopStackHack/release/4.1.2
Browse files Browse the repository at this point in the history
Release/4.1.2
  • Loading branch information
vincent-paing authored Oct 22, 2020
2 parents 6a70e43 + ea3100a commit c4f2def
Show file tree
Hide file tree
Showing 32 changed files with 229 additions and 91 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This repo contains the code for the mVoter 2020 Android App. mVoter 2020 is an u
The code need to be compiled with following specification

- **Sdk version** : 30 (Android 11)
- **Android Studio** : 4.0.1
- **Android Studio** : 4.1.0
- **Kotlin** : 1.4.0

The App is targeted for the following specification
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ android {
}

compileOptions {
coreLibraryDesugaringEnabled = true
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.popstack.mvoter2015.feature.about

import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.text.LineBreaker
import android.net.Uri
import android.os.Bundle
import android.text.Layout
import android.view.LayoutInflater
import androidx.lifecycle.lifecycleScope
import com.bluelinelabs.conductor.RouterTransaction
Expand Down Expand Up @@ -33,6 +36,7 @@ class AboutController : LifeCycleAwareController<ControllerAboutBinding>(), Inje
override val bindingInflater: (LayoutInflater) -> ControllerAboutBinding =
ControllerAboutBinding::inflate

@SuppressLint("WrongConstant")
override fun onBindView(savedViewState: Bundle?) {
super.onBindView(savedViewState)

Expand Down Expand Up @@ -74,6 +78,14 @@ class AboutController : LifeCycleAwareController<ControllerAboutBinding>(), Inje
openAppWebsite()
}

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
binding.tvCandidatePrivacyInstruction.justificationMode = LineBreaker.JUSTIFICATION_MODE_INTER_WORD
} else {
binding.tvCandidatePrivacyInstruction.justificationMode = Layout.JUSTIFICATION_MODE_INTER_WORD
}
}

binding.tvVersion.text = requireContext().getString(R.string.version, BuildConfig.VERSION_NAME)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.popstack.mvoter2015.feature.candidate.listing

import android.annotation.SuppressLint
import android.graphics.text.LineBreaker
import android.os.Bundle
import android.text.Layout
import android.view.LayoutInflater
import android.view.View
import androidx.core.view.isVisible
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import androidx.viewpager.widget.ViewPager
import com.bluelinelabs.conductor.RouterTransaction
import com.google.android.material.tabs.TabLayout
Expand All @@ -21,6 +25,9 @@ import com.popstack.mvoter2015.helper.conductor.requireContext
import com.popstack.mvoter2015.helper.conductor.setSupportActionBar
import com.popstack.mvoter2015.helper.conductor.supportActionBar
import com.popstack.mvoter2015.logging.HasTag
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import javax.inject.Inject

class CandidateListController :
MvvmController<ControllerCandidateListBinding>(), HasTag {
Expand Down Expand Up @@ -115,10 +122,38 @@ class CandidateListController :

CandidateListPagerParentRouter.setParentRouter(router)

showCandidatePrivacyInstructionIfNeeded()

viewModel.houseViewItemListLiveData.observe(lifecycleOwner, Observer(::observeHouseViewItem))
viewModel.loadHouses()
}

@Inject
lateinit var viewCache: CandidateListViewCache

@SuppressLint("WrongConstant")
private fun showCandidatePrivacyInstructionIfNeeded() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
binding.tvCandidatePrivacyInstruction.justificationMode = LineBreaker.JUSTIFICATION_MODE_INTER_WORD
} else {
binding.tvCandidatePrivacyInstruction.justificationMode = Layout.JUSTIFICATION_MODE_INTER_WORD
}
}

lifecycleScope.launch {
viewCache.shouldShowCandidatePrivacyInstruction().collectLatest {
binding.layoutCandidatePrivacyInstruction.isVisible = it
}
}

binding.ivCloseCandidatePrivacyInstruction.setOnClickListener {
lifecycleScope.launch {
viewCache.setShouldShowCandidatePrivacyInstruction(false)
}
}
}

private fun setupTabLayout() {
binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabReselected(tab: TabLayout.Tab?) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.popstack.mvoter2015.feature.candidate.listing

import android.content.Context
import androidx.datastore.preferences.createDataStore
import androidx.datastore.preferences.edit
import androidx.datastore.preferences.preferencesKey
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import javax.inject.Inject

class CandidateListViewCache @Inject constructor(
private val context: Context
) {

companion object {
private val KEY_SHOULD_SHOW_CANDIDATE_PRIVACY_INSTRUCTION = preferencesKey<Boolean>("candidate_privacy_instruction")
}

private val candidateListViewCachePrefCandidateListViewCachePref = context.createDataStore("candidate_list_view_cache")

suspend fun setShouldShowCandidatePrivacyInstruction(shouldShow: Boolean) {
candidateListViewCachePrefCandidateListViewCachePref.edit {
it[KEY_SHOULD_SHOW_CANDIDATE_PRIVACY_INSTRUCTION] = shouldShow
}
}

fun shouldShowCandidatePrivacyInstruction(): Flow<Boolean> {
return candidateListViewCachePrefCandidateListViewCachePref.data.map {
it[KEY_SHOULD_SHOW_CANDIDATE_PRIVACY_INSTRUCTION] ?: true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FaqViewModel @Inject constructor(
return lastResult
}
selectedFaqCategory = faqCategory
faqCategoryLiveData.postValue(selectedFaqCategory)
faqCategoryLiveData.postValue(selectedFaqCategory!!)

val newResult = faqPagerFactory.faqPager(PAGE_SIZE, category = faqCategory)
.flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BallotExampleViewModel @Inject constructor(
return@launch
}
selectedBallotExampleCategory = ballotExampleCategory
ballotExampleCategoryLiveData.postValue(selectedBallotExampleCategory)
ballotExampleCategoryLiveData.postValue(selectedBallotExampleCategory!!)
ballotViewItemLiveData.postLoading()
try {

Expand Down
Binary file removed app/src/main/res/drawable-nodpi/maepaysoh_logo.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-nodpi/taf_logo.webp
Binary file not shown.
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_close_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/layout-ldpi/controller_location.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:layout_width="105dp"
android:layout_height="60dp"
android:src="@drawable/ic_people_fill"
android:tint="@color/accent"
app:tint="@color/accent"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/tvInstruction"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout-mdpi/controller_location.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:layout_width="105dp"
android:layout_height="60dp"
android:src="@drawable/ic_people_fill"
android:tint="@color/accent"
app:tint="@color/accent"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/tvInstruction"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@
android:layout_height="36dp"
android:layout_marginTop="@dimen/candidate_details_horizontal_section_spacing"
android:src="@drawable/ic_candidate_filled"
android:tint="@color/accent"
app:tint="@color/accent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrierFatherRaceAndFatherReligion" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:layout_height="64dp"
android:layout_marginEnd="16dp"
android:src="@drawable/ic_check_voter_list"
android:tint="@color/accent"
app:tint="@color/accent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="h,1:1"
app:layout_constraintEnd_toStartOf="@id/guideline45PercentVertical"
Expand Down
65 changes: 21 additions & 44 deletions app/src/main/res/layout/controller_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,50 +70,16 @@
<ImageView
android:id="@+id/ivUecLogo"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_height="100dp"
android:scaleType="fitCenter"
android:src="@drawable/uec_logo"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toStartOf="@+id/ivTafLogo"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSupportedBy" />

<ImageView
android:id="@+id/ivTafLogo"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:src="@drawable/taf_logo"
app:layout_constraintDimensionRatio="h,2:1"
app:layout_constraintEnd_toStartOf="@+id/ivMaePaySohLogo"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toEndOf="@+id/ivUecLogo"
app:layout_constraintTop_toBottomOf="@id/tvSupportedBy" />

<ImageView
android:id="@+id/ivMaePaySohLogo"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:src="@drawable/maepaysoh_logo"
app:layout_constraintDimensionRatio="w,1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="@+id/ivTafLogo"
app:layout_constraintTop_toBottomOf="@id/tvSupportedBy" />

<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrierLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="ivUecLogo,ivTafLogo,ivMaePaySohLogo" />

<com.google.android.material.button.MaterialButton
android:id="@+id/viewTermOfUse"
style="@style/Widget.MaterialComponents.Button.TextButton"
Expand All @@ -124,7 +90,7 @@
android:textColor="@color/accent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrierLogo"
app:layout_constraintTop_toBottomOf="@id/ivUecLogo"
app:rippleColor="@color/grey" />

<com.google.android.material.button.MaterialButton
Expand Down Expand Up @@ -170,12 +136,12 @@
android:background="@drawable/background_accent_oval"
android:padding="8dp"
android:src="@drawable/ic_facebook_24"
android:tint="@android:color/white"
app:layout_constraintEnd_toStartOf="@+id/ivContactMail"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvContactUs" />
app:layout_constraintTop_toBottomOf="@id/tvContactUs"
app:tint="@android:color/white" />

<ImageView
android:id="@+id/ivContactMail"
Expand All @@ -186,11 +152,11 @@
android:background="@drawable/background_accent_oval"
android:padding="8dp"
android:src="@drawable/ic_email_24"
android:tint="@android:color/white"
app:layout_constraintEnd_toStartOf="@+id/ivContactWebsite"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/ivContactFacebook"
app:layout_constraintTop_toBottomOf="@id/tvContactUs" />
app:layout_constraintTop_toBottomOf="@id/tvContactUs"
app:tint="@android:color/white" />

<ImageView
android:id="@+id/ivContactWebsite"
Expand All @@ -201,11 +167,22 @@
android:background="@drawable/background_accent_oval"
android:padding="8dp"
android:src="@drawable/ic_website_24"
android:tint="@android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/ivContactMail"
app:layout_constraintTop_toBottomOf="@id/tvContactUs" />
app:layout_constraintTop_toBottomOf="@id/tvContactUs"
app:tint="@android:color/white" />

<TextView
android:id="@+id/tvCandidatePrivacyInstruction"
style="@style/TextMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/candidate_privacy_instruction_full"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivContactWebsite" />

<TextView
android:id="@+id/tvVersion"
Expand All @@ -216,7 +193,7 @@
android:text="@string/version"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivContactWebsite" />
app:layout_constraintTop_toBottomOf="@id/tvCandidatePrivacyInstruction" />

<TextView
android:id="@+id/tvCopyright"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/controller_candidate_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@
android:layout_height="36dp"
android:layout_marginTop="@dimen/candidate_details_horizontal_section_spacing"
android:src="@drawable/ic_candidate_filled"
android:tint="@color/accent"
app:tint="@color/accent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvFatherReligion" />
Expand Down
Loading

0 comments on commit c4f2def

Please sign in to comment.