Skip to content

Commit

Permalink
initial commit for native android fixes issue #83
Browse files Browse the repository at this point in the history
Signed-off-by: Rishabh Khanna <rishabhkhanna777@gmail.com>
  • Loading branch information
Rishabhk07 authored and niranjan94 committed May 11, 2017
1 parent a435ec0 commit 9ce92e1
Show file tree
Hide file tree
Showing 58 changed files with 3,426 additions and 8 deletions.
18 changes: 10 additions & 8 deletions .gitignore
Expand Up @@ -12,20 +12,22 @@ log.txt
.vscode/
npm-debug.log*

.idea/
.sass-cache/
.tmp/
.versions/
coverage/
dist/
node_modules/
tmp/
temp/
hooks/
platforms/
plugins/
$RECYCLE.BIN/
.DS_Store
Thumbs.db
UserInterfaceState.xcuserstate
/.io-config.json

*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild

1 change: 1 addition & 0 deletions app/.gitignore
@@ -0,0 +1 @@
/build
47 changes: 47 additions & 0 deletions app/build.gradle
@@ -0,0 +1,47 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "org.fossasia.fossasiaorgaandroidapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

repositories {
maven {
url "https://jitpack.io"
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-compat:25.3.1'
compile group: 'com.google.code.gson', name: 'gson', version: '2.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-vision:10.0.1'
compile 'com.github.tajchert:nammu:1.1.3'


}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/rishabhkhanna/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
@@ -0,0 +1,26 @@
package org.fossasia.fossasiaorgaandroidapp;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("org.fossasia.fossasiaorgaandroidapp", appContext.getPackageName());
}
}
26 changes: 26 additions & 0 deletions app/src/main/AndroidManifest.xml
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fossasia.fossasiaorgaandroidapp">

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Views.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Views.EventsActivity" />
<activity android:name=".Views.EventDetailsActivity" />
<activity android:name=".Views.AttendeeListActivity" />
<activity android:name=".Views.ScanQRActivity"></activity>
</application>

</manifest>
@@ -0,0 +1,142 @@
package org.fossasia.fossasiaorgaandroidapp.Adapters;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.android.volley.VolleyError;
import com.google.gson.Gson;
import com.google.gson.internal.bind.ArrayTypeAdapter;

import org.fossasia.fossasiaorgaandroidapp.Api.ApiCall;
import org.fossasia.fossasiaorgaandroidapp.Api.LoginCall;
import org.fossasia.fossasiaorgaandroidapp.Interfaces.VolleyCallBack;
import org.fossasia.fossasiaorgaandroidapp.R;
import org.fossasia.fossasiaorgaandroidapp.Utils.Constants;
import org.fossasia.fossasiaorgaandroidapp.model.AttendeeDetails;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Created by rishabhkhanna on 27/04/17.
*/

public class AttendeeListAdapter extends RecyclerView.Adapter<AttendeeListAdapter.AttendeeListAdapterHolder> {
ArrayList<AttendeeDetails> attendeeDetailses;
Activity activity;
long id;
public static final String TAG = "AttendeeAdapter";

public AttendeeListAdapter(ArrayList<AttendeeDetails> attendeeDetailses, Activity activity, long id) {
this.attendeeDetailses = attendeeDetailses;
this.activity = activity;
this.id = id;
}

@Override
public AttendeeListAdapterHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater li = activity.getLayoutInflater();
View itemView = li.inflate(R.layout.attendee_layout,null);

AttendeeListAdapterHolder attendeeListAdapterHolder = new AttendeeListAdapterHolder(itemView);
return attendeeListAdapterHolder;
}

