-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit bda2f7c.
- Loading branch information
1 parent
bda2f7c
commit 5f0d786
Showing
55 changed files
with
271 additions
and
4,370 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.oppia.app | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
|
||
/** The central activity for all users entering the app. */ | ||
class HomeActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.home_activity) | ||
supportFragmentManager.beginTransaction().add(R.id.home_fragment_placeholder, HomeFragment()).commitNow() | ||
} | ||
} |
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,55 @@ | ||
package org.oppia.app | ||
|
||
import android.os.Bundle | ||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.Transformations | ||
import androidx.lifecycle.ViewModelProviders | ||
import org.oppia.app.databinding.HomeFragmentBinding | ||
import org.oppia.app.model.UserAppHistory | ||
import org.oppia.domain.UserAppHistoryController | ||
import org.oppia.util.data.AsyncResult | ||
|
||
/** Fragment that contains an introduction to the app. */ | ||
class HomeFragment : Fragment() { | ||
private val userAppHistoryController = UserAppHistoryController() | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
val binding = HomeFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false) | ||
val viewModel = getUserAppHistoryViewModel() | ||
val appUserHistory = getUserAppHistory() | ||
viewModel.userAppHistoryLiveData = appUserHistory | ||
// NB: Both the view model and lifecycle owner must be set in order to correctly bind LiveData elements to | ||
// data-bound view models. | ||
binding.let { | ||
it.viewModel = viewModel | ||
it.lifecycleOwner = this | ||
} | ||
|
||
// TODO(#70): Mark that the user opened the app once it's persisted to disk. | ||
|
||
return binding.root | ||
} | ||
|
||
private fun getUserAppHistoryViewModel(): UserAppHistoryViewModel { | ||
return ViewModelProviders.of(this).get(UserAppHistoryViewModel::class.java) | ||
} | ||
|
||
private fun getUserAppHistory(): LiveData<UserAppHistory> { | ||
// If there's an error loading the data, assume the default. | ||
return Transformations.map( | ||
userAppHistoryController.getUserAppHistory() | ||
) { result: AsyncResult<UserAppHistory> -> processUserAppHistoryResult(result) } | ||
} | ||
|
||
private fun processUserAppHistoryResult(appHistoryResult: AsyncResult<UserAppHistory>): UserAppHistory { | ||
if (appHistoryResult.isFailure()) { | ||
Log.e("HomeFragment", "Failed to retrieve user app history", appHistoryResult.error) | ||
} | ||
return appHistoryResult.getOrDefault(UserAppHistory.getDefaultInstance()) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/oppia/app/UserAppHistoryViewModel.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,10 @@ | ||
package org.oppia.app | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.ViewModel | ||
import org.oppia.app.model.UserAppHistory | ||
|
||
/** [ViewModel] for user app usage history. */ | ||
class UserAppHistoryViewModel: ViewModel() { | ||
var userAppHistoryLiveData: LiveData<UserAppHistory>? = null | ||
} |
23 changes: 0 additions & 23 deletions
23
app/src/main/java/org/oppia/app/activity/ActivityComponent.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
app/src/main/java/org/oppia/app/activity/InjectableAppCompatActivity.kt
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
app/src/main/java/org/oppia/app/application/ApplicationComponent.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
app/src/main/java/org/oppia/app/application/ApplicationContext.kt
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
app/src/main/java/org/oppia/app/application/ApplicationModule.kt
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
app/src/main/java/org/oppia/app/application/OppiaApplication.kt
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
app/src/main/java/org/oppia/app/fragment/FragmentComponent.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.