-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/oppia/oppia-android into #…
- Loading branch information
Showing
148 changed files
with
2,630 additions
and
748 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/oppia/android/app/notice/DeprecationNoticeActionListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.oppia.android.app.notice | ||
|
||
import org.oppia.android.app.splash.DeprecationNoticeActionType | ||
|
||
/** Listener for when an option on any deprecation dialog is clicked. */ | ||
interface DeprecationNoticeActionListener { | ||
/** Called when a dialog button is clicked. */ | ||
fun onActionButtonClicked(noticeType: DeprecationNoticeActionType) | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.oppia.android.app.notice | ||
|
||
import android.app.Dialog | ||
import android.content.Context | ||
import android.os.Bundle | ||
import org.oppia.android.app.fragment.FragmentComponentImpl | ||
import org.oppia.android.app.fragment.InjectableDialogFragment | ||
import javax.inject.Inject | ||
|
||
/** Dialog fragment that informs the user of an app deprecation. */ | ||
class ForcedAppDeprecationNoticeDialogFragment : InjectableDialogFragment() { | ||
companion object { | ||
/** Returns a new instance of [ForcedAppDeprecationNoticeDialogFragment]. */ | ||
fun newInstance(): ForcedAppDeprecationNoticeDialogFragment { | ||
return ForcedAppDeprecationNoticeDialogFragment() | ||
} | ||
} | ||
|
||
@Inject lateinit var presenter: ForcedAppDeprecationNoticeDialogFragmentPresenter | ||
|
||
override fun onAttach(context: Context) { | ||
super.onAttach(context) | ||
(fragmentComponent as FragmentComponentImpl).inject(this) | ||
} | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
return presenter.handleOnCreateDialog() | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...in/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragmentPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.oppia.android.app.notice | ||
|
||
import android.app.Dialog | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.app.AppCompatActivity | ||
import org.oppia.android.R | ||
import org.oppia.android.app.splash.DeprecationNoticeActionType | ||
import org.oppia.android.app.translation.AppLanguageResourceHandler | ||
import javax.inject.Inject | ||
|
||
/** Presenter class responsible for showing an app deprecation dialog to the user. */ | ||
class ForcedAppDeprecationNoticeDialogFragmentPresenter @Inject constructor( | ||
private val activity: AppCompatActivity, | ||
private val resourceHandler: AppLanguageResourceHandler | ||
) { | ||
private val deprecationNoticeActionListener by lazy { | ||
activity as DeprecationNoticeActionListener | ||
} | ||
|
||
/** Handles dialog creation for the forced app deprecation notice. */ | ||
fun handleOnCreateDialog(): Dialog { | ||
val appName = resourceHandler.getStringInLocale(R.string.app_name) | ||
|
||
val dialog = AlertDialog.Builder(activity, R.style.DeprecationAlertDialogTheme) | ||
.setTitle(R.string.forced_app_update_dialog_title) | ||
.setMessage( | ||
resourceHandler.getStringInLocaleWithWrapping( | ||
R.string.forced_app_update_dialog_message, | ||
appName | ||
) | ||
) | ||
.setPositiveButton(R.string.forced_app_update_dialog_update_button_text) { _, _ -> | ||
deprecationNoticeActionListener.onActionButtonClicked( | ||
DeprecationNoticeActionType.UPDATE | ||
) | ||
} | ||
.setNegativeButton(R.string.forced_app_update_dialog_close_button_text) { _, _ -> | ||
deprecationNoticeActionListener.onActionButtonClicked( | ||
DeprecationNoticeActionType.CLOSE | ||
) | ||
} | ||
.setCancelable(false) | ||
.create() | ||
dialog.setCanceledOnTouchOutside(false) | ||
return dialog | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.oppia.android.app.notice | ||
|
||
import android.app.Dialog | ||
import android.content.Context | ||
import android.os.Bundle | ||
import org.oppia.android.app.fragment.FragmentComponentImpl | ||
import org.oppia.android.app.fragment.InjectableDialogFragment | ||
import javax.inject.Inject | ||
|
||
/** Dialog fragment that informs the user that a new app version is available for download. */ | ||
class OptionalAppDeprecationNoticeDialogFragment : InjectableDialogFragment() { | ||
companion object { | ||
/** Returns a new instance of [OptionalAppDeprecationNoticeDialogFragment]. */ | ||
fun newInstance(): OptionalAppDeprecationNoticeDialogFragment { | ||
return OptionalAppDeprecationNoticeDialogFragment() | ||
} | ||
} | ||
|
||
@Inject lateinit var optionalAppDeprecationNoticeDialogFragmentPresenter: | ||
OptionalAppDeprecationNoticeDialogFragmentPresenter | ||
|
||
override fun onAttach(context: Context) { | ||
super.onAttach(context) | ||
(fragmentComponent as FragmentComponentImpl).inject(this) | ||
} | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
return optionalAppDeprecationNoticeDialogFragmentPresenter.handleOnCreateDialog() | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
.../java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragmentPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.oppia.android.app.notice | ||
|
||
import android.app.Dialog | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.app.AppCompatActivity | ||
import org.oppia.android.R | ||
import org.oppia.android.app.splash.DeprecationNoticeActionType | ||
import org.oppia.android.app.translation.AppLanguageResourceHandler | ||
import javax.inject.Inject | ||
|
||
/** Presenter class responsible for showing an optional update dialog to the user. */ | ||
class OptionalAppDeprecationNoticeDialogFragmentPresenter @Inject constructor( | ||
private val activity: AppCompatActivity, | ||
private val resourceHandler: AppLanguageResourceHandler | ||
) { | ||
private val deprecationNoticeActionListener by lazy { | ||
activity as DeprecationNoticeActionListener | ||
} | ||
|
||
/** Handles dialog creation for the optional app deprecation notice. */ | ||
fun handleOnCreateDialog(): Dialog { | ||
val appName = resourceHandler.getStringInLocale(R.string.app_name) | ||
|
||
val dialog = AlertDialog.Builder(activity, R.style.DeprecationAlertDialogTheme) | ||
.setTitle(R.string.optional_app_update_dialog_title) | ||
.setMessage( | ||
resourceHandler.getStringInLocaleWithWrapping( | ||
R.string.optional_app_update_dialog_message, | ||
appName | ||
) | ||
) | ||
.setPositiveButton(R.string.optional_app_update_dialog_update_button_text) { _, _ -> | ||
deprecationNoticeActionListener.onActionButtonClicked( | ||
DeprecationNoticeActionType.UPDATE | ||
) | ||
} | ||
.setNegativeButton(R.string.optional_app_update_dialog_dismiss_button_text) { _, _ -> | ||
deprecationNoticeActionListener.onActionButtonClicked( | ||
DeprecationNoticeActionType.DISMISS | ||
) | ||
} | ||
.setCancelable(false) | ||
.create() | ||
dialog.setCanceledOnTouchOutside(false) | ||
return dialog | ||
} | ||
} |
Oops, something went wrong.