Skip to content

Commit c4c62a7

Browse files
committed
Initial commit
0 parents  commit c4c62a7

Some content is hidden

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

42 files changed

+1279
-0
lines changed

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild

.idea/codeStyles/Project.xml

+116
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 28
5+
defaultConfig {
6+
applicationId "com.thegavners.parseservermessanger"
7+
minSdkVersion 19
8+
targetSdkVersion 28
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'androidx.appcompat:appcompat:1.0.0'
24+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
25+
testImplementation 'junit:junit:4.12'
26+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
27+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
28+
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.20.0"
29+
30+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.thegavners.parseservermessanger;
2+
3+
import android.content.Context;
4+
import androidx.test.platform.app.InstrumentationRegistry;
5+
import androidx.test.ext.junit.runners.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.thegavners.parseservermessanger", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.thegavners.parseservermessanger">
4+
5+
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
8+
9+
<application
10+
android:allowBackup="true"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/AppTheme">
16+
<activity android:name=".DirectChat"></activity>
17+
<activity android:name=".Chats" />
18+
<activity android:name=".Sign" />
19+
</application>
20+
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.thegavners.parseservermessanger;
2+
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
import androidx.appcompat.app.AppCompatActivity;
6+
import android.view.View;
7+
import android.widget.AdapterView;
8+
import android.widget.ArrayAdapter;
9+
import android.widget.ListView;
10+
11+
import com.parse.FindCallback;
12+
import com.parse.ParseException;
13+
import com.parse.ParseQuery;
14+
import com.parse.ParseUser;
15+
16+
import java.util.ArrayList;
17+
import java.util.List;
18+
19+
// Copyright Carlos Mbendera
20+
21+
public class Chats extends AppCompatActivity {
22+
23+
private final ArrayList<String> users = new ArrayList<>();
24+
private ArrayAdapter arrayAdapter;
25+
26+
27+
@Override
28+
protected void onCreate(Bundle savedInstanceState) {
29+
super.onCreate(savedInstanceState);
30+
setContentView(R.layout.activity_chats);
31+
32+
setTitle("Chats");
33+
34+
ListView userListView = findViewById(R.id.chatsListView);
35+
userListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
36+
@Override
37+
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
38+
39+
Intent intent = new Intent(getApplicationContext(), DirectChat.class);
40+
intent.putExtra("username", users.get(position));
41+
startActivity(intent);
42+
}
43+
});
44+
45+
users.clear();
46+
47+
arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1,users);
48+
userListView.setAdapter(arrayAdapter);
49+
50+
ParseQuery<ParseUser> userQuery = ParseUser.getQuery();
51+
userQuery.whereNotEqualTo("username", ParseUser.getCurrentUser().getUsername());
52+
53+
userQuery.findInBackground(new FindCallback<ParseUser>() {
54+
@Override
55+
public void done(List<ParseUser> objects, ParseException e) {
56+
57+
if (e== null){
58+
if(objects.size() > 0){
59+
for (ParseUser user : objects){
60+
61+
users.add(user.getUsername());
62+
63+
}
64+
arrayAdapter.notifyDataSetChanged();
65+
}
66+
}
67+
}
68+
});
69+
70+
71+
72+
73+
}
74+
}

0 commit comments

Comments
 (0)