Skip to content

Commit

Permalink
Main Activity Attendance
Browse files Browse the repository at this point in the history
#2
- users and companys image

TODO
- set users and companys image
  • Loading branch information
eurosecom committed Jul 28, 2017
1 parent 31a7b36 commit 34201df
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Expand Down
115 changes: 109 additions & 6 deletions app/src/main/java/com/eusecom/attendance/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -49,6 +51,8 @@
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -84,7 +88,7 @@ public class MainActivity extends ActionBarActivity {
private static final String TAG = "MainActivity";
private TextView mStatusTextView, usicoTextView, mText3;
FirebaseUser user;
private ImageView mCompanyImage;
private ImageView mCompanyImage, mUserImage, mIntoworkImage;
private ImageButton intowork, outsidework, imglogin, imgnepritomnost;
private String userIDX = "";
ValueEventListener connlist;
Expand All @@ -96,9 +100,23 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_attendance);

/* Assinging the toolbar object ot the view
and setting the the Action bar to our toolbar
*/
//Create Folder
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

//File folder = new File("/storage/emulated/0/eusecom/attendance");
File folder = new File(Environment.getExternalStorageDirectory().toString()+"/eusecom/attendance");
if(!folder.exists()) {
folder.mkdirs();
}

}else{

File folder = new File(Environment.getExternalStorageDirectory().toString()+"/eusecom/attendance");
if(!folder.exists()) {
folder.mkdirs();
}
}

toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);

Expand All @@ -109,6 +127,8 @@ protected void onCreate(Bundle savedInstanceState) {
mStatusTextView = (TextView) findViewById(R.id.status);
usicoTextView = (TextView) findViewById(R.id.usico);
mCompanyImage = (ImageView) findViewById(R.id.mycompany);
mUserImage = (ImageView) findViewById(R.id.imglogin);
mIntoworkImage = (ImageView) findViewById(R.id.intowork);

mText3 = (TextView) findViewById(R.id.text3);

Expand Down Expand Up @@ -408,13 +428,78 @@ private void getCompanyIcon(FirebaseUser user) {

if (user != null) {

String myID = user.getUid();
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
String imgUser = baseDir + File.separator + "/eusecom/attendance/photo" + myID + ".png";
File fileUser = new File(imgUser);
Log.d("imgUser ", imgUser);

String myICO = SettingsActivity.getUsIco(MainActivity.this);
String imgIco = baseDir + File.separator + "/eusecom/attendance/photo" + myICO + ".png";
File fileIco = new File(imgIco);
Log.d("imgIco ", imgIco);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

if(fileUser.exists()){
Bitmap bmp = BitmapFactory.decodeFile(imgUser);
mUserImage.setImageBitmap(bmp);
}else{
mUserImage.setImageDrawable(getResources().getDrawable(R.drawable.zamestnanec, getApplicationContext().getTheme()));
}

if(fileIco.exists()){
Bitmap bmp2 = BitmapFactory.decodeFile(imgIco);
mIntoworkImage.setImageBitmap(bmp2);
}else{
mIntoworkImage.setImageDrawable(getResources().getDrawable(R.drawable.add2new, getApplicationContext().getTheme()));
}


} else {

if(fileUser.exists()){
Bitmap bmp = BitmapFactory.decodeFile(imgUser);
mUserImage.setImageBitmap(bmp);
}else{
mUserImage.setImageDrawable(getResources().getDrawable(R.drawable.zamestnanec));
}

if(fileIco.exists()){
Bitmap bmp2 = BitmapFactory.decodeFile(imgIco);
mIntoworkImage.setImageBitmap(bmp2);
}else{
mIntoworkImage.setImageDrawable(getResources().getDrawable(R.drawable.add2new));
}

}

String usatwx = SettingsActivity.getUsAtw(this);

if (usatwx.equals("1")) {

String baseDir3 = Environment.getExternalStorageDirectory().getAbsolutePath();
String myICO3 = SettingsActivity.getUsIco(MainActivity.this);
String imgIco3 = baseDir3 + File.separator + "/eusecom/attendance/photo" + myICO3 + ".png";
File fileIco3 = new File(imgIco3);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mCompanyImage.setImageDrawable(getResources().getDrawable(R.drawable.add2new, getApplicationContext().getTheme()));

if(fileIco.exists()){
Bitmap bmp3 = BitmapFactory.decodeFile(imgIco3);
mCompanyImage.setImageBitmap(bmp3);
}else{
mCompanyImage.setImageDrawable(getResources().getDrawable(R.drawable.add2new, getApplicationContext().getTheme()));
}

} else {
mCompanyImage.setImageDrawable(getResources().getDrawable(R.drawable.add2new));

if(fileIco.exists()){
Bitmap bmp3 = BitmapFactory.decodeFile(imgIco3);
mCompanyImage.setImageBitmap(bmp3);
}else{
mCompanyImage.setImageDrawable(getResources().getDrawable(R.drawable.add2new));
}
}
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Expand All @@ -427,6 +512,14 @@ private void getCompanyIcon(FirebaseUser user) {

} else {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mUserImage.setImageDrawable(getResources().getDrawable(R.drawable.login, getApplicationContext().getTheme()));
mIntoworkImage.setImageDrawable(getResources().getDrawable(R.drawable.intowork, getApplicationContext().getTheme()));
} else {
mUserImage.setImageDrawable(getResources().getDrawable(R.drawable.login));
mIntoworkImage.setImageDrawable(getResources().getDrawable(R.drawable.intowork));
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mCompanyImage.setImageDrawable(getResources().getDrawable(R.drawable.clock, getApplicationContext().getTheme()));
} else {
Expand Down Expand Up @@ -565,6 +658,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
}

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

return true;
}

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

return true;
}

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

Intent is = new Intent(getApplicationContext(), ApproveActivity.class);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_person_black_24dp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/zamestnanec.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="eusecom.com.attendance.MainActivity">

<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />

<item
android:id="@+id/setuserimage"
android:orderInCategory="100"
android:title="@string/action_setuserimage"
app:showAsAction="never" />

<item
android:id="@+id/seticoimage"
android:orderInCategory="100"
android:title="@string/action_seticoimage"
app:showAsAction="never" />

</menu>
10 changes: 10 additions & 0 deletions app/src/main/res/menu/options_mainallmenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
android:title="@string/action_settings">
</item>

<item
android:id="@+id/setuserimage"
android:title="@string/action_setuserimage"
/>

<item
android:id="@+id/seticoimage"
android:title="@string/action_seticoimage"
/>




Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@

//database
<string name="action_settings">Settings</string>
<string name="action_setuserimage">Set my user image</string>
<string name="action_seticoimage">Set my company image</string>
<string name="menu_login">Log in</string>
<string name="menu_logout">Log out</string>
<string name="menu_settings">Settings</string>
Expand Down

0 comments on commit 34201df

Please sign in to comment.