Skip to content

Commit 8330148

Browse files
authored
Merge pull request #123 from brian2509/musicdao_mvp
Music DAO MVP
2 parents b348ac5 + ed05929 commit 8330148

File tree

205 files changed

+8661
-3990
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+8661
-3990
lines changed

app/build.gradle

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ apply plugin: 'org.jlleitschuh.gradle.ktlint'
66
apply plugin: 'com.google.gms.google-services'
77
apply plugin: 'com.google.firebase.crashlytics'
88
apply plugin: 'kotlinx-serialization'
9+
apply plugin: "dagger.hilt.android.plugin"
10+
apply plugin: "kotlin-kapt"
911

1012
buildscript {
1113
repositories {
@@ -15,6 +17,8 @@ buildscript {
1517

1618
dependencies {
1719
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
20+
classpath("com.google.dagger:hilt-android-gradle-plugin:$hilt_ver")
21+
1822
}
1923
}
2024

@@ -103,7 +107,6 @@ allprojects {
103107
repositories {
104108
mavenCentral()
105109
jcenter()
106-
107110
}
108111
}
109112

@@ -181,6 +184,18 @@ dependencies {
181184
testImplementation 'junit:junit:4.13.2'
182185
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
183186
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
187+
188+
// Hilt
189+
implementation("com.google.dagger:hilt-android:$hilt_ver")
190+
implementation("androidx.hilt:hilt-navigation-fragment:1.0.0")
191+
implementation("androidx.hilt:hilt-navigation-compose:1.1.0-alpha01")
192+
kapt("com.google.dagger:hilt-android-compiler:$hilt_ver")
193+
194+
// Room
195+
implementation "androidx.room:room-runtime:$room_version"
196+
implementation("androidx.room:room-ktx:$room_version")
197+
annotationProcessor "androidx.room:room-compiler:$room_version"
198+
kapt("androidx.room:room-compiler:$room_version")
184199
}
185200

186201

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<shape xmlns:android="http://schemas.android.com/apk/res/android"
33
android:shape="rectangle">
4-
<solid android:color="#0fff" />
5-
<stroke
6-
android:width="1dp"
7-
android:color="#000" />
4+
<solid android:color="@color/android_green" />
85
</shape>
6+

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,12 @@
151151
android:windowSoftInputMode="stateAlwaysHidden" />
152152

153153
<activity
154-
android:name="com.example.musicdao.MusicService"
154+
android:name="nl.tudelft.trustchain.musicdao.MusicActivity"
155+
android:label="Music App"
155156
android:exported="true"
156-
android:label="Music app"
157157
android:parentActivityName=".ui.dashboard.DashboardActivity"
158-
android:screenOrientation="portrait">
159-
<intent-filter>
160-
<action android:name="android.intent.action.SEARCH" />
161-
</intent-filter>
162-
<meta-data
163-
android:name="android.app.searchable"
164-
android:resource="@xml/searchable" />
158+
android:screenOrientation="portrait"
159+
android:theme="@style/Theme.MusicDaoTheme">
165160
</activity>
166161

167162
<activity
@@ -183,7 +178,7 @@
183178
android:exported="false" />
184179

185180
<service
186-
android:name="com.example.musicdao.MusicGossipingService"
181+
android:name="nl.tudelft.trustchain.musicdao.core.repositories.MusicGossipingService"
187182
android:enabled="true"
188183
android:exported="false" />
189184

app/src/main/java/nl/tudelft/trustchain/app/AppDefinition.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package nl.tudelft.trustchain.app
33
import android.app.Activity
44
import androidx.annotation.ColorRes
55
import androidx.annotation.DrawableRes
6-
import com.example.musicdao.MusicService
6+
import nl.tudelft.trustchain.musicdao.MusicActivity
77
import nl.tudelft.trustchain.FOC.MainActivityFOC
88
import nl.tudelft.trustchain.atomicswap.AtomicSwapActivity
99
import nl.tudelft.trustchain.common.R
@@ -101,7 +101,7 @@ enum class AppDefinition(
101101
android.R.drawable.ic_media_play,
102102
"MusicDAO",
103103
R.color.black,
104-
MusicService::class.java
104+
MusicActivity::class.java
105105
),
106106
EUROTOKEN(
107107
R.drawable.ic_baseline_euro_symbol_24,

app/src/main/java/nl/tudelft/trustchain/app/AppLoader.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package nl.tudelft.trustchain.app
22

3+
import android.annotation.SuppressLint
34
import androidx.datastore.core.DataStore
45
import androidx.datastore.preferences.core.Preferences
56
import androidx.datastore.preferences.core.edit
@@ -58,6 +59,7 @@ class AppLoader(
5859
}
5960
}
6061

62+
@SuppressLint("NewApi")
6163
private suspend fun setPreferredAppList(newPreferences: Set<String>) {
6264
dataStore.edit { settings ->
6365
settings[PREFERRED_APPS] = newPreferences

app/src/main/java/nl/tudelft/trustchain/app/TrustChainApplication.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ import androidx.datastore.preferences.core.booleanPreferencesKey
1313
import androidx.datastore.preferences.core.edit
1414
import androidx.datastore.preferences.preferencesDataStore
1515
import androidx.preference.PreferenceManager
16-
import com.example.musicdao.ipv8.MusicCommunity
16+
import nl.tudelft.trustchain.musicdao.core.ipv8.MusicCommunity
17+
import nl.tudelft.trustchain.musicdao.core.dao.DaoCommunity
1718
import com.squareup.sqldelight.android.AndroidSqliteDriver
1819
import com.squareup.sqldelight.db.SqlDriver
20+
import dagger.hilt.android.HiltAndroidApp
21+
import kotlinx.coroutines.DelicateCoroutinesApi
22+
import kotlinx.coroutines.GlobalScope
23+
import kotlinx.coroutines.launch
1924
import kotlinx.coroutines.*
2025
import kotlinx.coroutines.flow.Flow
2126
import kotlinx.coroutines.flow.first
@@ -71,7 +76,9 @@ import nl.tudelft.gossipML.sqldelight.Database as MLDatabase
7176

7277
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")
7378

79+
@OptIn(DelicateCoroutinesApi::class)
7480
@ExperimentalUnsignedTypes
81+
@HiltAndroidApp
7582
class TrustChainApplication : Application() {
7683

7784
var isFirstRun: Boolean = false
@@ -104,6 +111,7 @@ class TrustChainApplication : Application() {
104111
createAtomicSwapCommunity(),
105112
createMarketCommunity(),
106113
createCoinCommunity(),
114+
createDaoCommunity(),
107115
createVotingCommunity(),
108116
createMusicCommunity(),
109117
createLiteratureCommunity(),
@@ -358,6 +366,16 @@ class TrustChainApplication : Application() {
358366
)
359367
}
360368

369+
private fun createDaoCommunity(): OverlayConfiguration<DaoCommunity> {
370+
val randomWalk = RandomWalk.Factory()
371+
val nsd = NetworkServiceDiscovery.Factory(getSystemService()!!)
372+
373+
return OverlayConfiguration(
374+
Overlay.Factory(DaoCommunity::class.java),
375+
listOf(randomWalk, nsd)
376+
)
377+
}
378+
361379
private fun createCoinCommunity(): OverlayConfiguration<CoinCommunity> {
362380
val randomWalk = RandomWalk.Factory()
363381
val nsd = NetworkServiceDiscovery.Factory(getSystemService()!!)
@@ -381,7 +399,8 @@ class TrustChainApplication : Application() {
381399

382400
private fun createMusicCommunity(): OverlayConfiguration<MusicCommunity> {
383401
val settings = TrustChainSettings()
384-
val driver = AndroidSqliteDriver(Database.Schema, this, "music.db")
402+
// TODO: Re-concile this community with Reccomender Community
403+
val driver = AndroidSqliteDriver(Database.Schema, this, "music-private.db")
385404
val store = TrustChainSQLiteStore(Database(driver))
386405
val randomWalk = RandomWalk.Factory()
387406
return OverlayConfiguration(

app/src/main/java/nl/tudelft/trustchain/app/ui/dashboard/DashboardActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class DashboardActivity : AppCompatActivity() {
108108
}
109109
}
110110

111+
@Suppress("DEPRECATION")
111112
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
112113
when (requestCode) {
113114
SETTINGS_INTENT_CODE -> {

app/src/main/res/xml/network_security_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
<domain includeSubdomains="true">131.180.27.224</domain>
88
<!-- IP address of the host machine when ran from the Android emulator -->
99
<!-- <domain includeSubdomains="true">10.0.2.2</domain>-->
10+
11+
<!-- This is for RegTest faucet, to claim some starter money -->
12+
<domain includeSubdomains="true">95.179.182.243</domain>
1013
</domain-config>
1114
</network-security-config>

app/src/test/java/nl/tudelft/trustchain/app/ExampleUnitTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import org.junit.Test
1111
class ExampleUnitTest {
1212
@Test
1313
fun addition_isCorrect() {
14-
assertEquals(4, 2 + 2)
14+
assertEquals(4, (2 + 2))
1515
}
1616
}

atomic-swap/src/main/java/nl/tudelft/trustchain/atomicswap/swap/Trade.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ enum class Currency(val currencyCodeStringResourceId: Int) {
9696

9797
companion object {
9898
fun fromString(coin: String): Currency {
99+
@Suppress("DEPRECATION")
99100
return when (coin.toLowerCase()) {
100101
"btc" -> BTC
101102
"eth" -> ETH

0 commit comments

Comments
 (0)