@Override
public void onBindViewHolder(final AttendeeListAdapterHolder holder, final int position) {
final AttendeeDetails thisAttendee = attendeeDetailses.get(position);
holder.tvLastName.setText(thisAttendee.getLastname());
holder.tvFirstName.setText(thisAttendee.getFirstname());
holder.tvEmail.setText(thisAttendee.getEmail());
if(thisAttendee.getCheckedIn()) {
holder.btnCheckedIn.setText("Checked In");
holder.btnCheckedIn.setBackgroundColor(ContextCompat.getColor(activity,android.R.color.holo_green_dark));
}else{
holder.btnCheckedIn.setText("Check In");
holder.btnCheckedIn.setBackgroundColor(ContextCompat.getColor(activity,android.R.color.holo_red_light));
}
holder.btnCheckedIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "onClick: alert builder click");
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
String alertTitle = "";
if(thisAttendee.getCheckedIn()){
alertTitle = Constants.AttendeeCheckingOut;
}else{
alertTitle = Constants.attendeeChechingIn;
}
builder.setTitle(alertTitle).setMessage(thisAttendee.getFirstname() + " "
+ thisAttendee.getLastname() + "\n"
+ "Ticket: " + thisAttendee.getTicket().getType() )
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.d(TAG, "onClick: inside ok");
changeCheckStatus(activity,thisAttendee,holder.btnCheckedIn,attendeeDetailses,position);
}
}).setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

}
});
builder.create();
builder.show();
}
});

}

@Override
public int getItemCount() {
return attendeeDetailses.size();
}

public class AttendeeListAdapterHolder extends RecyclerView.ViewHolder{

TextView tvLastName;
TextView tvFirstName;
TextView tvEmail;
Button btnCheckedIn;

public AttendeeListAdapterHolder(View itemView) {
super(itemView);
tvLastName = (TextView) itemView.findViewById(R.id.tvLastName);
tvFirstName = (TextView) itemView.findViewById(R.id.tvFirstName);
tvEmail = (TextView) itemView.findViewById(R.id.tvEmail);
btnCheckedIn = (Button) itemView.findViewById(R.id.btnCheckedin);
}
}

public void changeCheckStatus(Activity activity, AttendeeDetails thisAttendee, final Button btnCheckedIn, final ArrayList<AttendeeDetails> attendeeDetailses, final int position){
ApiCall.PostApiCall(activity, Constants.eventDetails +id + Constants.attendeesToggle + thisAttendee.getId(), new VolleyCallBack() {
@Override
public void onSuccess(String result) {
Log.d(TAG, "onSuccess: " + result);
Gson gson = new Gson();
AttendeeDetails newattendeeDetailses = gson.fromJson(result,AttendeeDetails.class);
attendeeDetailses.set(position , newattendeeDetailses);
notifyDataSetChanged();
}

@Override
public void onError(VolleyError error) {

}
});
}

}
@@ -0,0 +1,93 @@
package org.fossasia.fossasiaorgaandroidapp.Adapters;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import org.fossasia.fossasiaorgaandroidapp.R;
import org.fossasia.fossasiaorgaandroidapp.Views.EventDetailsActivity;
import org.fossasia.fossasiaorgaandroidapp.model.UserEvents;

import java.util.ArrayList;
import java.util.EventListener;

/**
* Created by rishabhkhanna on 26/04/17.
*/

public class EventListAdapter extends RecyclerView.Adapter<EventListAdapter.EventRecyclerViewHolder>{

static ArrayList<UserEvents> eventsArrayList = new ArrayList<>();
Activity activity;

public EventListAdapter(ArrayList<UserEvents> eventsArrayList ,Activity context) {
this.eventsArrayList = eventsArrayList;
this.activity = context;
}

@Override
public EventRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

LayoutInflater li = activity.getLayoutInflater();
View itemView = li.inflate(R.layout.event_layout,null);

itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

}
});

EventRecyclerViewHolder eventRecyclerViewHolder = new EventRecyclerViewHolder(itemView);
return eventRecyclerViewHolder;
}



@Override
public void onBindViewHolder(EventRecyclerViewHolder holder, final int position) {

final UserEvents thisEvent = eventsArrayList.get(position);
holder.eventTitle.setText(thisEvent.getName());
Picasso.with(activity).load(thisEvent.getThumbnail()).into(holder.eventImage);

holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(activity , EventDetailsActivity.class);
i.putExtra("position",position);
i.putExtra("id",thisEvent.getId());
activity.startActivity(i);
}
});


}

@Override
public int getItemCount() {
return eventsArrayList.size();
}


//view holder class
public class EventRecyclerViewHolder extends RecyclerView.ViewHolder{
TextView eventTitle;
ImageView eventImage;

public EventRecyclerViewHolder(View itemView) {
super(itemView);
eventTitle = (TextView) itemView.findViewById(R.id.tvEventTitle);
eventImage = (ImageView) itemView.findViewById(R.id.ivEventProfile);
}

}

}

0 comments on commit 9ce92e1

Please sign in to comment.