commit 6b62c02d52832dee54c923495ecfb7ab107519dd Author: saad.siddiq Date: Thu Apr 10 12:03:52 2025 +0500 First Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..f3124be --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,47 @@ +plugins { + alias(libs.plugins.android.application) +} + +android { + namespace 'com.utopiaindustries.hseobservationsapp' + compileSdk 34 + + defaultConfig { + applicationId "com.utopiaindustries.hseobservationsapp" + minSdk 24 + targetSdk 34 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation libs.appcompat + implementation libs.material + implementation libs.activity + implementation libs.constraintlayout + testImplementation libs.junit + androidTestImplementation libs.ext.junit + androidTestImplementation libs.espresso.core + + implementation libs.retrofit + implementation libs.converter.gson + implementation libs.glide + implementation libs.easypermissions + implementation libs.preference + +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# 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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/utopiaindustries/hseobservationsapp/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/utopiaindustries/hseobservationsapp/ExampleInstrumentedTest.java new file mode 100644 index 0000000..539dff5 --- /dev/null +++ b/app/src/androidTest/java/com/utopiaindustries/hseobservationsapp/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.utopiaindustries.hseobservationsapp; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.utopiaindustries.hseobservationsapp", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..87704c6 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/activities/DashboardActivity.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/activities/DashboardActivity.java new file mode 100644 index 0000000..1dcc305 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/activities/DashboardActivity.java @@ -0,0 +1,138 @@ +package com.utopiaindustries.hseobservationsapp.activities; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.activity.EdgeToEdge; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; +import androidx.viewpager.widget.ViewPager; + +import com.google.android.material.tabs.TabLayout; +import com.utopiaindustries.hseobservationsapp.R; +import com.utopiaindustries.hseobservationsapp.adapters.PagerAdapter; + +public class DashboardActivity extends AppCompatActivity { + + TabLayout tabLayout; + ViewPager viewPager; + + PagerAdapter pagerAdapter; + + ImageView imgLogout; + ImageView img_back; + + public int[] tabIcons = { + R.drawable.icon_tab_home, + R.drawable.icon_tab_drafts + }; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + EdgeToEdge.enable(this); + setContentView(R.layout.activity_dashboard); + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { + Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); + return insets; + }); + + initializeLayout(); + + imgLogout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + alertLogOut(DashboardActivity.this); + } + }); + + img_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (getSupportFragmentManager().getBackStackEntryCount() > 0) { + getSupportFragmentManager().popBackStack(); // Go back to the previous fragment + } else { + finish(); + } + } + }); + + } + + public void initializeLayout() { + img_back = findViewById(R.id.img_back); + imgLogout = findViewById(R.id.img_logout); + + viewPager = (ViewPager) findViewById(R.id.viewpager); + pagerAdapter = new PagerAdapter(getSupportFragmentManager(), DashboardActivity.this); + viewPager.setAdapter(pagerAdapter); + + tabLayout = (TabLayout) findViewById(R.id.tab_layout); + tabLayout.setupWithViewPager(viewPager); + + tabLayout.getTabAt(0).setIcon(tabIcons[0]); + tabLayout.getTabAt(1).setIcon(tabIcons[1]); + + for (int i = 0; i < tabLayout.getTabCount(); i++) { + TabLayout.Tab tab = tabLayout.getTabAt(i); + tab.setCustomView(pagerAdapter.getTabView(i)); + } + } + + public void alertLogOut(Context con) { + ViewGroup viewGroup = findViewById(android.R.id.content); + + TextView dialogOkBtn, dialogCancelBtn; + + AlertDialog.Builder builder = new AlertDialog.Builder(con); + View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_logout, viewGroup, false); + builder.setCancelable(false); + builder.setView(view1); + + dialogOkBtn = view1.findViewById(R.id.dialogOkBtn); + dialogCancelBtn = view1.findViewById(R.id.dialogCancelBtn); + + AlertDialog alertDialog = builder.create(); + alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + + dialogOkBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + alertDialog.dismiss(); + + finish(); + Intent i = new Intent(DashboardActivity.this, LoginActivity.class); + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(i); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + + } + }); + + dialogCancelBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + alertDialog.dismiss(); + //Toast.makeText(con, "Cancel", Toast.LENGTH_SHORT).show(); + + } + }); + + alertDialog.show(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/activities/LoginActivity.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/activities/LoginActivity.java new file mode 100644 index 0000000..1988d11 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/activities/LoginActivity.java @@ -0,0 +1,162 @@ +package com.utopiaindustries.hseobservationsapp.activities; + +import android.content.Intent; +import android.os.Bundle; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import androidx.activity.EdgeToEdge; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; +import androidx.lifecycle.ViewModelProvider; + +import com.utopiaindustries.hseobservationsapp.R; +import com.utopiaindustries.hseobservationsapp.apiservice.ApiService; +import com.utopiaindustries.hseobservationsapp.apiservice.ApiServiceFactory; +import com.utopiaindustries.hseobservationsapp.helper.Helper; +import com.utopiaindustries.hseobservationsapp.helper.Preference; +import com.utopiaindustries.hseobservationsapp.utils.ProgressDialogFragment; +import com.utopiaindustries.hseobservationsapp.viewmodels.LoginViewModel; + +public class LoginActivity extends AppCompatActivity { + + EditText tfEmail, tfPassword; + Button btnLogin; + LoginViewModel loginViewModel; + ApiService apiService; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + EdgeToEdge.enable(this); + setContentView(R.layout.activity_login); + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { + Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); + return insets; + }); + + if (!Helper.isNetworkConnected(this)) { + Toast.makeText(this, "No Internet Connection", Toast.LENGTH_LONG).show(); + } + + initializeLayout(); + + btnLogin.setOnClickListener(v -> { + if (isValidate()) { + /*loginViewModel.isUserAuthenticated(tfEmail.getText().toString().trim(), + tfPassword.getText().toString(), + new String[]{"ROLE_UIM_QC_APP_ACCESS_YES"});*/ + + Preference.setMyBooleanPref(Helper.project_file, "isLoggedIn", getApplicationContext(), true); + Preference.setMyStringPref(Helper.project_file,Helper.logInUser,this,tfEmail.getText().toString()); + + Intent intent = new Intent(this, DashboardActivity.class); + startActivity(intent); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + } + }); + } + + public void initializeLayout() { + tfEmail = findViewById(R.id.tf_email); + tfPassword = findViewById(R.id.tf_password); + btnLogin = findViewById(R.id.btn_login); + apiService = ApiServiceFactory.getApiService(); + + //tfEmail.setText("adnan.niaz"); + //tfPassword.setText("Utopia01"); + + loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class); + + loginViewModel.getLoadingState().observe(this, isLoading -> { + if (isLoading != null && isLoading) { + showProgressDialog(); + } else { + dismissProgressDialog(); + } + }); + + loginViewModel.getErrorMessage().observe(this, errorResponse -> { + if (errorResponse.isEmpty()) { + Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show(); + } + + }); + + loginViewModel.getLoginUser().observe(this, loginUser -> { + if (loginUser) { + Preference.setMyBooleanPref(Helper.project_file, "isLoggedIn", getApplicationContext(), true); + Preference.setMyStringPref(Helper.project_file,Helper.logInUser,this,tfEmail.getText().toString()); + + Intent intent = new Intent(this, DashboardActivity.class); + startActivity(intent); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + } + else { + Toast.makeText(this, "Login Failed", Toast.LENGTH_SHORT).show(); + } + }); + + /*loginViewModel.getUserLiveData().observe(this, user -> { + if (user != null) { + Preference.setMyBooleanPref(Helper.project_file, "isLoggedIn", getApplicationContext(), true); + Helper.setPreferenceObject(getApplicationContext(), user, "DriverResponse"); + + //Toast.makeText(this, "Welcome " + user.getTruckerName(), Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(this, HomeActivity.class); + startActivity(intent); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + } else { + Toast.makeText(this, "Login Failed", Toast.LENGTH_SHORT).show(); + } + });*/ + } + + public boolean isValidate() { + boolean returnValue = true; + String message = ""; + + if (tfPassword.getText().toString().isEmpty()) { + message = "Please enter password."; + returnValue = false; + } + + /*if (!Helper.isValidEmail(tfEmail.getText().toString())) { + message = "Please enter valid email."; + returnValue = false; + }*/ + + if (tfEmail.getText().toString().isEmpty()) { + message = "Please enter user name."; + returnValue = false; + } + + if (!returnValue) { + Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); + } + + return returnValue; + } + + public void showProgressDialog() { + ProgressDialogFragment progressDialog = new ProgressDialogFragment(); + progressDialog.setCancelable(false); + progressDialog.show(getSupportFragmentManager(), "progressDialog"); + } + + public void dismissProgressDialog() { + ProgressDialogFragment progressDialog = (ProgressDialogFragment) getSupportFragmentManager().findFragmentByTag("progressDialog"); + if (progressDialog != null) { + progressDialog.dismiss(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/adapters/PagerAdapter.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/adapters/PagerAdapter.java new file mode 100644 index 0000000..fd34374 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/adapters/PagerAdapter.java @@ -0,0 +1,71 @@ +package com.utopiaindustries.hseobservationsapp.adapters; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentStatePagerAdapter; + +import com.utopiaindustries.hseobservationsapp.R; +import com.utopiaindustries.hseobservationsapp.fragments.DraftFragment; +import com.utopiaindustries.hseobservationsapp.fragments.HomeFragment; + +@SuppressWarnings("deprecation") +public class PagerAdapter extends FragmentStatePagerAdapter { + + String tabTitles[] = new String[]{"Home", "Draft"}; + Context context; + + public PagerAdapter(FragmentManager fm, Context context) { + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); + this.context = context; + } + + public int[] tabIcons = { + R.drawable.icon_tab_home, + R.drawable.icon_tab_drafts + }; + + @Override + public int getCount() { + return tabTitles.length; + } + + @NonNull + @Override + public Fragment getItem(int position) { + + switch (position) { + case 0: + return new HomeFragment(); + case 1: + return new DraftFragment(); + } + return null; + } + + @Override + public CharSequence getPageTitle(int position) { + // Generate title based on item position + // return tabTitles[position]; + return null; + } + + public View getTabView(int position) { + View tab = LayoutInflater.from(context).inflate(R.layout.custom_tab, null); + + TextView tv = (TextView) tab.findViewById(R.id.txt_name); + ImageView imgView = (ImageView) tab.findViewById(R.id.imgView); + tv.setText(tabTitles[position]); + imgView.setBackgroundResource(tabIcons[position]); + + // tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, context.getResources().getDimension(R.dimen.tab_text_size)); + + return tab; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/apiservice/ApiService.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/apiservice/ApiService.java new file mode 100644 index 0000000..9e1c32d --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/apiservice/ApiService.java @@ -0,0 +1,35 @@ +package com.utopiaindustries.hseobservationsapp.apiservice; + +import com.utopiaindustries.hseobservationsapp.models.QualityControl; +import com.utopiaindustries.hseobservationsapp.models.QualityControlResponse; +import com.utopiaindustries.hseobservationsapp.models.QualitySaveResponse; + +import retrofit2.Call; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.POST; +import retrofit2.http.Query; + +public interface ApiService { + + /*@GET("rest/uic/inspection-report") + Call> fetchAllReports( + @Query("username") String username + );*/ + + @GET("rest/uic/quality-control/get-quality-control-data") + Call getQualityControlData(); + + + @POST("rest/uic/quality-control/save-quality-control") + Call saveQualityControlReport( + @Body QualityControl request + ); + + @POST("rest/authentication/authenticate-user") + Call isUserAuthenticated( + @Query("username") String username, + @Query("password") String password, + @Query("roles") String[] roles + ); +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/apiservice/ApiServiceFactory.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/apiservice/ApiServiceFactory.java new file mode 100644 index 0000000..d5bbef2 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/apiservice/ApiServiceFactory.java @@ -0,0 +1,17 @@ +package com.utopiaindustries.hseobservationsapp.apiservice; + +import retrofit2.Retrofit; + +public class ApiServiceFactory { + + private static ApiService apiService; + + public synchronized static ApiService getApiService() { + if ( apiService == null ) { + Retrofit retrofit = RetrofitClient.getClient(); + apiService = retrofit.create( ApiService.class ); + } + return apiService; + } + +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/apiservice/RetrofitClient.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/apiservice/RetrofitClient.java new file mode 100644 index 0000000..573d3d8 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/apiservice/RetrofitClient.java @@ -0,0 +1,49 @@ +package com.utopiaindustries.hseobservationsapp.apiservice; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.util.concurrent.TimeUnit; + +import okhttp3.OkHttpClient; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class RetrofitClient { + + //Live url + //private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/"; + + //Test Url + private final static String BASE_URL = "http://192.168.91.44:8081/uind/"; + + private static Retrofit retrofit; + + public synchronized static Retrofit getClient() { + + Gson gson = new GsonBuilder() + //.registerTypeAdapter(Boolean.class, new BooleanTypeAdapter()) + .create(); + + + if (retrofit == null) { + try { + + OkHttpClient okHttpClient = new OkHttpClient.Builder() + .connectTimeout(40, TimeUnit.SECONDS) + .readTimeout(40, TimeUnit.SECONDS) + .writeTimeout(40, TimeUnit.SECONDS) + .build(); + + retrofit = new Retrofit.Builder() + .baseUrl(BASE_URL) + .client(okHttpClient) + .addConverterFactory(GsonConverterFactory.create(gson)) + .build(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return retrofit; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/fragments/DraftFragment.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/fragments/DraftFragment.java new file mode 100644 index 0000000..f886a5d --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/fragments/DraftFragment.java @@ -0,0 +1,27 @@ +package com.utopiaindustries.hseobservationsapp.fragments; + +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.utopiaindustries.hseobservationsapp.R; + +public class DraftFragment extends Fragment { + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_draft, container, false); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/fragments/HomeFragment.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/fragments/HomeFragment.java new file mode 100644 index 0000000..84dc442 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/fragments/HomeFragment.java @@ -0,0 +1,27 @@ +package com.utopiaindustries.hseobservationsapp.fragments; + +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.utopiaindustries.hseobservationsapp.R; + +public class HomeFragment extends Fragment { + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_home, container, false); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/helper/Helper.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/helper/Helper.java new file mode 100644 index 0000000..a015470 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/helper/Helper.java @@ -0,0 +1,127 @@ +package com.utopiaindustries.hseobservationsapp.helper; + +import android.content.Context; +import android.content.SharedPreferences; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.text.TextUtils; +import android.util.Log; + +import androidx.preference.PreferenceManager; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +public class Helper { + + public static final String project_file = "Quality-Control"; + + public static final String departmentId = "departId"; + public static final String departmentName = "departName"; + public static final String locationSiteId = "locationSiteId"; + public static final String locationSiteName = "locationSiteName"; + public static final String unitId = "unitId"; + public static final String unitName = "unitName"; + public static final String floorId = "floorId"; + public static final String floorName = "floorName"; + + public static final String logInUser = "LogInUser"; + + public static boolean isValidEmail(CharSequence target) { + return !TextUtils.isEmpty(target) && android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches(); + } + + public static boolean isNetworkConnected(Context context) { + ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo(); + return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); + } + + static public void setPreferenceObject(Context c, Object modal, String key) { + + SharedPreferences appSharedPrefs = PreferenceManager.getDefaultSharedPreferences(c.getApplicationContext()); + SharedPreferences.Editor prefsEditor = appSharedPrefs.edit(); + + Gson gson = new Gson(); + String jsonObject = gson.toJson(modal); + prefsEditor.putString(key, jsonObject); + prefsEditor.commit(); + } + + /*static public QualityControlResponse getPreferenceObjectJson(Context c, String key) { + + SharedPreferences appSharedPrefs = PreferenceManager.getDefaultSharedPreferences(c.getApplicationContext()); + + String json = appSharedPrefs.getString(key, ""); + Gson gson = new Gson(); + QualityControlResponse selectedUser = gson.fromJson(json, QualityControlResponse.class); + return selectedUser; + }*/ + + /*static public void saveArrayList(List list, String key, Context context){ + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences.Editor editor = prefs.edit(); + Gson gson = new Gson(); + String json = gson.toJson(list); + editor.putString(key, json); + editor.apply(); + + }*/ + + /*static public List getArrayList(String key, Context context){ + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + + // Check if the key exists + if (!prefs.contains(key)) { + return null; // Return null if the key doesn't exist + } + + Gson gson = new Gson(); + String json = prefs.getString(key, null); + Type type = new TypeToken>() {}.getType(); + return gson.fromJson(json, type); + }*/ + + static public void RemoveArrayList(String key, Context context) { + if (context != null) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + if (prefs.contains(key)) { // Check if the key exists + SharedPreferences.Editor editor = prefs.edit(); + editor.remove(key); // Remove the key-value pair + editor.apply(); // Apply changes + ///Log.e("SharedPreferences", "Key '" + key + "' removed successfully."); + } else { + Log.e("SharedPreferences", "Key '" + key + "' does not exist."); + } + } + + } + + //for department, site, unit, floor + public static void saveList(List list, String key, Context context) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences.Editor editor = prefs.edit(); + Gson gson = new Gson(); + String json = gson.toJson(list); // Convert the list to JSON + editor.putString(key, json); + editor.apply(); // Save to SharedPreferences + } + + public static List getList(String key, Context context, Class clazz) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + + // Check if the key exists + if (!prefs.contains(key)) { + return new ArrayList<>(); // Return an empty list if the key doesn't exist + } + + Gson gson = new Gson(); + String json = prefs.getString(key, null); + Type type = TypeToken.getParameterized(ArrayList.class, clazz).getType(); // Use the provided class type + return gson.fromJson(json, type); // Convert JSON back to the list + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/helper/Preference.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/helper/Preference.java new file mode 100644 index 0000000..45deab4 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/helper/Preference.java @@ -0,0 +1,82 @@ +package com.utopiaindustries.hseobservationsapp.helper; + +import android.content.Context; +import android.content.SharedPreferences; + +public class Preference { + + private static final int PREFERENCE_MODE_PRIVATE = 0; + private static String MY_STRING_PREF = "mystringpref"; + public static String LOGIN_FILE = "login_prefs"; + public static String TEMP_FILE = "temp_prefs"; + + + public static String KEY_PIN_CODE = "pin_code"; + + public static String KEY_CUSTOMER_ID = "cus_id"; + public static String KEY_CUSTOMER_NAME = "cus_name"; + + public static String KEY_USER_IS_MASTER = "user_is_master"; + + public static SharedPreferences getPrefs(String nameOfFile, Context context) { + + return context.getSharedPreferences(nameOfFile, Context.MODE_PRIVATE); + } + + public static boolean containsKey(String fileName, String key, Context context) { + return getPrefs(fileName, context).contains(key); + } + + public static String getMyStringPref(String fileName, String key, Context context) { + + return getPrefs(fileName,context).getString(key, "default"); + } + public static boolean getMyBooleanPref(String fileName, String key, Context context) { + + return getPrefs(fileName,context).getBoolean(key,false); + } + public static int getMyIntPref(String fileName, String key, Context context) { + + return getPrefs(fileName,context).getInt(key, 0); + } + + public static long getMyLongPref(String fileName, String key, Context context) { + + return getPrefs(fileName,context).getLong(key, 0); + } + + public static void setMyLongPref(String fileName, String key, Context context, long value) { + // perform validation etc.. + getPrefs(fileName,context).edit().putLong(key, value).apply(); + } + + public static void setMyStringPref(String fileName, String key, Context context, String value) { + // perform validation etc.. + getPrefs(fileName,context).edit().putString(key, value).apply(); + } + + public static void setMyBooleanPref(String fileName, String key, Context context, boolean value) { + // perform validation etc.. + getPrefs(fileName,context).edit().putBoolean(key, value).apply(); + } + + public static void setMyIntPref(String fileName, String key, Context context, int value) { + // perform validation etc.. + getPrefs(fileName,context).edit().putInt(key, value).apply(); + } + + + public static void remove(String fileName, String key, Context context) { + // perform validation etc.. + if (context != null) { + if (getPrefs(fileName,context).contains(key)) { + getPrefs(fileName,context).edit().remove(key).apply(); + } + } + + } + public static void removeAll(String fileName, Context context) { + // perform validation etc.. + getPrefs(fileName,context).edit().clear().apply(); + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/Department.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/Department.java new file mode 100644 index 0000000..719521e --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/Department.java @@ -0,0 +1,177 @@ + +package com.utopiaindustries.hseobservationsapp.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class Department { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("companyId") + @Expose + private Integer companyId; + @SerializedName("functionId") + @Expose + private Integer functionId; + @SerializedName("title") + @Expose + private String title; + @SerializedName("organization") + @Expose + private String organization; + @SerializedName("code") + @Expose + private Integer code; + @SerializedName("email") + @Expose + private Object email; + @SerializedName("isActive") + @Expose + private Boolean isActive; + @SerializedName("sections") + @Expose + private Object sections; + @SerializedName("hierarchyString") + @Expose + private Object hierarchyString; + @SerializedName("costCenters") + @Expose + private Object costCenters; + @SerializedName("locationSites") + @Expose + private Object locationSites; + @SerializedName("departmentLocationSites") + @Expose + private Object departmentLocationSites; + @SerializedName("utilitySubMeterDepartments") + @Expose + private List utilitySubMeterDepartments; + @SerializedName("capitalizedTitle") + @Expose + private String capitalizedTitle; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getCompanyId() { + return companyId; + } + + public void setCompanyId(Integer companyId) { + this.companyId = companyId; + } + + public Integer getFunctionId() { + return functionId; + } + + public void setFunctionId(Integer functionId) { + this.functionId = functionId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getOrganization() { + return organization; + } + + public void setOrganization(String organization) { + this.organization = organization; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public Object getEmail() { + return email; + } + + public void setEmail(Object email) { + this.email = email; + } + + public Boolean getIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + public Object getSections() { + return sections; + } + + public void setSections(Object sections) { + this.sections = sections; + } + + public Object getHierarchyString() { + return hierarchyString; + } + + public void setHierarchyString(Object hierarchyString) { + this.hierarchyString = hierarchyString; + } + + public Object getCostCenters() { + return costCenters; + } + + public void setCostCenters(Object costCenters) { + this.costCenters = costCenters; + } + + public Object getLocationSites() { + return locationSites; + } + + public void setLocationSites(Object locationSites) { + this.locationSites = locationSites; + } + + public Object getDepartmentLocationSites() { + return departmentLocationSites; + } + + public void setDepartmentLocationSites(Object departmentLocationSites) { + this.departmentLocationSites = departmentLocationSites; + } + + public List getUtilitySubMeterDepartments() { + return utilitySubMeterDepartments; + } + + public void setUtilitySubMeterDepartments(List utilitySubMeterDepartments) { + this.utilitySubMeterDepartments = utilitySubMeterDepartments; + } + + public String getCapitalizedTitle() { + return capitalizedTitle; + } + + public void setCapitalizedTitle(String capitalizedTitle) { + this.capitalizedTitle = capitalizedTitle; + } + +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/Item.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/Item.java new file mode 100644 index 0000000..49002bd --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/Item.java @@ -0,0 +1,24 @@ +package com.utopiaindustries.hseobservationsapp.models; + +public class Item { + + private final String name; + private int selectedOption; // Index of the selected dropdown option + + public Item(String name, int selectedOption) { + this.name = name; + this.selectedOption = selectedOption; + } + + public String getName() { + return name; + } + + public int getSelectedOption() { + return selectedOption; + } + + public void setSelectedOption(int selectedOption) { + this.selectedOption = selectedOption; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/ItemModel.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/ItemModel.java new file mode 100644 index 0000000..b1d7e39 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/ItemModel.java @@ -0,0 +1,93 @@ +package com.utopiaindustries.hseobservationsapp.models; + +import java.util.List; + +public class ItemModel { + + private int processId; + private int stepId; + private double rating; + private String percentage; + private String remarks; + private int selectedOption; + private byte[] imageByteArray; + private List files; + + public ItemModel() { + } + + public ItemModel(int processId, int stepId, double rating, String percentage, String remarks, int selectedOption, byte[] imageByteArray, List imageArrayList) { + this.processId = processId; + this.stepId = stepId; + this.rating = rating; + this.percentage = percentage; + this.remarks = remarks; + this.selectedOption = selectedOption; + this.imageByteArray = imageByteArray; + this.files = imageArrayList; + } + + public int getProcessId() { + return processId; + } + + public void setProcessId(int processId) { + this.processId = processId; + } + + public int getStepId() { + return stepId; + } + + public void setStepId(int stepId) { + this.stepId = stepId; + } + + public String getPercentage() { + return percentage; + } + + public void setPercentage(String percentage) { + this.percentage = percentage; + } + + public String getRemarks() { + return remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } + + public int getSelectedOption() { + return selectedOption; + } + + public void setSelectedOption(int selectedOption) { + this.selectedOption = selectedOption; + } + + public double getRating() { + return rating; + } + + public void setRating(double rating) { + this.rating = rating; + } + + public byte[] getImageUri() { + return imageByteArray; + } + + public void setImageUri(byte[] imageUri) { + this.imageByteArray = imageUri; + } + + public List getImageArrayList() { + return files; + } + + public void setImageArrayList(List imageArrayList) { + this.files = imageArrayList; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/LocationFloor.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/LocationFloor.java new file mode 100644 index 0000000..b642936 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/LocationFloor.java @@ -0,0 +1,69 @@ + +package com.utopiaindustries.hseobservationsapp.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class LocationFloor { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("title") + @Expose + private String title; + @SerializedName("siteId") + @Expose + private Integer siteId; + @SerializedName("unitId") + @Expose + private Integer unitId; + @SerializedName("stores") + @Expose + private Object stores; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getSiteId() { + return siteId; + } + + public void setSiteId(Integer siteId) { + this.siteId = siteId; + } + + public Integer getUnitId() { + return unitId; + } + + public void setUnitId(Integer unitId) { + this.unitId = unitId; + } + + public Object getStores() { + return stores; + } + + public void setStores(Object stores) { + this.stores = stores; + } + + @Override + public String toString() { + return title; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/LocationSite.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/LocationSite.java new file mode 100644 index 0000000..79f2bce --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/LocationSite.java @@ -0,0 +1,80 @@ + +package com.utopiaindustries.hseobservationsapp.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class LocationSite { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("title") + @Expose + private String title; + @SerializedName("shortTitle") + @Expose + private String shortTitle; + @SerializedName("address") + @Expose + private String address; + @SerializedName("hasColony") + @Expose + private Boolean hasColony; + @SerializedName("units") + @Expose + private Object units; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getShortTitle() { + return shortTitle; + } + + public void setShortTitle(String shortTitle) { + this.shortTitle = shortTitle; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public Boolean getHasColony() { + return hasColony; + } + + public void setHasColony(Boolean hasColony) { + this.hasColony = hasColony; + } + + public Object getUnits() { + return units; + } + + public void setUnits(Object units) { + this.units = units; + } + + @Override + public String toString() { + return title; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/LocationUnit.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/LocationUnit.java new file mode 100644 index 0000000..2c5542c --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/LocationUnit.java @@ -0,0 +1,59 @@ + +package com.utopiaindustries.hseobservationsapp.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class LocationUnit { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("title") + @Expose + private String title; + @SerializedName("siteId") + @Expose + private Integer siteId; + @SerializedName("floors") + @Expose + private Object floors; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getSiteId() { + return siteId; + } + + public void setSiteId(Integer siteId) { + this.siteId = siteId; + } + + public Object getFloors() { + return floors; + } + + public void setFloors(Object floors) { + this.floors = floors; + } + + @Override + public String toString() { + return title; + } + +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControl.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControl.java new file mode 100644 index 0000000..a54b79f --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControl.java @@ -0,0 +1,70 @@ +package com.utopiaindustries.hseobservationsapp.models; + +import java.util.List; + +public class QualityControl { + + private String generatedBy; + private int siteId; + private int unitId; + private int departmentId; + private int floorId; + private List qualityControlItemList; + + public QualityControl(String generatedBy, int siteId, int unitId, int departmentId, int floorId, List qualityControlItemList) { + this.generatedBy = generatedBy; + this.siteId = siteId; + this.unitId = unitId; + this.departmentId = departmentId; + this.floorId = floorId; + this.qualityControlItemList = qualityControlItemList; + } + + public String getGeneratedBy() { + return generatedBy; + } + + public void setGeneratedBy(String generatedBy) { + this.generatedBy = generatedBy; + } + + public int getSiteId() { + return siteId; + } + + public void setSiteId(int siteId) { + this.siteId = siteId; + } + + public int getUnitId() { + return unitId; + } + + public void setUnitId(int unitId) { + this.unitId = unitId; + } + + public int getDepartmentId() { + return departmentId; + } + + public void setDepartmentId(int departmentId) { + this.departmentId = departmentId; + } + + public int getFloorId() { + return floorId; + } + + public void setFloorId(int floorId) { + this.floorId = floorId; + } + + public List getQualityControlItemList() { + return qualityControlItemList; + } + + public void setQualityControlItemList(List qualityControlItemList) { + this.qualityControlItemList = qualityControlItemList; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControlProcess.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControlProcess.java new file mode 100644 index 0000000..d8ff836 --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControlProcess.java @@ -0,0 +1,32 @@ + +package com.utopiaindustries.hseobservationsapp.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class QualityControlProcess { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("name") + @Expose + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControlProcessStep.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControlProcessStep.java new file mode 100644 index 0000000..e116d3d --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControlProcessStep.java @@ -0,0 +1,43 @@ + +package com.utopiaindustries.hseobservationsapp.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class QualityControlProcessStep { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("title") + @Expose + private String title; + @SerializedName("description") + @Expose + private String description; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControlResponse.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControlResponse.java new file mode 100644 index 0000000..f5d0aca --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualityControlResponse.java @@ -0,0 +1,77 @@ +package com.utopiaindustries.hseobservationsapp.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class QualityControlResponse { + + @SerializedName("locationUnits") + @Expose + private List locationUnits; + @SerializedName("locationFloors") + @Expose + private List locationFloors; + @SerializedName("qualityControlProcessSteps") + @Expose + private List qualityControlProcessSteps; + @SerializedName("locationSites") + @Expose + private List locationSites; + @SerializedName("departments") + @Expose + private List departments; + @SerializedName("qualityControlProcessList") + @Expose + private List qualityControlProcessList; + + public List getLocationUnits() { + return locationUnits; + } + + public void setLocationUnits(List locationUnits) { + this.locationUnits = locationUnits; + } + + + public List getLocationFloors() { + return locationFloors; + } + + public void setLocationFloors(List locationFloors) { + this.locationFloors = locationFloors; + } + + public List getQualityControlProcessSteps() { + return qualityControlProcessSteps; + } + + public void setQualityControlProcessSteps(List qualityControlProcessSteps) { + this.qualityControlProcessSteps = qualityControlProcessSteps; + } + + public List getLocationSites() { + return locationSites; + } + + public void setLocationSites(List locationSites) { + this.locationSites = locationSites; + } + + public List getDepartments() { + return departments; + } + + public void setDepartments(List departments) { + this.departments = departments; + } + + public List getQualityControlProcessList() { + return qualityControlProcessList; + } + + public void setQualityControlProcessList(List qualityControlProcessList) { + this.qualityControlProcessList = qualityControlProcessList; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualitySaveResponse.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualitySaveResponse.java new file mode 100644 index 0000000..25f207f --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/models/QualitySaveResponse.java @@ -0,0 +1,117 @@ +package com.utopiaindustries.hseobservationsapp.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class QualitySaveResponse implements Serializable { + + @SerializedName("overAllPercentage") + @Expose + private String overAllPercentage; + + @SerializedName("status") + @Expose + private String status; + + @SerializedName("message") + @Expose + private String message; + + @SerializedName("Cutting") + @Expose + private String Cutting; + + @SerializedName("Stiching") + @Expose + private String Stiching; + + @SerializedName("Checking") + @Expose + private String Checking; + + @SerializedName("Packing") + @Expose + private String Packing; + + @SerializedName("Sub Store") + @Expose + private String Sub_Store; + + @SerializedName("code") + @Expose + private String ReportId; + + public String getOverAllPercentage() { + return overAllPercentage; + } + + public void setOverAllPercentage(String overAllPercentage) { + this.overAllPercentage = overAllPercentage; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getCutting() { + return Cutting; + } + + public void setCutting(String cutting) { + Cutting = cutting; + } + + public String getStiching() { + return Stiching; + } + + public void setStiching(String stiching) { + Stiching = stiching; + } + + public String getChecking() { + return Checking; + } + + public void setChecking(String checking) { + Checking = checking; + } + + public String getPacking() { + return Packing; + } + + public void setPacking(String packing) { + Packing = packing; + } + + public String getSub_Store() { + return Sub_Store; + } + + public void setSub_Store(String sub_Store) { + Sub_Store = sub_Store; + } + + public String getReportId() { + return ReportId; + } + + public void setReportId(String reportId) { + ReportId = reportId; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/utils/NonSwipeableViewPager.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/utils/NonSwipeableViewPager.java new file mode 100644 index 0000000..6bad83f --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/utils/NonSwipeableViewPager.java @@ -0,0 +1,33 @@ +package com.utopiaindustries.hseobservationsapp.utils; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; + +import androidx.viewpager.widget.ViewPager; + +/** + * Created by Development on 05-Oct-2021. + */ +public class NonSwipeableViewPager extends ViewPager +{ + public NonSwipeableViewPager(Context context) { + super(context); + } + + public NonSwipeableViewPager(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent event) { + // Never allow swiping to switch between pages + return false; + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + // Never allow swiping to switch between pages + return false; + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/utils/ProgressDialogFragment.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/utils/ProgressDialogFragment.java new file mode 100644 index 0000000..286aebc --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/utils/ProgressDialogFragment.java @@ -0,0 +1,37 @@ +package com.utopiaindustries.hseobservationsapp.utils; + +import android.content.DialogInterface; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; + +import com.utopiaindustries.hseobservationsapp.R; + +public class ProgressDialogFragment extends DialogFragment { + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.dialog_progress, container, false); + } + + @Override + public void onStart() { + super.onStart(); + if (getDialog() != null && getDialog().getWindow() != null) { + getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + getDialog().getWindow().setBackgroundDrawableResource(android.R.color.transparent); + } + } + + @Override + public void onCancel(@NonNull DialogInterface dialog) { + // Prevent the dialog from being canceled when touched outside + setCancelable(false); + } +} diff --git a/app/src/main/java/com/utopiaindustries/hseobservationsapp/viewmodels/LoginViewModel.java b/app/src/main/java/com/utopiaindustries/hseobservationsapp/viewmodels/LoginViewModel.java new file mode 100644 index 0000000..13400ad --- /dev/null +++ b/app/src/main/java/com/utopiaindustries/hseobservationsapp/viewmodels/LoginViewModel.java @@ -0,0 +1,80 @@ +package com.utopiaindustries.hseobservationsapp.viewmodels; + +import androidx.annotation.NonNull; +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +import com.utopiaindustries.hseobservationsapp.apiservice.ApiService; +import com.utopiaindustries.hseobservationsapp.apiservice.ApiServiceFactory; +import com.utopiaindustries.hseobservationsapp.models.QualityControlResponse; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class LoginViewModel extends ViewModel { + + private MutableLiveData userLiveData; + private MutableLiveData userLoginLiveData; + private MutableLiveData errorLiveData; + private MutableLiveData isLoading; + private ApiService apiService; + + public LoginViewModel() { + apiService = ApiServiceFactory.getApiService(); + userLiveData = new MutableLiveData<>(); + userLoginLiveData = new MutableLiveData<>(); + errorLiveData = new MutableLiveData<>(); + isLoading = new MutableLiveData<>(); + } + + public LiveData getUserLiveData() { + return userLiveData; + } + + public LiveData getLoadingState() { + + return isLoading; + } + + public LiveData getErrorMessage() { + return errorLiveData; + } + + public void isUserAuthenticated(String username, String password, String[] roles) { + isLoading.setValue(true); + apiService.isUserAuthenticated(username, password, roles).enqueue(new Callback() { + @Override + public void onResponse(@NonNull Call call, @NonNull Response response) { + isLoading.setValue(false); + //Log.e("onResponse-1: ", "Successful: "+response); + if (response.isSuccessful() && response.body() != null) { + //Log.e("onResponse-2: ", "Successful: "+response); + userLoginLiveData.setValue(response.body()); + } else { + userLoginLiveData.setValue(false); + } + } + + @Override + public void onFailure(@NonNull Call call, @NonNull Throwable t) { + //Log.e("onResponse-2: ", "failed"+t.getMessage()); + isLoading.setValue(false); + errorLiveData.setValue(t.getMessage()); + } + }); + } + + public LiveData getLoginUser() { + return userLoginLiveData; + } + + public LiveData getUser() { + return userLiveData; + } + + public LiveData getError() { + return errorLiveData; + } +} diff --git a/app/src/main/res/anim/bs_list_layout_fade_in.xml b/app/src/main/res/anim/bs_list_layout_fade_in.xml new file mode 100644 index 0000000..f967280 --- /dev/null +++ b/app/src/main/res/anim/bs_list_layout_fade_in.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fade_in.xml b/app/src/main/res/anim/fade_in.xml new file mode 100644 index 0000000..e27221b --- /dev/null +++ b/app/src/main/res/anim/fade_in.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fade_out.xml b/app/src/main/res/anim/fade_out.xml new file mode 100644 index 0000000..4ebd4e2 --- /dev/null +++ b/app/src/main/res/anim/fade_out.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/grow_from_bottom.xml b/app/src/main/res/anim/grow_from_bottom.xml new file mode 100644 index 0000000..be9e03a --- /dev/null +++ b/app/src/main/res/anim/grow_from_bottom.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/grow_from_top.xml b/app/src/main/res/anim/grow_from_top.xml new file mode 100644 index 0000000..16c36e8 --- /dev/null +++ b/app/src/main/res/anim/grow_from_top.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..e311d4b --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,8 @@ + + + + diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..d90ef50 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,8 @@ + + + + diff --git a/app/src/main/res/anim/slide_down.xml b/app/src/main/res/anim/slide_down.xml new file mode 100644 index 0000000..be798a9 --- /dev/null +++ b/app/src/main/res/anim/slide_down.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in_bottom.xml b/app/src/main/res/anim/slide_in_bottom.xml new file mode 100644 index 0000000..ae4e011 --- /dev/null +++ b/app/src/main/res/anim/slide_in_bottom.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in_left.xml b/app/src/main/res/anim/slide_in_left.xml new file mode 100644 index 0000000..44e6eb9 --- /dev/null +++ b/app/src/main/res/anim/slide_in_left.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in_left_menu.xml b/app/src/main/res/anim/slide_in_left_menu.xml new file mode 100644 index 0000000..bc4f72c --- /dev/null +++ b/app/src/main/res/anim/slide_in_left_menu.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in_right.xml b/app/src/main/res/anim/slide_in_right.xml new file mode 100644 index 0000000..740308b --- /dev/null +++ b/app/src/main/res/anim/slide_in_right.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in_right_menu.xml b/app/src/main/res/anim/slide_in_right_menu.xml new file mode 100644 index 0000000..bb153b3 --- /dev/null +++ b/app/src/main/res/anim/slide_in_right_menu.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in_top.xml b/app/src/main/res/anim/slide_in_top.xml new file mode 100644 index 0000000..a608380 --- /dev/null +++ b/app/src/main/res/anim/slide_in_top.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_out_bottom.xml b/app/src/main/res/anim/slide_out_bottom.xml new file mode 100644 index 0000000..46b3bf1 --- /dev/null +++ b/app/src/main/res/anim/slide_out_bottom.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/app/src/main/res/anim/slide_out_left.xml b/app/src/main/res/anim/slide_out_left.xml new file mode 100644 index 0000000..4db9289 --- /dev/null +++ b/app/src/main/res/anim/slide_out_left.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_out_right.xml b/app/src/main/res/anim/slide_out_right.xml new file mode 100644 index 0000000..73e7bfc --- /dev/null +++ b/app/src/main/res/anim/slide_out_right.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_out_top.xml b/app/src/main/res/anim/slide_out_top.xml new file mode 100644 index 0000000..6d813cd --- /dev/null +++ b/app/src/main/res/anim/slide_out_top.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_up.xml b/app/src/main/res/anim/slide_up.xml new file mode 100644 index 0000000..57f2be5 --- /dev/null +++ b/app/src/main/res/anim/slide_up.xml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/arrow_back.xml b/app/src/main/res/drawable/arrow_back.xml new file mode 100644 index 0000000..7b7c7d0 --- /dev/null +++ b/app/src/main/res/drawable/arrow_back.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/curved_layout.xml b/app/src/main/res/drawable/curved_layout.xml new file mode 100644 index 0000000..0306638 --- /dev/null +++ b/app/src/main/res/drawable/curved_layout.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/custom_button.xml b/app/src/main/res/drawable/custom_button.xml new file mode 100644 index 0000000..151887f --- /dev/null +++ b/app/src/main/res/drawable/custom_button.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/drawable/dropdown_item_bg.xml b/app/src/main/res/drawable/dropdown_item_bg.xml new file mode 100644 index 0000000..16b011c --- /dev/null +++ b/app/src/main/res/drawable/dropdown_item_bg.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/et_border.xml b/app/src/main/res/drawable/et_border.xml new file mode 100644 index 0000000..28504f7 --- /dev/null +++ b/app/src/main/res/drawable/et_border.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/app/src/main/res/drawable/et_border_dropdown.xml b/app/src/main/res/drawable/et_border_dropdown.xml new file mode 100644 index 0000000..d8998b5 --- /dev/null +++ b/app/src/main/res/drawable/et_border_dropdown.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/app/src/main/res/drawable/hse.png b/app/src/main/res/drawable/hse.png new file mode 100644 index 0000000..10912a0 Binary files /dev/null and b/app/src/main/res/drawable/hse.png differ diff --git a/app/src/main/res/drawable/ic_delete.xml b/app/src/main/res/drawable/ic_delete.xml new file mode 100644 index 0000000..883bcaa --- /dev/null +++ b/app/src/main/res/drawable/ic_delete.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_email.xml b/app/src/main/res/drawable/ic_email.xml new file mode 100644 index 0000000..4c104e9 --- /dev/null +++ b/app/src/main/res/drawable/ic_email.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_logout.xml b/app/src/main/res/drawable/ic_logout.xml new file mode 100644 index 0000000..bf421c2 --- /dev/null +++ b/app/src/main/res/drawable/ic_logout.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_password.xml b/app/src/main/res/drawable/ic_password.xml new file mode 100644 index 0000000..1813549 --- /dev/null +++ b/app/src/main/res/drawable/ic_password.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/icon_home.png b/app/src/main/res/drawable/icon_home.png new file mode 100644 index 0000000..c81b39a Binary files /dev/null and b/app/src/main/res/drawable/icon_home.png differ diff --git a/app/src/main/res/drawable/icon_hse.png b/app/src/main/res/drawable/icon_hse.png new file mode 100644 index 0000000..a2d1d1f Binary files /dev/null and b/app/src/main/res/drawable/icon_hse.png differ diff --git a/app/src/main/res/drawable/icon_tab_drafts.xml b/app/src/main/res/drawable/icon_tab_drafts.xml new file mode 100644 index 0000000..2b728d0 --- /dev/null +++ b/app/src/main/res/drawable/icon_tab_drafts.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/icon_tab_home.xml b/app/src/main/res/drawable/icon_tab_home.xml new file mode 100644 index 0000000..a1cb4ef --- /dev/null +++ b/app/src/main/res/drawable/icon_tab_home.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/image_picker.xml b/app/src/main/res/drawable/image_picker.xml new file mode 100644 index 0000000..fd890ce --- /dev/null +++ b/app/src/main/res/drawable/image_picker.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/img_load.xml b/app/src/main/res/drawable/img_load.xml new file mode 100644 index 0000000..2102567 --- /dev/null +++ b/app/src/main/res/drawable/img_load.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/app/src/main/res/drawable/rounded_border.xml b/app/src/main/res/drawable/rounded_border.xml new file mode 100644 index 0000000..db35694 --- /dev/null +++ b/app/src/main/res/drawable/rounded_border.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_btn_login.xml b/app/src/main/res/drawable/rounded_btn_login.xml new file mode 100644 index 0000000..0e174d6 --- /dev/null +++ b/app/src/main/res/drawable/rounded_btn_login.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_white.xml b/app/src/main/res/drawable/rounded_white.xml new file mode 100644 index 0000000..6072ca7 --- /dev/null +++ b/app/src/main/res/drawable/rounded_white.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/wave_4_.xml b/app/src/main/res/drawable/wave_4_.xml new file mode 100644 index 0000000..01a16b0 --- /dev/null +++ b/app/src/main/res/drawable/wave_4_.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_dashboard.xml b/app/src/main/res/layout/activity_dashboard.xml new file mode 100644 index 0000000..d1ec7fd --- /dev/null +++ b/app/src/main/res/layout/activity_dashboard.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..f91becd --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + +