Skip to content

Commit

Permalink
Revert "Fix #4, #70, #71, #86, #87: Introduce data module (#85)"
Browse files Browse the repository at this point in the history
This reverts commit bda2f7c.
  • Loading branch information
BenHenning authored Sep 3, 2019
1 parent bda2f7c commit 5f0d786
Show file tree
Hide file tree
Showing 55 changed files with 271 additions and 4,370 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
app/build
data/build
domain/build
model/build
utility/build
Expand Down
6 changes: 0 additions & 6 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 2 additions & 27 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 28
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "org.oppia.app"
minSdkVersion 19
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// https://developer.android.com/training/testing/junit-runner#ato-gradle
testInstrumentationRunnerArguments clearPackageData: 'true'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
buildTypes {
release {
Expand All @@ -33,8 +23,6 @@ android {
enabled = true
}
testOptions {
// https://developer.android.com/training/testing/junit-runner#ato-gradle
execution 'ANDROIDX_TEST_ORCHESTRATOR'
unitTests {
includeAndroidResources = true
}
Expand All @@ -61,7 +49,6 @@ dependencies {
'androidx.constraintlayout:constraintlayout:1.1.3',
'androidx.core:core-ktx:1.0.2',
'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha03',
'com.google.dagger:dagger:2.24',
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version",
)
testImplementation(
Expand All @@ -78,18 +65,6 @@ dependencies {
'androidx.test:runner:1.2.0',
'com.google.truth:truth:0.43',
)
androidTestUtil(
'androidx.test:orchestrator:1.2.0',
)
kapt(
'com.google.dagger:dagger-compiler:2.24'
)
kaptTest(
'com.google.dagger:dagger-compiler:2.24'
)
kaptAndroidTest(
'com.google.dagger:dagger-compiler:2.24'
)
implementation project(":model")
implementation project(":domain")
implementation project(":utility")
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
package="org.oppia.app">

<application
android:name=".application.OppiaApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/OppiaTheme">
<activity android:name="org.oppia.app.home.HomeActivity">
<activity android:name="org.oppia.app.HomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/org/oppia/app/HomeActivity.kt
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()
}
}
55 changes: 55 additions & 0 deletions app/src/main/java/org/oppia/app/HomeFragment.kt
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 app/src/main/java/org/oppia/app/UserAppHistoryViewModel.kt
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 app/src/main/java/org/oppia/app/activity/ActivityComponent.kt

This file was deleted.

7 changes: 0 additions & 7 deletions app/src/main/java/org/oppia/app/activity/ActivityModule.kt

This file was deleted.

6 changes: 0 additions & 6 deletions app/src/main/java/org/oppia/app/activity/ActivityScope.kt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

26 changes: 0 additions & 26 deletions app/src/main/java/org/oppia/app/application/ApplicationModule.kt

This file was deleted.

23 changes: 0 additions & 23 deletions app/src/main/java/org/oppia/app/application/OppiaApplication.kt

This file was deleted.

19 changes: 0 additions & 19 deletions app/src/main/java/org/oppia/app/fragment/FragmentComponent.kt

This file was deleted.

6 changes: 0 additions & 6 deletions app/src/main/java/org/oppia/app/fragment/FragmentScope.kt

This file was deleted.

Loading

0 comments on commit 5f0d786

Please sign in to comment.