| @ -0,0 +1,13 @@ | |||
| *.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 | |||
| @ -0,0 +1,3 @@ | |||
| # Default ignored files | |||
| /shelf/ | |||
| /workspace.xml | |||
| @ -0,0 +1,6 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project version="4"> | |||
| <component name="AppInsightsSettings"> | |||
| <option name="selectedTabId" value="Firebase Crashlytics" /> | |||
| </component> | |||
| </project> | |||
| @ -0,0 +1,116 @@ | |||
| <component name="ProjectCodeStyleConfiguration"> | |||
| <code_scheme name="Project" version="173"> | |||
| <codeStyleSettings language="XML"> | |||
| <indentOptions> | |||
| <option name="CONTINUATION_INDENT_SIZE" value="4" /> | |||
| </indentOptions> | |||
| <arrangement> | |||
| <rules> | |||
| <section> | |||
| <rule> | |||
| <match> | |||
| <AND> | |||
| <NAME>xmlns:android</NAME> | |||
| <XML_ATTRIBUTE /> | |||
| <XML_NAMESPACE>^$</XML_NAMESPACE> | |||
| </AND> | |||
| </match> | |||
| </rule> | |||
| </section> | |||
| <section> | |||
| <rule> | |||
| <match> | |||
| <AND> | |||
| <NAME>xmlns:.*</NAME> | |||
| <XML_ATTRIBUTE /> | |||
| <XML_NAMESPACE>^$</XML_NAMESPACE> | |||
| </AND> | |||
| </match> | |||
| <order>BY_NAME</order> | |||
| </rule> | |||
| </section> | |||
| <section> | |||
| <rule> | |||
| <match> | |||
| <AND> | |||
| <NAME>.*:id</NAME> | |||
| <XML_ATTRIBUTE /> | |||
| <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> | |||
| </AND> | |||
| </match> | |||
| </rule> | |||
| </section> | |||
| <section> | |||
| <rule> | |||
| <match> | |||
| <AND> | |||
| <NAME>.*:name</NAME> | |||
| <XML_ATTRIBUTE /> | |||
| <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> | |||
| </AND> | |||
| </match> | |||
| </rule> | |||
| </section> | |||
| <section> | |||
| <rule> | |||
| <match> | |||
| <AND> | |||
| <NAME>name</NAME> | |||
| <XML_ATTRIBUTE /> | |||
| <XML_NAMESPACE>^$</XML_NAMESPACE> | |||
| </AND> | |||
| </match> | |||
| </rule> | |||
| </section> | |||
| <section> | |||
| <rule> | |||
| <match> | |||
| <AND> | |||
| <NAME>style</NAME> | |||
| <XML_ATTRIBUTE /> | |||
| <XML_NAMESPACE>^$</XML_NAMESPACE> | |||
| </AND> | |||
| </match> | |||
| </rule> | |||
| </section> | |||
| <section> | |||
| <rule> | |||
| <match> | |||
| <AND> | |||
| <NAME>.*</NAME> | |||
| <XML_ATTRIBUTE /> | |||
| <XML_NAMESPACE>^$</XML_NAMESPACE> | |||
| </AND> | |||
| </match> | |||
| <order>BY_NAME</order> | |||
| </rule> | |||
| </section> | |||
| <section> | |||
| <rule> | |||
| <match> | |||
| <AND> | |||
| <NAME>.*</NAME> | |||
| <XML_ATTRIBUTE /> | |||
| <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> | |||
| </AND> | |||
| </match> | |||
| <order>ANDROID_ATTRIBUTE_ORDER</order> | |||
| </rule> | |||
| </section> | |||
| <section> | |||
| <rule> | |||
| <match> | |||
| <AND> | |||
| <NAME>.*</NAME> | |||
| <XML_ATTRIBUTE /> | |||
| <XML_NAMESPACE>.*</XML_NAMESPACE> | |||
| </AND> | |||
| </match> | |||
| <order>BY_NAME</order> | |||
| </rule> | |||
| </section> | |||
| </rules> | |||
| </arrangement> | |||
| </codeStyleSettings> | |||
| </code_scheme> | |||
| </component> | |||
| @ -0,0 +1,6 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project version="4"> | |||
| <component name="CompilerConfiguration"> | |||
| <bytecodeTargetLevel target="17" /> | |||
| </component> | |||
| </project> | |||
| @ -0,0 +1,18 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project version="4"> | |||
| <component name="deploymentTargetSelector"> | |||
| <selectionStates> | |||
| <SelectionState runConfigName="app"> | |||
| <option name="selectionMode" value="DROPDOWN" /> | |||
| <DropdownSelection timestamp="2024-05-21T20:26:20.917717500Z"> | |||
| <Target type="DEFAULT_BOOT"> | |||
| <handle> | |||
| <DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\dolivaresr\.android\avd\Pixel_7_API_30.avd" /> | |||
| </handle> | |||
| </Target> | |||
| </DropdownSelection> | |||
| <DialogSelection /> | |||
| </SelectionState> | |||
| </selectionStates> | |||
| </component> | |||
| </project> | |||
| @ -0,0 +1,4 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project version="4"> | |||
| <component name="Encoding" addBOMForNewFiles="with NO BOM" /> | |||
| </project> | |||
| @ -0,0 +1,19 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project version="4"> | |||
| <component name="GradleMigrationSettings" migrationVersion="1" /> | |||
| <component name="GradleSettings"> | |||
| <option name="linkedExternalProjectsSettings"> | |||
| <GradleProjectSettings> | |||
| <option name="externalProjectPath" value="$PROJECT_DIR$" /> | |||
| <option name="gradleJvm" value="#JAVA_HOME" /> | |||
| <option name="modules"> | |||
| <set> | |||
| <option value="$PROJECT_DIR$" /> | |||
| <option value="$PROJECT_DIR$/app" /> | |||
| </set> | |||
| </option> | |||
| <option name="resolveExternalAnnotations" value="false" /> | |||
| </GradleProjectSettings> | |||
| </option> | |||
| </component> | |||
| </project> | |||
| @ -0,0 +1,35 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project version="4"> | |||
| <component name="RemoteRepositoriesConfiguration"> | |||
| <remote-repository> | |||
| <option name="id" value="central" /> | |||
| <option name="name" value="Maven Central repository" /> | |||
| <option name="url" value="https://repo1.maven.org/maven2" /> | |||
| </remote-repository> | |||
| <remote-repository> | |||
| <option name="id" value="jboss.community" /> | |||
| <option name="name" value="JBoss Community repository" /> | |||
| <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> | |||
| </remote-repository> | |||
| <remote-repository> | |||
| <option name="id" value="BintrayJCenter" /> | |||
| <option name="name" value="BintrayJCenter" /> | |||
| <option name="url" value="https://jcenter.bintray.com/" /> | |||
| </remote-repository> | |||
| <remote-repository> | |||
| <option name="id" value="Google" /> | |||
| <option name="name" value="Google" /> | |||
| <option name="url" value="https://dl.google.com/dl/android/maven2/" /> | |||
| </remote-repository> | |||
| <remote-repository> | |||
| <option name="id" value="MavenRepo" /> | |||
| <option name="name" value="MavenRepo" /> | |||
| <option name="url" value="https://repo.maven.apache.org/maven2/" /> | |||
| </remote-repository> | |||
| <remote-repository> | |||
| <option name="id" value="maven" /> | |||
| <option name="name" value="maven" /> | |||
| <option name="url" value="http://dl.bintray.com/journeyapps/maven" /> | |||
| </remote-repository> | |||
| </component> | |||
| </project> | |||
| @ -0,0 +1,13 @@ | |||
| <project version="4"> | |||
| <component name="CMakeSettings"> | |||
| <configurations> | |||
| <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" /> | |||
| </configurations> | |||
| </component> | |||
| <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK"> | |||
| <output url="file://$PROJECT_DIR$/build/classes" /> | |||
| </component> | |||
| <component name="ProjectType"> | |||
| <option name="id" value="Android" /> | |||
| </component> | |||
| </project> | |||
| @ -0,0 +1 @@ | |||
| /build | |||
| @ -0,0 +1,72 @@ | |||
| apply plugin: 'com.android.application' | |||
| android { | |||
| namespace 'jumapacelaya.gob.mx.almacen' | |||
| compileSdk 34 | |||
| defaultConfig { | |||
| applicationId "jumapacelaya.gob.mx.almacen" | |||
| minSdkVersion 23 | |||
| targetSdkVersion 33 | |||
| versionCode 1 | |||
| versionName "1.0" | |||
| testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' | |||
| } | |||
| buildTypes { | |||
| release { | |||
| minifyEnabled false | |||
| proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | |||
| signingConfig signingConfigs.debug | |||
| } | |||
| } | |||
| compileOptions { | |||
| sourceCompatibility = 11 | |||
| targetCompatibility = 11 | |||
| } | |||
| } | |||
| repositories { | |||
| mavenCentral() | |||
| maven { | |||
| url "http://dl.bintray.com/journeyapps/maven" | |||
| allowInsecureProtocol = true | |||
| } | |||
| } | |||
| dependencies { | |||
| implementation fileTree(dir: 'libs', include: ['*.jar']) | |||
| implementation 'androidx.appcompat:appcompat:1.6.1' | |||
| implementation 'com.google.android.material:material:1.12.0' | |||
| implementation 'androidx.recyclerview:recyclerview:1.3.2' | |||
| implementation 'androidx.cardview:cardview:1.0.0' | |||
| implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | |||
| implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' | |||
| implementation 'com.google.code.gson:gson:2.10.1' | |||
| implementation 'com.android.volley:volley:1.2.1' | |||
| implementation 'androidx.room:room-runtime:2.6.1' | |||
| implementation 'androidx.legacy:legacy-support-v4:1.0.0' | |||
| annotationProcessor 'androidx.room:room-compiler:2.6.1' | |||
| implementation('com.journeyapps:zxing-android-embedded:3.6.0') { transitive = false } | |||
| implementation 'com.google.zxing:core:3.3.2' | |||
| testImplementation 'junit:junit:4.13.2' | |||
| androidTestImplementation 'androidx.test.ext:junit:1.1.5' | |||
| androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | |||
| implementation 'androidx.core:core:1.13.1' | |||
| implementation 'com.daimajia.easing:library:2.0@aar' | |||
| implementation 'com.daimajia.androidanimations:library:2.3@aar' | |||
| implementation "androidx.compose.material3:material3:1.2.1" | |||
| implementation 'com.squareup.retrofit2:retrofit:2.9.0' | |||
| implementation 'com.squareup.retrofit2:converter-gson:2.9.0' | |||
| implementation 'com.google.code.gson:gson:2.10.1' | |||
| } | |||
| @ -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 | |||
| @ -0,0 +1,73 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| > | |||
| <uses-feature | |||
| android:name="android.hardware.camera" | |||
| android:required="false" /> | |||
| <uses-permission android:name="android.permission.CAMERA" /> | |||
| <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |||
| <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |||
| <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |||
| <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> | |||
| <uses-permission android:name="android.permission.INTERNET" /> | |||
| <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |||
| <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | |||
| <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | |||
| <uses-permission android:name="android.permission.READ_PROFILE" /> | |||
| <uses-permission android:name="android.permission.READ_CONTACTS" /> | |||
| <uses-permission android:name="android.permission.RECORD_AUDIO" /> | |||
| <application | |||
| android:allowBackup="true" | |||
| android:icon="@drawable/logo_circle" | |||
| android:label="@string/app_name" | |||
| android:usesCleartextTraffic="true" | |||
| android:roundIcon="@drawable/logo_circle" | |||
| android:supportsRtl="true" | |||
| android:hardwareAccelerated="true" | |||
| android:theme="@style/AppTheme"> | |||
| <activity android:name=".ConteoActivity" /> | |||
| <activity | |||
| android:name=".splash" | |||
| android:exported="true" | |||
| android:theme="@style/Theme.Material3.Light.NoActionBar.FullScreen"> | |||
| <intent-filter> | |||
| <action android:name="android.intent.action.MAIN" /> | |||
| <category android:name="android.intent.category.LAUNCHER" /> | |||
| </intent-filter> | |||
| </activity> | |||
| <activity | |||
| android:name=".MainActivity" | |||
| android:windowSoftInputMode="adjustResize" | |||
| android:configChanges="orientation|screenSize|keyboardHidden" | |||
| android:theme="@style/Theme.Material3.Light.NoActionBar" /> | |||
| <activity | |||
| android:name="com.journeyapps.barcodescanner.CaptureActivity" | |||
| android:screenOrientation="fullSensor" | |||
| tools:replace="screenOrientation" /> | |||
| <provider | |||
| android:name="androidx.core.content.FileProvider" | |||
| android:authorities="${applicationId}.provider" | |||
| android:exported="false" | |||
| android:grantUriPermissions="true"> | |||
| <meta-data | |||
| android:name="android.support.FILE_PROVIDER_PATHS" | |||
| android:resource="@xml/file_paths" /> | |||
| </provider> | |||
| </application> | |||
| </manifest> | |||
| @ -0,0 +1,635 @@ | |||
| package jumapacelaya.gob.mx.almacen; | |||
| import android.Manifest; | |||
| import android.app.ActivityOptions; | |||
| import android.content.Intent; | |||
| import android.content.pm.PackageManager; | |||
| import android.os.AsyncTask; | |||
| import androidx.annotation.NonNull; | |||
| import androidx.constraintlayout.widget.ConstraintLayout; | |||
| import androidx.core.app.ActivityCompat; | |||
| import androidx.appcompat.app.AppCompatActivity; | |||
| import android.os.Bundle; | |||
| import android.os.Handler; | |||
| import android.os.Looper; | |||
| import android.provider.Settings; | |||
| import android.telephony.TelephonyManager; | |||
| import android.util.Log; | |||
| import android.view.Menu; | |||
| import android.view.MenuInflater; | |||
| import android.view.MenuItem; | |||
| import android.view.View; | |||
| import android.widget.AdapterView; | |||
| import android.widget.ArrayAdapter; | |||
| import android.widget.Button; | |||
| import android.widget.Spinner; | |||
| import android.widget.TextView; | |||
| import android.widget.Toast; | |||
| import com.android.volley.AuthFailureError; | |||
| import com.android.volley.Request; | |||
| import com.android.volley.RequestQueue; | |||
| import com.android.volley.Response; | |||
| import com.android.volley.VolleyError; | |||
| import com.android.volley.toolbox.JsonObjectRequest; | |||
| import com.android.volley.toolbox.Volley; | |||
| import com.google.gson.Gson; | |||
| import com.google.gson.GsonBuilder; | |||
| import com.google.gson.reflect.TypeToken; | |||
| import org.json.JSONArray; | |||
| import org.json.JSONException; | |||
| import org.json.JSONObject; | |||
| import java.io.Serializable; | |||
| import java.lang.reflect.Type; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.concurrent.ExecutorService; | |||
| import java.util.concurrent.Executors; | |||
| import jumapacelaya.gob.mx.almacen.bean.Conteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.Inventario; | |||
| import jumapacelaya.gob.mx.almacen.dao.AppDatabase; | |||
| import jumapacelaya.gob.mx.almacen.dao.inventarioDao; | |||
| import jumapacelaya.gob.mx.almacen.request.DetalleRequest; | |||
| import jumapacelaya.gob.mx.almacen.ui.main.Constant; | |||
| import retrofit2.Call; | |||
| import retrofit2.Callback; | |||
| import retrofit2.Retrofit; | |||
| import retrofit2.converter.gson.GsonConverterFactory; | |||
| public class ConteoActivity extends AppCompatActivity { | |||
| ConstraintLayout root_conteo_layout; | |||
| Spinner cbxConteo; | |||
| Spinner cbxInventarios; | |||
| TextView lbtitle; | |||
| Button btniniciar; | |||
| String imei; | |||
| private final int MY_PERMISSIONS_REQUEST_STATUS = 80; | |||
| inventarioDao database; | |||
| ArrayAdapter<Conteo> dataAdapter; | |||
| ArrayAdapter<Inventario> dataAdapterinv; | |||
| @Override | |||
| protected void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| setContentView(R.layout.activity_conteo); | |||
| root_conteo_layout = findViewById(R.id.root_conteo_layout); | |||
| cbxConteo = findViewById(R.id.cbxConteos); | |||
| cbxInventarios = findViewById(R.id.cbxInventarios); | |||
| lbtitle = findViewById(R.id.lbConteo); | |||
| btniniciar = findViewById(R.id.btnIniciar); | |||
| database = AppDatabase.getAppDatabaseDB(getApplicationContext()).inventarioDao(); | |||
| /*android.support.v7.app.ActionBar actionBar = getSupportActionBar(); | |||
| if (actionBar != null) { | |||
| actionBar.setBackgroundDrawable(new ColorDrawable(R.drawable.gradient_fondo)); | |||
| actionBar.setElevation(0); | |||
| //Activar Flecha atras | |||
| //actionBar.setDisplayHomeAsUpEnabled(true); | |||
| //actionBar.setTitle("Predio :" + predioLectura.getPredioid()); | |||
| }*/ | |||
| /*AnimationDrawable animDrawable = (AnimationDrawable) root_conteo_layout.getBackground(); | |||
| animDrawable.setEnterFadeDuration(10); | |||
| animDrawable.setExitFadeDuration(5000); | |||
| animDrawable.start();*/ | |||
| btniniciar.setOnClickListener(e -> { | |||
| if(cbxConteo.getSelectedItem() != null) | |||
| ConteoActivity.this.onClick(e); | |||
| }); | |||
| cbxInventarios.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | |||
| @Override | |||
| public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { | |||
| Inventario inv = (Inventario) adapterView.getSelectedItem(); | |||
| mostrarConteo(inv.getInventariopk()); | |||
| } | |||
| @Override | |||
| public void onNothingSelected(AdapterView<?> adapterView) { | |||
| } | |||
| }); | |||
| cargarPreferencias(); | |||
| } | |||
| private void onClick(View view){ | |||
| //Obtenemos los articulo para el conteo desde DB | |||
| loadArticulosConteo( ((Inventario)cbxInventarios.getSelectedItem()).getInventariopk()); | |||
| Conteo c= (Conteo) cbxConteo.getSelectedItem(); | |||
| Intent intent = new Intent(ConteoActivity.this, MainActivity.class); | |||
| intent.putExtra(Constant.CONTEODET,(Serializable) c); | |||
| startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(ConteoActivity.this).toBundle()); | |||
| } | |||
| @Override | |||
| protected void onStart() { | |||
| super.onStart(); | |||
| cargarPreferencias(); | |||
| mostrarInventarios(); | |||
| } | |||
| @Override | |||
| public boolean onCreateOptionsMenu(Menu menu) { | |||
| MenuInflater inflater = getMenuInflater(); | |||
| inflater.inflate(R.menu.menu_reload, menu); | |||
| return true; | |||
| } | |||
| @Override | |||
| public boolean onOptionsItemSelected(MenuItem item) { | |||
| int id = item.getItemId(); | |||
| int idxml = R.id.action_reload; | |||
| if (id == idxml) { | |||
| mostrarInventarios(); | |||
| return true; | |||
| } | |||
| return true; | |||
| } | |||
| private void cargarPreferencias() { | |||
| imei = getIMEI(); | |||
| } | |||
| private void mostrarInventarios(){ | |||
| JSONObject jsonObject = new JSONObject(); | |||
| if (imei != null) { | |||
| try { | |||
| jsonObject.put("imei", getIMEI()); | |||
| JsonObjectRequest requestarr = new JsonObjectRequest(Request.Method.POST, restAlmacen.instance(this).URL_inventarios, jsonObject, | |||
| s -> { | |||
| try { | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| executor.execute(() -> { | |||
| String msg; | |||
| boolean flag; | |||
| try { | |||
| if (s.has("inventarios")) { | |||
| saveInventarios(s); | |||
| } else { | |||
| throw new Exception("no se encontro información de predios en la consulta"); | |||
| } | |||
| } catch (Exception ex) { | |||
| System.out.println(ex.getMessage()); | |||
| msg = ex.getMessage(); | |||
| flag = true; | |||
| } | |||
| handler.post(() -> { | |||
| loadComboboxInv(); | |||
| }); | |||
| }); | |||
| } catch (Exception e) { | |||
| Toast.makeText(ConteoActivity.this, "Incorrect Details", Toast.LENGTH_LONG).show(); | |||
| loadComboboxInv(); | |||
| } | |||
| }, | |||
| new Response.ErrorListener() { | |||
| @Override | |||
| public void onErrorResponse(VolleyError error) { | |||
| if(error.getMessage() == null) { | |||
| if(error.networkResponse != null){ | |||
| try { | |||
| if (error.networkResponse.headers.containsKey("Content-Type") && error.networkResponse.headers.get("Content-Type").equals("application/json")) | |||
| { | |||
| JSONObject json = new JSONObject(new String(error.networkResponse.data)); | |||
| Toast.makeText(getApplicationContext(), json.getString("message"), Toast.LENGTH_LONG).show(); | |||
| }else{ | |||
| Toast.makeText(getApplicationContext(), "Metodo no Permitido, " + error.networkResponse.headers.get("X-Android-Response-Source"), Toast.LENGTH_LONG).show(); | |||
| } | |||
| } catch (JSONException e) { | |||
| Toast.makeText(getApplicationContext(), "Unable to connect to server, try again later", Toast.LENGTH_LONG).show(); | |||
| } | |||
| }else { | |||
| Toast.makeText(getApplicationContext(), "Unable to connect to server, try again later", Toast.LENGTH_LONG).show(); | |||
| } | |||
| }else{ | |||
| Log.d("Volley Error:", "Volley Error:" + (error.getMessage() == null?"": error.getMessage()) + ", Code:" + (error.networkResponse == null? "": error.networkResponse.statusCode) ); | |||
| if(error.networkResponse != null) { | |||
| switch (error.networkResponse.statusCode) { | |||
| case 401: | |||
| Toast.makeText(getApplicationContext(), "No tiene permiso para realizar esta operación", Toast.LENGTH_LONG).show(); | |||
| break; | |||
| case 404: | |||
| Toast.makeText(getApplicationContext(), "Servicio tiene Errores para la Solicitud.", Toast.LENGTH_LONG).show(); | |||
| break; | |||
| default: | |||
| Toast.makeText(getApplicationContext(), "Unable to connect to server. codigo :" + error.networkResponse.statusCode, Toast.LENGTH_LONG).show(); | |||
| } | |||
| }else{ | |||
| Toast.makeText(getApplicationContext(), (error.getMessage() == null?"Unable to connect to server": error.getMessage()) , Toast.LENGTH_LONG).show(); | |||
| } | |||
| } | |||
| //cargar informacion db si existe en el spinner | |||
| loadComboboxInv(); | |||
| } | |||
| }); | |||
| RequestQueue rQueue = Volley.newRequestQueue(ConteoActivity.this); | |||
| rQueue.add(requestarr); | |||
| } catch (JSONException e) { | |||
| Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); | |||
| loadComboboxInv(); | |||
| } | |||
| } else { | |||
| Toast.makeText(getApplicationContext(), "No se tiene permiso para obtener informacion sin IMEI", Toast.LENGTH_LONG).show(); | |||
| } | |||
| } | |||
| private void mostrarConteo(final int inventariopk){ | |||
| JSONObject jsonObject = new JSONObject(); | |||
| if (imei != null) { | |||
| try { | |||
| jsonObject.put("imei", getIMEI()); | |||
| jsonObject.put("inventariopk", inventariopk); | |||
| JsonObjectRequest requestarr = new JsonObjectRequest(Request.Method.POST, restAlmacen.instance(this).URL_conteos, jsonObject, | |||
| s -> { | |||
| try { | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| executor.execute(() -> { | |||
| String msg; | |||
| boolean flag; | |||
| try { | |||
| if (s.has("conteos")) { | |||
| saveConteos(s); | |||
| } else { | |||
| throw new Exception("no se encontro información de predios en la consulta"); | |||
| } | |||
| } catch (Exception ex) { | |||
| System.out.println(ex.getMessage()); | |||
| msg = ex.getMessage(); | |||
| flag = true; | |||
| } | |||
| handler.post(() -> { | |||
| loadCombobox(inventariopk); | |||
| }); | |||
| }); | |||
| } catch (Exception e) { | |||
| Toast.makeText(ConteoActivity.this, "Incorrect Details", Toast.LENGTH_LONG).show(); | |||
| loadCombobox(inventariopk); | |||
| } | |||
| }, | |||
| new Response.ErrorListener() { | |||
| @Override | |||
| public void onErrorResponse(VolleyError error) { | |||
| if(error.getMessage() == null) { | |||
| if(error.networkResponse != null){ | |||
| try { | |||
| if (error.networkResponse.headers.containsKey("Content-Type") && error.networkResponse.headers.get("Content-Type").equals("application/json")) | |||
| { | |||
| JSONObject json = new JSONObject(new String(error.networkResponse.data)); | |||
| Toast.makeText(getApplicationContext(), json.getString("message"), Toast.LENGTH_LONG).show(); | |||
| }else{ | |||
| Toast.makeText(getApplicationContext(), "Metodo no Permitido, " + error.networkResponse.headers.get("X-Android-Response-Source"), Toast.LENGTH_LONG).show(); | |||
| } | |||
| } catch (JSONException e) { | |||
| Toast.makeText(getApplicationContext(), "Unable to connect to server, try again later", Toast.LENGTH_LONG).show(); | |||
| } | |||
| }else { | |||
| Toast.makeText(getApplicationContext(), "Unable to connect to server, try again later", Toast.LENGTH_LONG).show(); | |||
| } | |||
| }else{ | |||
| Log.d("Volley Error:", "Volley Error:" + (error.getMessage() == null?"": error.getMessage()) + ", Code:" + (error.networkResponse == null? "": error.networkResponse.statusCode) ); | |||
| if(error.networkResponse != null) { | |||
| switch (error.networkResponse.statusCode) { | |||
| case 401: | |||
| Toast.makeText(getApplicationContext(), "No tiene permiso para realizar esta operación", Toast.LENGTH_LONG).show(); | |||
| break; | |||
| case 404: | |||
| Toast.makeText(getApplicationContext(), "Servicio tiene Errores para la Solicitud.", Toast.LENGTH_LONG).show(); | |||
| break; | |||
| default: | |||
| Toast.makeText(getApplicationContext(), "Unable to connect to server. codigo :" + error.networkResponse.statusCode, Toast.LENGTH_LONG).show(); | |||
| } | |||
| }else{ | |||
| Toast.makeText(getApplicationContext(), (error.getMessage() == null?"Unable to connect to server": error.getMessage()) , Toast.LENGTH_LONG).show(); | |||
| } | |||
| } | |||
| //cargar informacion db si existe en el spinner | |||
| loadCombobox(inventariopk); | |||
| } | |||
| }); | |||
| RequestQueue rQueue = Volley.newRequestQueue(ConteoActivity.this); | |||
| rQueue.add(requestarr); | |||
| } catch (JSONException e) { | |||
| Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); | |||
| loadCombobox(inventariopk); | |||
| } | |||
| } else { | |||
| Toast.makeText(getApplicationContext(), "No se tiene permiso para obtener informacion sin IMEI", Toast.LENGTH_LONG).show(); | |||
| } | |||
| } | |||
| private void loadCombobox(int inventarioPk) { | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| executor.execute(() -> { | |||
| //Background work here | |||
| String msg; | |||
| boolean flag; | |||
| List<Conteo> db = null; | |||
| //load database data | |||
| try { | |||
| //load database data | |||
| db = database.listInventariosInv(inventarioPk); | |||
| } catch (Exception ex) { | |||
| System.out.println(ex.getMessage()); | |||
| msg = ex.getMessage(); | |||
| flag = true; | |||
| } | |||
| List<Conteo> finalDb = db; | |||
| handler.post(() -> { | |||
| if(finalDb != null) { | |||
| // Creating adapter for spinner | |||
| dataAdapter = new ArrayAdapter<Conteo>(ConteoActivity.this, | |||
| android.R.layout.simple_spinner_item, finalDb); | |||
| dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | |||
| // attaching data adapter to spinner | |||
| cbxConteo.setAdapter(dataAdapter); | |||
| } | |||
| }); | |||
| }); | |||
| } | |||
| private void loadComboboxInv() { | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| executor.execute(() -> { | |||
| //Background work here | |||
| String msg; | |||
| boolean flag; | |||
| List<Inventario> db = null; | |||
| //load database data | |||
| try { | |||
| //load database data | |||
| db = database.listInventariosActivos(); | |||
| } catch (Exception ex) { | |||
| System.out.println(ex.getMessage()); | |||
| msg = ex.getMessage(); | |||
| flag = true; | |||
| } | |||
| List<Inventario> finalDb = db; | |||
| handler.post(() -> { | |||
| if(finalDb != null) { | |||
| // Creating adapter for spinner | |||
| dataAdapterinv = new ArrayAdapter<>(ConteoActivity.this, | |||
| android.R.layout.simple_spinner_item, finalDb); | |||
| dataAdapterinv.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | |||
| // attaching data adapter to spinner | |||
| cbxInventarios.setAdapter(dataAdapterinv); | |||
| if(cbxInventarios.getSelectedItem() != null) | |||
| loadCombobox(((Inventario)cbxInventarios.getSelectedItem()).getInventariopk() ); | |||
| } | |||
| }); | |||
| }); | |||
| } | |||
| private void saveConteos(JSONObject s) throws JSONException { | |||
| JSONArray jsonconteos = s.getJSONArray("conteos"); | |||
| final List<Conteo> l; | |||
| Type listType = new TypeToken<List<Conteo>>() { | |||
| }.getType(); | |||
| Gson gson= new GsonBuilder().setDateFormat("yyyy-MM-dd").create(); | |||
| l = gson.fromJson(jsonconteos.toString(), listType); | |||
| //insertar en lote desde el primer registro | |||
| if (l.size() >= 1) { | |||
| //conteos.clear(); | |||
| //si existe se borra la informacion | |||
| for (Conteo c : l) { | |||
| database.upsertConteo(c); | |||
| //conteos.add(c); | |||
| } | |||
| } | |||
| } | |||
| private void saveInventarios(JSONObject s) throws JSONException { | |||
| JSONArray jsoninventario = s.getJSONArray("inventarios"); | |||
| final List<Inventario> l; | |||
| Type listType = new TypeToken<List<Inventario>>() { | |||
| }.getType(); | |||
| Gson gson= new GsonBuilder().setDateFormat("dd/MM/yyyy").create(); | |||
| l = gson.fromJson(jsoninventario.toString(), listType); | |||
| //estado a C | |||
| database.updateInventarioN(); | |||
| //insertar en lote desde el primer registro | |||
| if (l.size() >= 1) { | |||
| //conteos.clear(); | |||
| //si existe se borra la informacion | |||
| for (Inventario c : l) { | |||
| database.upsertInventario(c); | |||
| //conteos.add(c); | |||
| } | |||
| } | |||
| } | |||
| public String getIMEI() { | |||
| String ID = Settings.Secure.getString(getContentResolver(), | |||
| Settings.Secure.ANDROID_ID); | |||
| return ID; | |||
| } | |||
| // | |||
| // Carga los articulos del conteo | |||
| private void loadArticulosConteo(final int inventarioPk){ | |||
| JSONObject jsonObject = new JSONObject(); | |||
| //Obtener el conteo seleccionado | |||
| Conteo conteo = (Conteo) cbxConteo.getSelectedItem(); | |||
| if (imei != null && conteo != null) { | |||
| // try { | |||
| /*jsonObject.put("imei", getIMEI()); | |||
| jsonObject.put("invanteriopk", inventarioPk); | |||
| jsonObject.put("conteopk", conteo.getConteopk()); | |||
| jsonObject.put("foliopk", 0);*/ | |||
| //RequestQueue rQueue = Volley.newRequestQueue(this); | |||
| Retrofit retrofit = new Retrofit.Builder() | |||
| .baseUrl(restAlmacen.instance(this).BASE_URL) | |||
| .addConverterFactory(GsonConverterFactory.create()) | |||
| .build(); | |||
| InventarioService postService = retrofit.create(InventarioService.class); | |||
| Call< List<DetalleConteo> > call = postService.getDetalleConteo(new DetalleRequest(getIMEI(), inventarioPk, conteo.getConteopk(), 0)); | |||
| call.enqueue(new Callback<>() { | |||
| @Override | |||
| public void onResponse(@NonNull Call<List<DetalleConteo>> call, @NonNull retrofit2.Response<List<DetalleConteo>> response) { | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| executor.execute(() -> { | |||
| String msg = ""; | |||
| boolean flag = false; | |||
| try { | |||
| if (response.body() != null) { | |||
| saveArticulosObj( response.body()); | |||
| } else { | |||
| throw new Exception("no se encontro información de inventario"); | |||
| } | |||
| } catch (Exception ex) { | |||
| System.out.println(ex.getMessage()); | |||
| msg = ex.getMessage(); | |||
| flag = true; | |||
| } | |||
| boolean finalFlag = flag; | |||
| String finalMsg = msg; | |||
| handler.post(() -> { | |||
| if (finalFlag) | |||
| Toast.makeText(ConteoActivity.this, finalMsg, Toast.LENGTH_LONG).show(); | |||
| }); | |||
| }); | |||
| } | |||
| @Override | |||
| public void onFailure(Call<List<DetalleConteo>> call, Throwable t) { | |||
| Toast.makeText(ConteoActivity.this, t.getMessage(), Toast.LENGTH_LONG).show(); | |||
| } | |||
| }); | |||
| } else { | |||
| Toast.makeText(getApplicationContext(), "No se tiene permiso para obtener informacion sin IMEI", Toast.LENGTH_LONG).show(); | |||
| } | |||
| } | |||
| private void saveArticulos(JSONObject s) throws JSONException { | |||
| JSONArray jsonconteos = s.getJSONArray("inventario"); | |||
| final List<DetalleConteo> l; | |||
| Type listType = new TypeToken<List<DetalleConteo>>() { | |||
| }.getType(); | |||
| Gson gson= new GsonBuilder().setDateFormat("yyyy-MM-dd").create(); | |||
| l = gson.fromJson(jsonconteos.toString(), listType); | |||
| //insertar en lote desde el primer registro | |||
| if (l.size() >= 1) { | |||
| DetalleConteo c1 = l.get(0); | |||
| database.clearConteo(c1.getAlmacenpk(), c1.getConteopk()); | |||
| //conteos.clear(); | |||
| //si existe se borra la informacion | |||
| for (DetalleConteo c : l) { | |||
| c.setEnviado(false); | |||
| if(database.exist(c.getAlmacenpk(),c.getConteopk(),c.getFolio(),c.getArticulopk(), c.getInventariopk()) != null) | |||
| database.updateCantidad(c.getCantidad(),c.getAlmacenpk(), c.getConteopk(),c.getFolio(), c.getArticulopk(), c.getInventariopk(), false, false ); | |||
| else | |||
| database.isertDetalleConteo(c); | |||
| //conteos.add(c); | |||
| } | |||
| } | |||
| } | |||
| private void saveArticulosObj(List<DetalleConteo> l) { | |||
| //insertar en lote desde el primer registro | |||
| if (!l.isEmpty()) { | |||
| DetalleConteo c1 = l.get(0); | |||
| database.clearConteo(c1.getAlmacenpk(), c1.getConteopk()); | |||
| //conteos.clear(); | |||
| //si existe se borra la informacion | |||
| for (DetalleConteo c : l) { | |||
| c.setEnviado(false); | |||
| if(database.exist(c.getAlmacenpk(),c.getConteopk(),c.getFolio(),c.getArticulopk(), c.getInventariopk()) != null){ | |||
| //revisar que si enciado es 0 entocens no realiza actualizacion | |||
| if(database.existSinenviar(c.getAlmacenpk(),c.getConteopk(),c.getFolio(),c.getArticulopk(), c.getInventariopk(), false, true) == null) { | |||
| database.updateCantidad(c.getCantidad(), c.getAlmacenpk(), c.getConteopk(), c.getFolio(), c.getArticulopk(), c.getInventariopk(), false, false); | |||
| } | |||
| }else { | |||
| database.isertDetalleConteo(c); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,24 @@ | |||
| package jumapacelaya.gob.mx.almacen; | |||
| import java.util.List; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.Inventario; | |||
| import jumapacelaya.gob.mx.almacen.request.DetalleRequest; | |||
| import retrofit2.Call; | |||
| import retrofit2.http.Body; | |||
| import retrofit2.http.GET; | |||
| import retrofit2.http.POST; | |||
| public interface InventarioService { | |||
| String API_ROUTE = "/rest/almservice/listConteoArticulo"; | |||
| String API_UPDINVENTARIO = "/rest/almservice/saveFolio"; | |||
| @POST(API_ROUTE) | |||
| Call< List<DetalleConteo> > getDetalleConteo(@Body DetalleRequest body); | |||
| @POST(API_UPDINVENTARIO) | |||
| Call<Void> updateDetalle(@Body DetalleConteo body); | |||
| } | |||
| @ -0,0 +1,25 @@ | |||
| package jumapacelaya.gob.mx.almacen; | |||
| import android.os.Build; | |||
| import com.google.gson.JsonDeserializationContext; | |||
| import com.google.gson.JsonDeserializer; | |||
| import com.google.gson.JsonElement; | |||
| import com.google.gson.JsonParseException; | |||
| import java.lang.reflect.Type; | |||
| import java.time.LocalDate; | |||
| import java.time.format.DateTimeFormatter; | |||
| import java.util.Locale; | |||
| public class LocalDateDeserializer implements JsonDeserializer<LocalDate> { | |||
| @Override | |||
| public LocalDate deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) | |||
| throws JsonParseException { | |||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |||
| return LocalDate.parse(json.getAsString(), | |||
| DateTimeFormatter.ofPattern("d-MMM-yyyy").withLocale(new Locale("es","MX"))); | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @ -0,0 +1,356 @@ | |||
| package jumapacelaya.gob.mx.almacen; | |||
| import static android.widget.Toast.LENGTH_SHORT; | |||
| import android.Manifest; | |||
| import android.content.Intent; | |||
| import android.content.pm.PackageManager; | |||
| import android.os.AsyncTask; | |||
| import android.os.Build; | |||
| import android.os.Bundle; | |||
| import com.google.android.material.appbar.MaterialToolbar; | |||
| import com.google.android.material.badge.BadgeDrawable; | |||
| import com.google.android.material.badge.BadgeUtils; | |||
| import com.google.android.material.badge.ExperimentalBadgeUtils; | |||
| import com.google.android.material.floatingactionbutton.FloatingActionButton; | |||
| import com.google.android.material.tabs.TabLayout; | |||
| import androidx.annotation.NonNull; | |||
| import androidx.annotation.OptIn; | |||
| import androidx.viewpager.widget.ViewPager; | |||
| import androidx.appcompat.app.AppCompatActivity; | |||
| import android.os.Handler; | |||
| import android.os.Looper; | |||
| import android.view.MenuItem; | |||
| import android.view.View; | |||
| import android.view.animation.Animation; | |||
| import android.view.animation.AnimationUtils; | |||
| import android.widget.Toast; | |||
| import com.google.gson.Gson; | |||
| import com.google.gson.GsonBuilder; | |||
| import com.google.zxing.integration.android.IntentIntegrator; | |||
| import com.google.zxing.integration.android.IntentResult; | |||
| import java.lang.ref.WeakReference; | |||
| import java.util.List; | |||
| import java.util.concurrent.ExecutorService; | |||
| import java.util.concurrent.Executors; | |||
| import java.util.concurrent.atomic.AtomicReference; | |||
| import jumapacelaya.gob.mx.almacen.bean.ArticuloScan; | |||
| import jumapacelaya.gob.mx.almacen.bean.Conteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| import jumapacelaya.gob.mx.almacen.dao.AppDatabase; | |||
| import jumapacelaya.gob.mx.almacen.dao.inventarioDao; | |||
| import jumapacelaya.gob.mx.almacen.ui.main.avance.AvanceFragment; | |||
| import jumapacelaya.gob.mx.almacen.ui.main.Constant; | |||
| import jumapacelaya.gob.mx.almacen.ui.main.PendienteFragment; | |||
| import jumapacelaya.gob.mx.almacen.ui.main.PlaceholderFragment; | |||
| import jumapacelaya.gob.mx.almacen.ui.main.SectionsPagerAdapter; | |||
| import retrofit2.Call; | |||
| import retrofit2.Callback; | |||
| import retrofit2.Response; | |||
| import retrofit2.Retrofit; | |||
| import retrofit2.converter.gson.GsonConverterFactory; | |||
| public class MainActivity extends AppCompatActivity implements PendienteFragment.OnListFragmentInteractionListener, AvanceFragment.OnListAvanceFragmentInteractionListener { | |||
| private static final int REQUEST_CAMERARESULT=201; | |||
| private Conteo conteo; | |||
| TabLayout tabs; | |||
| private MaterialToolbar topAppBar; | |||
| private BadgeDrawable badge; | |||
| private Animation rotation; | |||
| private MenuItem refreshItem; | |||
| inventarioDao database; | |||
| @OptIn(markerClass = ExperimentalBadgeUtils.class) | |||
| @Override | |||
| protected void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| Bundle bundle = getIntent().getExtras(); | |||
| conteo = (Conteo) bundle.get(Constant.CONTEODET); | |||
| setContentView(R.layout.activity_main); | |||
| SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager()); | |||
| ViewPager viewPager = findViewById(R.id.view_pager); | |||
| viewPager.setAdapter(sectionsPagerAdapter); | |||
| viewPager.setOffscreenPageLimit(10); | |||
| tabs = findViewById(R.id.tabs); | |||
| tabs.setupWithViewPager(viewPager); | |||
| topAppBar = findViewById(R.id.topAppBar); | |||
| topAppBar.inflateMenu(R.menu.top_app_bar); | |||
| topAppBar.setOnMenuItemClickListener(item -> { | |||
| if (item.getItemId() == R.id.refresh) { | |||
| actualizarPendientes(); | |||
| return true; | |||
| } | |||
| return true; | |||
| }); | |||
| badge = BadgeDrawable.create(this); | |||
| BadgeUtils.attachBadgeDrawable(badge, topAppBar, R.id.refresh); | |||
| rotation = AnimationUtils.loadAnimation(this, R.anim.anim_rotate); | |||
| rotation.setRepeatCount(Animation.INFINITE); | |||
| if(conteo != null){ | |||
| topAppBar.setTitle("Almacen " + conteo.getNombre()); | |||
| } | |||
| FloatingActionButton fab = findViewById(R.id.fab); | |||
| fab.setOnClickListener(view -> { | |||
| IntentIntegrator scanIntegrator = new IntentIntegrator(MainActivity.this); | |||
| //IntentIntegrator scanIntegrator = IntentIntegrator.forSupportFragment(this); | |||
| //scanIntegrator.setDesiredBarcodeFormats(CustomIntegrator.PDF_417); | |||
| scanIntegrator.setPrompt("Escanear Articulo"); | |||
| //scanIntegrator.setCameraId(0); // Use a specific camera of the device | |||
| scanIntegrator.setOrientationLocked(false); | |||
| /*scanIntegrator.setOrientationLocked(true); | |||
| scanIntegrator.setBeepEnabled(true); | |||
| scanIntegrator.setCaptureActivity(CaptureActivityPortrait.class);*/ | |||
| scanIntegrator.initiateScan(); | |||
| }); | |||
| database = AppDatabase.getAppDatabaseDB(getApplicationContext()).inventarioDao(); | |||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |||
| if(getApplicationContext().checkSelfPermission(Manifest.permission.CAMERA)== PackageManager.PERMISSION_GRANTED){ | |||
| ///method to get Images | |||
| }else{ | |||
| if(shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)){ | |||
| Toast.makeText(getApplicationContext(),"Your Permission is needed to get access the camera",Toast.LENGTH_LONG).show(); | |||
| } | |||
| requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.CAMERA}, REQUEST_CAMERARESULT); | |||
| } | |||
| }else{ | |||
| } | |||
| //refreshBadge(); | |||
| } | |||
| @Override | |||
| protected void onResume() { | |||
| super.onResume(); | |||
| refreshBadge(); | |||
| } | |||
| public void refreshBadge(){ | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| View refreshitem = findViewById(R.id.refresh); | |||
| refreshitem.startAnimation(rotation); | |||
| executor.execute(() -> { | |||
| int cantidad = 0; | |||
| try { | |||
| cantidad = database.pendienteEnviar(conteo.getConteopk(), conteo.getInventariopk(), false, true); | |||
| } catch (Exception ex) { | |||
| System.out.println(ex.getMessage()); | |||
| Toast.makeText(MainActivity.this, "Error al consultar los pendietes", Toast.LENGTH_LONG).show(); | |||
| } | |||
| int finalCantidad = cantidad; | |||
| handler.post(() -> { | |||
| badge.clearNumber(); | |||
| badge.setText(String.valueOf(finalCantidad)); | |||
| rotation.cancel(); | |||
| }); | |||
| }); | |||
| } | |||
| private void actualizarPendientes(){ | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| View refreshitem = findViewById(R.id.refresh); | |||
| refreshitem.startAnimation(rotation); | |||
| executor.execute(() -> { | |||
| List<DetalleConteo> detalles = database.lstpendienteEnviar(conteo.getConteopk(), conteo.getInventariopk(), false, true); | |||
| GsonBuilder builder = new GsonBuilder(); | |||
| builder.excludeFieldsWithoutExposeAnnotation(); | |||
| Retrofit retrofit = new Retrofit.Builder() | |||
| .baseUrl(restAlmacen.instance(MainActivity.this).BASE_URL) | |||
| .addConverterFactory(GsonConverterFactory.create(builder.create())) | |||
| .build(); | |||
| InventarioService postService = retrofit.create(InventarioService.class); | |||
| if(detalles.size() == 0) | |||
| refreshBadge(); | |||
| for(DetalleConteo d:detalles){ | |||
| Call<Void> call = postService.updateDetalle(d); | |||
| call.enqueue(new Callback<>() { | |||
| @Override | |||
| public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) { | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| executor.execute(() -> { | |||
| String msg = ""; | |||
| boolean flag = false; | |||
| if (response.code() == 200){ | |||
| d.setEnviado(true); | |||
| database.updateDetalle(d); | |||
| } | |||
| handler.post(() -> { | |||
| refreshBadge(); | |||
| }); | |||
| }); | |||
| } | |||
| @Override | |||
| public void onFailure(Call<Void> call, Throwable t) { | |||
| Toast.makeText(MainActivity.this, t.getMessage(), Toast.LENGTH_LONG).show(); | |||
| refreshBadge(); | |||
| } | |||
| }); | |||
| } | |||
| }); | |||
| } | |||
| @Override | |||
| public void onListFragmentInteraction(DetalleConteo item) { | |||
| //Toast.makeText(MainActivity.this, item.getDescFamilia() + ":" + item.getFolio() + " - " +item.getDescArticulo(), Toast.LENGTH_LONG).show(); | |||
| String tag = "android:switcher:" + R.id.view_pager + ":" + 0; | |||
| PlaceholderFragment ff = (PlaceholderFragment) getSupportFragmentManager().findFragmentByTag(tag); | |||
| ff.displayReceivedData(item); | |||
| TabLayout.Tab tab= tabs.getTabAt(0); | |||
| tab.select(); | |||
| } | |||
| @Override | |||
| public void onListAvanceFragmentInteraction(DetalleConteo item) { | |||
| //Toast.makeText(MainActivity.this, item.getDescFamilia() + ":" + item.getFolio() + " - " +item.getDescArticulo(), Toast.LENGTH_LONG).show(); | |||
| String tag = "android:switcher:" + R.id.view_pager + ":" + 0; | |||
| PlaceholderFragment f = (PlaceholderFragment) getSupportFragmentManager().findFragmentByTag(tag); | |||
| f.displayReceivedData(item); | |||
| TabLayout.Tab tab= tabs.getTabAt(0); | |||
| tab.select(); | |||
| } | |||
| public Conteo getConteo(){ | |||
| return conteo; | |||
| } | |||
| @Override | |||
| public void onActivityResult(int requestCode, int resultCode, Intent intent) { | |||
| try { | |||
| final IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); | |||
| if(scanResult != null) | |||
| handleResult(scanResult); | |||
| else | |||
| super.onActivityResult(requestCode, resultCode, intent); | |||
| }catch (Exception ex){ | |||
| Toast.makeText(getApplicationContext(), ex.getMessage(), LENGTH_SHORT).show(); | |||
| } | |||
| } | |||
| private void handleResult(IntentResult scanResult) { | |||
| if (scanResult != null) { | |||
| Gson gson = new Gson(); | |||
| ArticuloScan articuloScan = gson.fromJson(scanResult.getContents(), ArticuloScan.class); | |||
| if(articuloScan != null){ | |||
| final inventarioDao db = AppDatabase.getAppDatabaseDB(this).inventarioDao(); | |||
| //consultar base de datos | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| executor.execute(() -> { | |||
| DetalleConteo detalle = null; | |||
| detalle = db.getDetalleID(conteo.getInventariopk(), conteo.getConteopk(), articuloScan.getArticuloid()); | |||
| DetalleConteo finalDetalle = detalle; | |||
| handler.post(() -> { | |||
| String tag = "android:switcher:" + R.id.view_pager + ":" + 0; | |||
| PlaceholderFragment f = (PlaceholderFragment) getSupportFragmentManager().findFragmentByTag(tag); | |||
| f.displayReceivedData(finalDetalle); | |||
| TabLayout.Tab tab= tabs.getTabAt(0); | |||
| assert tab != null; | |||
| tab.select(); | |||
| }); | |||
| }); | |||
| }else{ | |||
| Toast.makeText(this, "Información Incorrecta :(", LENGTH_SHORT).show(); | |||
| } | |||
| } else { | |||
| Toast.makeText(this, "No se ha leído nada :(", LENGTH_SHORT).show(); | |||
| } | |||
| } | |||
| private class SelectDetalleTask extends AsyncTask<Void,Void,DetalleConteo> { | |||
| private WeakReference<MainActivity> activityReference; | |||
| private Conteo conteo; | |||
| private String folio; | |||
| // only retain a weak reference to the activity | |||
| SelectDetalleTask(MainActivity context, Conteo conteo,String folio) { | |||
| activityReference = new WeakReference<>(context); | |||
| this.conteo = conteo; | |||
| this.folio = folio; | |||
| } | |||
| // doInBackground methods runs on a worker thread | |||
| @Override | |||
| protected DetalleConteo doInBackground(Void... objs) { | |||
| return AppDatabase.getAppDatabaseDB(activityReference.get()).inventarioDao().getDetalle(conteo.getInventariopk(),conteo.getConteopk(),folio); | |||
| } | |||
| // onPostExecute runs on main thread | |||
| @Override | |||
| protected void onPostExecute(DetalleConteo det) { | |||
| if (det != null){ | |||
| String tag = "android:switcher:" + R.id.view_pager + ":" + 0; | |||
| PlaceholderFragment f = (PlaceholderFragment) getSupportFragmentManager().findFragmentByTag(tag); | |||
| f.displayReceivedData(det); | |||
| TabLayout.Tab tab = tabs.getTabAt(0); | |||
| tab.select(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,42 @@ | |||
| package jumapacelaya.gob.mx.almacen.bean; | |||
| import java.io.Serializable; | |||
| public class ArticuloScan implements Serializable { | |||
| private int articuloid; | |||
| private String nombre; | |||
| private int cogid; | |||
| private String unidad; | |||
| public int getArticuloid() { | |||
| return articuloid; | |||
| } | |||
| public void setArticuloid(int articuloid) { | |||
| this.articuloid = articuloid; | |||
| } | |||
| public String getNombre() { | |||
| return nombre; | |||
| } | |||
| public void setNombre(String nombre) { | |||
| this.nombre = nombre; | |||
| } | |||
| public int getCogid() { | |||
| return cogid; | |||
| } | |||
| public void setCogid(int cogid) { | |||
| this.cogid = cogid; | |||
| } | |||
| public String getUnidad() { | |||
| return unidad; | |||
| } | |||
| public void setUnidad(String unidad) { | |||
| this.unidad = unidad; | |||
| } | |||
| } | |||
| @ -0,0 +1,48 @@ | |||
| package jumapacelaya.gob.mx.almacen.bean; | |||
| import androidx.room.Entity; | |||
| import androidx.room.PrimaryKey; | |||
| import androidx.annotation.NonNull; | |||
| import java.io.Serializable; | |||
| @Entity | |||
| public class Conteo implements Serializable { | |||
| @PrimaryKey | |||
| @NonNull | |||
| private Integer conteopk; | |||
| private String nombre; | |||
| private Integer inventariopk; | |||
| public Integer getConteopk() { | |||
| return conteopk; | |||
| } | |||
| public void setConteopk(Integer conteopk) { | |||
| this.conteopk = conteopk; | |||
| } | |||
| public String getNombre() { | |||
| return nombre; | |||
| } | |||
| public void setNombre(String nombre) { | |||
| this.nombre = nombre; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return getNombre(); | |||
| } | |||
| public Integer getInventariopk() { | |||
| return inventariopk; | |||
| } | |||
| public void setInventariopk(Integer inventariopk) { | |||
| this.inventariopk = inventariopk; | |||
| } | |||
| } | |||
| @ -0,0 +1,162 @@ | |||
| package jumapacelaya.gob.mx.almacen.bean; | |||
| import androidx.room.Embedded; | |||
| import androidx.room.Entity; | |||
| import androidx.annotation.NonNull; | |||
| import com.google.gson.annotations.Expose; | |||
| import java.io.Serializable; | |||
| import java.math.BigDecimal; | |||
| @Entity(primaryKeys = {"almacenpk","articulopk","conteopk"}) | |||
| public class DetalleConteo implements Serializable { | |||
| @NonNull | |||
| @Expose | |||
| private Integer folio; | |||
| @Expose | |||
| private String clave; | |||
| @Expose | |||
| private String descArticulo; | |||
| @Expose | |||
| private String descunidad; | |||
| @Expose | |||
| @NonNull | |||
| private Integer inventariopk; | |||
| @NonNull | |||
| @Expose | |||
| private Integer almacenpk; | |||
| @NonNull | |||
| @Expose | |||
| private Integer articulopk; | |||
| @Expose | |||
| private BigDecimal cantidad; | |||
| @Expose | |||
| private String descFamilia; | |||
| @Expose | |||
| private String descSubFamilia; | |||
| @NonNull | |||
| @Expose | |||
| private Integer conteopk; | |||
| @NonNull | |||
| @Expose(deserialize = false, serialize = false) | |||
| private Boolean enviado = false; | |||
| @NonNull | |||
| @Expose(deserialize = false, serialize = false) | |||
| private Boolean actualizado = false; | |||
| public Integer getAlmacenpk() { | |||
| return almacenpk; | |||
| } | |||
| public void setAlmacenpk(Integer almacenpk) { | |||
| this.almacenpk = almacenpk; | |||
| } | |||
| public Integer getArticulopk() { | |||
| return articulopk; | |||
| } | |||
| public void setArticulopk(Integer articulopk) { | |||
| this.articulopk = articulopk; | |||
| } | |||
| public Integer getConteopk() { | |||
| return conteopk; | |||
| } | |||
| public void setConteopk(Integer conteopk) { | |||
| this.conteopk = conteopk; | |||
| } | |||
| public Integer getFolio() { | |||
| return folio; | |||
| } | |||
| public void setFolio(Integer folio) { | |||
| this.folio = folio; | |||
| } | |||
| public BigDecimal getCantidad() { | |||
| return cantidad; | |||
| } | |||
| public void setCantidad(BigDecimal cantidad) { | |||
| this.cantidad = cantidad; | |||
| } | |||
| @NonNull | |||
| public Boolean getEnviado() { | |||
| return enviado; | |||
| } | |||
| public void setEnviado(@NonNull Boolean enviado) { | |||
| this.enviado = enviado; | |||
| } | |||
| public String getClave() { | |||
| return clave; | |||
| } | |||
| public void setClave(String clave) { | |||
| this.clave = clave; | |||
| } | |||
| public String getDescArticulo() { | |||
| return descArticulo; | |||
| } | |||
| public void setDescArticulo(String descArticulo) { | |||
| this.descArticulo = descArticulo; | |||
| } | |||
| public String getDescunidad() { | |||
| return descunidad; | |||
| } | |||
| public void setDescunidad(String descunidad) { | |||
| this.descunidad = descunidad; | |||
| } | |||
| public String getDescFamilia() { | |||
| return descFamilia; | |||
| } | |||
| public void setDescFamilia(String descFamilia) { | |||
| this.descFamilia = descFamilia; | |||
| } | |||
| public String getDescSubFamilia() { | |||
| return descSubFamilia; | |||
| } | |||
| public void setDescSubFamilia(String descSubFamilia) { | |||
| this.descSubFamilia = descSubFamilia; | |||
| } | |||
| @NonNull | |||
| public Integer getInventariopk() { | |||
| return inventariopk; | |||
| } | |||
| public void setInventariopk(@NonNull Integer inventariopk) { | |||
| this.inventariopk = inventariopk; | |||
| } | |||
| @NonNull | |||
| public Boolean getActualizado() { | |||
| return actualizado; | |||
| } | |||
| public void setActualizado(@NonNull Boolean actualizado) { | |||
| this.actualizado = actualizado; | |||
| } | |||
| } | |||
| @ -0,0 +1,96 @@ | |||
| package jumapacelaya.gob.mx.almacen.bean; | |||
| import androidx.room.Entity; | |||
| import androidx.room.PrimaryKey; | |||
| import java.time.LocalDate; | |||
| import java.util.Date; | |||
| @Entity | |||
| public class Inventario { | |||
| @PrimaryKey | |||
| private int inventariopk; | |||
| private String descripcion; | |||
| private Date fecha; | |||
| private String estado; | |||
| private int polizapk; | |||
| private String usuario; | |||
| private int folio; | |||
| private int folioFResp; | |||
| public int getInventariopk() { | |||
| return inventariopk; | |||
| } | |||
| public void setInventariopk(int inventariopk) { | |||
| this.inventariopk = inventariopk; | |||
| } | |||
| public String getDescripcion() { | |||
| return descripcion; | |||
| } | |||
| public void setDescripcion(String descripcion) { | |||
| this.descripcion = descripcion; | |||
| } | |||
| public String getEstado() { | |||
| return estado; | |||
| } | |||
| public void setEstado(String estado) { | |||
| this.estado = estado; | |||
| } | |||
| public int getPolizapk() { | |||
| return polizapk; | |||
| } | |||
| public void setPolizapk(int polizapk) { | |||
| this.polizapk = polizapk; | |||
| } | |||
| public String getUsuario() { | |||
| return usuario; | |||
| } | |||
| public void setUsuario(String usuario) { | |||
| this.usuario = usuario; | |||
| } | |||
| public int getFolio() { | |||
| return folio; | |||
| } | |||
| public void setFolio(int folio) { | |||
| this.folio = folio; | |||
| } | |||
| public int getFolioFResp() { | |||
| return folioFResp; | |||
| } | |||
| public void setFolioFResp(int folioFResp) { | |||
| this.folioFResp = folioFResp; | |||
| } | |||
| public Date getFecha() { | |||
| return fecha; | |||
| } | |||
| public void setFecha(Date fecha) { | |||
| this.fecha = fecha; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.descripcion; // What to display in the Spinner list. | |||
| } | |||
| } | |||
| @ -0,0 +1,45 @@ | |||
| package jumapacelaya.gob.mx.almacen.dao; | |||
| import androidx.room.Database; | |||
| import androidx.room.Room; | |||
| import androidx.room.RoomDatabase; | |||
| import androidx.room.TypeConverters; | |||
| import android.content.Context; | |||
| import jumapacelaya.gob.mx.almacen.bean.Inventario; | |||
| import jumapacelaya.gob.mx.almacen.dao.converts.BigdecimalToLong; | |||
| import jumapacelaya.gob.mx.almacen.dao.converts.BooleanTointeger; | |||
| import jumapacelaya.gob.mx.almacen.bean.Conteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| import jumapacelaya.gob.mx.almacen.dao.converts.DateConverter; | |||
| import jumapacelaya.gob.mx.almacen.dao.converts.LocalDateConverter; | |||
| @Database(entities = {Conteo.class, DetalleConteo.class, Inventario.class}, version = 8, exportSchema = false) | |||
| @TypeConverters({BooleanTointeger.class, BigdecimalToLong.class, DateConverter.class}) | |||
| public abstract class AppDatabase extends RoomDatabase { | |||
| private static AppDatabase INSTANCE; | |||
| public abstract inventarioDao inventarioDao(); | |||
| public static AppDatabase getAppDatabaseDB(Context context){ | |||
| if(INSTANCE == null){ | |||
| INSTANCE = Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, "Inventario.DB") //.addMigrations(MIGRATION_1_2) | |||
| .fallbackToDestructiveMigration().build(); //Esta opcion incremetala version pero elimina todos los datos de la base de datos. | |||
| /*INSTANCE = Room.databaseBuilder(context.getApplicationContext(), Lecturasdb.class, consNamesDB.NAME_DATABASE).addMigrations(MIGRATION_19_20) | |||
| .build();*/ | |||
| } | |||
| return INSTANCE; | |||
| } | |||
| public static void destroyInstance(){ | |||
| INSTANCE = null; | |||
| } | |||
| } | |||
| @ -0,0 +1,60 @@ | |||
| package jumapacelaya.gob.mx.almacen.dao; | |||
| import android.app.Application; | |||
| import androidx.lifecycle.AndroidViewModel; | |||
| import androidx.lifecycle.LiveData; | |||
| import androidx.annotation.NonNull; | |||
| import java.util.List; | |||
| import java.util.concurrent.ExecutorService; | |||
| import java.util.concurrent.Executors; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| public class PostViewModel extends AndroidViewModel { | |||
| public inventarioDao postDao; | |||
| private ExecutorService executorService; | |||
| private Application app; | |||
| public PostViewModel(@NonNull Application application) { | |||
| super(application); | |||
| postDao = AppDatabase.getAppDatabaseDB(application).inventarioDao(); | |||
| executorService = Executors.newSingleThreadExecutor(); | |||
| } | |||
| public LiveData<List<DetalleConteo>> getAllConteo() { | |||
| return postDao.liveDetalleConteos(); | |||
| } | |||
| public LiveData<List<DetalleConteo>> getPendientesConteo(int inventariopk, Integer conteo) { | |||
| return postDao.livePendiente_Detalles(inventariopk, conteo); | |||
| } | |||
| public LiveData<List<DetalleConteo>> getAvanceConteo(int inventariopk, Integer conteo) { | |||
| return postDao.liveAvance_Detalles(inventariopk, conteo); | |||
| } | |||
| public void saveDetalleConteo(final DetalleConteo detalleConteo) { | |||
| executorService.execute(new Runnable() { | |||
| @Override | |||
| public void run() { | |||
| postDao.insertDetalleConteos(detalleConteo); | |||
| } | |||
| }); | |||
| } | |||
| public void deleteDetalleConteo(final DetalleConteo detalleConteo) { | |||
| executorService.execute(new Runnable() { | |||
| @Override | |||
| public void run() { | |||
| postDao.deleteDetalleConteo(detalleConteo); | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| @ -0,0 +1,21 @@ | |||
| package jumapacelaya.gob.mx.almacen.dao.converts; | |||
| import androidx.room.TypeConverter; | |||
| import java.math.BigDecimal; | |||
| public class BigdecimalToLong { | |||
| @TypeConverter | |||
| public BigDecimal fromLong(Long value) { | |||
| return value == null ? null : new BigDecimal(value).divide(new BigDecimal(100)); | |||
| } | |||
| @TypeConverter | |||
| public Long toLong(BigDecimal bigDecimal) { | |||
| if (bigDecimal == null) { | |||
| return null; | |||
| } else { | |||
| return bigDecimal.multiply(new BigDecimal(100)).longValue(); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,20 @@ | |||
| package jumapacelaya.gob.mx.almacen.dao.converts; | |||
| import androidx.room.TypeConverter; | |||
| public class BooleanTointeger { | |||
| @TypeConverter | |||
| public Boolean fromTimestamp(Integer value) { | |||
| return value == null ? null : value > 0? new Boolean(true): new Boolean(false); | |||
| } | |||
| @TypeConverter | |||
| public Integer dateToTimestamp(Boolean value) { | |||
| if (value == null) { | |||
| return null; | |||
| } else { | |||
| return value? 1: 0; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,19 @@ | |||
| package jumapacelaya.gob.mx.almacen.dao.converts; | |||
| import androidx.room.TypeConverter; | |||
| import java.time.LocalDate; | |||
| import java.util.Date; | |||
| public class DateConverter { | |||
| @TypeConverter | |||
| public static Date toDate(Long dateLong){ | |||
| return dateLong == null ? null: new Date(dateLong); | |||
| } | |||
| @TypeConverter | |||
| public static Long fromDate(Date date){ | |||
| return date == null ? null : date.getTime(); | |||
| } | |||
| } | |||
| @ -0,0 +1,27 @@ | |||
| package jumapacelaya.gob.mx.almacen.dao.converts; | |||
| import androidx.room.TypeConverter; | |||
| import java.time.LocalDate; | |||
| public class LocalDateConverter { | |||
| @TypeConverter | |||
| public static LocalDate toDate(String dateString) { | |||
| if (dateString == null) { | |||
| return null; | |||
| } else { | |||
| return LocalDate.parse(dateString); | |||
| } | |||
| } | |||
| @TypeConverter | |||
| public static String toDateString(LocalDate date) { | |||
| if (date == null) { | |||
| return null; | |||
| } else { | |||
| return date.toString(); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,156 @@ | |||
| package jumapacelaya.gob.mx.almacen.dao; | |||
| import android.database.sqlite.SQLiteConstraintException; | |||
| import androidx.lifecycle.LiveData; | |||
| import androidx.room.Dao; | |||
| import androidx.room.Delete; | |||
| import androidx.room.Insert; | |||
| import androidx.room.Query; | |||
| import androidx.room.Transaction; | |||
| import androidx.room.Update; | |||
| import java.math.BigDecimal; | |||
| import java.util.List; | |||
| import jumapacelaya.gob.mx.almacen.bean.Conteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.Inventario; | |||
| @Dao | |||
| public abstract class inventarioDao { | |||
| @Query("Select * from Conteo") | |||
| public abstract List<Conteo> listConteos(); | |||
| @Query("Select * from Inventario") | |||
| public abstract List<Inventario> listInventarios(); | |||
| @Query("Select * from Inventario Where estado = 'A' ") | |||
| public abstract List<Inventario> listInventariosActivos(); | |||
| @Query("Select * from Conteo Where inventariopk = :pinventariopk ") | |||
| public abstract List<Conteo> listInventariosInv(int pinventariopk); | |||
| @Query("Select * from Conteo Where conteopk= :conteopk ") | |||
| public abstract Conteo listConteos(Integer conteopk); | |||
| @Insert | |||
| public abstract void insertConteos(Conteo... conteos); | |||
| @Insert | |||
| public abstract void insertConteo(Conteo conteo); | |||
| @Update | |||
| public abstract void updateConteo(Conteo conteo); | |||
| public void upsertConteo(Conteo conteo) { | |||
| try { | |||
| insertConteo(conteo); | |||
| } | |||
| catch (SQLiteConstraintException e) { | |||
| updateConteo(conteo); | |||
| } | |||
| } | |||
| //@Insert(onConflict = OnConflictStrategy.REPLACE) | |||
| @Insert | |||
| public abstract void insertInventarios(Inventario... inventarios); | |||
| @Insert | |||
| public abstract void insertInventario(Inventario inventario); | |||
| @Update | |||
| public abstract void updateInventario(Inventario inventario); | |||
| public void upsertInventario(Inventario inventario) { | |||
| try { | |||
| insertInventario(inventario); | |||
| } | |||
| catch (SQLiteConstraintException e) { | |||
| updateInventario(inventario); | |||
| } | |||
| } | |||
| @Insert | |||
| public abstract void isertConteo(Conteo conteo); | |||
| @Delete | |||
| public abstract void deleteConteo(Conteo conteo); | |||
| @Query("Select * from DetalleConteo") | |||
| public abstract List<DetalleConteo> listDetalleConteos(); | |||
| @Query("Select * from DetalleConteo ") | |||
| public abstract LiveData<List<DetalleConteo>> liveDetalleConteos(); | |||
| @Query("Select * from DetalleConteo Where inventariopk = :inventariopk And conteopk= :conteopk and folio = :folio") | |||
| public abstract DetalleConteo getDetalle(Integer inventariopk, Integer conteopk, String folio); | |||
| @Query("Select * from DetalleConteo Where inventariopk = :inventariopk And conteopk= :conteopk and articulopk = :articulo") | |||
| public abstract DetalleConteo getDetalleID(Integer inventariopk, Integer conteopk, Integer articulo); | |||
| @Query("Select * from DetalleConteo Where almacenpk = :almacenpk And conteopk= :conteopk ") | |||
| public abstract List<DetalleConteo> listDetalles(Integer almacenpk, Integer conteopk); | |||
| @Query("Select * from DetalleConteo Where almacenpk = :almacenpk And conteopk= :conteopk ") | |||
| public abstract LiveData<List<DetalleConteo>> liveDetalles(Integer almacenpk, Integer conteopk); | |||
| @Query("Select * from DetalleConteo Where inventariopk = :inventariopk And conteopk= :conteopk and (cantidad == null or cantidad <> 0) ") | |||
| public abstract List<DetalleConteo> listPendiente_Detalles(Integer inventariopk, Integer conteopk); | |||
| @Query("Select * from DetalleConteo Where inventariopk = :inventariopk And conteopk= :conteopk and (cantidad is null or cantidad = 0) Order by folio") | |||
| public abstract LiveData<List<DetalleConteo>> livePendiente_Detalles(Integer inventariopk, Integer conteopk); | |||
| @Query("Select * from DetalleConteo Where inventariopk = :inventariopk And conteopk= :conteopk ") | |||
| public abstract List<DetalleConteo> listContados_Detalles(Integer inventariopk, Integer conteopk); | |||
| @Query("Select * from DetalleConteo Where inventariopk = :inventariopk And conteopk= :conteopk and (CASE WHEN Cantidad IS NULL THEN 0 ELSE Cantidad END) <> 0 Order by folio") | |||
| public abstract LiveData<List<DetalleConteo>> liveAvance_Detalles(Integer inventariopk, Integer conteopk ); | |||
| @Insert | |||
| public abstract void insertDetalleConteos(DetalleConteo... detalleConteos); | |||
| @Insert | |||
| public abstract void isertDetalleConteo(DetalleConteo detalleConteo); | |||
| @Query("Update detalleconteo Set cantidad= :cantidad, enviado = :enviado, actualizado = :actualizado Where almacenpk = :almacen And conteopk = :conteo And folio = :folio And articulopk= :articulo And inventariopk = :inventariopk ") | |||
| public abstract void updateCantidad(BigDecimal cantidad,Integer almacen, Integer conteo, Integer folio,Integer articulo, int inventariopk, boolean actualizado, boolean enviado); | |||
| @Query("Select * From detalleconteo Where almacenpk = :almacen And conteopk = :conteo And folio = :folio And articulopk= :articulo And inventariopk = :inventariopk ") | |||
| public abstract Conteo exist(Integer almacen, Integer conteo, Integer folio,Integer articulo, Integer inventariopk); | |||
| @Query("Select * From detalleconteo Where almacenpk = :almacen And conteopk = :conteo And folio = :folio And articulopk= :articulo And inventariopk = :inventariopk And enviado = :enviado And actualizado = :actualizado") | |||
| public abstract Conteo existSinenviar(Integer almacen, Integer conteo, Integer folio,Integer articulo, Integer inventariopk, boolean enviado, boolean actualizado); | |||
| @Query("Select count(*) From detalleconteo Where conteopk = :conteo And inventariopk = :inventariopk And enviado = :enviado And actualizado = :actualizado") | |||
| public abstract int pendienteEnviar(Integer conteo, Integer inventariopk, boolean enviado, boolean actualizado); | |||
| @Query("Select * From detalleconteo Where conteopk = :conteo And inventariopk = :inventariopk And enviado = :enviado And actualizado = :actualizado") | |||
| public abstract List<DetalleConteo> lstpendienteEnviar(Integer conteo, Integer inventariopk, boolean enviado, boolean actualizado); | |||
| @Query("Update inventario Set estado= 'C'") | |||
| public abstract void updateInventarioN(); | |||
| @Delete | |||
| public abstract void deleteDetalleConteo(DetalleConteo detalleConteo); | |||
| @Query("Delete from detalleconteo where almacenpk = :almacen And conteopk = :conteo") | |||
| public abstract void clearConteo(Integer almacen, Integer conteo); | |||
| @Update | |||
| public abstract void updateDetalle(DetalleConteo detalleConteo); | |||
| @Transaction | |||
| public void setLoggedInUser(DetalleConteo detalleConteo, Conteo conteo ) { | |||
| deleteDetalleConteo(detalleConteo); | |||
| deleteConteo(conteo); | |||
| } | |||
| } | |||
| @ -0,0 +1,20 @@ | |||
| package jumapacelaya.gob.mx.almacen.request; | |||
| public class DetalleRequest { | |||
| String imei; | |||
| Integer inventariopk; | |||
| Integer conteopk; | |||
| Integer foliopk; | |||
| public DetalleRequest(String imei, Integer inventariopk, Integer conteopk, Integer foliopk){ | |||
| this.imei = imei; | |||
| this.inventariopk = inventariopk; | |||
| this.conteopk = conteopk; | |||
| this.foliopk = foliopk; | |||
| } | |||
| } | |||
| @ -0,0 +1,42 @@ | |||
| package jumapacelaya.gob.mx.almacen; | |||
| import android.content.Context; | |||
| import android.content.SharedPreferences; | |||
| import android.preference.PreferenceManager; | |||
| public class restAlmacen { | |||
| public String URL_conteos = ""; | |||
| public String URL_inventarios = ""; | |||
| public String URL_Articulos = ""; | |||
| public String URL_updateDetalle = ""; | |||
| public String BASE_URL = ""; | |||
| String server; | |||
| String port; | |||
| String servicio; | |||
| SharedPreferences pref; | |||
| public static restAlmacen instance(Context context){ | |||
| restAlmacen rest = new restAlmacen(); | |||
| SharedPreferences pref;// = PreferenceManager.getDefaultSharedPreferences(context); | |||
| pref = PreferenceManager.getDefaultSharedPreferences(context); | |||
| rest.server = pref.getString("server_text", "172.16.0.9"); | |||
| rest.port = pref.getString("port_text", "85"); | |||
| rest.servicio = pref.getString("servicio_text",""); | |||
| rest.BASE_URL = "http://"+rest.server+":"+rest.port+ (rest.servicio.equals("")?"" : "/" + rest.servicio); | |||
| rest.URL_inventarios = rest.BASE_URL + "/rest/almservice/listInventarios"; // Muestra los invnetarios activos de un almacen | |||
| rest.URL_conteos = rest.BASE_URL + "/rest/almservice/listConteos"; // Muestra la lista de conteos | |||
| rest.URL_Articulos = rest.BASE_URL + "/rest/almservice/listConteoArticulo"; //muestra los articulos del conteo | |||
| rest.URL_updateDetalle = rest.BASE_URL + "/rest/almservice/saveFolio"; //Actualiza el inventario con los conteos realizados. | |||
| rest.BASE_URL = "http://"+rest.server+":"+rest.port+ (rest.servicio.equals("")?"" : "/" + rest.servicio); | |||
| return rest; | |||
| } | |||
| } | |||
| @ -0,0 +1,28 @@ | |||
| package jumapacelaya.gob.mx.almacen; | |||
| import android.app.Activity; | |||
| import android.content.Intent; | |||
| import android.os.Handler; | |||
| import androidx.appcompat.app.AppCompatActivity; | |||
| import android.os.Bundle; | |||
| public class splash extends Activity { | |||
| private final int SPLASH_DISPLAY_LENGHT = 3000; | |||
| @Override | |||
| protected void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| setContentView(R.layout.activity_splash); | |||
| new Handler().postDelayed(new Runnable(){ | |||
| @Override | |||
| public void run() { | |||
| /* Create an Intent that will start the Menu-Activity. */ | |||
| Intent mainIntent = new Intent(splash.this,ConteoActivity.class); | |||
| splash.this.startActivity(mainIntent); | |||
| splash.this.finish(); | |||
| } | |||
| }, SPLASH_DISPLAY_LENGHT); | |||
| } | |||
| } | |||
| @ -0,0 +1,10 @@ | |||
| package jumapacelaya.gob.mx.almacen.ui.main; | |||
| import com.journeyapps.barcodescanner.CaptureActivity; | |||
| public class CaptureActivityPortrait extends CaptureActivity { | |||
| //Nothing in side. | |||
| } | |||
| @ -0,0 +1,8 @@ | |||
| package jumapacelaya.gob.mx.almacen.ui.main; | |||
| public class Constant { | |||
| public static String CONTEODET = "conteodet"; | |||
| } | |||
| @ -0,0 +1,18 @@ | |||
| package jumapacelaya.gob.mx.almacen.ui.main; | |||
| import androidx.lifecycle.MutableLiveData; | |||
| import androidx.lifecycle.ViewModel; | |||
| public class PageViewModel extends ViewModel { | |||
| private MutableLiveData<Integer> mIndex = new MutableLiveData<>(); | |||
| //private LiveData<String> mText = Transformations.map(mIndex, (Function<Integer, String>) input -> "Hello world from section: " + input); | |||
| public void setIndex(int index) { | |||
| mIndex.setValue(index); | |||
| } | |||
| /*public LiveData<String> getText() { | |||
| return mText; | |||
| }*/ | |||
| } | |||
| @ -0,0 +1,124 @@ | |||
| package jumapacelaya.gob.mx.almacen.ui.main; | |||
| import androidx.annotation.NonNull; | |||
| import androidx.lifecycle.ViewModelProviders; | |||
| import android.content.Context; | |||
| import android.os.Bundle; | |||
| import androidx.fragment.app.Fragment; | |||
| import androidx.recyclerview.widget.LinearLayoutManager; | |||
| import androidx.recyclerview.widget.RecyclerView; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import jumapacelaya.gob.mx.almacen.MainActivity; | |||
| import jumapacelaya.gob.mx.almacen.R; | |||
| import jumapacelaya.gob.mx.almacen.bean.Conteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| import jumapacelaya.gob.mx.almacen.dao.PostViewModel; | |||
| /** | |||
| * A fragment representing a list of Items. | |||
| * <p/> | |||
| * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} | |||
| * interface. | |||
| */ | |||
| public class PendienteFragment extends Fragment { | |||
| // TODO: Customize parameter argument names | |||
| private static final String ARG_COLUMN_COUNT = "column-count"; | |||
| // TODO: Customize parameters | |||
| private int mColumnCount = 1; | |||
| PostViewModel postViewModel; | |||
| PendienteViewAdapter adapter; | |||
| Conteo conteo; | |||
| MainActivity activity; | |||
| private OnListFragmentInteractionListener mListener; | |||
| /** | |||
| * Mandatory empty constructor for the fragment manager to instantiate the | |||
| * fragment (e.g. upon screen orientation changes). | |||
| */ | |||
| public PendienteFragment() { | |||
| } | |||
| // TODO: Customize parameter initialization | |||
| @SuppressWarnings("unused") | |||
| public static PendienteFragment newInstance(int columnCount, Conteo conteo, MainActivity activity) { | |||
| PendienteFragment fragment = new PendienteFragment(); | |||
| Bundle args = new Bundle(); | |||
| args.putInt(ARG_COLUMN_COUNT, columnCount); | |||
| fragment.setArguments(args); | |||
| fragment.conteo = conteo; | |||
| fragment.activity = activity; | |||
| return fragment; | |||
| } | |||
| @Override | |||
| public void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| postViewModel = ViewModelProviders.of(this).get(PostViewModel.class); | |||
| if (getArguments() != null) { | |||
| mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT); | |||
| } | |||
| } | |||
| @Override | |||
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
| Bundle savedInstanceState) { | |||
| View view = inflater.inflate(R.layout.fragment_item_list, container, false); | |||
| // Set the adapter | |||
| if (view instanceof RecyclerView) { | |||
| Context context = view.getContext(); | |||
| RecyclerView recyclerView = (RecyclerView) view; | |||
| //if (mColumnCount <= 1) { | |||
| recyclerView.setLayoutManager(new LinearLayoutManager(context)); | |||
| //} else { | |||
| // recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount)); | |||
| //} | |||
| adapter = new PendienteViewAdapter( mListener); | |||
| postViewModel.getPendientesConteo(conteo.getInventariopk(),conteo.getConteopk()).observe(getViewLifecycleOwner(), detalleConteos -> adapter.setData(detalleConteos)); | |||
| recyclerView.setAdapter(adapter); | |||
| } | |||
| return view; | |||
| } | |||
| @Override | |||
| public void onAttach(@NonNull Context context) { | |||
| super.onAttach(context); | |||
| if (context instanceof OnListFragmentInteractionListener) { | |||
| mListener = (OnListFragmentInteractionListener) context; | |||
| } else { | |||
| throw new RuntimeException(context.toString() | |||
| + " must implement OnListFragmentInteractionListener"); | |||
| } | |||
| } | |||
| @Override | |||
| public void onDetach() { | |||
| super.onDetach(); | |||
| mListener = null; | |||
| } | |||
| /** | |||
| * This interface must be implemented by activities that contain this | |||
| * fragment to allow an interaction in this fragment to be communicated | |||
| * to the activity and potentially other fragments contained in that | |||
| * activity. | |||
| * <p/> | |||
| * See the Android Training lesson <a href= | |||
| * "http://developer.android.com/training/basics/fragments/communicating.html" | |||
| * >Communicating with Other Fragments</a> for more information. | |||
| */ | |||
| public interface OnListFragmentInteractionListener { | |||
| // TODO: Update argument type and name | |||
| void onListFragmentInteraction(DetalleConteo item); | |||
| } | |||
| } | |||
| @ -0,0 +1,88 @@ | |||
| package jumapacelaya.gob.mx.almacen.ui.main; | |||
| import androidx.recyclerview.widget.RecyclerView; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.widget.TextView; | |||
| import jumapacelaya.gob.mx.almacen.R; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| import jumapacelaya.gob.mx.almacen.ui.main.PendienteFragment.OnListFragmentInteractionListener; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| * {@link RecyclerView.Adapter} that can display a {@link DetalleConteo} and makes a call to the | |||
| * specified {@link OnListFragmentInteractionListener}. | |||
| * TODO: Replace the implementation with code for your data type. | |||
| */ | |||
| public class PendienteViewAdapter extends RecyclerView.Adapter<PendienteViewAdapter.ViewHolder> { | |||
| private List<DetalleConteo> mValues; | |||
| private final OnListFragmentInteractionListener mListener; | |||
| public PendienteViewAdapter(OnListFragmentInteractionListener listener) { | |||
| mValues = new ArrayList<>(); | |||
| mListener = listener; | |||
| } | |||
| @Override | |||
| public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |||
| View view = LayoutInflater.from(parent.getContext()) | |||
| .inflate(R.layout.fragment_item, parent, false); | |||
| return new ViewHolder(view); | |||
| } | |||
| @Override | |||
| public void onBindViewHolder(final ViewHolder holder, int position) { | |||
| holder.mItem = mValues.get(position); | |||
| holder.mIdView.setText(mValues.get(position).getFolio().toString()); | |||
| holder.mContentView.setText(mValues.get(position).getDescArticulo()); | |||
| holder.mclave.setText(mValues.get(position).getClave()); | |||
| holder.mcantidad.setText(mValues.get(position).getCantidad().toString()); | |||
| holder.mView.setOnClickListener(v -> { | |||
| if (null != mListener) { | |||
| // Notify the active callbacks interface (the activity, if the | |||
| // fragment is attached to one) that an item has been selected. | |||
| mListener.onListFragmentInteraction(holder.mItem); | |||
| } | |||
| }); | |||
| } | |||
| @Override | |||
| public int getItemCount() { | |||
| return mValues.size(); | |||
| } | |||
| public void setData(List<DetalleConteo> newData) { | |||
| this.mValues = newData; | |||
| notifyDataSetChanged(); | |||
| } | |||
| public class ViewHolder extends RecyclerView.ViewHolder { | |||
| public final View mView; | |||
| public final TextView mIdView; | |||
| public final TextView mContentView; | |||
| public final TextView mclave; | |||
| public final TextView mcantidad; | |||
| public DetalleConteo mItem; | |||
| public ViewHolder(View view) { | |||
| super(view); | |||
| mView = view; | |||
| mIdView = view.findViewById(R.id.item_number); | |||
| mContentView = view.findViewById(R.id.content); | |||
| mclave = view.findViewById(R.id.item_clave); | |||
| mcantidad = view.findViewById(R.id.item_cantidad); | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return super.toString() + " '" + mContentView.getText() + "'"; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,363 @@ | |||
| package jumapacelaya.gob.mx.almacen.ui.main; | |||
| import android.app.Activity; | |||
| import android.app.Dialog; | |||
| import androidx.lifecycle.ViewModelProviders; | |||
| import android.content.ActivityNotFoundException; | |||
| import android.content.Context; | |||
| import android.content.DialogInterface; | |||
| import android.content.Intent; | |||
| import android.graphics.Color; | |||
| import android.net.Uri; | |||
| import android.os.AsyncTask; | |||
| import android.os.Bundle; | |||
| import androidx.annotation.NonNull; | |||
| import androidx.fragment.app.Fragment; | |||
| import androidx.appcompat.app.AlertDialog; | |||
| import android.os.Handler; | |||
| import android.os.Looper; | |||
| import android.text.util.Linkify; | |||
| import android.util.Log; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.view.inputmethod.InputMethodManager; | |||
| import android.widget.Button; | |||
| import android.widget.EditText; | |||
| import android.widget.TextView; | |||
| import android.widget.Toast; | |||
| import com.android.volley.Request; | |||
| import com.android.volley.RequestQueue; | |||
| import com.android.volley.toolbox.JsonObjectRequest; | |||
| import com.android.volley.toolbox.Volley; | |||
| import com.google.android.material.snackbar.Snackbar; | |||
| import com.google.gson.Gson; | |||
| import com.google.gson.GsonBuilder; | |||
| import com.google.zxing.integration.android.IntentIntegrator; | |||
| import com.google.zxing.integration.android.IntentResult; | |||
| import org.json.JSONException; | |||
| import org.json.JSONObject; | |||
| import java.math.BigDecimal; | |||
| import java.util.List; | |||
| import java.util.concurrent.ExecutorService; | |||
| import java.util.concurrent.Executors; | |||
| import jumapacelaya.gob.mx.almacen.ConteoActivity; | |||
| import jumapacelaya.gob.mx.almacen.InventarioService; | |||
| import jumapacelaya.gob.mx.almacen.MainActivity; | |||
| import jumapacelaya.gob.mx.almacen.R; | |||
| import jumapacelaya.gob.mx.almacen.bean.ArticuloScan; | |||
| import jumapacelaya.gob.mx.almacen.bean.Conteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| import jumapacelaya.gob.mx.almacen.dao.AppDatabase; | |||
| import jumapacelaya.gob.mx.almacen.dao.inventarioDao; | |||
| import jumapacelaya.gob.mx.almacen.restAlmacen; | |||
| import retrofit2.Call; | |||
| import retrofit2.Callback; | |||
| import retrofit2.Response; | |||
| import retrofit2.Retrofit; | |||
| import retrofit2.converter.gson.GsonConverterFactory; | |||
| import static android.app.ProgressDialog.show; | |||
| import static android.widget.Toast.LENGTH_SHORT; | |||
| import static androidx.core.content.ContextCompat.getSystemService; | |||
| /** | |||
| * A placeholder fragment containing a simple view. | |||
| */ | |||
| public class PlaceholderFragment extends Fragment { | |||
| private static final String ARG_SECTION_NUMBER = "section_number"; | |||
| static final String SCAN = "com.google.zxing.client.android"; | |||
| private PageViewModel pageViewModel; | |||
| TextView txtfolio; | |||
| TextView txtclave; | |||
| TextView txtarticulo; | |||
| TextView txtfamilia; | |||
| TextView txtsubfamilia; | |||
| EditText txtCantidad; | |||
| Button btnAceptar; | |||
| DetalleConteo detalle; | |||
| MainActivity activity; | |||
| Conteo conteo; | |||
| //ImageView code; | |||
| public PlaceholderFragment() { | |||
| } | |||
| public static PlaceholderFragment newInstance(int index, Conteo conteo, MainActivity activity) { | |||
| PlaceholderFragment fragment = new PlaceholderFragment(); | |||
| Bundle bundle = new Bundle(); | |||
| bundle.putInt(ARG_SECTION_NUMBER, index); | |||
| fragment.setArguments(bundle); | |||
| fragment.conteo = conteo; | |||
| fragment.activity = activity; | |||
| return fragment; | |||
| } | |||
| @Override | |||
| public void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| pageViewModel = ViewModelProviders.of(this).get(PageViewModel.class); | |||
| int index = 1; | |||
| if (getArguments() != null) { | |||
| index = getArguments().getInt(ARG_SECTION_NUMBER); | |||
| } | |||
| pageViewModel.setIndex(index); | |||
| } | |||
| @Override | |||
| public View onCreateView( | |||
| @NonNull LayoutInflater inflater, ViewGroup container, | |||
| Bundle savedInstanceState) { | |||
| View root = inflater.inflate(R.layout.fragment_main, container, false); | |||
| //controles | |||
| txtfolio = root.findViewById(R.id.txtcap_folio); | |||
| txtclave = root.findViewById(R.id.txtcap_clave); | |||
| txtarticulo = root.findViewById(R.id.txtcap_articulo); | |||
| //code = root.findViewById(R.id.imageView); | |||
| txtfamilia = root.findViewById(R.id.txtcap_descfamilia); | |||
| txtsubfamilia= root.findViewById(R.id.txtcap_subfamilia); | |||
| txtCantidad= root.findViewById(R.id.txtcap_Cantidad); | |||
| btnAceptar = root.findViewById(R.id.btncap_aceptar); | |||
| btnAceptar.setOnClickListener(event -> { | |||
| //guardar y enviar los datos | |||
| if(txtCantidad.getText().toString().trim().equals("")){ | |||
| Toast.makeText(getContext(), "El valor de cantidad no es valido", LENGTH_SHORT).show(); | |||
| return; | |||
| } | |||
| saveconteo(); | |||
| }); | |||
| /*pageViewModel.getText().observe(this, new Observer<String>() { | |||
| @Override | |||
| public void onChanged(@Nullable String s) { | |||
| //textView.setText(s); | |||
| } | |||
| });*/ | |||
| return root; | |||
| } | |||
| /*@Override | |||
| public void onActivityResult(int requestCode, int resultCode, Intent intent) { | |||
| try { | |||
| final IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); | |||
| if(scanResult != null) | |||
| handleResult(scanResult); | |||
| else | |||
| super.onActivityResult(requestCode, resultCode, intent); | |||
| }catch (Exception ex){ | |||
| Toast.makeText(getContext(), ex.getMessage(), LENGTH_SHORT).show(); | |||
| } | |||
| } | |||
| private void handleResult(IntentResult scanResult) { | |||
| if (scanResult != null) { | |||
| Gson gson = new Gson(); | |||
| ArticuloScan articuloScan = gson.fromJson(scanResult.getContents(), ArticuloScan.class); | |||
| if(articuloScan != null){ | |||
| final inventarioDao db = AppDatabase.getAppDatabaseDB(getContext()).inventarioDao(); | |||
| //consultar bae de datos | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| executor.execute(() -> { | |||
| detalle = db.getDetalleID(conteo.getInventariopk(), conteo.getConteopk(), articuloScan.getArticuloID()); | |||
| handler.post(() -> { | |||
| updateUITextViews(detalle); | |||
| }); | |||
| }); | |||
| }else{ | |||
| Toast.makeText(getContext(), "Información Incorrecta :(", LENGTH_SHORT).show(); | |||
| } | |||
| } else { | |||
| Toast.makeText(getContext(), "No se ha leído nada :(", LENGTH_SHORT).show(); | |||
| } | |||
| }*/ | |||
| private void updateUITextViews(DetalleConteo d) { | |||
| txtfolio.setText(d.getFolio()); | |||
| txtclave.setText(d.getClave()); | |||
| txtarticulo.setText(d.getArticulopk()); | |||
| Linkify.addLinks(txtfolio, Linkify.ALL); | |||
| } | |||
| private Dialog showDialog (final Activity act, CharSequence title, CharSequence message, CharSequence yes, CharSequence no ) { | |||
| // a subclass of dialog that can display buttons and message | |||
| AlertDialog.Builder download = new AlertDialog.Builder( act ); | |||
| download.setTitle( title ); | |||
| download.setMessage ( message ); | |||
| download.setPositiveButton ( yes, new DialogInterface.OnClickListener ( ) { | |||
| @Override | |||
| public void onClick( DialogInterface dialog, int i ) { | |||
| // TODO Auto-generated method stub | |||
| //uri to download barcode scanner | |||
| Uri uri = Uri.parse( "market://search?q=pname:" + "com.google.zxing.client.android" ); | |||
| Intent in = new Intent ( Intent.ACTION_VIEW, uri ); | |||
| try { | |||
| act.startActivity ( in ); | |||
| } catch ( ActivityNotFoundException e) { | |||
| } | |||
| } | |||
| }); | |||
| download.setNegativeButton ( no, new DialogInterface.OnClickListener() { | |||
| @Override | |||
| public void onClick ( DialogInterface dialog, int i ) { | |||
| // TODO Auto-generated method stub | |||
| } | |||
| }); | |||
| return download.show(); | |||
| } | |||
| //recibir datos | |||
| public void displayReceivedData(DetalleConteo detalle) | |||
| { | |||
| this.detalle = detalle; | |||
| txtfolio.setText(detalle.getFolio().toString()); | |||
| txtclave.setText(detalle.getClave()); | |||
| txtarticulo.setText(detalle.getDescArticulo()); | |||
| txtfamilia.setText(detalle.getDescFamilia()); | |||
| txtsubfamilia.setText(detalle.getDescSubFamilia()); | |||
| txtCantidad.setText(detalle.getCantidad() == null ? "0.0": detalle.getCantidad().toString()); | |||
| //txtCantidad.requestFocus(); | |||
| txtCantidad.selectAll(); | |||
| InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); | |||
| imm.showSoftInput(txtCantidad, InputMethodManager.SHOW_IMPLICIT); | |||
| Toast.makeText(getContext(),detalle.getDescArticulo(), LENGTH_SHORT).show(); | |||
| } | |||
| private void saveconteo(){ | |||
| if(detalle != null) { | |||
| detalle.setCantidad(new BigDecimal(txtCantidad.getText().toString())); | |||
| detalle.setEnviado(false); | |||
| new UpdateTask().execute(detalle); | |||
| } | |||
| } | |||
| private void updateServerDetalle(inventarioDao db, DetalleConteo d){ | |||
| final Activity thisactivity = getActivity(); | |||
| GsonBuilder builder = new GsonBuilder(); | |||
| builder.excludeFieldsWithoutExposeAnnotation(); | |||
| Retrofit retrofit = new Retrofit.Builder() | |||
| .baseUrl(restAlmacen.instance(activity).BASE_URL) | |||
| .addConverterFactory(GsonConverterFactory.create(builder.create())) | |||
| .build(); | |||
| InventarioService postService = retrofit.create(InventarioService.class); | |||
| Call<Void> call = postService.updateDetalle(d); | |||
| call.enqueue(new Callback<>() { | |||
| @Override | |||
| public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) { | |||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | |||
| Handler handler = new Handler(Looper.getMainLooper()); | |||
| executor.execute(() -> { | |||
| String msg = ""; | |||
| boolean flag = false; | |||
| if (response.code() == 200){ | |||
| flag = true; | |||
| d.setEnviado(true); | |||
| db.updateDetalle(d); | |||
| } | |||
| boolean finalFlag = flag; | |||
| String finalMsg = msg; | |||
| handler.post(() -> { | |||
| //if (finalFlag) | |||
| //Toast.makeText(thisactivity, "Articulo enviado", Toast.LENGTH_LONG).show(); | |||
| activity.refreshBadge(); | |||
| }); | |||
| }); | |||
| } | |||
| @Override | |||
| public void onFailure(Call<Void> call, Throwable t) { | |||
| //Toast.makeText(thisactivity, t.getMessage(), Toast.LENGTH_LONG).show(); | |||
| activity.refreshBadge(); | |||
| } | |||
| }); | |||
| } | |||
| private class UpdateTask extends AsyncTask<DetalleConteo, Void, Integer> { | |||
| Boolean tag = false; | |||
| /* | |||
| Ejecución del ordenamiento y transmision de progreso | |||
| */ | |||
| @Override | |||
| protected Integer doInBackground(DetalleConteo... params) { | |||
| final inventarioDao db = AppDatabase.getAppDatabaseDB(getContext()).inventarioDao(); | |||
| int i = 0; | |||
| for (DetalleConteo d:params) { | |||
| d.setActualizado(true); | |||
| d.setEnviado(false); | |||
| db.updateCantidad(d.getCantidad(), d.getAlmacenpk(), d.getConteopk(), d.getFolio(), d.getArticulopk(), d.getInventariopk(), d.getActualizado(), d.getEnviado()); | |||
| tag = true; | |||
| i++; | |||
| } | |||
| for (DetalleConteo d:params) { | |||
| //update server | |||
| updateServerDetalle(db, d); | |||
| } | |||
| //si ho hay error | |||
| activity.refreshBadge(); | |||
| return i; | |||
| } | |||
| @Override | |||
| protected void onPostExecute(Integer integer) { | |||
| if(tag) | |||
| Snackbar.make(activity.getCurrentFocus(), "Guardado", Snackbar.LENGTH_LONG) | |||
| .setBackgroundTint(Color.parseColor("#008000")) | |||
| .setActionTextColor(Color.parseColor("#000000")) | |||
| .show(); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,65 @@ | |||
| package jumapacelaya.gob.mx.almacen.ui.main; | |||
| import android.content.Context; | |||
| import androidx.annotation.Nullable; | |||
| import androidx.annotation.StringRes; | |||
| import androidx.fragment.app.Fragment; | |||
| import androidx.fragment.app.FragmentManager; | |||
| import androidx.fragment.app.FragmentPagerAdapter; | |||
| import jumapacelaya.gob.mx.almacen.MainActivity; | |||
| import jumapacelaya.gob.mx.almacen.R; | |||
| import jumapacelaya.gob.mx.almacen.ui.main.avance.AvanceFragment; | |||
| /** | |||
| * A [FragmentPagerAdapter] that returns a fragment corresponding to | |||
| * one of the sections/tabs/pages. | |||
| */ | |||
| public class SectionsPagerAdapter extends FragmentPagerAdapter { | |||
| @StringRes | |||
| private static final int[] TAB_TITLES = new int[]{R.string.tab_captura,R.string.tab_Avance, R.string.tab_Pendietnes}; | |||
| private final Context mContext; | |||
| public SectionsPagerAdapter(Context context, FragmentManager fm) { | |||
| super(fm); | |||
| mContext = context; | |||
| } | |||
| @Override | |||
| public Fragment getItem(int position) { | |||
| // getItem is called to instantiate the fragment for the given page. | |||
| // Return a PlaceholderFragment (defined as a static inner class below). | |||
| Fragment fragment; | |||
| switch (position){ | |||
| case 0: | |||
| fragment = PlaceholderFragment.newInstance(position + 1, ((MainActivity)mContext).getConteo(), (MainActivity)mContext); | |||
| break; | |||
| case 2: | |||
| fragment = PendienteFragment.newInstance(position , ((MainActivity)mContext).getConteo(), (MainActivity)mContext); | |||
| break; | |||
| case 1: | |||
| fragment = AvanceFragment.newInstance(position , ((MainActivity)mContext).getConteo(), (MainActivity)mContext); | |||
| break; | |||
| default: | |||
| throw new IllegalStateException("Unexpected value: " + position); | |||
| } | |||
| return fragment; | |||
| } | |||
| @Nullable | |||
| @Override | |||
| public CharSequence getPageTitle(int position) { | |||
| return mContext.getResources().getString(TAB_TITLES[position]); | |||
| } | |||
| @Override | |||
| public int getCount() { | |||
| // Show 2 total pages. | |||
| return 3; | |||
| } | |||
| } | |||
| @ -0,0 +1,124 @@ | |||
| package jumapacelaya.gob.mx.almacen.ui.main.avance; | |||
| import androidx.lifecycle.ViewModelProviders; | |||
| import android.content.Context; | |||
| import android.os.Bundle; | |||
| import androidx.fragment.app.Fragment; | |||
| import androidx.recyclerview.widget.LinearLayoutManager; | |||
| import androidx.recyclerview.widget.RecyclerView; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import jumapacelaya.gob.mx.almacen.MainActivity; | |||
| import jumapacelaya.gob.mx.almacen.R; | |||
| import jumapacelaya.gob.mx.almacen.bean.Conteo; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| import jumapacelaya.gob.mx.almacen.dao.PostViewModel; | |||
| /** | |||
| * A fragment representing a list of Items. | |||
| * <p/> | |||
| * Activities containing this fragment MUST implement the {@link OnListAvanceFragmentInteractionListener} | |||
| * interface. | |||
| */ | |||
| public class AvanceFragment extends Fragment { | |||
| // TODO: Customize parameter argument names | |||
| private static final String ARG_COLUMN_COUNT = "column-count"; | |||
| // TODO: Customize parameters | |||
| private int mColumnCount = 1; | |||
| PostViewModel postViewModel; | |||
| AvanceViewAdapter adapter; | |||
| Conteo conteo; | |||
| MainActivity activity; | |||
| private OnListAvanceFragmentInteractionListener mListener; | |||
| /** | |||
| * Mandatory empty constructor for the fragment manager to instantiate the | |||
| * fragment (e.g. upon screen orientation changes). | |||
| */ | |||
| public AvanceFragment() { | |||
| } | |||
| // TODO: Customize parameter initialization | |||
| @SuppressWarnings("unused") | |||
| public static AvanceFragment newInstance(int columnCount, Conteo conteo, MainActivity activity) { | |||
| AvanceFragment fragment = new AvanceFragment(); | |||
| Bundle args = new Bundle(); | |||
| args.putInt(ARG_COLUMN_COUNT, columnCount); | |||
| fragment.setArguments(args); | |||
| fragment.conteo = conteo; | |||
| fragment.activity = activity; | |||
| return fragment; | |||
| } | |||
| @Override | |||
| public void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| postViewModel = ViewModelProviders.of(this).get(PostViewModel.class); | |||
| if (getArguments() != null) { | |||
| mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT); | |||
| } | |||
| } | |||
| @Override | |||
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
| Bundle savedInstanceState) { | |||
| View view = inflater.inflate(R.layout.fragment_item_avance_list, container, false); | |||
| // Set the adapter | |||
| if (view instanceof RecyclerView) { | |||
| Context context = view.getContext(); | |||
| RecyclerView recyclerView = (RecyclerView) view; | |||
| //if (mColumnCount <= 1) { | |||
| recyclerView.setLayoutManager(new LinearLayoutManager(context)); | |||
| //} else { | |||
| // recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount)); | |||
| //} | |||
| adapter = new AvanceViewAdapter(mListener); | |||
| postViewModel.getAvanceConteo(conteo.getInventariopk(),conteo.getConteopk()).observe(getViewLifecycleOwner(), detalleConteos -> adapter.setData(detalleConteos)); | |||
| recyclerView.setAdapter(adapter); | |||
| } | |||
| return view; | |||
| } | |||
| @Override | |||
| public void onAttach(Context context) { | |||
| super.onAttach(context); | |||
| if (context instanceof OnListAvanceFragmentInteractionListener) { | |||
| mListener = (OnListAvanceFragmentInteractionListener) context; | |||
| } else { | |||
| throw new RuntimeException(context.toString() | |||
| + " must implement OnListFragmentInteractionListener"); | |||
| } | |||
| } | |||
| @Override | |||
| public void onDetach() { | |||
| super.onDetach(); | |||
| mListener = null; | |||
| } | |||
| /** | |||
| * This interface must be implemented by activities that contain this | |||
| * fragment to allow an interaction in this fragment to be communicated | |||
| * to the activity and potentially other fragments contained in that | |||
| * activity. | |||
| * <p/> | |||
| * See the Android Training lesson <a href= | |||
| * "http://developer.android.com/training/basics/fragments/communicating.html" | |||
| * >Communicating with Other Fragments</a> for more information. | |||
| */ | |||
| public interface OnListAvanceFragmentInteractionListener { | |||
| // TODO: Update argument type and name | |||
| void onListAvanceFragmentInteraction(DetalleConteo item); | |||
| } | |||
| } | |||
| @ -0,0 +1,95 @@ | |||
| package jumapacelaya.gob.mx.almacen.ui.main.avance; | |||
| import androidx.recyclerview.widget.RecyclerView; | |||
| import android.graphics.Color; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.widget.TextView; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import jumapacelaya.gob.mx.almacen.R; | |||
| import jumapacelaya.gob.mx.almacen.bean.DetalleConteo; | |||
| /** | |||
| * {@link RecyclerView.Adapter} that can display a {@link DetalleConteo} and makes a call to the | |||
| * specified {@link AvanceFragment.OnListAvanceFragmentInteractionListener}. | |||
| * TODO: Replace the implementation with code for your data type. | |||
| */ | |||
| public class AvanceViewAdapter extends RecyclerView.Adapter<AvanceViewAdapter.ViewHolder> { | |||
| private List<DetalleConteo> mValues; | |||
| private final AvanceFragment.OnListAvanceFragmentInteractionListener mListener; | |||
| public AvanceViewAdapter(AvanceFragment.OnListAvanceFragmentInteractionListener listener) { | |||
| mValues = new ArrayList<>(); | |||
| mListener = listener; | |||
| } | |||
| @Override | |||
| public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |||
| View view = LayoutInflater.from(parent.getContext()) | |||
| .inflate(R.layout.fragment_avance_item, parent, false); | |||
| return new ViewHolder(view); | |||
| } | |||
| @Override | |||
| public void onBindViewHolder(final ViewHolder holder, int position) { | |||
| holder.mItem = mValues.get(position); | |||
| holder.mIdView.setText(mValues.get(position).getFolio().toString()); | |||
| holder.mContentView.setText(mValues.get(position).getDescArticulo()); | |||
| holder.mclave.setText(mValues.get(position).getClave()); | |||
| holder.mCantidad.setText(mValues.get(position).getCantidad().toString()); | |||
| if(!mValues.get(position).getEnviado() && mValues.get(position).getActualizado()) { | |||
| holder.mclave.setBackgroundColor(Color.parseColor("#9b2226")); | |||
| }else{ | |||
| holder.mclave.setBackgroundColor(Color.parseColor("#FFFFFF")); | |||
| } | |||
| holder.mView.setOnClickListener(v -> { | |||
| if (null != mListener) { | |||
| // Notify the active callbacks interface (the activity, if the | |||
| // fragment is attached to one) that an item has been selected. | |||
| mListener.onListAvanceFragmentInteraction(holder.mItem); | |||
| } | |||
| }); | |||
| } | |||
| @Override | |||
| public int getItemCount() { | |||
| return mValues.size(); | |||
| } | |||
| public void setData(List<DetalleConteo> newData) { | |||
| this.mValues = newData; | |||
| notifyDataSetChanged(); | |||
| } | |||
| public class ViewHolder extends RecyclerView.ViewHolder { | |||
| public final View mView; | |||
| public final TextView mIdView; | |||
| public final TextView mContentView; | |||
| public final TextView mclave; | |||
| public final TextView mCantidad; | |||
| public DetalleConteo mItem; | |||
| public ViewHolder(View view) { | |||
| super(view); | |||
| mView = view; | |||
| mIdView = view.findViewById(R.id.item_number); | |||
| mContentView = view.findViewById(R.id.content); | |||
| mclave = view.findViewById(R.id.item_clave); | |||
| mCantidad = view.findViewById(R.id.item_cantidad); | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return super.toString() + " '" + mContentView.getText() + "'"; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,229 @@ | |||
| package jumapacelaya.gob.mx.almacen.updatepp; | |||
| import android.content.Intent; | |||
| import android.net.Uri; | |||
| import android.os.Build; | |||
| import android.os.Bundle; | |||
| import android.os.Environment; | |||
| import android.os.Handler; | |||
| import androidx.core.content.FileProvider; | |||
| import androidx.appcompat.app.AppCompatActivity; | |||
| import android.view.View; | |||
| import android.widget.Button; | |||
| import android.widget.TextView; | |||
| import android.widget.Toast; | |||
| import com.google.zxing.client.android.BuildConfig; | |||
| import java.io.File; | |||
| import jumapacelaya.gob.mx.almacen.R; | |||
| public class AutoUpdateActivity extends AppCompatActivity { | |||
| // Handler para la actualización de la interfaz desde el hilo en segundo | |||
| // plano | |||
| private Handler handler = new Handler(); | |||
| // Objeto de nuestra clase de utilidad | |||
| private VersionCheck mVC = new VersionCheck(); | |||
| // Elementos de la interfaz | |||
| private View mActualizada, mActualizacion, mProgressBar; | |||
| private TextView mVersionActual, mVersionNueva; | |||
| private Button mObtenerDatos, mDescargar; | |||
| // Runnable que se ejecutará desde el hilo principal cuando termina la | |||
| // obtención de datos en segundo plano. Equivalente al onPostExecute() de AsyncTask | |||
| private Runnable finishBackgroundDownload = new Runnable() { | |||
| @Override | |||
| public void run() { | |||
| mProgressBar.setVisibility(View.GONE); | |||
| if(mVC.isNewVersionAvailable()){ | |||
| // Hay una nueva versión disponible | |||
| mActualizacion.setVisibility(View.VISIBLE); | |||
| mActualizada.setVisibility(View.GONE); | |||
| // Mostramos los datos | |||
| mVersionActual.setText("Versión actual: " + mVC.getCurrentVersionName()); | |||
| mVersionNueva.setText("Versión disponible: " + mVC.getLatestVersionName()); | |||
| }else{ | |||
| // La aplicación está actualizada | |||
| mActualizacion.setVisibility(View.GONE); | |||
| mActualizada.setVisibility(View.VISIBLE); | |||
| } | |||
| } | |||
| }; | |||
| // Runnable encargado de descargar los datos en un hilo en segundo plano. | |||
| // Equivalente al doInBackground() de AsyncTask | |||
| private Runnable backgroundDownload = new Runnable() { | |||
| @Override | |||
| public void run() { | |||
| mVC.getData(AutoUpdateActivity.this); | |||
| // Cuando acabe la descarga actualiza la interfaz | |||
| handler.post(finishBackgroundDownload); | |||
| } | |||
| }; | |||
| // Runnable encargado de descargar los datos en un hilo en segundo plano. | |||
| // Equivalente al doInBackground() de AsyncTask | |||
| private Runnable backgroundDownloadAPK = new Runnable() { | |||
| @Override | |||
| public void run() { | |||
| try { | |||
| File storageDir = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS); | |||
| String pathapk = storageDir.getAbsolutePath() + "/almacen.apk"; //AutoUpdateActivity.this.getFilesDir() + "/lectura.apk"; | |||
| mVC.getDownloadURL(pathapk); | |||
| //final Uri uri = Uri.parse(pathapk); | |||
| //File toInstall = new File(pathapk); | |||
| File toInstall = new File(pathapk); | |||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |||
| Uri apkUri = FileProvider.getUriForFile(AutoUpdateActivity.this, BuildConfig.APPLICATION_ID + ".provider", toInstall); | |||
| Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); | |||
| intent.setData(apkUri); | |||
| intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | |||
| AutoUpdateActivity.this.startActivity(intent); | |||
| finish(); | |||
| } else { | |||
| Uri apkUri = Uri.fromFile(toInstall); | |||
| Intent intent = new Intent(Intent.ACTION_VIEW); | |||
| intent.setDataAndType(apkUri, "application/vnd.android.package-archive"); | |||
| intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
| AutoUpdateActivity.this.startActivity(intent); | |||
| finish(); | |||
| } | |||
| ///data/user/0/mx.gob.jumapacelaya.lecturas/files/lectura.apk | |||
| /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |||
| Uri contentUri = FileProvider.getUriForFile(getBaseContext(), BuildConfig.APPLICATION_ID + ".provider", new File(finalDestination)); | |||
| Intent openFileIntent = new Intent(Intent.ACTION_VIEW); | |||
| openFileIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | |||
| openFileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
| openFileIntent.setData(contentUri); | |||
| startActivity(openFileIntent); | |||
| finish(); | |||
| } else { | |||
| /*Uri apkUri = Uri.fromFile(new File(pathapk)); | |||
| Intent intent = new Intent(Intent.ACTION_VIEW); | |||
| intent.setDataAndType(apkUri, "application/vnd.android.package-archive"); | |||
| intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); | |||
| startActivity(intent); | |||
| finish(); | |||
| Uri apkUri = Uri.fromFile(new File(pathapk)); | |||
| Intent install = new Intent(Intent.ACTION_VIEW); | |||
| install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
| install.setDataAndType(apkUri, | |||
| "application/vnd.android.package-archive"); | |||
| startActivity(install); | |||
| finish(); | |||
| }*/ | |||
| }catch (Exception ex){ | |||
| ex.printStackTrace(); | |||
| Toast t = Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG); | |||
| t.show(); | |||
| } | |||
| } | |||
| }; | |||
| @Override | |||
| public void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| // Inicializa la interfaz | |||
| setContentView(R.layout.activity_auto_update); | |||
| mActualizada = findViewById(R.id.actualizada); | |||
| mActualizacion = findViewById(R.id.actualizacion); | |||
| mProgressBar = findViewById(R.id.progress_datos); | |||
| mDescargar = (Button)findViewById(R.id.bt_descarga); | |||
| mObtenerDatos = (Button)findViewById(R.id.bt_obtener_datos); | |||
| mVersionActual = (TextView)findViewById(R.id.actualizacion_version_actual); | |||
| mVersionNueva = (TextView)findViewById(R.id.actualizacion_version_nueva); | |||
| // Coloca listeners en los dos botones | |||
| mObtenerDatos.setOnClickListener(new View.OnClickListener() { | |||
| @Override | |||
| public void onClick(View v) { | |||
| // Crea un nuevo hilo para descargar los datos | |||
| mProgressBar.setVisibility(View.VISIBLE); | |||
| Thread downloadThread = new Thread(backgroundDownload, "VersionChecker"); | |||
| downloadThread.start(); | |||
| } | |||
| }); | |||
| mDescargar.setOnClickListener(new View.OnClickListener() { | |||
| @Override | |||
| public void onClick(View v) { | |||
| Thread downloadThread = new Thread(backgroundDownloadAPK, "APK Donwload"); | |||
| downloadThread.start(); | |||
| // Lanza un Intent con el enlace de la descarga, Android se | |||
| // encargará del resto | |||
| //startActivity(new Intent("android.intent.action.VIEW", Uri.parse(mVC.getDownloadURL()))); | |||
| /*String uri = "googlechrome://navigate?url=" + mVC.getDownloadURL(); | |||
| Intent i = new Intent(Intent.ACTION_VIEW); | |||
| i.setData(Uri.parse(uri)); | |||
| //i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
| //i.setPackage("com.android.chrome"); | |||
| startActivity(i); | |||
| */ | |||
| /*Intent intent = new Intent(); | |||
| intent.setAction(Intent.ACTION_VIEW); | |||
| intent.setData(Uri.parse("ftp://172.16.0.9:21")); | |||
| //You can add FTP credentials: | |||
| intent.putExtra("ftp_username", "lecturas"); | |||
| intent.putExtra("ftp_password", "lec134med"); | |||
| //intent.putExtra("ftp_keyfile", "/sdcard/rsakey.txt"); | |||
| //intent.putExtra("ftp_keypass", "optionalkeypassword"); | |||
| //If credentials are not provided but required then AndFTP will prompt for login and password. | |||
| //Setup optional FTP preferences: | |||
| intent.putExtra("ftp_pasv", "true"); | |||
| //intent.putExtra("ftps_mode", "implicit"); | |||
| //intent.putExtra("ftp_encoding", "UTF-8"); | |||
| //Finally start the Activity: | |||
| //startActivityForResult(intent, BROWSE_REQUEST); | |||
| startActivity(intent);*/ | |||
| /*Intent i = new Intent(Intent.ACTION_VIEW); | |||
| i.setData(Uri.parse(mVC.getDownloadURL())); | |||
| i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
| i.setPackage("com.android.chrome");*/ | |||
| /*PackageManager packageManager = AutoUpdateActivity.this.getPackageManager(); | |||
| File file = new File(AutoUpdateActivity.this.getFilesDir(),"lecturas.apk"); | |||
| String mimeType = "application/vnd.android.package-archive"; | |||
| String target= mVC.getDownloadURL(); | |||
| Intent intent = new Intent(android.content.Intent.ACTION_SENDTO); | |||
| intent.setDataAndType(android.net.Uri.parse(target),mimeType); | |||
| //intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); | |||
| startActivity(intent); | |||
| if (packageManager.queryIntentActivities(intent,0).size() == 0) { | |||
| Toast.makeText(getBaseContext(), | |||
| "", Toast.LENGTH_LONG) | |||
| .show(); | |||
| } else { | |||
| startActivity(intent); | |||
| }*/ | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| @ -0,0 +1,41 @@ | |||
| package jumapacelaya.gob.mx.almacen.updatepp; | |||
| import com.google.gson.Gson; | |||
| public class Version { | |||
| private double versionCode; | |||
| private String versionName; | |||
| private String downloadURL; | |||
| public static Version fromJson(String s){ | |||
| return new Gson().fromJson(s, Version.class); | |||
| } | |||
| public String toString(){ | |||
| return new Gson().toJson(this); | |||
| } | |||
| public double getVersionCode() { | |||
| return versionCode; | |||
| } | |||
| public void setVersionCode(double versionCode) { | |||
| this.versionCode = versionCode; | |||
| } | |||
| public String getVersionName() { | |||
| return versionName; | |||
| } | |||
| public void setVersionName(String versionName) { | |||
| this.versionName = versionName; | |||
| } | |||
| public String getDownloadURL() { | |||
| return downloadURL; | |||
| } | |||
| public void setDownloadURL(String downloadURL) { | |||
| this.downloadURL = downloadURL; | |||
| } | |||
| } | |||
| @ -0,0 +1,294 @@ | |||
| package jumapacelaya.gob.mx.almacen.updatepp; | |||
| import android.content.Context; | |||
| import android.content.pm.PackageInfo; | |||
| import android.content.pm.PackageManager; | |||
| import android.util.Log; | |||
| import org.json.JSONException; | |||
| import org.json.JSONObject; | |||
| import java.io.BufferedOutputStream; | |||
| import java.io.BufferedReader; | |||
| import java.io.File; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.InputStreamReader; | |||
| import java.io.OutputStream; | |||
| import java.net.HttpURLConnection; | |||
| import java.net.URL; | |||
| import java.net.URLConnection; | |||
| public class VersionCheck { | |||
| /** | |||
| * Enlace al archivo publico de la version | |||
| */ | |||
| public static final String INFO_FILE = "https://www.dropbox.com/s/8xp3jss13vfpvd3/versionApp.txt?dl=0"; | |||
| public static final String SERVER = "172.16.0.9"; | |||
| public static final String FTP_INFO_FILE = "versionApp.txt"; | |||
| public static final String FTP_USER = "almacen"; | |||
| public static final String FTP_PWD = "alm134jumapa"; | |||
| /** | |||
| * El código de versión establecido en el AndroidManifest.xml de la versión | |||
| * instalada de la aplicación. Es el valor numérico que usa Android para | |||
| * diferenciar las versiones. | |||
| */ | |||
| private int currentVersionCode; | |||
| /** | |||
| * El nombre de versión establecido en el AndroidManifest.xml de la versión | |||
| * instalada. Es la cadena de texto que se usa para identificar al versión | |||
| * de cara al usuario. | |||
| */ | |||
| private String currentVersionName; | |||
| /** | |||
| * El código de versión establecido en el AndroidManifest.xml de la última | |||
| * versión disponible de la aplicación. | |||
| */ | |||
| private int latestVersionCode; | |||
| /** | |||
| * El nombre de versión establecido en el AndroidManifest.xml de la última | |||
| * versión disponible. | |||
| */ | |||
| private String latestVersionName; | |||
| /** | |||
| * Enlace de descarga directa de la última versión disponible. | |||
| */ | |||
| private String downloadURL; | |||
| /** | |||
| * Método para inicializar el objeto. Se debe llamar antes que a cualquie | |||
| * otro, y en un hilo propio (o un AsyncTask) para no bloquear al interfaz | |||
| * ya que hace uso de Internet. | |||
| * | |||
| * @param context | |||
| * El contexto de la aplicación, para obtener la información de | |||
| * la versión actual. | |||
| */ | |||
| public void getData(Context context) { | |||
| try{ | |||
| // Datos locales | |||
| PackageInfo pckginfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); | |||
| currentVersionCode = pckginfo.versionCode; | |||
| currentVersionName = pckginfo.versionName; | |||
| // Datos remotos | |||
| //String data = downloadHttp(new URL(INFO_FILE)); | |||
| //Por FTP | |||
| String data = downloadFtp2(); | |||
| JSONObject json = new JSONObject(data); | |||
| if(json.has("lecturas")){ | |||
| json = json.getJSONObject("lecturas"); | |||
| latestVersionCode = json.getInt("versionCode"); | |||
| latestVersionName = json.getString("versionName"); | |||
| downloadURL = json.getString("downloadURL"); | |||
| Log.d("AutoUpdate", "Datos obtenidos con éxito"); | |||
| } | |||
| }catch(JSONException e){ | |||
| Log.e("AutoUpdate", "Ha habido un error con el JSON", e); | |||
| }catch(PackageManager.NameNotFoundException e){ | |||
| Log.e("AutoUpdate", "Ha habido un error con el packete :S", e); | |||
| }catch(IOException e){ | |||
| Log.e("AutoUpdate", "Ha habido un error con la descarga", e); | |||
| } | |||
| } | |||
| /** | |||
| * Método para comparar la versión actual con la última . | |||
| * | |||
| * @return true si hay una versión más nueva disponible que la actual. | |||
| */ | |||
| public boolean isNewVersionAvailable() { | |||
| if(getLatestVersionCode() > getCurrentVersionCode()) | |||
| return true; | |||
| else if(getLatestVersionCode() == getCurrentVersionCode()) | |||
| return !getLatestVersionName().equals(getCurrentVersionName()); | |||
| else | |||
| return false; | |||
| } | |||
| /** | |||
| * Devuelve el código de versión actual. | |||
| * | |||
| * @return | |||
| */ | |||
| public int getCurrentVersionCode() { | |||
| return currentVersionCode; | |||
| } | |||
| /** | |||
| * Devuelve el nombre de versión actual. | |||
| * | |||
| * @return | |||
| */ | |||
| public String getCurrentVersionName() { | |||
| return currentVersionName; | |||
| } | |||
| /** | |||
| * Devuelve el código de la última versión disponible. | |||
| * | |||
| * @return | |||
| */ | |||
| public int getLatestVersionCode() { | |||
| return latestVersionCode; | |||
| } | |||
| /** | |||
| * Devuelve el nombre de la última versión disponible. | |||
| * | |||
| * @return | |||
| */ | |||
| public String getLatestVersionName() { | |||
| return latestVersionName; | |||
| } | |||
| /** | |||
| * Devuelve el enlace de descarga de la última versión disponible | |||
| * | |||
| * @return | |||
| */ | |||
| public boolean getDownloadURL(String path) throws IOException { | |||
| String ftpUrl = String.format( | |||
| "ftp://"+FTP_USER+":"+FTP_PWD+"@"+SERVER+":%d/" + downloadURL, 21); | |||
| URLConnection urlConnection = new URL(ftpUrl).openConnection(); | |||
| InputStream inputStream = urlConnection.getInputStream(); | |||
| File file = new File(path); | |||
| if (file.exists()) | |||
| file.delete(); | |||
| //write file | |||
| OutputStream out = new BufferedOutputStream(new FileOutputStream(path)); | |||
| byte[] buffer = new byte[1024]; | |||
| int lengthRead; | |||
| while((lengthRead = inputStream.read(buffer))>0) | |||
| { | |||
| out.write(buffer, 0, lengthRead); | |||
| out.flush(); | |||
| } | |||
| out.close(); | |||
| inputStream.close(); | |||
| return true; | |||
| } | |||
| /** | |||
| * Método auxiliar usado por getData() para leer el archivo de información. | |||
| * Encargado de conectarse a la red, descargar el archivo y convertirlo a | |||
| * String. | |||
| * | |||
| * @param url | |||
| * La URL del archivo que se quiere descargar. | |||
| * @return Cadena de texto con el contenido del archivo | |||
| * @throws IOException | |||
| * Si hay algún problema en la conexión | |||
| */ | |||
| private static String downloadHttp(URL url) throws IOException { | |||
| HttpURLConnection c = (HttpURLConnection)url.openConnection(); | |||
| c.setRequestMethod("GET"); | |||
| c.setReadTimeout(15 * 1000); | |||
| c.setUseCaches(false); | |||
| c.connect(); | |||
| BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream())); | |||
| StringBuilder stringBuilder = new StringBuilder(); | |||
| String line = null; | |||
| while((line = reader.readLine()) != null){ | |||
| stringBuilder.append(line + "n"); | |||
| } | |||
| return stringBuilder.toString(); | |||
| } | |||
| /** | |||
| * Método auxiliar usado por getData() para leer el archivo de información. | |||
| * Encargado de conectarse a la red, descargar el archivo y convertirlo a | |||
| * String. | |||
| * | |||
| * @return Cadena de texto con el contenido del archivo | |||
| * @throws IOException | |||
| * Si hay algún problema en la conexión | |||
| */ | |||
| private static String downloadFtp2() throws IOException { | |||
| String ftpUrl = String.format( | |||
| "ftp://"+FTP_USER+":"+FTP_PWD+"@"+SERVER+":%d/" + FTP_INFO_FILE, 21); | |||
| URLConnection urlConnection = new URL(ftpUrl).openConnection(); | |||
| InputStream inputStream = urlConnection.getInputStream(); | |||
| BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); | |||
| StringBuilder stringBuilder = new StringBuilder(); | |||
| String line = null; | |||
| while((line = reader.readLine()) != null){ | |||
| stringBuilder.append(line + "\n"); | |||
| } | |||
| return stringBuilder.toString(); | |||
| } | |||
| /** | |||
| * Método auxiliar usado por getData() para leer el archivo de información. | |||
| * Encargado de conectarse a la red, descargar el archivo y convertirlo a | |||
| * String. | |||
| * | |||
| * @param server | |||
| * La URL del archivo que se quiere descargar. | |||
| * @return Cadena de texto con el contenido del archivo | |||
| * @throws IOException | |||
| * Si hay algún problema en la conexión | |||
| */ | |||
| /*private static String downloadFtp(String server, String fileversion) throws IOException { | |||
| boolean status = false; | |||
| StringBuilder stringBuilder = new StringBuilder(); | |||
| try { | |||
| FTPClient ftpClient = new FTPClient(); | |||
| ftpClient.setConnectTimeout(10 * 1000); | |||
| ftpClient.connect(InetAddress.getByName(server)); | |||
| status = ftpClient.login(FTP_USER, FTP_PWD); | |||
| Log.e("isFTPConnect", String.valueOf(status)); | |||
| if(FTPReply.isPositiveCompletion(ftpClient.getReplyCode())){ | |||
| ftpClient.setFileType(FTP.ASCII_FILE_TYPE); | |||
| ftpClient.enterLocalActiveMode(); | |||
| String workingDir = ftpClient.printWorkingDirectory(); | |||
| ftpClient.changeWorkingDirectory("apps"); | |||
| FileOutputStream desFileStream = new FileOutputStream(desFilePath); | |||
| status = ftpClient.retrieveFile(srcFilePath, desFileStream); | |||
| desFileStream.close(); | |||
| BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream())); | |||
| String line = null; | |||
| while ((line = reader.readLine()) != null) { | |||
| stringBuilder.append(line + "n"); | |||
| } | |||
| } | |||
| ftpClient.logout(); | |||
| ftpClient.disconnect(); | |||
| }catch (SocketException e){ | |||
| }catch (UnknownHostException e){ | |||
| }catch (IOException e){ | |||
| } | |||
| return stringBuilder.toString(); | |||
| }*/ | |||
| } | |||
| @ -0,0 +1,17 @@ | |||
| package jumapacelaya.gob.mx.almacen.utils; | |||
| public class StringUitils { | |||
| public static String jsonescape(String raw){ | |||
| String escaped = raw; | |||
| escaped = escaped.replace("\\", "\\\\"); | |||
| escaped = escaped.replace("\"", "\\\""); | |||
| escaped = escaped.replace("\b", "\\b"); | |||
| escaped = escaped.replace("\f", "\\f"); | |||
| escaped = escaped.replace("\n", "\\n"); | |||
| escaped = escaped.replace("\r", "\\r"); | |||
| escaped = escaped.replace("\t", "\\t"); | |||
| // TODO: escape other non-printing characters using uXXXX notation | |||
| return escaped; | |||
| } | |||
| } | |||
| @ -0,0 +1,12 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <rotate | |||
| xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:fromDegrees="0" | |||
| android:interpolator="@android:anim/linear_interpolator" | |||
| android:toDegrees="360" | |||
| android:pivotX="50%" | |||
| android:pivotY="50%" | |||
| android:duration="500" | |||
| android:startOffset="0" | |||
| android:repeatCount="infinite" | |||
| /> | |||
| @ -0,0 +1,34 @@ | |||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:aapt="http://schemas.android.com/aapt" | |||
| android:width="108dp" | |||
| android:height="108dp" | |||
| android:viewportWidth="108" | |||
| android:viewportHeight="108"> | |||
| <path | |||
| android:fillType="evenOdd" | |||
| android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z" | |||
| android:strokeWidth="1" | |||
| android:strokeColor="#00000000"> | |||
| <aapt:attr name="android:fillColor"> | |||
| <gradient | |||
| android:endX="78.5885" | |||
| android:endY="90.9159" | |||
| android:startX="48.7653" | |||
| android:startY="61.0927" | |||
| android:type="linear"> | |||
| <item | |||
| android:color="#44000000" | |||
| android:offset="0.0" /> | |||
| <item | |||
| android:color="#00000000" | |||
| android:offset="1.0" /> | |||
| </gradient> | |||
| </aapt:attr> | |||
| </path> | |||
| <path | |||
| android:fillColor="#FFFFFF" | |||
| android:fillType="nonZero" | |||
| android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z" | |||
| android:strokeWidth="1" | |||
| android:strokeColor="#00000000" /> | |||
| </vector> | |||
| @ -0,0 +1,9 @@ | |||
| <shape xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <solid | |||
| android:color="#00ac73"/> | |||
| <corners | |||
| android:bottomLeftRadius="48dp" | |||
| android:topLeftRadius="48dp" | |||
| android:bottomRightRadius="48dp" | |||
| android:topRightRadius="48dp"/> | |||
| </shape> | |||
| @ -0,0 +1,11 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <ripple xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:color="?android:attr/colorControlHighlight"> | |||
| <item android:id="@android:id/mask"> | |||
| <shape android:shape="rectangle"> | |||
| <solid android:color="#FFF" /> | |||
| <corners android:radius="15dp" /> | |||
| </shape> | |||
| </item> | |||
| <item android:drawable="@drawable/bg" /> | |||
| </ripple> | |||
| @ -0,0 +1,9 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <ripple xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:color="@color/white"> | |||
| <item> | |||
| <shape android:shape="rectangle"> | |||
| <solid android:color="@color/colorSecondary" /> | |||
| </shape> | |||
| </item> | |||
| </ripple> | |||
| @ -0,0 +1,13 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <animation-list xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <item android:duration="5000" | |||
| android:drawable="@drawable/gradient_start"/> | |||
| <item android:duration="5000" | |||
| android:drawable="@drawable/gradient_center"/> | |||
| <item android:duration="5000" | |||
| android:drawable="@drawable/gradient_end"/> | |||
| </animation-list> | |||
| @ -0,0 +1,10 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:shape="rectangle"> | |||
| <gradient | |||
| android:type="linear" | |||
| android:angle="315" | |||
| android:startColor="@color/colorGradientCenter" | |||
| android:centerColor="@color/colorGradientEnd" | |||
| android:endColor="@color/colorGradientStart"/> | |||
| </shape> | |||
| @ -0,0 +1,10 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:shape="rectangle"> | |||
| <gradient | |||
| android:type="linear" | |||
| android:angle="315" | |||
| android:startColor="@color/colorGradientEnd" | |||
| android:centerColor="@color/colorGradientStart" | |||
| android:endColor="@color/colorGradientCenter"/> | |||
| </shape> | |||
| @ -0,0 +1,9 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:shape="rectangle"> | |||
| <gradient | |||
| android:type="linear" | |||
| android:angle="270" | |||
| android:startColor="@color/fondopantalla" | |||
| android:endColor="@color/fondopantalla2"/> | |||
| </shape> | |||
| @ -0,0 +1,10 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:shape="rectangle"> | |||
| <gradient | |||
| android:type="linear" | |||
| android:angle="315" | |||
| android:startColor="@color/colorGradientStart" | |||
| android:centerColor="@color/colorGradientCenter" | |||
| android:endColor="@color/colorGradientEnd"/> | |||
| </shape> | |||
| @ -0,0 +1,16 @@ | |||
| <vector android:height="24dp" android:viewportHeight="480" | |||
| android:viewportWidth="480" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <path android:fillColor="#2196F3" android:pathData="M80,48H16C7.168,48 0,55.168 0,64v64c0,8.832 7.168,16 16,16s16,-7.168 16,-16V80h48c8.832,0 16,-7.168 16,-16S88.832,48 80,48z"/> | |||
| <path android:fillColor="#2196F3" android:pathData="M464,336c-8.832,0 -16,7.168 -16,16v48h-48c-8.832,0 -16,7.168 -16,16s7.168,16 16,16h64c8.832,0 16,-7.168 16,-16v-64C480,343.168 472.832,336 464,336z"/> | |||
| <path android:fillColor="#2196F3" android:pathData="M464,48h-64c-8.832,0 -16,7.168 -16,16s7.168,16 16,16h48v48c0,8.832 7.168,16 16,16s16,-7.168 16,-16V64C480,55.168 472.832,48 464,48z"/> | |||
| <path android:fillColor="#2196F3" android:pathData="M80,400H32v-48c0,-8.832 -7.168,-16 -16,-16s-16,7.168 -16,16v64c0,8.832 7.168,16 16,16h64c8.832,0 16,-7.168 16,-16S88.832,400 80,400z"/> | |||
| <path android:fillColor="#455A64" android:pathData="M64,112h32v256h-32z"/> | |||
| <path android:fillColor="#455A64" android:pathData="M128,112h32v192h-32z"/> | |||
| <path android:fillColor="#455A64" android:pathData="M192,112h32v192h-32z"/> | |||
| <path android:fillColor="#455A64" android:pathData="M256,112h32v256h-32z"/> | |||
| <path android:fillColor="#455A64" android:pathData="M320,112h32v192h-32z"/> | |||
| <path android:fillColor="#455A64" android:pathData="M384,112h32v256h-32z"/> | |||
| <path android:fillColor="#455A64" android:pathData="M128,336h32v32h-32z"/> | |||
| <path android:fillColor="#455A64" android:pathData="M192,336h32v32h-32z"/> | |||
| <path android:fillColor="#455A64" android:pathData="M320,336h32v32h-32z"/> | |||
| </vector> | |||
| @ -0,0 +1,170 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:width="108dp" | |||
| android:height="108dp" | |||
| android:viewportWidth="108" | |||
| android:viewportHeight="108"> | |||
| <path | |||
| android:fillColor="#008577" | |||
| android:pathData="M0,0h108v108h-108z" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M9,0L9,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M19,0L19,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M29,0L29,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M39,0L39,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M49,0L49,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M59,0L59,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M69,0L69,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M79,0L79,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M89,0L89,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M99,0L99,108" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,9L108,9" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,19L108,19" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,29L108,29" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,39L108,39" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,49L108,49" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,59L108,59" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,69L108,69" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,79L108,79" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,89L108,89" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M0,99L108,99" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M19,29L89,29" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M19,39L89,39" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M19,49L89,49" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M19,59L89,59" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M19,69L89,69" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M19,79L89,79" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M29,19L29,89" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M39,19L39,89" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M49,19L49,89" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M59,19L59,89" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M69,19L69,89" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| <path | |||
| android:fillColor="#00000000" | |||
| android:pathData="M79,19L79,89" | |||
| android:strokeWidth="0.8" | |||
| android:strokeColor="#33FFFFFF" /> | |||
| </vector> | |||
| @ -0,0 +1,10 @@ | |||
| <vector android:height="25dp" android:viewportHeight="51" | |||
| android:viewportWidth="51" android:width="25dp" xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <path android:fillColor="#00000000" android:pathData="M25,13L25,38" | |||
| android:strokeColor="#43A047" android:strokeLineCap="round" | |||
| android:strokeLineJoin="round" android:strokeWidth="2"/> | |||
| <path android:fillColor="#00000000" | |||
| android:pathData="M37.5,25L12.5,25" | |||
| android:strokeColor="#43A047" android:strokeLineCap="round" | |||
| android:strokeLineJoin="round" android:strokeWidth="2"/> | |||
| </vector> | |||
| @ -0,0 +1,94 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:layout_width="fill_parent" | |||
| android:layout_height="fill_parent" | |||
| android:orientation="vertical" > | |||
| <LinearLayout | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:orientation="vertical" > | |||
| <TextView | |||
| android:id="@+id/textView1" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="Lecturas.jumapacelaya AutoUpdater" | |||
| android:gravity="center" | |||
| android:textAppearance="?android:attr/textAppearanceLarge" /> | |||
| </LinearLayout> | |||
| <TextView | |||
| android:id="@+id/textView3" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:text="@string/version_name" | |||
| android:paddingBottom="10dp" | |||
| android:textAppearance="?android:attr/textAppearanceMedium" /> | |||
| <Button | |||
| android:id="@+id/bt_obtener_datos" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:text="Verificar Versión" /> | |||
| <ProgressBar | |||
| android:id="@+id/progress_datos" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:visibility="gone" /> | |||
| <TextView | |||
| android:id="@+id/actualizada" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:visibility="gone" | |||
| android:text="La aplicación está actualiza :)" | |||
| android:textAppearance="?android:attr/textAppearanceLarge" /> | |||
| <LinearLayout | |||
| android:id="@+id/actualizacion" | |||
| android:layout_width="fill_parent" | |||
| android:layout_height="fill_parent" | |||
| android:layout_gravity="center_horizontal" | |||
| android:orientation="vertical" | |||
| android:gravity="center" | |||
| android:padding="15dp" | |||
| android:visibility="gone" > | |||
| <TextView | |||
| android:id="@+id/textView2" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:gravity="center_horizontal" | |||
| android:text="Hay una actualización disponible!" | |||
| android:textAppearance="?android:attr/textAppearanceLarge" /> | |||
| <TextView | |||
| android:id="@+id/actualizacion_version_actual" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="Versión actual: " | |||
| android:textAppearance="?android:attr/textAppearanceMedium" /> | |||
| <TextView | |||
| android:id="@+id/actualizacion_version_nueva" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="Versión disponible: " | |||
| android:textAppearance="?android:attr/textAppearanceMedium" /> | |||
| <Button | |||
| android:id="@+id/bt_descarga" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:text="Descargar" /> | |||
| </LinearLayout> | |||
| </LinearLayout> | |||
| @ -0,0 +1,58 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| android:id="@+id/root_conteo_layout" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:padding="0dp" | |||
| tools:context=".ConteoActivity"> | |||
| <TextView | |||
| android:id="@+id/lbConteo" | |||
| android:layout_width="200dp" | |||
| android:layout_height="35dp" | |||
| android:text="@string/selecciona_conteo" | |||
| android:textAlignment="center" | |||
| android:textSize="24sp" | |||
| app:layout_constraintBottom_toTopOf="@+id/btnIniciar" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintHorizontal_bias="0.497" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" | |||
| app:layout_constraintVertical_bias="0.217" /> | |||
| <Spinner | |||
| android:id="@+id/cbxInventarios" | |||
| android:layout_width="242dp" | |||
| android:layout_height="38dp" | |||
| android:layout_marginTop="40dp" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintHorizontal_bias="0.497" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toBottomOf="@+id/lbConteo" /> | |||
| <Spinner | |||
| android:id="@+id/cbxConteos" | |||
| android:layout_width="242dp" | |||
| android:layout_height="38dp" | |||
| android:layout_marginTop="44dp" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintHorizontal_bias="0.497" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toBottomOf="@+id/cbxInventarios" /> | |||
| <Button | |||
| android:id="@+id/btnIniciar" | |||
| android:layout_width="0dp" | |||
| android:layout_height="85dip" | |||
| android:text="@string/iniciar" | |||
| android:background="@drawable/custom_ripple2" | |||
| android:textColor="@color/white" | |||
| android:textSize="30sp" | |||
| app:layout_constraintBottom_toBottomOf="parent" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintHorizontal_bias="1.0" | |||
| app:layout_constraintStart_toStartOf="parent" /> | |||
| </androidx.constraintlayout.widget.ConstraintLayout> | |||
| @ -0,0 +1,44 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| tools:context=".MainActivity"> | |||
| <com.google.android.material.appbar.AppBarLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| > | |||
| <com.google.android.material.appbar.MaterialToolbar | |||
| android:id="@+id/topAppBar" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="?attr/actionBarSize" | |||
| app:title="@string/splash_title" | |||
| style="@style/Widget.MaterialComponents.Toolbar.Primary" | |||
| /> | |||
| <com.google.android.material.tabs.TabLayout | |||
| android:id="@+id/tabs" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| /> | |||
| </com.google.android.material.appbar.AppBarLayout> | |||
| <androidx.viewpager.widget.ViewPager | |||
| android:id="@+id/view_pager" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| app:layout_behavior="@string/appbar_scrolling_view_behavior" /> | |||
| <com.google.android.material.floatingactionbutton.FloatingActionButton | |||
| android:id="@+id/fab" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="bottom|end" | |||
| android:layout_margin="@dimen/fab_margin" | |||
| android:contentDescription="@string/escanar_codigo" | |||
| app:backgroundTint="@color/colorPrimaryLight" | |||
| app:srcCompat="@drawable/ic_barcode" /> | |||
| </androidx.coordinatorlayout.widget.CoordinatorLayout> | |||
| @ -0,0 +1,37 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:background="@color/design_default_color_on_secondary" | |||
| tools:context=".splash"> | |||
| <ImageView | |||
| android:id="@+id/img_logo_splash" | |||
| android:layout_width="257dp" | |||
| android:layout_height="253dp" | |||
| android:contentDescription="@string/splash_logo" | |||
| android:src="@drawable/logojumcel" | |||
| app:layout_constraintBottom_toBottomOf="parent" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <TextView | |||
| android:id="@+id/editText" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="16dp" | |||
| android:ems="12" | |||
| android:fontFamily="casual" | |||
| android:text="@string/splash_title" | |||
| android:textAlignment="center" | |||
| android:textColor="#FFFFFF" | |||
| android:textSize="24sp" | |||
| android:textStyle="bold" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toBottomOf="@+id/img_logo_splash" /> | |||
| </androidx.constraintlayout.widget.ConstraintLayout> | |||
| @ -0,0 +1,93 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| > | |||
| <!--app:cardCornerRadius="4dp" app:cardElevation="4dp" android:layout_margin="5dp"--> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="100dp" | |||
| android:orientation="vertical"> | |||
| <RelativeLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="98dp" | |||
| android:background="?android:attr/selectableItemBackground" | |||
| android:padding="5dp"> | |||
| <TextView | |||
| android:id="@+id/item_number" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_alignParentTop="true" | |||
| android:textAppearance="?attr/textAppearanceListItem" | |||
| android:textSize="28sp" | |||
| tools:text="10001" /> | |||
| <TextView | |||
| android:id="@+id/item_clave" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_alignParentEnd="true" | |||
| android:textAppearance="?attr/textAppearanceListItem" | |||
| android:textSize="28sp" | |||
| tools:text="VF001" /> | |||
| <LinearLayout | |||
| android:id="@+id/layer_cantidad" | |||
| android:layout_width="146dp" | |||
| android:layout_height="29dp" | |||
| android:layout_below="@+id/item_clave" | |||
| android:layout_alignParentEnd="true" | |||
| android:layout_marginTop="3dp" | |||
| android:orientation="horizontal"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="match_parent" | |||
| android:gravity="center" | |||
| android:text="Cantidad" /> | |||
| <TextView | |||
| android:id="@+id/item_cantidad" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:layout_below="@+id/item_clave" | |||
| android:layout_alignParentEnd="true" | |||
| android:layout_marginStart="10dp" | |||
| android:hint="Cantidad" | |||
| android:textAppearance="?attr/textAppearanceListItem" | |||
| android:textSize="18sp" | |||
| tools:text="25" /> | |||
| </LinearLayout> | |||
| <TextView | |||
| android:id="@+id/content" | |||
| android:layout_width="252dp" | |||
| android:layout_height="44dp" | |||
| android:layout_below="@+id/item_number" | |||
| android:layout_alignParentStart="true" | |||
| android:layout_marginTop="1dp" | |||
| android:layout_marginEnd="4dp" | |||
| android:layout_toStartOf="@+id/layer_cantidad" | |||
| android:textAlignment="viewStart" | |||
| android:textSize="18sp" | |||
| tools:text="Almabre de Cobre 1/2'" /> | |||
| </RelativeLayout> | |||
| <View | |||
| android:id="@+id/border" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="1dp" | |||
| android:background="#2196F3" /> | |||
| </LinearLayout> | |||
| </androidx.cardview.widget.CardView> | |||
| @ -0,0 +1,93 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| > | |||
| <!--app:cardCornerRadius="4dp" app:cardElevation="4dp" android:layout_margin="5dp"--> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="100dp" | |||
| android:orientation="vertical"> | |||
| <RelativeLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="98dp" | |||
| android:background="?android:attr/selectableItemBackground" | |||
| android:padding="5dp"> | |||
| <TextView | |||
| android:id="@+id/item_number" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_alignParentTop="true" | |||
| android:textAppearance="?attr/textAppearanceListItem" | |||
| android:textSize="28sp" | |||
| tools:text="10001" /> | |||
| <TextView | |||
| android:id="@+id/item_clave" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_alignParentEnd="true" | |||
| android:textAppearance="?attr/textAppearanceListItem" | |||
| android:textSize="28sp" | |||
| tools:text="VF001" /> | |||
| <LinearLayout | |||
| android:id="@+id/layer_cantidad" | |||
| android:layout_width="146dp" | |||
| android:layout_height="29dp" | |||
| android:layout_below="@+id/item_clave" | |||
| android:layout_alignParentEnd="true" | |||
| android:layout_marginTop="3dp" | |||
| android:orientation="horizontal"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="match_parent" | |||
| android:gravity="center" | |||
| android:text="Cantidad" /> | |||
| <TextView | |||
| android:id="@+id/item_cantidad" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:layout_below="@+id/item_clave" | |||
| android:layout_alignParentEnd="true" | |||
| android:layout_marginStart="10dp" | |||
| android:hint="Cantidad" | |||
| android:textAppearance="?attr/textAppearanceListItem" | |||
| android:textSize="18sp" | |||
| tools:text="25" /> | |||
| </LinearLayout> | |||
| <TextView | |||
| android:id="@+id/content" | |||
| android:layout_width="252dp" | |||
| android:layout_height="44dp" | |||
| android:layout_below="@+id/item_number" | |||
| android:layout_alignParentStart="true" | |||
| android:layout_marginTop="1dp" | |||
| android:layout_marginEnd="4dp" | |||
| android:layout_toStartOf="@+id/layer_cantidad" | |||
| android:textAlignment="viewStart" | |||
| android:textSize="18sp" | |||
| tools:text="Almabre de Cobre 1/2'" /> | |||
| </RelativeLayout> | |||
| <View | |||
| android:id="@+id/border" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="1dp" | |||
| android:background="#2196F3" /> | |||
| </LinearLayout> | |||
| </androidx.cardview.widget.CardView> | |||
| @ -0,0 +1,14 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| android:id="@+id/list" | |||
| android:name="jumapacelaya.gob.mx.almacen.ui.main.AvanceFragment" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:layout_marginLeft="16dp" | |||
| android:layout_marginRight="16dp" | |||
| app:layoutManager="LinearLayoutManager" | |||
| tools:context=".ui.main.avance.AvanceFragment" | |||
| tools:listitem="@layout/fragment_item" | |||
| /> | |||
| @ -0,0 +1,14 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| android:id="@+id/list" | |||
| android:name="jumapacelaya.gob.mx.almacen.ui.main.PendienteFragment" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:layout_marginLeft="16dp" | |||
| android:layout_marginRight="16dp" | |||
| app:layoutManager="LinearLayoutManager" | |||
| tools:context=".ui.main.PendienteFragment" | |||
| tools:listitem="@layout/fragment_item" | |||
| /> | |||
| @ -0,0 +1,183 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| android:id="@+id/constraintLayout" | |||
| tools:context=".ui.main.PlaceholderFragment" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:isScrollContainer="true" | |||
| android:orientation="vertical"> | |||
| <LinearLayout | |||
| android:id="@+id/linearLayout" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="vertical"> | |||
| <androidx.cardview.widget.CardView | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_margin="10dp" | |||
| android:elevation="5dp" | |||
| app:cardCornerRadius="8dp"> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:background="@color/md_theme_primaryContainer" | |||
| android:orientation="vertical"> | |||
| <RelativeLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="16dp"> | |||
| <TextView | |||
| android:id="@+id/txtcap_folio2" | |||
| android:layout_width="152dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_marginStart="8dp" | |||
| android:layout_marginTop="4dp" | |||
| android:text="@string/folio" | |||
| android:textColor="@color/md_theme_onPrimary" | |||
| android:textSize="14sp" | |||
| android:textStyle="bold" /> | |||
| <TextView | |||
| android:id="@+id/txtcap_clave" | |||
| android:textColor="@color/colorTextPrimary" | |||
| android:layout_width="191dp" | |||
| android:layout_height="25dp" | |||
| android:layout_below="@+id/txtcap_clave2" | |||
| android:layout_alignParentEnd="true" | |||
| android:layout_marginTop="3dp" | |||
| android:layout_marginEnd="6dp" | |||
| android:textSize="14sp" | |||
| android:textStyle="bold" /> | |||
| <TextView | |||
| android:id="@+id/txtcap_clave2" | |||
| android:textColor="@color/colorTextPrimary" | |||
| android:layout_width="191dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_alignParentEnd="true" | |||
| android:layout_marginTop="4dp" | |||
| android:layout_marginEnd="6dp" | |||
| android:text="@string/clave" | |||
| android:textSize="14sp" | |||
| android:textStyle="bold" /> | |||
| <TextView | |||
| android:id="@+id/txtcap_folio" | |||
| android:textColor="@color/colorTextPrimary" | |||
| android:layout_width="152dp" | |||
| android:layout_height="25dp" | |||
| android:layout_below="@+id/txtcap_folio2" | |||
| android:layout_marginStart="8dp" | |||
| android:layout_marginTop="3dp" | |||
| android:textSize="14sp" | |||
| android:textStyle="bold" /> | |||
| </RelativeLayout> | |||
| <RelativeLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="5dp"> | |||
| <TextView | |||
| android:id="@+id/txtcap_descfamilia2" | |||
| android:layout_width="152dp" | |||
| android:textColor="@color/colorTextPrimary" | |||
| android:layout_height="wrap_content" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_marginStart="8dp" | |||
| android:layout_marginTop="4dp" | |||
| android:text="@string/familia" | |||
| android:textSize="14sp" | |||
| android:textStyle="bold" /> | |||
| <TextView | |||
| android:id="@+id/txtcap_descfamilia" | |||
| android:layout_width="186dp" | |||
| android:textColor="@color/colorTextPrimary" | |||
| android:layout_height="32dp" | |||
| android:layout_below="@+id/txtcap_descfamilia2" | |||
| android:layout_alignParentEnd="true" | |||
| android:layout_marginTop="0dp" | |||
| android:layout_marginEnd="10dp" | |||
| android:textSize="14sp" | |||
| android:textStyle="bold" /> | |||
| <TextView | |||
| android:id="@+id/txtcap_subfamilia2" | |||
| android:layout_width="187dp" | |||
| android:textColor="@color/colorTextPrimary" | |||
| android:layout_height="wrap_content" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_alignParentEnd="true" | |||
| android:layout_marginTop="1dp" | |||
| android:layout_marginEnd="8dp" | |||
| android:text="@string/sub_familia" | |||
| android:textSize="14sp" | |||
| android:textStyle="bold" /> | |||
| <TextView | |||
| android:id="@+id/txtcap_subfamilia" | |||
| android:layout_width="152dp" | |||
| android:textColor="@color/colorTextPrimary" | |||
| android:layout_height="32dp" | |||
| android:layout_below="@+id/txtcap_subfamilia2" | |||
| android:layout_marginStart="8dp" | |||
| android:layout_marginTop="3dp" | |||
| android:textSize="14sp" | |||
| android:textStyle="bold" /> | |||
| </RelativeLayout> | |||
| <TextView | |||
| android:id="@+id/txtcap_articulo" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:textColor="@color/colorTextPrimary" | |||
| android:layout_marginBottom="10dp" | |||
| android:layout_marginEnd="5dp" | |||
| android:layout_marginStart="5dp" | |||
| android:text="@string/articulo" | |||
| android:textAlignment="center" | |||
| android:textSize="18sp" | |||
| android:textStyle="bold" /> | |||
| </LinearLayout> | |||
| </androidx.cardview.widget.CardView> | |||
| <LinearLayout | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="horizontal" | |||
| android:layout_gravity="center"> | |||
| <EditText | |||
| android:id="@+id/txtcap_Cantidad" | |||
| android:layout_width="162dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="5dp" | |||
| android:autofillHints="" | |||
| android:selectAllOnFocus="true" | |||
| android:ems="10" | |||
| android:inputType="number" | |||
| android:textAlignment="center" | |||
| android:textAllCaps="false" /> | |||
| <Button | |||
| android:id="@+id/btncap_aceptar" | |||
| android:layout_width="0dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:text="@string/btnaceptar" /> | |||
| </LinearLayout> | |||
| </LinearLayout> | |||
| </ScrollView> | |||
| @ -0,0 +1,12 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:id="@android:id/text1" | |||
| style="?android:attr/spinnerDropDownItemStyle" | |||
| android:singleLine="true" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="35dp" | |||
| android:ellipsize="marquee" | |||
| android:textSize="15dp" | |||
| android:maxLines="3" | |||
| /> | |||
| @ -0,0 +1,12 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <TextView xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:id="@android:id/text1" | |||
| style="?android:attr/spinnerItemStyle" | |||
| android:singleLine="false" | |||
| android:maxLines="3" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:ellipsize="marquee" | |||
| android:textSize="12dp" | |||
| android:textAlignment="inherit"/> | |||
| @ -0,0 +1,10 @@ | |||
| <menu xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto"> | |||
| <item android:id="@+id/action_reload" | |||
| android:title="@string/realod" | |||
| android:icon="@drawable/ic_plus" | |||
| app:showAsAction="always"/> | |||
| </menu> | |||
| @ -0,0 +1,13 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <menu xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto"> | |||
| <item | |||
| android:id="@+id/refresh" | |||
| android:icon="@drawable/ic_launcher" | |||
| android:title="@string/refreshitems" | |||
| android:contentDescription="@string/desrefreshitems" | |||
| app:showAsAction="ifRoom" /> | |||
| </menu> | |||
| @ -0,0 +1,5 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <background android:drawable="@color/ic_launcher_background"/> | |||
| <foreground android:drawable="@mipmap/ly_codebar_icon"/> | |||
| </adaptive-icon> | |||
| @ -0,0 +1,5 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <background android:drawable="@color/ic_launcher_background"/> | |||
| <foreground android:drawable="@mipmap/ly_codebar_icon"/> | |||
| </adaptive-icon> | |||
| @ -0,0 +1,5 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <background android:drawable="@drawable/ic_launcher_background" /> | |||
| <foreground android:drawable="@drawable/ic_launcher_foreground" /> | |||
| </adaptive-icon> | |||
| @ -0,0 +1,5 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <background android:drawable="@drawable/ic_launcher_background" /> | |||
| <foreground android:drawable="@drawable/ic_launcher_foreground" /> | |||
| </adaptive-icon> | |||