Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add funding reminder #8384

Closed
wants to merge 2 commits into from
Closed

Conversation

wmontwe
Copy link
Member

@wmontwe wmontwe commented Oct 22, 2024

This adds the forgotten funding reminder. It will show once after 30 minutes of activity.

(cherry picked from commit 35dd88b2423a5de98525dc40dc95dff149868baa)
@wmontwe wmontwe requested a review from cketti as a code owner October 22, 2024 10:51
@wmontwe wmontwe force-pushed the add-funding-reminder branch 2 times, most recently from 8635230 to 67d7058 Compare October 22, 2024 11:17
(cherry picked from commit 1c278dbbaa005f22bbac6672d7699ee34913e518)
import com.fsck.k9.feature.featureLauncherModule
import org.koin.dsl.module

val featureModule = module {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use the plural form (featuresModule) considering this combines multiple features?

Comment on lines +67 to +69
return Intent(intent).apply {
data = FundingRoute.Contribution.toDeepLinkUri()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This couples the feature to the existing FeatureLauncherActivity implementation detail of using a separate activity with a base intent and a navigation path in the data field. Instead, we could use a callback and leave it up to the module using this feature module on how to launch the action when the user presses the "Yes" button.

The callback could then use FeatureLauncherActivity.getIntent(context, target = FeatureLauncherTarget.Funding) like we already do in SettingsListFragment.

override fun getFundingType(): FundingType {
return FundingType.GOOGLE_PLAY
}

override fun addFundingReminder(activity: AppCompatActivity, launcherIntent: Intent) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses launcherIntent instead of the launcherBaseIntent that is used in the interface. This leads to a warning in the IDE ("This may cause problems when calling this function with named arguments").

return
}

showDialogRunnable = createShowDialogRunnable(activity, launcherIntent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a local variable. That way we can get rid of the !! and we don't leak the Activity when ´FundingReminderholds on to it via theshowDialogRunnable` property.

.setPositiveButton(R.string.funding_googleplay_contribution_reminder_positive_button) { _, _ ->
activity.startActivity(getSupportIntent(launcherIntent))
}
.setNegativeButton(R.string.funding_googleplay_contribution_reminder_negative_button) { _, _ -> }.show()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.setNegativeButton(R.string.funding_googleplay_contribution_reminder_negative_button) { _, _ -> }.show()
.setNegativeButton(R.string.funding_googleplay_contribution_reminder_negative_button, null)
.show()

@@ -90,4 +90,9 @@
<item>Make our boldest ideas a reality</item>
<item>Contributions are not tax-deductible</item>
</array>

<string name="funding_googleplay_contribution_reminder_title">Support Thunderbird</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could reuse funding_googleplay_contribution_header_title for this.

@@ -33,7 +33,7 @@ class Settings {
*
* @see SettingsExporter
*/
public static final int VERSION = 100;
public static final int VERSION = 101;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the version for settings export. If we want the value in the settings file, an entry has to be added to GeneralSettingsDescriptions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The settings need to be improved, it's unclear which component belongs to what functionality and what defines that a setting is importable/exportable.

Comment on lines +105 to +119
override fun getLong(key: String, defValue: Long): Long {
return when (key) {
"fundingReminderShownTimestamp" -> K9.fundingReminderShownTimestamp
else -> defValue
}
}

override fun putLong(key: String?, value: Long) {
when (key) {
"fundingReminderShownTimestamp" -> K9.fundingReminderShownTimestamp = value
else -> return
}

saveSettings()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GeneralSettingsDataStore is only used by the settings screen. Since we don't have a visual setting, this is not necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to document how this is supposed to work. From reading the implementation, it's not obvious.

@wmontwe
Copy link
Member Author

wmontwe commented Oct 23, 2024

Closing this in favor of #8397 and a reworked reminder logic.

@wmontwe wmontwe closed this Oct 23, 2024
@wmontwe wmontwe deleted the add-funding-reminder branch October 23, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants