diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 21549fb..5b102e3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,8 +14,10 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" + android:usesCleartextTraffic="true" android:theme="@style/AppTheme"> - + + diff --git a/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/PdfAdapter.java b/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/PdfAdapter.java index b3611ef..301f838 100644 --- a/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/PdfAdapter.java +++ b/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/PdfAdapter.java @@ -1,6 +1,7 @@ package com.thundersharp.cadmin.core.globalAdapters; import android.content.Context; +import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -8,9 +9,8 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; - -import com.github.barteksc.pdfviewer.PDFView; import com.thundersharp.cadmin.R; +import com.thundersharp.cadmin.ui.activity.PdfLoader; import java.util.List; @@ -44,11 +44,17 @@ public int getItemCount() { }else return 0; } - public class ViewHolder extends RecyclerView.ViewHolder{ + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { ImageView pdfView; public ViewHolder(@NonNull View itemView) { super(itemView); pdfView = itemView.findViewById(R.id.pdf_viewer); + itemView.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + context.startActivity(new Intent(context, PdfLoader.class).putExtra("url",pdfuri.get(getAdapterPosition()))); } } } diff --git a/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/WorkForceAdapter.java b/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/WorkForceAdapter.java index 9f3b543..3b02a9c 100644 --- a/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/WorkForceAdapter.java +++ b/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/WorkForceAdapter.java @@ -19,6 +19,8 @@ import java.util.List; +import thundersharp.timeline.TimelineView; + public class WorkForceAdapter extends RecyclerView.Adapter { Context context; @@ -35,7 +37,7 @@ public WorkForceAdapter(Context context,List data,AddProject_mod @Override public CustomViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(context).inflate(R.layout.item_work_force,null); - return new CustomViewHolder(view); + return new CustomViewHolder(view,viewType); } @Override @@ -61,17 +63,20 @@ class CustomViewHolder extends RecyclerView.ViewHolder implements View.OnClickLi ImageView iv; TextView starttime,name_proj,id_proj,desc_proj,end_time; Button evpand; + TimelineView timelineView; - public CustomViewHolder(@NonNull View itemView) { + public CustomViewHolder(@NonNull View itemView ,int viewtype) { super(itemView); iv = itemView.findViewById(R.id.iv); - evpand = itemView.findViewById(R.id.recyclertodo); - evpand.setOnClickListener(this); + //evpand = itemView.findViewById(R.id.recyclertodo); + //evpand.setOnClickListener(this); starttime = itemView.findViewById(R.id.starttime); end_time = itemView.findViewById(R.id.end_time); desc_proj = itemView.findViewById(R.id.desc_proj); id_proj = itemView.findViewById(R.id.id_proj); name_proj = itemView.findViewById(R.id.name_proj); + timelineView = itemView.findViewById(R.id.timeline); + timelineView.initLine(viewtype); } diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/activity/PdfLoader.java b/app/src/main/java/com/thundersharp/cadmin/ui/activity/PdfLoader.java new file mode 100644 index 0000000..78cd5da --- /dev/null +++ b/app/src/main/java/com/thundersharp/cadmin/ui/activity/PdfLoader.java @@ -0,0 +1,97 @@ +package com.thundersharp.cadmin.ui.activity; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.graphics.Bitmap; +import android.net.Uri; +import android.os.Bundle; +import android.os.Vibrator; +import android.view.View; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.ProgressBar; + +import com.thundersharp.cadmin.R; + +public class PdfLoader extends AppCompatActivity { + + WebView webView; + ProgressBar progressBar; + String url; + Vibrator vibrator; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_pdf_loader); + + webView = findViewById(R.id.webview); + + url = getIntent().getStringExtra("url"); + progressBar = findViewById(R.id.prooooo); + + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setPluginState(WebSettings.PluginState.ON); + + //---you need this to prevent the webview from + // launching another browser when a url + // redirection occurs--- + webView.setWebViewClient(new Callback()); + Uri uri = Uri.parse(url); + + webView.loadUrl(uri.toString()); + + } + + private class Callback extends WebViewClient { + boolean loadingFinished = true; + boolean redirect = false; + + @Override + public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) { + if (!loadingFinished) { + redirect = true; + } + + loadingFinished = false; + view.loadUrl(urlNewString); + return false; + } + + @Override + public void onPageStarted(WebView view, String url, Bitmap facIcon) { + loadingFinished = false; + //SHOW LOADING IF IT ISNT ALREADY VISIBLE + progressBar.setVisibility(View.VISIBLE); + } + + @Override + public void onPageFinished(WebView view, String url) { + if(!redirect){ + loadingFinished = true; + } + + if(loadingFinished && !redirect){ + //HIDE LOADING IT HAS FINISHED + progressBar.setVisibility(View.GONE); + /* if (settingsData.getvibratePdf() && settingsData.getHaptic()){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + vibrator.vibrate(VibrationEffect.createOneShot(200, VibrationEffect.EFFECT_HEAVY_CLICK)); + } else { + //deprecated in API 26 + vibrator.vibrate(200); + } + }*/ + + + } else{ + redirect = false; + } + + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/WorkForce.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/WorkForce.java index f86df41..076dbb7 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/WorkForce.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/WorkForce.java @@ -174,6 +174,7 @@ public void onNothingSelected(AdapterView adapterView) { public void loadDataFromServer(final String key,@NonNull final String orgid){ //TODO UPDATE THE VALUES TO BE LOADED FROM SHARED PREFRENCES SAVED //TODO @GET FROM SPF @DESC (NOT NECESSARY) + workforceModels.clear(); FirebaseDatabase.getInstance() .getReference("organisation") .child(orgid) diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Files.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Files.java index b7e3ece..74d0a51 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Files.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Files.java @@ -35,11 +35,13 @@ import com.google.firebase.storage.UploadTask; import com.thundersharp.cadmin.R; import com.thundersharp.cadmin.core.globalAdapters.PdfAdapter; +import com.thundersharp.cadmin.ui.activity.MainActivity; import java.util.ArrayList; import java.util.List; import static android.app.Activity.RESULT_OK; +import static com.thundersharp.cadmin.ui.activity.MainActivity.floatingActionButton; public class Files extends Fragment { @@ -61,9 +63,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_files, container, false); + MainActivity.floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_outline_note_add_24,getActivity().getTheme())); + + MainActivity.floatingActionButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + selectPdf(); + + } + }); imageView = view.findViewById(R.id.imageView_files); textView = view.findViewById(R.id.tv_files); - fab1 = view.findViewById(R.id.upload_files); storage = FirebaseStorage.getInstance(); database = FirebaseDatabase.getInstance(); @@ -71,16 +82,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, sharedPreferences =getActivity().getSharedPreferences("selected_org", Context.MODE_PRIVATE); filesRecycler= view.findViewById(R.id.recycler_view_all_files); filesRecycler.setHasFixedSize(true); - filesRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 4)); + filesRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 3)); - fab1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - selectPdf(); - } - }); - org_id = sharedPreferences.getString("selected",null); project_key = ProjectDetails.project_key; @@ -105,7 +109,7 @@ private void loadImagesfromServer(String org_id, String project_key) { .child(org_id) .child("projects") .child(project_key) - .child("images") + .child("pdfFiles") .addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot snapshot) { @@ -167,24 +171,30 @@ private void uploadPdfFile(Uri data) { .addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { - String url = taskSnapshot.getMetadata().toString(); - DatabaseReference reference = database.getReference("organisation") - .child(org_id) - .child("projects") - .child(project_key) - .child("pdfFiles"); - reference.child(fileName).setValue(url).addOnCompleteListener(new OnCompleteListener() { + taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener() { @Override - public void onComplete(@NonNull Task task) { - if (task.isSuccessful()){ - progressDialog.dismiss(); - Toast.makeText(getContext(), "File Successfully Uploaded", Toast.LENGTH_SHORT).show(); - } else { - progressDialog.dismiss(); - Toast.makeText(getContext(), "File not uploaded", Toast.LENGTH_SHORT).show(); - } + public void onSuccess(Uri uri) { + String url = uri.toString(); + DatabaseReference reference = database.getReference("organisation") + .child(org_id) + .child("projects") + .child(project_key) + .child("pdfFiles"); + reference.child(fileName).setValue(url).addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (task.isSuccessful()){ + progressDialog.dismiss(); + Toast.makeText(getContext(), "File Successfully Uploaded", Toast.LENGTH_SHORT).show(); + } else { + progressDialog.dismiss(); + Toast.makeText(getContext(), "File not uploaded", Toast.LENGTH_SHORT).show(); + } + } + }); } }); + } }).addOnFailureListener(new OnFailureListener() { @Override diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Photo.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Photo.java index e24a1fe..764adb3 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Photo.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Photo.java @@ -26,6 +26,8 @@ import java.util.ArrayList; import java.util.List; +import static com.thundersharp.cadmin.ui.activity.MainActivity.floatingActionButton; + public class Photo extends Fragment { @@ -42,6 +44,17 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, // Inflate the layout for this fragment View view= inflater.inflate(R.layout.fragment_photo, container, false); + floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_outline_add_photo_alternate_24,getActivity().getTheme())); + + floatingActionButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + //selectPdf(); + + } + }); + url = new ArrayList<>(); sharedPreferences =getActivity().getSharedPreferences("selected_org",Context.MODE_PRIVATE); gallaryrecuycler= view.findViewById(R.id.gallaryrecuycler); diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/ProjectDetails.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/ProjectDetails.java index 07a1a19..77c5fc7 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/ProjectDetails.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/ProjectDetails.java @@ -91,6 +91,23 @@ public void onClick(View view) { tabLayout.setupWithViewPager(viewPager); viewPager.setOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); + viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }); + tabLayout.getTabAt(0).setIcon(R.drawable.ic_outline_photo_library_24); tabLayout.getTabAt(1).setIcon(R.drawable.ic_outline_file_copy_24); tabLayout.getTabAt(2).setIcon(R.drawable.ic_outline_video_library_24); diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Video.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Video.java index 25daa33..b8e5912 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Video.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Video.java @@ -43,6 +43,7 @@ import java.util.List; import static android.app.Activity.RESULT_OK; +import static com.thundersharp.cadmin.ui.activity.MainActivity.floatingActionButton; public class Video extends Fragment { @@ -65,9 +66,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_video, container, false); + floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_baseline_slow_motion_video_24,getActivity().getTheme())); + + floatingActionButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + selectVideo(); + + } + }); imageView = view.findViewById(R.id.imageView_video); textView = view.findViewById(R.id.tv_video); - fabVideo = view.findViewById(R.id.upload_videos); imageView.setVisibility(View.VISIBLE); imageView.setImageResource(R.drawable.sad); @@ -82,14 +92,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, videoRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 3)); - - fabVideo.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - selectVideo(); - } - }); - org_id = sharedPreferences.getString("selected",null); project_key = ProjectDetails.project_key; diff --git a/app/src/main/res/drawable/ic_baseline_slow_motion_video_24.xml b/app/src/main/res/drawable/ic_baseline_slow_motion_video_24.xml new file mode 100644 index 0000000..1c6917c --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_slow_motion_video_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_add_photo_alternate_24.xml b/app/src/main/res/drawable/ic_outline_add_photo_alternate_24.xml new file mode 100644 index 0000000..f8004f3 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_add_photo_alternate_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_note_add_24.xml b/app/src/main/res/drawable/ic_outline_note_add_24.xml new file mode 100644 index 0000000..48de8ab --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_note_add_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/activity_pdf_loader.xml b/app/src/main/res/layout/activity_pdf_loader.xml new file mode 100644 index 0000000..8e401be --- /dev/null +++ b/app/src/main/res/layout/activity_pdf_loader.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/add_project_view.xml b/app/src/main/res/layout/add_project_view.xml index 9fede01..3f53f8c 100644 --- a/app/src/main/res/layout/add_project_view.xml +++ b/app/src/main/res/layout/add_project_view.xml @@ -33,6 +33,7 @@ android:id="@+id/org_image1" android:layout_width="50dp" android:layout_height="50dp" + android:layout_marginEnd="8dp" android:layout_gravity="center" android:padding="2dp" android:scaleType="centerCrop" @@ -40,12 +41,13 @@ + android:tint="#000" + android:layout_gravity="center_horizontal"/> diff --git a/app/src/main/res/layout/fragment_files.xml b/app/src/main/res/layout/fragment_files.xml index d5a0121..9685bcb 100644 --- a/app/src/main/res/layout/fragment_files.xml +++ b/app/src/main/res/layout/fragment_files.xml @@ -33,14 +33,5 @@ android:layout_height="match_parent" shimmer:layoutManager="androidx.recyclerview.widget.GridLayoutManager"/> - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_gallery.xml b/app/src/main/res/layout/fragment_gallery.xml index 0697e30..2a0e3ac 100644 --- a/app/src/main/res/layout/fragment_gallery.xml +++ b/app/src/main/res/layout/fragment_gallery.xml @@ -25,6 +25,7 @@ android:id="@+id/refresh" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_marginTop="5dp" android:layout_below="@+id/progressorg"> - \ No newline at end of file diff --git a/app/src/main/res/layout/grid_pdf.xml b/app/src/main/res/layout/grid_pdf.xml index 1b10f28..9b9c6f7 100644 --- a/app/src/main/res/layout/grid_pdf.xml +++ b/app/src/main/res/layout/grid_pdf.xml @@ -2,15 +2,31 @@ + android:layout_height="130dp" + android:background="@color/grey_300" + android:layout_margin="1dp"> + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_work_force.xml b/app/src/main/res/layout/item_work_force.xml index 75d7f6a..31a4e85 100644 --- a/app/src/main/res/layout/item_work_force.xml +++ b/app/src/main/res/layout/item_work_force.xml @@ -1,158 +1,150 @@ - - - + + + + - - - - + + - - + + - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + android:layout_height="wrap_content" + android:layout_below="@+id/desc_proj" + android:layout_marginStart="10dp" + android:layout_marginTop="5dp" + android:text="End time : 26/07/2020" + android:textColor="@color/Brown" /> + + + + + + + + + + \ No newline at end of file