-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code refactoring. Use AppData instead AppDataHolder.kt
- Loading branch information
1 parent
432fd4e
commit a962fee
Showing
16 changed files
with
67 additions
and
66 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
5 changes: 5 additions & 0 deletions
5
core/src/main/java/org/openedx/core/presentation/global/AppData.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,5 @@ | ||
package org.openedx.core.presentation.global | ||
|
||
data class AppData( | ||
val versionName: String | ||
) |
11 changes: 0 additions & 11 deletions
11
core/src/main/java/org/openedx/core/presentation/global/AppDataHolder.kt
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
core/src/main/java/org/openedx/core/presentation/global/WhatsNewGlobalManager.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,5 @@ | ||
package org.openedx.core.presentation.global | ||
|
||
interface WhatsNewGlobalManager { | ||
fun shouldShowWhatsNew(): Boolean | ||
} |
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
15 changes: 0 additions & 15 deletions
15
whatsnew/src/main/java/org/openedx/whatsnew/WhatsNewFileManager.kt
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
whatsnew/src/main/java/org/openedx/whatsnew/WhatsNewManagerManager.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.openedx.whatsnew | ||
|
||
import android.content.Context | ||
import com.google.gson.Gson | ||
import org.openedx.core.presentation.global.AppData | ||
import org.openedx.core.presentation.global.WhatsNewGlobalManager | ||
import org.openedx.whatsnew.data.model.WhatsNewItem | ||
import org.openedx.whatsnew.data.storage.WhatsNewPreferences | ||
|
||
class WhatsNewManagerManager( | ||
private val context: Context, | ||
private val whatsNewPreferences: WhatsNewPreferences, | ||
private val appData: AppData | ||
): WhatsNewGlobalManager { | ||
fun getNewestData(): org.openedx.whatsnew.domain.model.WhatsNewItem { | ||
val jsonString = context.resources.openRawResource(R.raw.whats_new) | ||
.bufferedReader() | ||
.use { it.readText() } | ||
val whatsNewListData = Gson().fromJson(jsonString, Array<WhatsNewItem>::class.java) | ||
return whatsNewListData[0].mapToDomain(context) | ||
} | ||
|
||
override fun shouldShowWhatsNew(): Boolean { | ||
val dataVersion = getNewestData().version | ||
return appData.versionName == dataVersion | ||
&& whatsNewPreferences.lastWhatsNewVersion != dataVersion | ||
&& org.openedx.core.BuildConfig.SHOW_WHATS_NEW | ||
} | ||
} |
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