Compare commits

...

12 Commits

Author SHA1 Message Date
67f8e89598 renamed gallery to settings 2022-01-16 17:50:54 +01:00
987116e877 update room version 2022-01-16 17:41:05 +01:00
7fa3f21e30 Added queries for Chats 2022-01-16 17:32:34 +01:00
9d665cf4e9 Can now display a executed query 2022-01-11 20:01:24 +01:00
1269f1552f Corrected file locations 2022-01-11 19:26:55 +01:00
71c1611e3e Apollo client is now accesible 2022-01-11 18:25:00 +01:00
6d99fab472 Fix app crash due to internet permission not requested 2022-01-11 18:22:53 +01:00
8cfe6e97fa more graphql queries 2022-01-04 02:34:29 +01:00
67f2a6b9c5 added schema from noise.sfs 2021-12-20 16:46:02 +01:00
845c969c46 apollo upgrade to version 3 2021-12-20 08:44:27 +01:00
1885ba5477 All correct dependencies now added 2021-12-13 15:00:46 +01:00
ee32ac2093 Update 2021-10-16 22:48:44 +02:00
23 changed files with 321 additions and 121 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -1,22 +1,17 @@
plugins { plugins {
id 'com.android.application' id 'com.android.application'
id 'kotlin-android' id 'kotlin-android'
id ("com.apollographql.apollo").version("$apollo_version") id("com.apollographql.apollo3").version("3.0.0")
} }
apollo {
// instruct the compiler to generate Kotlin models
generateKotlinModels.set(true)
}
android { android {
compileSdkVersion 30 compileSdk 31
buildToolsVersion "30.0.3"
defaultConfig { defaultConfig {
applicationId "org.dnss.sfs.git.wdg.noise" applicationId "org.ddnss.sfs.git.wdg.test"
minSdkVersion 21 minSdk 24
targetSdkVersion 30 targetSdk 31
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
@ -41,23 +36,53 @@ android {
} }
} }
apollo {
packageName.set("org.ddnss.sfs.git.wdg.noise")
}
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.core:core-ktx:1.6.0' implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0' implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
// The core runtime dependencies
implementation("com.apollographql.apollo:apollo-runtime:$apollo_version")
// Coroutines extensions for easier asynchronicity handling
implementation("com.apollographql.apollo:apollo-coroutines-support:$apollo_version")
testImplementation 'junit:junit:4.+' testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
} }
dependencies {
def room_version = "2.4.1"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
// optional - RxJava2 support for Room
implementation "androidx.room:room-rxjava2:$room_version"
// optional - RxJava3 support for Room
implementation "androidx.room:room-rxjava3:$room_version"
// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:$room_version"
// optional - Test helpers
testImplementation "androidx.room:room-testing:$room_version"
// optional - Paging 3 Integration
implementation "androidx.room:room-paging:$room_version"
}
dependencies {
// ...
implementation("com.apollographql.apollo3:apollo-runtime:3.0.0")
}

View File

@ -1,4 +1,4 @@
package org.dnss.sfs.git.wdg.noise package org.ddnss.sfs.git.wdg.noise
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.dnss.sfs.git.wdg.noise"> package="org.ddnss.sfs.git.wdg.noise">
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -10,9 +10,10 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Noise"> android:theme="@style/Theme.Noise">
<activity <activity
android:name=".MainActivity" android:name="org.ddnss.sfs.git.wdg.noise.MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/Theme.Noise.NoActionBar"> android:theme="@style/Theme.Noise.NoActionBar"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -21,4 +22,7 @@
</activity> </activity>
</application> </application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest> </manifest>

View File

@ -0,0 +1,6 @@
query GetChats($id: ID!, $pw: String!){
chats(user: $id, passwordHash: $pw){
id
users
}
}

View File

@ -0,0 +1,8 @@
query GetGroupChats($id: ID!, $pw: String!){
groupChats(user: $id, passwordHash: $pw){
id
users
title
description
}
}

View File

@ -0,0 +1,3 @@
#query GetMessages{
#}

View File

@ -0,0 +1,10 @@
query GetUsers {
users {
id
userName
displayName
activated
created
lastOnline
}
}

View File

@ -0,0 +1,166 @@
type Message {
id: ID!
timestamp: String!
sender: ID!
msgType: MsgType!
content: String
hideFor: [ID!]
seenBy: [ID!]!
}
type ExternalServersPreferences {
privacyPreferences: PrivacyPreferences!
externalServers: RestrictionPolicy!
externalServersLimit: [Url!]!
}
type Mutation {
newUser(newUser: NewUser!): ID!
newChat(user: ID!, passwordHash: String!, with: ID!): ID!
newGroupChat(user: ID!, passwordHash: String!, title: String!, description: String, with: [ID!]!): ID!
sendMessage(user: ID!, passwordHash: String!, chat: ID!, msg: MessageInput!): ID!
}
enum RestrictionPolicy {
EVERYONE
EXCLUDING
INCLUDING
NONE
}
type NotificationPreferences {
lockDetails: Boolean!
doNotDisturb: Boolean!
}
"""
DateTime
"""
scalar DateTimeUtc
"""
Url
"""
scalar Url
type Query {
getUserID(username: String!): ID!
isUsernameUsed(username: String!): Boolean!
users: [User!]!
userPreferences(id: ID!, passwordHash: String!): UserPreferences!
chats(user: ID!, passwordHash: String!): [Chat!]!
groupChats(user: ID!, passwordHash: String!): [GroupChat!]!
getMessages(user: ID!, passwordHash: String!, chat: ID!, lastMsg: ID, limit: Int): [Message!]!
}
type SecurityPreferences {
accountTokens: [ID!]!
passwordHash: String!
}
type PrivacyPreferences {
discovery: RestrictionPolicy!
discoveryUserLimit: [String!]!
discoveryServerLimit: [Url!]!
lastSeen: RestrictionPolicy!
lastSeenUserLimit: [String!]!
lastSeenServerLimit: [Url!]!
lastSeenCourse: Boolean!
info: RestrictionPolicy!
infoUserLimit: [String!]!
infoServerLimit: [Url!]!
}
type UserPreferences {
privacyPreferences: PrivacyPreferences!
notificationPreferences: NotificationPreferences!
securityPreferences: SecurityPreferences!
externalServersPreferences: ExternalServersPreferences!
}
input NewUser {
userName: String!
displayName: String
passwordHash: String!
}
input MessageInput {
msgType: MsgType!
content: String
}
type User {
id: ID!
userName: String!
displayName: String
activated: Boolean!
created: DateTimeUtc!
lastOnline: DateTimeUtc
}
enum MsgType {
TEXT
}
type Chat {
id: ID!
users: [ID!]!
}
type GroupChat {
id: ID!
title: String!
description: String
users: [ID!]!
}
schema {
query: Query
mutation: Mutation
}

View File

@ -0,0 +1,6 @@
package org.ddnss.sfs.git.wdg.noise
import com.apollographql.apollo3.ApolloClient
val apolloClient = ApolloClient.Builder()
.serverUrl("https://noise.sfs.ddnss.org/graphql")
.build()

View File

@ -1,10 +1,8 @@
package org.dnss.sfs.git.wdg.noise package org.ddnss.sfs.git.wdg.noise
import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.widget.Button import android.widget.TextView
import android.widget.LinearLayout
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import com.google.android.material.navigation.NavigationView import com.google.android.material.navigation.NavigationView
import androidx.navigation.findNavController import androidx.navigation.findNavController
@ -14,7 +12,8 @@ import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController import androidx.navigation.ui.setupWithNavController
import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import org.dnss.sfs.git.wdg.noise.databinding.ActivityMainBinding import androidx.lifecycle.lifecycleScope
import org.ddnss.sfs.git.wdg.noise.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
@ -45,11 +44,18 @@ class MainActivity : AppCompatActivity() {
) )
setupActionBarWithNavController(navController, appBarConfiguration) setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController) navView.setupWithNavController(navController)
getData()
}
addButton( "a", 0xff0000) fun getData(){
addButton( "b", 0xff0000) val text: TextView = findViewById<TextView>(R.id.testData)
addButton( "c", 0xff0000)
addButton( "d", 0xff0000) lifecycleScope.launchWhenResumed {
val response = apolloClient.query(GetGroupChatsQuery("7bea8833b6d64a37ae0949619e06b692", "1234567890")).execute()
//Log.d("LaunchList", "Success ${response.data}")
text.text = response.data.toString()
}
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
@ -63,19 +69,4 @@ class MainActivity : AppCompatActivity() {
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp() return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
} }
fun addButton(userName: String, color: Int) {
val contactScrollField = findViewById<LinearLayout>(R.id.linear_layout)
// = findViewById(R.id.linear_layout) as LinearLayout
val dynamicButton = Button(this)
/*dynamicButton.layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)*/
dynamicButton.text = userName
dynamicButton.setBackgroundColor(Color.GREEN)
contactScrollField.addView(dynamicButton)
}
} }

View File

@ -1,4 +1,4 @@
package org.dnss.sfs.git.wdg.noise.ui.gallery package org.ddnss.sfs.git.wdg.noise.ui.gallery
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -6,20 +6,23 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import org.dnss.sfs.git.wdg.noise.R import androidx.lifecycle.lifecycleScope
import org.dnss.sfs.git.wdg.noise.databinding.FragmentGalleryBinding import org.ddnss.sfs.git.wdg.noise.GetUsersQuery
import org.ddnss.sfs.git.wdg.noise.apolloClient
import org.ddnss.sfs.git.wdg.noise.databinding.FragmentSettingsBinding
class GalleryFragment : Fragment() { class GalleryFragment : Fragment() {
private lateinit var galleryViewModel: GalleryViewModel private lateinit var galleryViewModel: GalleryViewModel
private var _binding: FragmentGalleryBinding? = null private var _binding: FragmentSettingsBinding? = null
// This property is only valid between onCreateView and // This property is only valid between onCreateView and
// onDestroyView. // onDestroyView.
private val binding get() = _binding!! private val binding get() = _binding!!
//var text: TextView = findViewById(R.id.testData) as TextView
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
@ -28,16 +31,18 @@ class GalleryFragment : Fragment() {
galleryViewModel = galleryViewModel =
ViewModelProvider(this).get(GalleryViewModel::class.java) ViewModelProvider(this).get(GalleryViewModel::class.java)
_binding = FragmentGalleryBinding.inflate(inflater, container, false) _binding = FragmentSettingsBinding.inflate(inflater, container, false)
val root: View = binding.root val root: View = binding.root
val textView: TextView = binding.textGallery
galleryViewModel.text.observe(viewLifecycleOwner, Observer {
textView.text = it
})
return root return root
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
_binding = null _binding = null

View File

@ -0,0 +1,10 @@
package org.ddnss.sfs.git.wdg.noise.ui.gallery
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
class GalleryViewModel : ViewModel() {
}

View File

@ -1,15 +1,12 @@
package org.dnss.sfs.git.wdg.noise.ui.home package org.ddnss.sfs.git.wdg.noise.ui.home
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import org.dnss.sfs.git.wdg.noise.R import org.ddnss.sfs.git.wdg.noise.databinding.FragmentHomeBinding
import org.dnss.sfs.git.wdg.noise.databinding.FragmentHomeBinding
class HomeFragment : Fragment() { class HomeFragment : Fragment() {

View File

@ -1,4 +1,4 @@
package org.dnss.sfs.git.wdg.noise.ui.home package org.ddnss.sfs.git.wdg.noise.ui.home
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData

View File

@ -1,13 +0,0 @@
package org.dnss.sfs.git.wdg.noise.ui.gallery
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
class GalleryViewModel : ViewModel() {
private val _text = MutableLiveData<String>().apply {
value = "This is gallery Fragment"
}
val text: LiveData<String> = _text
}

View File

@ -17,20 +17,4 @@
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation" /> app:navGraph="@navigation/mobile_navigation" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="206dp"
tools:layout_editor_absoluteY="241dp">
<LinearLayout
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.gallery.GalleryFragment">
<TextView
android:id="@+id/text_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -6,4 +6,12 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.home.HomeFragment"> tools:context=".ui.home.HomeFragment">
<TextView
android:id="@+id/testData"
android:layout_width="406dp"
android:layout_height="715dp"
android:text="TestData"
tools:layout_editor_absoluteX="2dp"
tools:layout_editor_absoluteY="3dp" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.gallery.GalleryFragment">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -7,13 +7,13 @@
<fragment <fragment
android:id="@+id/nav_home" android:id="@+id/nav_home"
android:name="org.dnss.sfs.git.wdg.noise.ui.home.HomeFragment" android:name="org.ddnss.sfs.git.wdg.noise.ui.home.HomeFragment"
android:label="@string/menu_chat" android:label="@string/menu_chat"
tools:layout="@layout/fragment_home" /> tools:layout="@layout/fragment_home" />
<fragment <fragment
android:id="@+id/nav_gallery" android:id="@+id/nav_gallery"
android:name="org.dnss.sfs.git.wdg.noise.ui.gallery.GalleryFragment" android:name="org.ddnss.sfs.git.wdg.noise.ui.gallery.GalleryFragment"
android:label="@string/menu_settings" android:label="@string/menu_settings"
tools:layout="@layout/fragment_gallery" /> tools:layout="@layout/fragment_settings" />
</navigation> </navigation>

View File

@ -1,4 +1,4 @@
package org.dnss.sfs.git.wdg.noise package org.ddnss.sfs.git.wdg.noise
import org.junit.Test import org.junit.Test

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext { ext {
apollo_version = '2.5.9' apollo_version = '2.5.11'
} }
ext.kotlin_version = "1.5.20" ext.kotlin_version = "1.5.20"
repositories { repositories {
@ -9,7 +9,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.0.2' classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong