Skip to content

Commit

Permalink
Approve Activity
Browse files Browse the repository at this point in the history
#12
- activity, layout and fragment to approve absences
  • Loading branch information
eurosecom committed Mar 26, 2017
1 parent 0548593 commit dbb250c
Show file tree
Hide file tree
Showing 11 changed files with 701 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
android:windowSoftInputMode="stateAlwaysHidden" />

<activity android:name=".DatabaseActivity"/>
<activity android:name=".ApproveActivity" android:label="@string/action_approve"/>
<activity android:name=".AbsenceActivity" android:label="@string/absence"/>
<activity android:name=".NewAbsenceActivity" android:label="@string/absence"/>
<activity android:name=".NewPostActivity"/>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/eusecom/attendance/AbsenceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ protected void onCreate(Bundle savedInstanceState) {
new AbsTypesFragment()
};
private final String[] mFragmentNames = new String[] {
"Absences",
"Attendances",
"AbsTypes"
getString(R.string.absences),
getString(R.string.attendances),
getString(R.string.abstypes)
};
@Override
public Fragment getItem(int position) {
Expand Down
164 changes: 164 additions & 0 deletions app/src/main/java/com/eusecom/attendance/ApproveActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.eusecom.attendance;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;

import com.eusecom.attendance.fragment.AbsTypesFragment;
import com.eusecom.attendance.fragment.ContactFragment;
import com.eusecom.attendance.fragment.LiveFragment;
import com.eusecom.attendance.fragment.MyAbsenceFragment;
import com.eusecom.attendance.fragment.MyAttendanceFragment;
import com.google.firebase.auth.FirebaseAuth;


public class ApproveActivity extends BaseDatabaseActivity implements LiveFragment.OnFragmentInteractionListener {

private FragmentPagerAdapter mPagerAdapter;
private ViewPager mViewPager;
private FloatingActionButton fab;
int whatispage=0;
Toolbar mActionBarToolbar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_approve);
//showProgressDialog();

mActionBarToolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(mActionBarToolbar);
getSupportActionBar().setTitle(getString(R.string.action_approve));

// Create the adapter that will return a fragment for each section
mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
private final Fragment[] mFragments = new Fragment[] {
new MyAbsenceFragment(),
new AbsTypesFragment()
};
private final String[] mFragmentNames = new String[] {
getString(R.string.approve),
getString(R.string.abstypes)
};
@Override
public Fragment getItem(int position) {
return mFragments[position];
}
@Override
public int getCount() {
return mFragments.length;
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentNames[position];
}
};
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mPagerAdapter);


mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}

public void onPageSelected(int position) {
// Check if this is the page you want.
if(position == 0){
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_new_post);
fab.setVisibility(View.VISIBLE);
whatispage=0;
}
if(position == 1){
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_new_post);
fab.setVisibility(View.GONE);
whatispage=1;
}

}
});


TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);

// Button launches NewPostActivity
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_new_post);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent i=null;
if( whatispage == 0 ) {
i = new Intent(ApproveActivity.this, NewAbsenceActivity.class);
}
Bundle extras = new Bundle();
extras.putString("editx", "0");
extras.putString("keyx", "0");

i.putExtras(extras);
startActivity(i);

}
});
//hideProgressDialog();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_database, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_logout:
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(this, EmailPasswordActivity.class));
finish();
return true;

case R.id.action_settings:
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(this, SettingsActivity.class));
finish();
return true;

default:
return super.onOptionsItemSelected(item);
}
}

@Override
public void onFragmentInteraction (Uri uri){
//only for LiveFragment
}

}
7 changes: 7 additions & 0 deletions app/src/main/java/com/eusecom/attendance/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
}

if (id == R.id.approve) {

Intent is = new Intent(getApplicationContext(), ApproveActivity.class);
startActivity(is);
return true;
}



return super.onOptionsItemSelected(item);
Expand Down
Loading

0 comments on commit dbb250c

Please sign in to comment.