Skip to content

Commit 9ce92e1

Browse files
Rishabhk07niranjan94
authored andcommitted
initial commit for native android fixes issue #83
Signed-off-by: Rishabh Khanna <[email protected]>
1 parent a435ec0 commit 9ce92e1

Some content is hidden

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

58 files changed

+3426
-8
lines changed

.gitignore

+10-8
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ log.txt
1212
.vscode/
1313
npm-debug.log*
1414

15-
.idea/
1615
.sass-cache/
1716
.tmp/
1817
.versions/
1918
coverage/
20-
dist/
21-
node_modules/
22-
tmp/
23-
temp/
24-
hooks/
25-
platforms/
26-
plugins/
2719
$RECYCLE.BIN/
2820
.DS_Store
2921
Thumbs.db
3022
UserInterfaceState.xcuserstate
3123
/.io-config.json
24+
25+
*.iml
26+
.gradle
27+
/local.properties
28+
/.idea
29+
.DS_Store
30+
/build
31+
/captures
32+
.externalNativeBuild
33+

app/.gitignore

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

app/build.gradle

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.2"
6+
defaultConfig {
7+
applicationId "org.fossasia.fossasiaorgaandroidapp"
8+
minSdkVersion 16
9+
targetSdkVersion 25
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
repositories {
23+
maven {
24+
url "https://jitpack.io"
25+
}
26+
}
27+
28+
29+
dependencies {
30+
compile fileTree(dir: 'libs', include: ['*.jar'])
31+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
32+
exclude group: 'com.android.support', module: 'support-annotations'
33+
})
34+
compile 'com.android.support:appcompat-v7:25.3.1'
35+
testCompile 'junit:junit:4.12'
36+
compile 'com.android.support:support-compat:25.3.1'
37+
compile group: 'com.google.code.gson', name: 'gson', version: '2.3.1'
38+
compile 'com.android.support:design:25.3.1'
39+
compile 'com.android.volley:volley:1.0.0'
40+
compile 'com.squareup.picasso:picasso:2.5.2'
41+
compile 'de.hdodenhof:circleimageview:2.1.0'
42+
compile 'com.google.android.gms:play-services:10.0.1'
43+
compile 'com.google.android.gms:play-services-vision:10.0.1'
44+
compile 'com.github.tajchert:nammu:1.1.3'
45+
46+
47+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/rishabhkhanna/Library/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.fossasia.fossasiaorgaandroidapp;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation 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() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("org.fossasia.fossasiaorgaandroidapp", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.fossasia.fossasiaorgaandroidapp">
4+
5+
<uses-permission android:name="android.permission.CAMERA" />
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
8+
<application
9+
android:allowBackup="true"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity android:name=".Views.LoginActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
<activity android:name=".Views.EventsActivity" />
21+
<activity android:name=".Views.EventDetailsActivity" />
22+
<activity android:name=".Views.AttendeeListActivity" />
23+
<activity android:name=".Views.ScanQRActivity"></activity>
24+
</application>
25+
26+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
package org.fossasia.fossasiaorgaandroidapp.Adapters;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.content.DialogInterface;
6+
import android.graphics.Color;
7+
import android.support.v4.content.ContextCompat;
8+
import android.support.v7.app.AlertDialog;
9+
import android.support.v7.widget.RecyclerView;
10+
import android.util.Log;
11+
import android.view.LayoutInflater;
12+
import android.view.View;
13+
import android.view.ViewGroup;
14+
import android.widget.Button;
15+
import android.widget.TextView;
16+
17+
import com.android.volley.VolleyError;
18+
import com.google.gson.Gson;
19+
import com.google.gson.internal.bind.ArrayTypeAdapter;
20+
21+
import org.fossasia.fossasiaorgaandroidapp.Api.ApiCall;
22+
import org.fossasia.fossasiaorgaandroidapp.Api.LoginCall;
23+
import org.fossasia.fossasiaorgaandroidapp.Interfaces.VolleyCallBack;
24+
import org.fossasia.fossasiaorgaandroidapp.R;
25+
import org.fossasia.fossasiaorgaandroidapp.Utils.Constants;
26+
import org.fossasia.fossasiaorgaandroidapp.model.AttendeeDetails;
27+
28+
import java.util.ArrayList;
29+
import java.util.Arrays;
30+
import java.util.List;
31+
32+
/**
33+
* Created by rishabhkhanna on 27/04/17.
34+
*/
35+
36+
public class AttendeeListAdapter extends RecyclerView.Adapter<AttendeeListAdapter.AttendeeListAdapterHolder> {
37+
ArrayList<AttendeeDetails> attendeeDetailses;
38+
Activity activity;
39+
long id;
40+
public static final String TAG = "AttendeeAdapter";
41+
42+
public AttendeeListAdapter(ArrayList<AttendeeDetails> attendeeDetailses, Activity activity, long id) {
43+
this.attendeeDetailses = attendeeDetailses;
44+
this.activity = activity;
45+
this.id = id;
46+
}
47+
48+
@Override
49+
public AttendeeListAdapterHolder onCreateViewHolder(ViewGroup parent, int viewType) {
50+
LayoutInflater li = activity.getLayoutInflater();
51+
View itemView = li.inflate(R.layout.attendee_layout,null);
52+
53+
AttendeeListAdapterHolder attendeeListAdapterHolder = new AttendeeListAdapterHolder(itemView);
54+
return attendeeListAdapterHolder;
55+
}
56+
57+
@Override
58+
public void onBindViewHolder(final AttendeeListAdapterHolder holder, final int position) {
59+
final AttendeeDetails thisAttendee = attendeeDetailses.get(position);
60+
holder.tvLastName.setText(thisAttendee.getLastname());
61+
holder.tvFirstName.setText(thisAttendee.getFirstname());
62+
holder.tvEmail.setText(thisAttendee.getEmail());
63+
if(thisAttendee.getCheckedIn()) {
64+
holder.btnCheckedIn.setText("Checked In");
65+
holder.btnCheckedIn.setBackgroundColor(ContextCompat.getColor(activity,android.R.color.holo_green_dark));
66+
}else{
67+
holder.btnCheckedIn.setText("Check In");
68+
holder.btnCheckedIn.setBackgroundColor(ContextCompat.getColor(activity,android.R.color.holo_red_light));
69+
}
70+
holder.btnCheckedIn.setOnClickListener(new View.OnClickListener() {
71+
@Override
72+
public void onClick(View v) {
73+
Log.d(TAG, "onClick: alert builder click");
74+
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
75+
String alertTitle = "";
76+
if(thisAttendee.getCheckedIn()){
77+
alertTitle = Constants.AttendeeCheckingOut;
78+
}else{
79+
alertTitle = Constants.attendeeChechingIn;
80+
}
81+
builder.setTitle(alertTitle).setMessage(thisAttendee.getFirstname() + " "
82+
+ thisAttendee.getLastname() + "\n"
83+
+ "Ticket: " + thisAttendee.getTicket().getType() )
84+
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
85+
@Override
86+
public void onClick(DialogInterface dialog, int which) {
87+
Log.d(TAG, "onClick: inside ok");
88+
changeCheckStatus(activity,thisAttendee,holder.btnCheckedIn,attendeeDetailses,position);
89+
}
90+
}).setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
91+
@Override
92+
public void onClick(DialogInterface dialog, int which) {
93+
94+
}
95+
});
96+
builder.create();
97+
builder.show();
98+
}
99+
});
100+
101+
}
102+
103+
@Override
104+
public int getItemCount() {
105+
return attendeeDetailses.size();
106+
}
107+
108+
public class AttendeeListAdapterHolder extends RecyclerView.ViewHolder{
109+
110+
TextView tvLastName;
111+
TextView tvFirstName;
112+
TextView tvEmail;
113+
Button btnCheckedIn;
114+
115+
public AttendeeListAdapterHolder(View itemView) {
116+
super(itemView);
117+
tvLastName = (TextView) itemView.findViewById(R.id.tvLastName);
118+
tvFirstName = (TextView) itemView.findViewById(R.id.tvFirstName);
119+
tvEmail = (TextView) itemView.findViewById(R.id.tvEmail);
120+
btnCheckedIn = (Button) itemView.findViewById(R.id.btnCheckedin);
121+
}
122+
}
123+
124+
public void changeCheckStatus(Activity activity, AttendeeDetails thisAttendee, final Button btnCheckedIn, final ArrayList<AttendeeDetails> attendeeDetailses, final int position){
125+
ApiCall.PostApiCall(activity, Constants.eventDetails +id + Constants.attendeesToggle + thisAttendee.getId(), new VolleyCallBack() {
126+
@Override
127+
public void onSuccess(String result) {
128+
Log.d(TAG, "onSuccess: " + result);
129+
Gson gson = new Gson();
130+
AttendeeDetails newattendeeDetailses = gson.fromJson(result,AttendeeDetails.class);
131+
attendeeDetailses.set(position , newattendeeDetailses);
132+
notifyDataSetChanged();
133+
}
134+
135+
@Override
136+
public void onError(VolleyError error) {
137+
138+
}
139+
});
140+
}
141+
142+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package org.fossasia.fossasiaorgaandroidapp.Adapters;
2+
3+
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.support.v7.widget.RecyclerView;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.ImageView;
10+
import android.widget.TextView;
11+
12+
import com.squareup.picasso.Picasso;
13+
14+
import org.fossasia.fossasiaorgaandroidapp.R;
15+
import org.fossasia.fossasiaorgaandroidapp.Views.EventDetailsActivity;
16+
import org.fossasia.fossasiaorgaandroidapp.model.UserEvents;
17+
18+
import java.util.ArrayList;
19+
import java.util.EventListener;
20+
21+
/**
22+
* Created by rishabhkhanna on 26/04/17.
23+
*/
24+
25+
public class EventListAdapter extends RecyclerView.Adapter<EventListAdapter.EventRecyclerViewHolder>{
26+
27+
static ArrayList<UserEvents> eventsArrayList = new ArrayList<>();
28+
Activity activity;
29+
30+
public EventListAdapter(ArrayList<UserEvents> eventsArrayList ,Activity context) {
31+
this.eventsArrayList = eventsArrayList;
32+
this.activity = context;
33+
}
34+
35+
@Override
36+
public EventRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
37+
38+
LayoutInflater li = activity.getLayoutInflater();
39+
View itemView = li.inflate(R.layout.event_layout,null);
40+
41+
itemView.setOnClickListener(new View.OnClickListener() {
42+
@Override
43+
public void onClick(View v) {
44+
45+
}
46+
});
47+
48+
EventRecyclerViewHolder eventRecyclerViewHolder = new EventRecyclerViewHolder(itemView);
49+
return eventRecyclerViewHolder;
50+
}
51+
52+
53+
54+
@Override
55+
public void onBindViewHolder(EventRecyclerViewHolder holder, final int position) {
56+
57+
final UserEvents thisEvent = eventsArrayList.get(position);
58+
holder.eventTitle.setText(thisEvent.getName());
59+
Picasso.with(activity).load(thisEvent.getThumbnail()).into(holder.eventImage);
60+
61+
holder.itemView.setOnClickListener(new View.OnClickListener() {
62+
@Override
63+
public void onClick(View v) {
64+
Intent i = new Intent(activity , EventDetailsActivity.class);
65+
i.putExtra("position",position);
66+
i.putExtra("id",thisEvent.getId());
67+
activity.startActivity(i);
68+
}
69+
});
70+
71+
72+
}
73+
74+
@Override
75+
public int getItemCount() {
76+
return eventsArrayList.size();
77+
}
78+
79+
80+
//view holder class
81+
public class EventRecyclerViewHolder extends RecyclerView.ViewHolder{
82+
TextView eventTitle;
83+
ImageView eventImage;
84+
85+
public EventRecyclerViewHolder(View itemView) {
86+
super(itemView);
87+
eventTitle = (TextView) itemView.findViewById(R.id.tvEventTitle);
88+
eventImage = (ImageView) itemView.findViewById(R.id.ivEventProfile);
89+
}
90+
91+
}
92+
93+
}

0 commit comments

Comments
 (0)