diff --git a/app/build.gradle b/app/build.gradle index 4f8f3c75..198a01b7 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { signingConfigs { } - compileSdkVersion 33 - buildToolsVersion '30.0.3' + compileSdkVersion 34 + buildToolsVersion '33.0.2' useLibrary 'org.apache.http.legacy' useLibrary 'android.test.runner' @@ -28,8 +28,8 @@ android { applicationId "com.stonefacesoft.ottaa" minSdkVersion 24 targetSdkVersion 33 - versionCode 107 - versionName "6.7.17" // + versionCode 108 + versionName "6.7.18" // // Enabling multidex support. multiDexEnabled true resConfigs 'ar,en,es,it' @@ -140,20 +140,20 @@ dependencies { // Optional -- Mockito framework //androidx library implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.browser:browser:1.5.0' + implementation 'androidx.browser:browser:1.7.0' implementation 'androidx.cardview:cardview:1.0.0' - implementation "androidx.core:core:1.9.0" + implementation "androidx.core:core:1.12.0" implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.gridlayout:gridlayout:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.preference:preference:1.2.0' - implementation 'androidx.recyclerview:recyclerview:1.3.0' + implementation 'androidx.preference:preference:1.2.1' + implementation 'androidx.recyclerview:recyclerview:1.3.2' // places library - implementation 'com.google.android.libraries.places:places:3.1.0' + implementation 'com.google.android.libraries.places:places:3.3.0' //play services library - implementation 'com.google.android.gms:play-services-analytics:18.0.2' - implementation 'com.google.android.gms:play-services-auth:20.5.0' + implementation 'com.google.android.gms:play-services-analytics:18.0.4' + implementation 'com.google.android.gms:play-services-auth:20.7.0' implementation 'com.google.android.gms:play-services-base:18.2.0' implementation 'com.google.android.gms:play-services-location:21.0.1' implementation 'com.google.http-client:google-http-client:1.43.0' @@ -163,8 +163,8 @@ dependencies { implementation 'com.airbnb.android:lottie:6.0.0' implementation group: 'com.google.apis', name: 'google-api-services-translate', version: 'v2-rev48-1.22.0' implementation group: 'com.google.api-client', name: 'google-api-client-gson', version: '2.2.0' - implementation 'androidx.navigation:navigation-fragment:2.5.3' - implementation 'androidx.navigation:navigation-ui:2.5.3' + implementation 'androidx.navigation:navigation-fragment:2.7.6' + implementation 'androidx.navigation:navigation-ui:2.7.6' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-core:5.2.0' @@ -219,48 +219,48 @@ dependencies { // firebase library implementation platform('com.google.firebase:firebase-bom:31.5.0') implementation 'com.google.firebase:firebase-auth' - implementation 'com.google.firebase:firebase-config:21.4.0' + implementation 'com.google.firebase:firebase-config:21.6.0' implementation 'com.google.firebase:firebase-core:21.1.1' - implementation 'com.google.firebase:firebase-database:20.2.1' - implementation 'com.google.firebase:firebase-functions:20.3.0' + implementation 'com.google.firebase:firebase-database:20.3.0' + implementation 'com.google.firebase:firebase-functions:20.4.0' - implementation ('com.google.firebase:firebase-messaging:23.1.2'){ + implementation ('com.google.firebase:firebase-messaging:23.4.0'){ exclude group: 'com.android.support' exclude module: 'appcompat-v7' exclude module: 'support-v4' exclude module: 'support-v13' } - implementation ('com.google.firebase:firebase-inappmessaging-display:20.3.2'){ + implementation ('com.google.firebase:firebase-inappmessaging-display:20.4.0'){ exclude group: 'com.android.support' exclude module: 'appcompat-v7' exclude module: 'support-v4' exclude module: 'support-v13' } - implementation 'com.google.firebase:firebase-perf:20.3.2' - implementation 'com.google.firebase:firebase-storage:20.2.0' - implementation 'com.google.firebase:firebase-crashlytics:18.3.7' - implementation 'com.google.firebase:firebase-analytics:21.2.2' + implementation 'com.google.firebase:firebase-perf:20.5.1' + implementation 'com.google.firebase:firebase-storage:20.3.0' + implementation 'com.google.firebase:firebase-crashlytics:18.6.0' + implementation 'com.google.firebase:firebase-analytics:21.5.0' implementation 'io.grpc:grpc-okhttp:1.53.0' // material library - implementation 'com.google.android.material:material:1.8.0' + implementation 'com.google.android.material:material:1.11.0' //Guava library implementation('com.google.guava:guava:31.1-android') //Image Cropper implementation 'com.github.CanHub:Android-Image-Cropper:4.3.0' // pictograms library - implementation 'com.github.OTTAA-Project:PictogramsLibrary:0.19.62' + implementation 'com.github.OTTAA-Project:PictogramsLibrary:0.19.66' //Sendgrid integration implementation 'com.android.volley:volley:1.2.1' - implementation 'com.google.android.exoplayer:exoplayer:2.18.6' - implementation 'com.google.android.exoplayer:exoplayer-dash:2.18.6' - implementation 'com.google.android.exoplayer:exoplayer-transformer:2.18.6' - implementation 'com.google.android.exoplayer:exoplayer-core:2.18.6' + implementation 'com.google.android.exoplayer:exoplayer:2.19.1' + implementation 'com.google.android.exoplayer:exoplayer-dash:2.19.1' + implementation 'com.google.android.exoplayer:exoplayer-transformer:2.19.1' + implementation 'com.google.android.exoplayer:exoplayer-core:2.19.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 569c1b73..350b5f6e 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,9 @@ + + + @@ -20,8 +23,7 @@ - + @@ -29,7 +31,6 @@ - 0) @@ -102,4 +124,9 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { } return super.onOptionsItemSelected(item); } + + @Override + public void startAudioTransformation(Transformer.Listener listener, String filePath, String locationPath) { + new FileEncoder(this).encodeAudioFile(listener,filePath,locationPath); + } } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/Adapters/MostUsedFavoritePhrasesAdapter.java b/app/src/main/java/com/stonefacesoft/ottaa/Adapters/MostUsedFavoritePhrasesAdapter.java index 3fdaeb06..83af8ec1 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/Adapters/MostUsedFavoritePhrasesAdapter.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/Adapters/MostUsedFavoritePhrasesAdapter.java @@ -126,6 +126,7 @@ protected Void doInBackground(Void... voids) { List frases = mDatosDeUso.getArrayListFrasesMasUsadas(4); for (int i = 0; i < frases.size(); i++) { FavModel model = new FavModel(); + model.setPictogram(mDatosDeUso.getFrasesOrdenadas().get(i)); mGestionarBitmap.getBitmapDeFrase(mDatosDeUso.getFrasesOrdenadas().get(i),new LoadOnlinePictograms() { @Override public void preparePictograms() { diff --git a/app/src/main/java/com/stonefacesoft/ottaa/Bitmap/GestionarBitmap.java b/app/src/main/java/com/stonefacesoft/ottaa/Bitmap/GestionarBitmap.java index 5d86900e..6bc2a3c3 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/Bitmap/GestionarBitmap.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/Bitmap/GestionarBitmap.java @@ -193,11 +193,9 @@ public Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { /** * Combine image method * */ - public Bitmap combineImages(int mDeltax,int mDeltay) { + public Bitmap combineImages(int mDeltax,int mDeltay)throws Exception { Bitmap mImagenFinal = null; - int mImagenFinalWidth, mImagenFinalHeight = 0; - if (imagenes.size() > 0 && imagenes.get(0) != null) { Bitmap nube=drawableToBitmap(mContext.getResources().getDrawable(R.drawable.ic_cloud_download_orange)); Bitmap bitmap = nube; @@ -232,7 +230,7 @@ public Bitmap combineImages(int mDeltax,int mDeltay) { mPosicionLogoY = mImagenFinalHeight-mDeltay-logo.getHeight(); comboImage.drawBitmap(logo,mPosicionLogoX,mPosicionLogoY,pinturas); } - return mImagenFinal; + return mImagenFinal; } @@ -306,7 +304,11 @@ public Bitmap redimensionarImagenMaximo(Bitmap mBitmap, float newWidth, float ne //metodo para armar las imagenes public void createImage(LoadOnlinePictograms loadOnlinePictograms) { - storeImage(combineImages(25,25),loadOnlinePictograms); + try { + storeImage(combineImages(25,25),loadOnlinePictograms); + } catch (Exception e) { + + } } @@ -359,8 +361,14 @@ public void setIdjson(ArrayList idjson) { public void getBitmapDeFrase(JSONObject frase,LoadOnlinePictograms loadOnlinePictograms) { preparePhrase(frase,loadOnlinePictograms); Bitmap bitmap = null; - if(combineImages(20, 20) != null ) { - bitmap = getRoundedCornerBitmap(combineImages(20, 2), 20); + Bitmap combineImages = null; + try { + combineImages = combineImages(20, 20); + }catch (Exception ex){ + combineImages = null; + } + if(combineImages != null ) { + bitmap = getRoundedCornerBitmap(combineImages, 20); loadOnlinePictograms.loadPictograms(bitmap); }else{ Log.d(TAG, "getBitmapDeFrase: "+ "Combine Images Error"); diff --git a/app/src/main/java/com/stonefacesoft/ottaa/Dialogos/DialogUtils/DialogUtils.java b/app/src/main/java/com/stonefacesoft/ottaa/Dialogos/DialogUtils/DialogUtils.java index 977431d5..db825e0b 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/Dialogos/DialogUtils/DialogUtils.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/Dialogos/DialogUtils/DialogUtils.java @@ -183,7 +183,7 @@ public Dialog_abstract_class settingButton( TextView v, int layout) { @Override public Dialog_abstract_class setOnClick( View v,View.OnClickListener clickListener) { if(v!=null) - v.setOnClickListener(clickListener); + v.setOnClickListener(clickListener); return this; } @@ -208,7 +208,7 @@ public void setDialog(Context mContext,int layout) { private void prepareDialog(int layout){ setLayout(layout); if(layout==R.layout.dialog_yes_no_cancel) - prepareDataDialog(); + prepareDataDialog(); activityUtilsEstatus=new ActivityUtilsEstatus(); } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/Dialogos/custom_dialog_option_item.java b/app/src/main/java/com/stonefacesoft/ottaa/Dialogos/custom_dialog_option_item.java index 928c5dcc..5bf9e68f 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/Dialogos/custom_dialog_option_item.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/Dialogos/custom_dialog_option_item.java @@ -78,7 +78,7 @@ public RecyclerView getRecycler(){ public void DissmisDialog(){ if(dialog.isShowing()) - dialog.dismiss(); + dialog.dismiss(); } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/Edit_Picto_Visual.java b/app/src/main/java/com/stonefacesoft/ottaa/Edit_Picto_Visual.java index a74b52c8..37b7407e 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/Edit_Picto_Visual.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/Edit_Picto_Visual.java @@ -1,6 +1,5 @@ package com.stonefacesoft.ottaa; -import android.Manifest; import android.app.Dialog; import android.content.Context; import android.content.Intent; @@ -11,7 +10,6 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.ParcelFileDescriptor; @@ -21,9 +19,7 @@ import android.text.Editable; import android.text.TextWatcher; import android.util.Log; -import android.view.Gravity; import android.view.KeyEvent; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -40,7 +36,6 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.cardview.widget.CardView; -import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; import com.canhub.cropper.CropImage; @@ -78,6 +73,7 @@ import com.stonefacesoft.ottaa.utils.Firebase.AnalyticsFirebase; import com.stonefacesoft.ottaa.utils.IntentCode; import com.stonefacesoft.ottaa.utils.JSONutils; +import com.stonefacesoft.ottaa.utils.RequestPersmissionClass; import com.stonefacesoft.ottaa.utils.constants.Constants; import com.stonefacesoft.ottaa.utils.exceptions.FiveMbException; import com.stonefacesoft.ottaa.utils.textToSpeech; @@ -537,8 +533,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == IntentCode.GALERIA.getCode() && resultCode == RESULT_OK) { selectedImageUri = data.getData(); imageBitmap = decodeUri(selectedImageUri); + storeImage(imageBitmap, "Fotos"); storeOffline(imageBitmap); + Drawable d = new BitmapDrawable(getResources(), imageBitmap); Picto.getGlideAttatcher().loadDrawable(d,Picto.getImageView()); formato = ".jpg"; @@ -699,26 +697,7 @@ private void cargarColor(int color) { public void showCustomAlert(CharSequence Testo) { - //Retrieve the layout inflator - LayoutInflater inflater = getLayoutInflater(); - //Assign the custom layout to view - //Parameter 1 - Custom layout XML - //Parameter 2 - Custom layout ID present in linearlayout tag of XML - View layout = inflater.inflate(R.layout.custom_toast, findViewById(R.id.toast_layout_root)); - TextView tv = layout.findViewById(R.id.text); - tv.setTextSize(sharedPrefsDefault.getInt("subtitulo_tamanio", 25)); - tv.setText(Testo); - //Return the application mContext - Toast toast = new Toast(getApplicationContext()); - //Set custom_toast gravity to bottom - toast.setGravity(Gravity.BOTTOM, 0, 50); - //Set custom_toast duration - toast.setDuration(Toast.LENGTH_SHORT); - //Set the custom layout to Toast - toast.setView(layout); - //Display custom_toast - toast.show(); - + myTTS.mostrarAlerta(Testo.toString()); } //------------------------------------------------------------------------------------ @@ -758,18 +737,10 @@ public void onClick(View v) { case R.id.ElPicto: //Pido los permisos para escribir en memoria externa - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat - .checkSelfPermission(getApplicationContext(), Manifest - .permission.WRITE_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission - (getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - requestPermissions(new String[]{ - //Ver a donde hay q pasarlo, posiblemente Galeria Pictos - android.Manifest.permission.WRITE_EXTERNAL_STORAGE - }, Constants.EXTERNAL_STORAGE); - } + RequestPersmissionClass requestPersmissionClass = new RequestPersmissionClass(); + boolean requestPermission = requestPersmissionClass.requestImagePermission(this); + if(!requestPermission){ + requestPersmissionClass.makeRequestImagePermission(requestPermission,this); } else SelectorFuente(); break; @@ -1184,6 +1155,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in SelectorFuente(); } else { //permission granted + showCustomAlert(getString(R.string.edit_permisos_archivos)); } } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/FavModel.java b/app/src/main/java/com/stonefacesoft/ottaa/FavModel.java index 83cc95a2..0bc252fc 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/FavModel.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/FavModel.java @@ -2,6 +2,8 @@ import android.graphics.Bitmap; +import androidx.annotation.NonNull; + import org.json.JSONObject; public class FavModel { @@ -45,4 +47,11 @@ public void setPosition(int position) { public int getPosition() { return position; } + + @NonNull + @Override + public String toString() { + + return pictogram.toString(); + } } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadGroups.java b/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadGroups.java index b64de7b9..272bdcf3 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadGroups.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadGroups.java @@ -6,13 +6,16 @@ import androidx.annotation.NonNull; +import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.OnSuccessListener; +import com.google.android.gms.tasks.Task; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.ValueEventListener; import com.google.firebase.storage.FileDownloadTask; import com.google.firebase.storage.FirebaseStorage; +import com.google.firebase.storage.StorageMetadata; import com.google.firebase.storage.StorageReference; import com.stonefacesoft.ottaa.FirebaseRequests.BajarJsonFirebase; import com.stonefacesoft.ottaa.R; @@ -35,7 +38,7 @@ public DownloadGroups(Context mContext, DatabaseReference mDatabase, StorageRefe } - public void syncGroups(){ + public void syncGroups(){ final File gruposUsuarioFile = new File(rootPath, Constants.ARCHIVO_GRUPOS); mDatabase.child(Constants.Grupos).child(uid).child("URL_grupos_" + sharedPrefsDefault.getString(mContext.getString(R.string.str_idioma), locale)).addListenerForSingleValueEvent(new ValueEventListener() { @@ -43,44 +46,33 @@ public void syncGroups(){ public void onDataChange(@NonNull DataSnapshot snapshot) { mStorageReference = FirebaseStorage.getInstance().getReference().child("Archivos_Usuarios").child("Grupos").child("grupos_" + email + "_" + ConfigurarIdioma.getLanguaje()+ "." + "txt"); + mStorageReference.getFile(gruposUsuarioFile).addOnSuccessListener(new OnSuccessListener() { + @Override + public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) { + Log.d("BAF_descGYPN", "TamañoArchivoGrupo :" + taskSnapshot.getTotalByteCount()); + Log.d("BAF_descGYPN", "NombreArchivo:" + gruposUsuarioFile); + try { + if (!getStringFromFile(gruposUsuarioFile + .getAbsolutePath()).equals("[]") && + gruposUsuarioFile.length() > 0 ) { + json.setmJSONArrayTodosLosGrupos(json.readJSONArrayFromFile(gruposUsuarioFile.getAbsolutePath())); + if (!json.guardarJson(Constants.ARCHIVO_GRUPOS)) + Log.e(TAG, "Error al guardar Json"); + } + observableInteger.incrementValue(); + } catch (Exception e) { + e.printStackTrace(); + Log.e("printStackTrace", "" + e); - mStorageReference.getFile(gruposUsuarioFile).addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) { - Log.d("BAF_descGYPN", "TamañoArchivoGrupo :" + taskSnapshot.getTotalByteCount()); - Log.d("BAF_descGYPN", "NombreArchivo:" + gruposUsuarioFile); + } + } - boolean areSamefile = false; - try { - areSamefile = json.verifyFiles(Constants.ARCHIVO_GRUPOS,gruposUsuarioFile); - Log.d(TAG, "onSuccess: are the same file"+areSamefile); - } catch (Exception ex){ - Log.d(TAG, "error: "+ex.getMessage()); - } - if(areSamefile){ - observableInteger.incrementValue(); - }else{ - try { - if (!getStringFromFile(gruposUsuarioFile - .getAbsolutePath()).equals("[]") && - gruposUsuarioFile.length() > 0 ) { - json.setmJSONArrayTodosLosGrupos(json.readJSONArrayFromFile(gruposUsuarioFile.getAbsolutePath())); - if (!json.guardarJson(Constants.ARCHIVO_GRUPOS)) - Log.e(TAG, "Error al guardar Json"); - } - } catch (Exception e) { - e.printStackTrace(); - Log.e("printStackTrace", "" + e); - }finally { - observableInteger.incrementValue(); - } - } + }); + - } - }); } @Override diff --git a/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadPhrases.java b/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadPhrases.java index abbfc00d..654922a7 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadPhrases.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadPhrases.java @@ -6,13 +6,16 @@ import androidx.annotation.NonNull; +import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.OnSuccessListener; +import com.google.android.gms.tasks.Task; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.ValueEventListener; import com.google.firebase.storage.FileDownloadTask; import com.google.firebase.storage.FirebaseStorage; +import com.google.firebase.storage.StorageMetadata; import com.google.firebase.storage.StorageReference; import com.stonefacesoft.ottaa.FirebaseRequests.BajarJsonFirebase; import com.stonefacesoft.ottaa.R; @@ -41,39 +44,32 @@ public void onDataChange(@NonNull DataSnapshot snapshot) { mStorageReference = FirebaseStorage.getInstance().getReference().child("Archivos_Usuarios").child(Constants.Frases).child(Constants.Frases.toLowerCase() + "_" + email + "_" + locale + "." + "txt"); final File frasesUsuarioFile = new File(rootPath, "frases.txt"); - mStorageReference.getFile(frasesUsuarioFile).addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) { - Log.e(TAG, "bajarFrases: "+ child ); - boolean areTheSameFile = false; - try{ - areTheSameFile = json.verifyFiles(Constants.ARCHIVO_FRASES,frasesUsuarioFile); - }catch (Exception ex){ - } - if(!areTheSameFile){ - try { - if (!getStringFromFile(frasesUsuarioFile.getAbsolutePath()).equals("[]") && frasesUsuarioFile.length() > 0) { - - json.setmJSONArrayTodasLasFrases(json.readJSONArrayFromFile(frasesUsuarioFile.getAbsolutePath())); - json.guardarJson(Constants.ARCHIVO_FRASES); - } - } catch (JSONException | FiveMbException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } + mStorageReference.getFile(frasesUsuarioFile).addOnSuccessListener(new OnSuccessListener() { + @Override + public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) { + try { + if (!getStringFromFile(frasesUsuarioFile.getAbsolutePath()).equals("[]") && frasesUsuarioFile.length() > 0) { + json.setmJSONArrayTodasLasFrases(json.readJSONArrayFromFile(frasesUsuarioFile.getAbsolutePath())); + json.guardarJson(Constants.ARCHIVO_FRASES); + } + } catch (JSONException | FiveMbException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + observableInteger.incrementValue(); + } + }); + }else { + observableInteger.incrementValue(); + } + - observableInteger.incrementValue(); - } - }); - }else{ - observableInteger.incrementValue(); - } } + @Override public void onCancelled(@NonNull DatabaseError error) { @@ -81,7 +77,7 @@ public void onCancelled(@NonNull DatabaseError error) { }); } - public void downloadPhrases(){ + public void downloadPhrases(){ Log.e(TAG, "bajarFrases: " ); mDatabase.child(Constants.Frases).child(uid).addListenerForSingleValueEvent(new ValueEventListener() { @Override diff --git a/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadPictograms.java b/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadPictograms.java index 1eb89760..82d24d56 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadPictograms.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/DownloadFile/DownloadPictograms.java @@ -6,6 +6,7 @@ import androidx.annotation.NonNull; +import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.OnSuccessListener; import com.google.android.gms.tasks.Task; @@ -15,6 +16,7 @@ import com.google.firebase.database.ValueEventListener; import com.google.firebase.storage.FileDownloadTask; import com.google.firebase.storage.FirebaseStorage; +import com.google.firebase.storage.StorageMetadata; import com.google.firebase.storage.StorageReference; import com.stonefacesoft.ottaa.idioma.ConfigurarIdioma; import com.stonefacesoft.ottaa.utils.Firebase.CrashlyticsUtils; @@ -44,41 +46,21 @@ public void onDataChange(@NonNull DataSnapshot snapshot) { mStorageReference.getFile(pictosUsuarioFile).addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) { - - Log.d("BAF_descGYPN", "TamañoArchivoPicto:" + taskSnapshot.getTotalByteCount()); - Log.d("BAF_descGYPN", "NombreArchivo:" + pictosUsuarioFile); - Log.d("BAF_descGYPN", "TamañoArchivoss :" + pictosUsuarioFile.length()); - boolean aresamefile = false; try { - aresamefile = json.verifyFiles(Constants.ARCHIVO_PICTOS,pictosUsuarioFile); - } catch (Exception e) { - Log.d(TAG, "onSuccess: " + e.getMessage()); - e.printStackTrace(); - } - if(aresamefile){ - observableInteger.incrementValue(); - }else{ - try{ - if (pictosUsuarioFile.length() > 0 && !getStringFromFile - (pictosUsuarioFile.getAbsolutePath()).equals("[]") && - getStringFromFile(pictosUsuarioFile.getAbsolutePath() - ) != null) { - json.setmJSONArrayTodosLosPictos(json.readJSONArrayFromFile(pictosUsuarioFile.getAbsolutePath())); - if (!json.guardarJson(Constants.ARCHIVO_PICTOS)) - Log.e(TAG, "Error al guardar Json"); - else { - Log.d(TAG, "Pictogram Saved"); - } - } - observableInteger.incrementValue(); - }catch (Exception ex){ + if (pictosUsuarioFile.length() > 0 && !getStringFromFile + (pictosUsuarioFile.getAbsolutePath()).equals("[]") && + getStringFromFile(pictosUsuarioFile.getAbsolutePath() + ) != null) { + json.setmJSONArrayTodosLosPictos(json.readJSONArrayFromFile(pictosUsuarioFile.getAbsolutePath())); + json.guardarJson(Constants.ARCHIVO_PICTOS); } - } + observableInteger.incrementValue(); + } catch (Exception ex) { + } } - - }); + }) ; } } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/UploadFiles/UploadPhrase.java b/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/UploadFiles/UploadPhrase.java index ebbd5f36..46ee0f38 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/UploadFiles/UploadPhrase.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/FirebaseRequests/UploadFiles/UploadPhrase.java @@ -22,7 +22,6 @@ public void uploadFile() { openFile(); if (fis.available() > 3) { Log.e("subirArchivosLog", "subirGruposFirebase: " + fis.available()); - mStorageReference.putStream(fis).continueWithTask(task -> { if (!task.isSuccessful()) { throw task.getException(); @@ -49,8 +48,6 @@ public void uploadFile() { } }); } - - } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { diff --git a/app/src/main/java/com/stonefacesoft/ottaa/GaleriaGrupos2.java b/app/src/main/java/com/stonefacesoft/ottaa/GaleriaGrupos2.java index 0a71719e..8681050f 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/GaleriaGrupos2.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/GaleriaGrupos2.java @@ -46,6 +46,8 @@ import com.stonefacesoft.ottaa.idioma.ConfigurarIdioma; import com.stonefacesoft.ottaa.idioma.myContextWrapper; import com.stonefacesoft.ottaa.utils.Accesibilidad.devices.GaleriaGruposControls; +import com.stonefacesoft.ottaa.utils.ConnectionDetector; +import com.stonefacesoft.ottaa.utils.RequestPersmissionClass; import com.stonefacesoft.ottaa.utils.constants.Constants; import com.stonefacesoft.ottaa.utils.Firebase.AnalyticsFirebase; import com.stonefacesoft.ottaa.utils.IntentCode; @@ -382,7 +384,17 @@ public boolean onOptionsItemSelected(MenuItem item) { Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ACHIEVEMENT_ID, "Bajar pictogramas"); analyticsFirebase.customEvents("Touch", "Galeria Grupos", "Download Pictograms"); - accionBajarFoto(); + if(ConnectionDetector.isNetworkAvailable(this)){ + RequestPersmissionClass requestPersmissionClass = new RequestPersmissionClass(); + boolean result = requestPersmissionClass.requestImagePermission(this); + if(!result){ + requestPersmissionClass.makeRequestImagePermission(result,this); + }else{ + accionBajarFoto(); + } + } + else + myTTS.mostrarAlerta(getString(R.string.problema_inet)); // subirTodasLasFotos(); return true; @@ -526,16 +538,16 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in if (grantResults[i] != PackageManager.PERMISSION_GRANTED) { //permission not granted mPermission = PackageManager.PERMISSION_DENIED; - } else if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { //permission granted mPermission = PackageManager.PERMISSION_GRANTED; - accionBajarFoto(); } } + if (mPermission == PackageManager.PERMISSION_GRANTED) { accionBajarFoto(); } else if (mPermission == PackageManager.PERMISSION_DENIED) { + showDismissDialog.sendMessage(0); myTTS.mostrarAlerta(getString(R.string.permisos_fotos_denegados)); } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/JSONutils/Json.java b/app/src/main/java/com/stonefacesoft/ottaa/JSONutils/Json.java index 4cf33f95..53556841 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/JSONutils/Json.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/JSONutils/Json.java @@ -28,6 +28,7 @@ import com.stonefacesoft.ottaa.R; import com.stonefacesoft.ottaa.idioma.ConfigurarIdioma; import com.stonefacesoft.ottaa.utils.JSONutils; +import com.stonefacesoft.ottaa.utils.PictogramPositionCounter; import com.stonefacesoft.ottaa.utils.constants.Constants; import com.stonefacesoft.ottaa.utils.exceptions.FiveMbException; @@ -51,6 +52,8 @@ import java.util.Calendar; import java.util.Collections; import java.util.Comparator; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * @author morro @@ -92,6 +95,9 @@ public class Json { private JSONArray mJSONArrayTodosLosGrupos; private JSONArray mJSONArrayTodasLasFrases; private JSONArray mJSONArrayTodosLosPictos; + + + private JSONArray mJSONArrayTodasLasFotosBackup; private JSONArray mJSonArrayJuegos; private JSONArray mJSonArrayFrasesFavoritas; @@ -104,6 +110,18 @@ public class Json { private static final String MD5_ALGORITHM = "MD5"; + private JSONObject parent; + + private volatile JSONArray child; + + private boolean refreshChild; + + + + public enum saveFile{ + SUCCESS,ERROR + } + //JSONArray @@ -284,7 +302,7 @@ public JSONArray getPhrasesByLanguage(){ return result; } - public void setmJSONArrayTodasLasFrases(JSONArray mJSONArrayTodasLasFrases) { + public synchronized void setmJSONArrayTodasLasFrases(JSONArray mJSONArrayTodasLasFrases) { this.mJSONArrayTodasLasFrases = mJSONArrayTodasLasFrases; } @@ -683,11 +701,9 @@ public int compareTo(double frec1, double frec2) { public JSONObject getGrupoFromId(int idABuscar) { for (int i = 0; i < GroupManagerClass.getInstance().getmGroup().length(); i++) { try { - if (GroupManagerClass.getInstance().getmGroup().getJSONObject(i).getInt("id") == idABuscar) { return GroupManagerClass.getInstance().getmGroup().getJSONObject(i); } - } catch (JSONException e) { e.printStackTrace(); } @@ -937,6 +953,27 @@ public byte[] readFromFileBytes(String fileName) { } + public boolean downloadFile(File file1,File file2){ + if(file1.lastModified()>file2.lastModified()) + return false; + else + return true; + } + + public boolean downloadFileLongTime(String tag,String file,long time){ + File files = mContext.getExternalFilesDir(file); + + // Get the file's last modified time. + long lastModified = files.lastModified(); + + Log.d(TAG, "downloadFileLongTime file: "+ lastModified); + Log.d(TAG, "downloadFileLongTime firebase file: "+ time); + if(lastModified<=time) + return false; + else + return true; + } + public boolean verifyFiles(String file1, File file2) throws IOException, NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance(MD5_ALGORITHM); @@ -987,29 +1024,19 @@ public JSONArray readJSONArrayFromFile(String constantFileName) throws JSONExcep private JSONArray elegirHijos2(JSONObject padre, boolean esSugerencia) throws JSONException { JSONArray array = padre.getJSONArray("relacion"); - // new SortArraysByScore().quickSort(array,0,array.length()-1); ArrayList relacion = new ArrayList<>(); for (int i = 0; i < array.length(); i++) { - relacion.add(array.getJSONObject(i)); + JSONObject object = array.getJSONObject(i); + if(object!=null) + relacion.add(object); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - relacion.sort(new Comparator() { - @Override - public int compare(JSONObject json1, JSONObject json2) { - return compareValues(json1,json2,esSugerencia); - } - }); - } else { - Collections.sort(relacion, new Comparator() { - @Override - public int compare(JSONObject json1, JSONObject json2) { - return compareValues(json1,json2,esSugerencia); - } - }); - } - Log.d(TAG, "elegirHijos2: Ordenado"); - return new JSONArray(relacion.toString()); - + relacion.sort(new Comparator() { + @Override + public int compare(JSONObject json1, JSONObject json2) { + return compareValues(json1,json2,esSugerencia); + } + }); + return new JSONArray(relacion); //return array; } @@ -1037,31 +1064,38 @@ public JSONObject getPictoFromCustomArrayById2(JSONArray jsonArray, int idABusca return null; } - public void loadPictogramsInsideArray(JSONObject father,JSONArray array,JSONArray relationShip,int lasPosition) throws JSONException { - for (int i = 0; i <4 ; i++) { - int position = i+lasPosition; + public void loadPictogramsInsideArray(JSONObject father,JSONArray array,JSONArray relationShip,int lasPosition,int pos)throws JSONException { + int position = pos+lasPosition; if(isLessThanArray(relationShip,position)){ addChildrenToArray(array,relationShip,position,false); }else{ - int lastLocation = position - array.length()+i; + int lastLocation = position - array.length()+pos; if(getValueBiggerOrEquals0(lastLocation)){ if(itIsASuggestedLanguage()){ if(mostrarSugerencias(father,lastLocation,array)){ + Log.d(TAG, "load PictogramsInsideArray: Option2"); int posPadre = getPosPictoBinarySearch(getmJSONArrayPictosSugeridos(),getId(father)); - upgradeIndexOfLoadOptions((relationShip.length() + mJSONArrayPictosSugeridos.getJSONObject(posPadre).getJSONArray("relacion").length()) / 4); + PictogramPositionCounter.getInstance().setLimit((relationShip.length() + mJSONArrayPictosSugeridos.getJSONObject(posPadre).getJSONArray("relacion").length()) / 4); }else{ - array.put(i,createAnEmptyObject()); - upgradeIndexOfLoadOptions(Constants.VUELTAS_CARRETE+1); + Log.d(TAG, "load PictogramsInsideArray: Option3"); + array.put(pos,createAnEmptyObject()); + PictogramPositionCounter.getInstance().setLimit(relationShip.length()); } }else{ - array.put(i,createAnEmptyObject()); - upgradeIndexOfLoadOptions(Constants.VUELTAS_CARRETE+1); + Log.d(TAG, "load PictogramsInsideArray: Option4"); + array.put(pos,createAnEmptyObject()); + PictogramPositionCounter.getInstance().setLimit(relationShip.length()); } }else{ - addChildrenToArray(array,relationShip,position,false); + Log.d(TAG, "load PictogramsInsideArray: Option5"); + addChildrenToArray(array,relationShip,position,false); } } - } + + + + + } public void upgradeIndexOfLoadOptions(int value){ @@ -1077,8 +1111,8 @@ public boolean getValueBiggerOrEquals0(int value){ } public void addChildrenToArray(JSONArray array, JSONArray relationShip, int position,boolean isSuggested) throws JSONException { - array.put(getPictoFromId2(relationShip.getJSONObject(position).getInt("id"))); - array.getJSONObject(array.length() - 1).put("esSugerencia", isSuggested); + array.put(getPictoFromId2(relationShip.getJSONObject(position).getInt("id"))); + array.getJSONObject(array.length() - 1).put("esSugerencia", isSuggested); } public boolean itIsASuggestedLanguage(){ @@ -1101,24 +1135,24 @@ public JSONObject createAnEmptyObject() throws JSONException { * * */ public void cargarOpciones(JSONObject padre, int cuentaMasPictos, SortPictogramsInterface sortPictograms) { - //mJSONArrayTodosLosPictos = readJSONArrayFromFile(Constants.ARCHIVO_PICTOS);// leo los pictos - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - if (!consultarPago()) - sharedPrefsDefault.edit().putBoolean("bool_sugerencias", consultarPago()).apply(); - JSONArray relacion = elegirHijos2(padre, false); //selecciono el picto padre - JSONArray jsonElegidos = new JSONArray(); - int ultimaPosicion = cuentaMasPictos * 4; //posicion del picto - loadPictogramsInsideArray(padre,jsonElegidos,relacion,ultimaPosicion); - sortPictograms.pictogramsAreSorted(jsonElegidos); - }catch (JSONException ex){ - Log.e(TAG, "exception: "+ ex.getMessage() ); - } - } + //mJSONArrayTodosLosPictos = readJSONArrayFromFile(Constants.ARCHIVO_PICTOS);// leo los + ExecutorService executorService = Executors.newFixedThreadPool(1); + if (!consultarPago()) + sharedPrefsDefault.edit().putBoolean("bool_sugerencias", consultarPago()).apply(); + loadChild(padre); + JSONArray jsonElegidos = new JSONArray(); + int position = cuentaMasPictos*4; + executorService.submit(()->{ + for (int i = 0; i < 4; i++) { + int pos = i; + try { + loadPictogramsInsideArray(padre,jsonElegidos,child,position,pos); + } catch (JSONException e) { + + } + } + sortPictograms.pictogramsAreSorted(jsonElegidos); }); - thread.start(); } @@ -1389,4 +1423,22 @@ public void addPictogramToAll(JSONObject object) { public Context getmContext() { return mContext; } + + public void loadChild(JSONObject padre){ + if(parent == null||! parent.toString().equals(padre.toString())|| refreshChild) { + parent = padre; + try { + refreshChild = false; + child = elegirHijos2(parent, false); //selecciono el picto padre + } catch (JSONException e) { + Log.e(TAG, "loadChild error 2022: "+ e.getMessage() ); + } + } + } + + public void setRefreshChild(){ + refreshChild = true; + } + + } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/JSONutils/Json0Recover.java b/app/src/main/java/com/stonefacesoft/ottaa/JSONutils/Json0Recover.java index 516d41ed..5607024f 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/JSONutils/Json0Recover.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/JSONutils/Json0Recover.java @@ -76,26 +76,27 @@ public void backupPictogram0(Context context,JSONObject parent,FailReadPictogram } } public void restorePictogram0(Context mContext, FailReadPictogramOrigin failReadPictogramOrigin){ - if(ConnectionDetector.isNetworkAvailable(mContext)) - FirebaseUtils.getInstance().getmDatabase().child("backupPictogramOrigin").child(User.getInstance(mContext).getUserUid()).child(ConfigurarIdioma.getLanguaje()).addListenerForSingleValueEvent(new ValueEventListener() { - @Override - public void onDataChange(@NonNull DataSnapshot snapshot) { - JSONObject object = null; - try { - String value = snapshot.getValue(String.class); - object = new JSONObject(snapshot.getValue(String.class)); - failReadPictogramOrigin.setParent(object); - - } catch (JSONException e) { - e.printStackTrace(); + if(ConnectionDetector.isNetworkAvailable(mContext)){ + FirebaseUtils.getInstance().getmDatabase().child("backupPictogramOrigin").child(User.getInstance(mContext).getUserUid()).child(ConfigurarIdioma.getLanguaje()).addListenerForSingleValueEvent(new ValueEventListener() { + @Override + public void onDataChange(@NonNull DataSnapshot snapshot) { + JSONObject object = null; + try { + String value = snapshot.getValue(String.class); + object = new JSONObject(snapshot.getValue(String.class)); + failReadPictogramOrigin.setParent(object); + + } catch (JSONException e) { + e.printStackTrace(); + } } - } - @Override - public void onCancelled(@NonNull DatabaseError error) { + @Override + public void onCancelled(@NonNull DatabaseError error) { - } - }); + } + }); + } else{ JSONObject aux = recoverFile(mContext); failReadPictogramOrigin.setParent(aux); diff --git a/app/src/main/java/com/stonefacesoft/ottaa/Principal.java b/app/src/main/java/com/stonefacesoft/ottaa/Principal.java index 80557a83..d08c3069 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/Principal.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/Principal.java @@ -111,6 +111,7 @@ import com.stonefacesoft.ottaa.utils.InmersiveMode; import com.stonefacesoft.ottaa.utils.IntentCode; import com.stonefacesoft.ottaa.utils.JSONutils; +import com.stonefacesoft.ottaa.utils.PictogramPositionCounter; import com.stonefacesoft.ottaa.utils.TalkActions.ProcessPhrase; import com.stonefacesoft.ottaa.utils.UserLicence.LicenciaUsuario; import com.stonefacesoft.ottaa.utils.MovableFloatingActionButton; @@ -154,7 +155,7 @@ public class Principal extends AppCompatActivity implements View .OnClickListener, View.OnLongClickListener, OnMenuItemClickListener, - FirebaseSuccessListener, NavigationView.OnNavigationItemSelectedListener, PlaceSuccessListener, ConnectionCallbacks, translateInterface, View.OnTouchListener, Make_Click_At_Time , SortPictogramsInterface, LoadPictograms, AudioTransformationListener { + FirebaseSuccessListener, NavigationView.OnNavigationItemSelectedListener, PlaceSuccessListener, ConnectionCallbacks, translateInterface, View.OnTouchListener, Make_Click_At_Time, SortPictogramsInterface, LoadPictograms, AudioTransformationListener, FailReadPictogramOrigin { private static final String TAG = "Principal"; public static boolean cerrarSession = false;// use this variable to notify when the session is closed @@ -162,7 +163,9 @@ public class Principal extends AppCompatActivity implements View private final Handler handlerHablar = new Handler(); public volatile Json json; // JSONObject que usamoss - JSONObject pictoPadre, opcion1, opcion2, opcion3, opcion4, onLongOpcion; + volatile JSONObject pictoPadre, onLongOpcion; + + private JSONObject option1,option2,option3,option4; SubirArchivosFirebase subirArchivos; String timeStamp; private Avatar avatar; @@ -172,17 +175,7 @@ public class Principal extends AppCompatActivity implements View private NavigationView navigationView; private PrincipalControls navigationControls; //Declaracion de los botones - - private PictoView Opcion1; - private PictoView Opcion2; - private PictoView Opcion3; - private PictoView Opcion4; - private timer_pictogram_clicker Opcion1_clicker; - private timer_pictogram_clicker Opcion2_clicker; - private timer_pictogram_clicker Opcion3_clicker; - private timer_pictogram_clicker Opcion4_clicker; - - //Declaracion de variables del TTS + private PictoView ViewOptions0,ViewOptions1, ViewOptions2,ViewOptions3; private User user; private boolean isSettings; private Button btnBarrido; @@ -196,9 +189,7 @@ public class Principal extends AppCompatActivity implements View private boolean doubleBackToExitPressedOnce = false; private String Oracion = ""; private int versionCode; - //Indica el proximo lugar en la seleccion - private int CantClicks; - //Handler para animar el Hablar cuando pasa cierto tiempo + //Indica el proximo lugar en la seleccion //Handler para animar el Hablar cuando pasa cierto tiempo private final Runnable animarHablar = new Runnable() { @Override public void run() { @@ -210,9 +201,6 @@ public void run() { private boolean editarPicto; - private int cuentaMasPictos; - private int placeTypeActual; - private int placeActual; private boolean vibrar = false; private StorageReference mStorageRef; private LottieAnimationView animationView; @@ -245,6 +233,10 @@ public void run() { private ImageButton masPictos; private ImageButton todosLosPictos; private ImageButton resetButton; + private timer_pictogram_clicker[] timer_pictogram_clickers ; + + private int CantClicks; + @@ -670,16 +662,64 @@ void CargarOracion(JSONObject jsonObject, String idioma) { * @param opcion */ private void CargarSeleccion(JSONObject opcion) { + GlideAttatcher attatcher = new GlideAttatcher(this); Pictogram pictogram = new Pictogram(opcion, ConfigurarIdioma.getLanguaje()); - int value = CantClicks+1; - if(CantClicks<=9){ - loadDrawable( pictogram, CantClicks); - ImageView aux = getImageView(value); - if(aux != null) - aux.setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + switch (CantClicks) { + case 0: + loadDrawable(attatcher, pictogram, getImageView(0)); + getImageView(0).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + getImageView(1).setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + break; + case 1: + loadDrawable(attatcher, pictogram, getImageView(1)); + getImageView(1).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + getImageView(2).setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + break; + case 2: + loadDrawable(attatcher, pictogram, getImageView(2)); + getImageView(2).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + getImageView(3).setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + break; + case 3: + loadDrawable(attatcher, pictogram, getImageView(3)); + getImageView(3).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + getImageView(4).setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + break; + case 4: + loadDrawable(attatcher, pictogram, getImageView(5)); + getImageView(5).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + getImageView(6).setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + break; + case 5: + loadDrawable(attatcher, pictogram, getImageView(6)); + getImageView(6).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + getImageView(7).setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + break; + case 6: + loadDrawable(attatcher, pictogram, getImageView(7)); + getImageView(7).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + getImageView(8).setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + break; + case 7: + loadDrawable(attatcher, pictogram, getImageView(8)); + getImageView(8).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + getImageView(9).setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + break; + case 8: + loadDrawable(attatcher, pictogram, getImageView(8)); + getImageView(8).setImageDrawable(getResources().getDrawable(R.drawable.icono_ottaa)); + getImageView(9).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + case 9: + loadDrawable(attatcher, pictogram, getImageView(9)); + getImageView(9).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); + break; } + + } + + /** * Inicializa la barra de seleccion poniendo la imagen por defecto */ @@ -694,47 +734,72 @@ private void inicializar_seleccion() { private void loadOptions(Json json, JSONObject padre) { Animation alphaAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.alpha_show); + Executor executor = Executors.newSingleThreadExecutor(); + Handler handler = new Handler(Looper.getMainLooper()); + executor.execute(() -> { + + handler.post(() -> { + ViewOptions0.setEnabled(true); + ViewOptions1.setEnabled(true); + ViewOptions2.setEnabled(true); + ViewOptions3.setEnabled(true); + if (json.getCantFallas() ==0) + loadChilds(padre, alphaAnimation); + if(json.getCantFallas()<4 && json.getCantFallas()>0) + downloadFailedFile(3); + } + ); + }); + - Opcion1.setEnabled(true); - Opcion2.setEnabled(true); - Opcion3.setEnabled(true); - Opcion4.setEnabled(true); - if (json.getCantFallas() ==0) - loadChilds(padre, alphaAnimation); - if(json.getCantFallas()<4 && json.getCantFallas()>0) - downloadFailedFile(3); } public void loadChildOption(JSONArray opciones, int index, Animation alphaAnimation) { + int option = -1; try { - if (opciones.getJSONObject(index).getInt("id") != -1) { - Log.d(TAG, "loadChildOption: Value"+index); - selectJsonOption(index, opciones.getJSONObject(index), alphaAnimation); - } else { - Log.d(TAG, "loadChildOption: null "); - loadOptionValue(index, null); - addOpcionNull(returnOption(index), alphaAnimation); - } + option= opciones.getJSONObject(index).getInt("id"); } catch (JSONException e) { + Log.d(TAG, "loadChildOption: exception at main"); e.printStackTrace(); } + if ( option!= -1) { + Log.d(TAG, "loadChildOption: Value"+index); + try { + selectJsonOption(index, opciones.getJSONObject(index), alphaAnimation); + } catch (JSONException e) { + Log.d(TAG, "loadChildOption: exception at main"); + e.printStackTrace(); } + } else { + + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(new Runnable() { + @Override + public void run() { + loadOptionValue(index, null); + addOpcionNull(returnOption(index), alphaAnimation); + } + }); + + + } + } public void selectJsonOption(int position, JSONObject object, Animation alphaAnimation) { loadOptionValue(position, object); switch (position) { case 0: - addOption(opcion1, returnOption(position), alphaAnimation); + addOption(option1, returnOption(position), alphaAnimation); break; case 1: - addOption(opcion2, returnOption(position), alphaAnimation); + addOption(option2, returnOption(position), alphaAnimation); break; case 2: - addOption(opcion3, returnOption(position), alphaAnimation); + addOption(option3, returnOption(position), alphaAnimation); break; case 3: - addOption(opcion4, returnOption(position), alphaAnimation); + addOption(option4, returnOption(position), alphaAnimation); break; } } @@ -742,31 +807,31 @@ public void selectJsonOption(int position, JSONObject object, Animation alphaAni private PictoView returnOption(int position) { switch (position) { case 0: - return Opcion1; + return ViewOptions0; case 1: - return Opcion2; + return ViewOptions1; case 2: - return Opcion3; + return ViewOptions2; case 3: - return Opcion4; + return ViewOptions3; default: - return Opcion1; + return ViewOptions0; } } private void loadOptionValue(int position, JSONObject value) { switch (position) { case 0: - opcion1 = value; + option1 = value; break; case 1: - opcion2 = value; + option2 = value; break; case 2: - opcion3 = value; + option3 = value; break; case 3: - opcion4 = value; + option4 = value; break; } } @@ -794,7 +859,7 @@ private Integer cargarColor(int tipo) { private void Reset() { pictoPadre = historial.removePictograms(true); ResetSeleccion(); - cuentaMasPictos = 0; + PictogramPositionCounter.getInstance().resetPosition(); loadOptions(json, pictoPadre); } @@ -816,7 +881,7 @@ public void ResetSeleccion() { private void volver() { pictoPadre = historial.removePictograms(false); ResetSeleccion(); - cuentaMasPictos = 0; + PictogramPositionCounter.getInstance().resetPosition(); for (int i = 0; i < historial.getListadoPictos().size(); i++) { CargarSeleccion(historial.getListadoPictos().get(i)); CantClicks++; @@ -825,7 +890,7 @@ private void volver() { } private void click(JSONObject opcion) { - cuentaMasPictos = 0; + PictogramPositionCounter.getInstance().resetPosition(); if (opcion == null || pictoPadre == null) { Log.d(TAG, "click: Opcion es null"); return; @@ -872,11 +937,15 @@ private void createRelationShip(JSONObject opcion,LoadPictograms loadPictograms) } private void cargarMasPictos() { - cuentaMasPictos++; - if (cuentaMasPictos > Constants.VUELTAS_CARRETE) { - cuentaMasPictos = 0; + PictogramPositionCounter.getInstance().incrementPosition(); + if (PictogramPositionCounter.getInstance().getPosChild() > PictogramPositionCounter.getInstance().getLimit()) { + PictogramPositionCounter.getInstance().resetPosition(); + } + try { + loadOptions(json, pictoPadre); + }catch (Exception ex){ + } - loadOptions(json, pictoPadre); } public void AlertBorrar(final int pos) { @@ -889,32 +958,16 @@ public void AlertBorrar(final int pos) { dialogs.setOnClick(dialogs.getObject(R.id.yes_button), new View.OnClickListener() { @Override public void onClick(View v) { - try { - if (sharedPrefsDefault.getBoolean("esmoderador", false)) { - JSONArray pictosSugeridos = json.readJSONArrayFromFile(Constants.ARCHIVO_PICTOS_DATABASE); - JSONutils.desvincularJson(pictosSugeridos.getJSONObject(pictoPadre.getInt("id")), pos); - json.setmJSONArrayPictosSugeridos(pictosSugeridos); - if (!json.guardarJson(Constants.ARCHIVO_PICTOS_DATABASE)) - Log.e(TAG, "onClick: eliminar: Error al guardar pictos sugeridos"); - } - - } catch (JSONException | FiveMbException e) { - e.printStackTrace(); - } - try { - JSONutils.desvincularJson(pictoPadre, pos); - JSONutils.setJsonEditado2(json.getmJSONArrayTodosLosPictos(), pictoPadre); - if (!json.guardarJson(Constants.ARCHIVO_PICTOS)) + JSONutils.desvincularJson(pictoPadre, pos); + try{ + JSONutils.setJsonEditado2(json.getmJSONArrayTodosLosPictos(), pictoPadre); + if (!json.guardarJson(Constants.ARCHIVO_PICTOS)) Log.e(TAG, "onClick: Error al guardar pictos sugeridos"); - cargarMasPictos(); - - } catch (JSONException e) { - e.printStackTrace(); - }catch (Exception ex){ - - } + }catch (JSONException ex){ + } + json.setRefreshChild(); + cargarMasPictos(); dialogs.cancelarDialogo(); - loadOptions(json, pictoPadre); } }); @@ -955,16 +1008,16 @@ public boolean onLongClick(View v) { if (editarPicto) { switch (v.getId()) { case R.id.Option1: - longClick(Opcion1, opcion1); + longClick(ViewOptions0, option1); break; case R.id.Option2: - longClick(Opcion2, opcion2); + longClick(ViewOptions1,option2); break; case R.id.Option3: - longClick(Opcion3, opcion3); + longClick(ViewOptions2, option3); break; case R.id.Option4: - longClick(Opcion4, opcion4); + longClick(ViewOptions3, option4); break; default: onClick(v); @@ -982,6 +1035,7 @@ public Context getContext() { } private void AnimarHablar() { + if(CantClicks<9){ getImageView(CantClicks).startAnimation(AnimationUtils.loadAnimation(this, R.anim.shake)); } @@ -1040,16 +1094,16 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { public void onClick(View v) { switch (v.getId()) { case R.id.Option1: - onClickOption(opcion1, Opcion1_clicker); + onClickOption(option1, timer_pictogram_clickers[0]); break; case R.id.Option2: - onClickOption(opcion2, Opcion2_clicker); + onClickOption(option2, timer_pictogram_clickers[1]); break; case R.id.Option3: - onClickOption(opcion3, Opcion3_clicker); + onClickOption(option3, timer_pictogram_clickers[2]); break; case R.id.Option4: - onClickOption(opcion4, Opcion4_clicker); + onClickOption(option4, timer_pictogram_clickers[3]); break; case R.id.btnFavoritos: startFavoritePhrases(); @@ -1318,10 +1372,10 @@ public void run() { } private ArrayList addObjects(ArrayList listadoObjetosBarrido){ - listadoObjetosBarrido.add(Opcion1); - listadoObjetosBarrido.add(Opcion2); - listadoObjetosBarrido.add(Opcion3); - listadoObjetosBarrido.add(Opcion4); + listadoObjetosBarrido.add(ViewOptions0); + listadoObjetosBarrido.add(ViewOptions1); + listadoObjetosBarrido.add(ViewOptions2); + listadoObjetosBarrido.add(ViewOptions3); listadoObjetosBarrido.add(botonFavoritos); listadoObjetosBarrido.add(borrar); listadoObjetosBarrido.add(talk); @@ -1335,17 +1389,24 @@ public void CargarJson() { initJson(); json.initJsonArrays(); json.cargarPictosSugeridosJson(); + loadJson(); + } + public void loadJson(){ if (json.getmJSONArrayTodosLosPictos() != null && json.getmJSONArrayTodosLosPictos().length() > 0) { - try { - if (pictoPadre == null || pictoPadre.getInt("id") == 0) - pictoPadre = json.getPictoFromId2(0); - cuentaMasPictos = 0; - if(pictoPadre != null) - loadOptions(json, pictoPadre); - } catch (JSONException e) { - e.printStackTrace(); + if(pictoPadre == null ){ + pictoPadre = json.getPictoFromId2(0); + } + if(historial == null) + historial = new Historial(json); + if (pictoPadre != null ){ + new Json0Recover().backupPictogram0(this,pictoPadre,this); + }else{ + new Json0Recover().restorePictogram0(this,this); } + PictogramPositionCounter.getInstance().resetPosition(); + loadOptions(json, pictoPadre); + } } @@ -1396,58 +1457,67 @@ public boolean tocarTeclaAcordeUbicacion(KeyEvent event, int keyCode, int ubic) } private void addOption(JSONObject opcion, PictoView picto, Animation animation) { - if(ValidateContext.isValidContext(this)){ - Pictogram pictogram = new Pictogram(opcion, ConfigurarIdioma.getLanguaje()); - picto.setUpGlideAttatcher(this); - picto.setUpContext(this); - picto.setPictogramsLibraryPictogram(pictogram); - picto.setVisibility(View.VISIBLE); - formatoTransparencia(picto, opcion); - picto.startAnimation(animation); - } + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(new Runnable() { + @Override + public void run() { + if(ValidateContext.isValidContext(getContext())){ + Pictogram pictogram = new Pictogram(opcion, ConfigurarIdioma.getLanguaje()); + picto.setUpGlideAttatcher(getContext()); + picto.setUpContext(getContext()); + picto.setPictogramsLibraryPictogram(pictogram); + picto.setVisibility(View.VISIBLE); + formatoTransparencia(picto, opcion); + picto.startAnimation(animation); + } + } + }); + } /** * use custom_picto opcion , animation alphaAnimation */ private void addOpcionNull(PictoView Opcion, Animation alphaAnimation) { - Opcion.setCustom_Img(getResources().getDrawable(R.drawable.ic_agregar_nuevo)); - Opcion.setCustom_Texto(getResources().getString(R.string.agregar_picto)); - Opcion.setCustom_Color(getResources().getColor(R.color.Black)); - Opcion.startAnimation(alphaAnimation); - Opcion.setAlpha((float) 1); - this.cuentaMasPictos = -1;// linea encargada de indicar que el contador esta en 0 - Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), - R.anim.alpha_dismiss); - - - if (isNullObject(opcion1)) { - hideAnimation(animation,1); - } else if (isNullObject(opcion2)) { - hideAnimation(animation,2); - } else if (isNullObject(opcion3)) { - hideAnimation(animation,3); - } else if (isNullObject(opcion4) && Opcion3.getVisibility() == View.VISIBLE) { - hideAnimation(animation,4); + if(Opcion!=null){ + Log.d(TAG, "loadChildOption: null "); + Opcion.setCustom_Img(getResources().getDrawable(R.drawable.ic_agregar_nuevo)); + Opcion.setCustom_Texto(getResources().getString(R.string.agregar_picto)); + Opcion.setCustom_Color(getResources().getColor(R.color.Black)); + Opcion.startAnimation(alphaAnimation); + Opcion.setAlpha((float) 1); + PictogramPositionCounter.getInstance().setlessone(); + Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), + R.anim.alpha_dismiss); + + if (isNullObject(option1)) { + hideAnimation(animation,1); + } else if (isNullObject(option2)) { + hideAnimation(animation,2); + } else if (isNullObject(option3)) { + hideAnimation(animation,3); + } else if (isNullObject(option4) && ViewOptions3.getVisibility() == View.VISIBLE) { + hideAnimation(animation,4); + } } } public void hideAnimation(Animation animation,int id){ switch (id){ case 1: - setInvisibleOption(Opcion2,animation); - setInvisibleOption(Opcion3,animation); - setInvisibleOption(Opcion4,animation); + setInvisibleOption(ViewOptions1,animation); + setInvisibleOption(ViewOptions2,animation); + setInvisibleOption(ViewOptions3,animation); break; case 2: - setInvisibleOption(Opcion3,animation); - setInvisibleOption(Opcion4,animation); + setInvisibleOption(ViewOptions2,animation); + setInvisibleOption(ViewOptions3,animation); break; case 3: - setInvisibleOption(Opcion4,animation); + setInvisibleOption(ViewOptions3,animation); break; case 4: - Opcion4.setVisibility(View.VISIBLE); + ViewOptions3.setVisibility(View.VISIBLE); break; } } @@ -1588,24 +1658,22 @@ public ScrollFunctionMainActivity getFunction_scroll() { return function_scroll; } - public void loadDrawable( Pictogram pictogram,int position) { - GlideAttatcher attatcher = new GlideAttatcher(this); + public void loadDrawable( GlideAttatcher attatcher,Pictogram pictogram,ImageView aux) { if (pictogram.getEditedPictogram().isEmpty()) { if(!pictogram.getPictogram().startsWith("https://")){ Drawable drawable = Json.getInstance().getIcono(pictogram.getObject()); if(drawable != null) - attatcher.UseCornerRadius(true).loadDrawable(drawable, getImageView(position)); + attatcher.UseCornerRadius(true).loadDrawable(drawable, aux); }else{ - attatcher.UseCornerRadius(true).loadDrawable(Uri.parse(pictogram.getPictogram()), getImageView(position)); + attatcher.UseCornerRadius(true).loadDrawable(Uri.parse(pictogram.getPictogram()), aux); } } else { File picto = new File(pictogram.getEditedPictogram()); if (picto.exists()) - attatcher.UseCornerRadius(true).loadDrawable(picto, getImageView(position)); + attatcher.UseCornerRadius(true).loadDrawable(picto, aux); else - attatcher.UseCornerRadius(true).loadDrawable(Uri.parse(pictogram.getUrl()), getImageView(position)); + attatcher.UseCornerRadius(true).loadDrawable(Uri.parse(pictogram.getUrl()),aux); } - getImageView(position).startAnimation(AnimationUtils.loadAnimation(this, R.anim.overshoot_arriba)); } public void showAvatar() { @@ -1847,6 +1915,7 @@ private void initComponents() { initAvatar(); initTTS(); initBarrido(); + new initComponentsClass().execute(); @@ -1871,28 +1940,23 @@ private void initDefaultSettings(Context context) { ConfigurarIdioma.setLanguage(sharedPrefsDefault.getString(getString(R.string.str_idioma), "en")); Log.d(TAG, "ConfigurarIdioma : " + ConfigurarIdioma.getLanguaje()); new ConfigurarIdioma(getApplicationContext(), ConfigurarIdioma.getLanguaje()); - initJson(context); + initJson(); json.initSharedPrefs(); Log.d(TAG, "hashCode: " + json.hashCode()); timeStamp = getTimeStamp(); historial = new Historial(json); sharedPrefsDefault.edit().putBoolean("usuario logueado", true).apply(); - cuentaMasPictos = 0; - placeTypeActual = 0; - placeActual = 0; + PictogramPositionCounter.getInstance().resetPosition(); historial.downloadPromt(); } - private void initJson(Context context){ - Json.getInstance().setmContext(context); - json = Json.getInstance(); - } - private void initJson(){ Json.getInstance().setmContext(this); json = Json.getInstance(); } + + private void initFlags() { sharedPrefs = getSharedPreferences(sharedPrefsDefault.getString(getString(R.string.str_userMail), "error"), Context.MODE_PRIVATE); TutoFlag = sharedPrefs.getBoolean("PrimerUso", true); @@ -1954,11 +2018,13 @@ private void initMenu() { private void initSelectionComponents() { + for (int i = 0; i < 10; i++) { int id = getResources().getIdentifier("Seleccion"+(i+1),"id",getPackageName()); - getSelectedImage(i).setImageview(findViewById(id)); + setImageView(id,i); AjustarAncho(id); } + } @AddTrace(name = "setOnLongClickListener", enabled = true /* optional */) @@ -1974,10 +2040,10 @@ private void setOnLongClickListener(){ setClickLongListener(resetButton); setClickLongListener(btn_share); setClickOnTouchListener(btnBarrido); - setClickLongListener(Opcion1); - setClickLongListener(Opcion2); - setClickLongListener(Opcion3); - setClickLongListener(Opcion4); + setClickLongListener(ViewOptions0); + setClickLongListener(ViewOptions1); + setClickLongListener(ViewOptions2); + setClickLongListener(ViewOptions3); } private void initActionButtons() { @@ -1994,23 +2060,25 @@ private void initActionButtons() { } private void initPictograms() { - Opcion1 = findViewById(R.id.Option1); - Opcion2 = findViewById(R.id.Option2); - Opcion3 = findViewById(R.id.Option3); - Opcion4 = findViewById(R.id.Option4); + + ViewOptions0 = findViewById(R.id.Option1); + ViewOptions1 = findViewById(R.id.Option2); + ViewOptions2 = findViewById(R.id.Option3); + ViewOptions3 = findViewById(R.id.Option4); Agregar = new PictoView(this); Agregar.setCustom_Color(R.color.Black); Agregar.setCustom_Texto(""); Agregar.setCustom_Img(getDrawable(R.drawable.agregar_picto_transp)); Agregar.setIdPictogram(0); - Opcion1_clicker = new timer_pictogram_clicker(this); - Opcion2_clicker = new timer_pictogram_clicker(this); - Opcion3_clicker = new timer_pictogram_clicker(this); - Opcion4_clicker = new timer_pictogram_clicker(this); + timer_pictogram_clickers = new timer_pictogram_clicker[4]; + for (int i = 0; i { boolean used = false; @@ -2264,7 +2357,6 @@ protected Void doInBackground(Void... voids) { protected void onPostExecute(Void unused) { super.onPostExecute(unused); user.connectClient(); - initFirstPictograms(); uploadFiles(); initPlaceImplementationClass(); showMenu(); @@ -2281,57 +2373,6 @@ protected void onPostExecute(Void unused) { } - public class loadPictograms implements FailReadPictogramOrigin { - boolean used; - - public void execute(){ - ExecutorService executorService = Executors.newSingleThreadExecutor(); - Handler handler = new Handler(Looper.getMainLooper()); - executorService.execute(new Runnable() { - @Override - public void run() { - if (json.getmJSONArrayTodosLosPictos() != null && json.getmJSONArrayTodosLosPictos().length() > 0) { - pictoPadre = json.getPictoFromId2(0); - if(pictoPadre != null) - new Json0Recover().backupPictogram0(getApplicationContext(),pictoPadre,loadPictograms.this); - } - if(pictoPadre == null){ - new Json0Recover().restorePictogram0(getApplicationContext(),loadPictograms.this); - } - handler.post(new Runnable() { - @Override - public void run() { - if(used) { - used = false; - ResetSeleccion(); - } - } - }); - } - }); - } - - - - @Override - public void setParent(JSONObject parent) { - json.getmJSONArrayTodosLosPictos().put(parent); - json.setmJSONArrayTodosLosPictos(json.getmJSONArrayTodosLosPictos()); - json.guardarJson(Constants.ARCHIVO_PICTOS); - json.refreshJsonArrays(); - pictoPadre = json.getPictoFromId2(0); - loadDialog(); - } - - @Override - public void loadDialog() { - if (pictoPadre != null) { - if(historial==null) - loadOptions(json, pictoPadre); // y despues cargamos las opciones con el orden correspondiente - used = true; - } - } - } private boolean requestScreenScanningIsEnabled(){ if(barridoPantalla != null) @@ -2339,36 +2380,14 @@ private boolean requestScreenScanningIsEnabled(){ return false; } - private EnumImageView getSelectedImage(int option){ - switch (option){ - case 0: - return EnumImageView.ImageView1; - case 1: - return EnumImageView.ImageView2; - case 2: - return EnumImageView.ImageView3; - case 3: - return EnumImageView.ImageView4; - case 4: - return EnumImageView.ImageView5; - case 5: - return EnumImageView.ImageView6; - case 6: - return EnumImageView.ImageView7; - case 7: - return EnumImageView.ImageView8; - case 8: - return EnumImageView.ImageView9; - case 9: - return EnumImageView.ImageView10; - default: - return null; - } - } + private ImageView getImageView(int position){ - EnumImageView aux = getSelectedImage(position); - if(aux != null) - return aux.getImageview(); - return null; + return EnumImageView.getInstance().getImageview()[position]; + } + + private void setImageView(int id,int pos){ + EnumImageView.getInstance().setImageview(findViewById(id),pos); } + + } \ No newline at end of file diff --git a/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/AllPhrasesRecyclerView.java b/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/AllPhrasesRecyclerView.java index ad3a3281..eb18ae47 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/AllPhrasesRecyclerView.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/AllPhrasesRecyclerView.java @@ -1,5 +1,6 @@ package com.stonefacesoft.ottaa.RecyclerViews; +import android.graphics.drawable.Drawable; import android.view.View; import androidx.appcompat.app.AppCompatActivity; @@ -7,9 +8,15 @@ import com.google.firebase.auth.FirebaseAuth; import com.stonefacesoft.ottaa.Adapters.PhrasesAdapter; +import com.stonefacesoft.ottaa.Bitmap.GestionarBitmap; +import com.stonefacesoft.ottaa.CompartirArchivos; import com.stonefacesoft.ottaa.R; +import org.json.JSONArray; import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; public class AllPhrasesRecyclerView extends Custom_recyclerView { private PhrasesAdapter adapter; @@ -113,5 +120,38 @@ public void talkAtPosition(){ } } + public void shareAudio(CompartirArchivos compartirArchivos){ + try { + if(createReturnPositionItem()){ + int value = getPositionItem.getPosition(); + if(validatePosition(value)) { + GestionarBitmap gestionarBitmap = new GestionarBitmap(mActivity); + JSONArray child =gestionarBitmap.getJsonArray(adapter.getUserPhrases().getJSONObject(value)); + compartirArchivos.setHistorial(getJSonObjectList(child)); + compartirArchivos.seleccionarFormato(adapter.getUserPhrases().getJSONObject(value).getString("frase")); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private ArrayList getJSonObjectList(JSONArray array){ + ArrayList pictograms = new ArrayList<>(); + try { + for (int i = 0; i <= array.length()-1; i++) { + JSONObject picto = json.getPictoFromId2(array.getJSONObject(i).getInt("id")); + if(picto!=null){ + pictograms.add(picto); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + return pictograms; + } + + + } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/Favorite_Phrases_recycler_view.java b/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/Favorite_Phrases_recycler_view.java index 78ecc2c8..5206f0c1 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/Favorite_Phrases_recycler_view.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/Favorite_Phrases_recycler_view.java @@ -8,9 +8,17 @@ import com.google.firebase.auth.FirebaseAuth; import com.stonefacesoft.ottaa.Adapters.CustomFavoritePhrasesAdapter; +import com.stonefacesoft.ottaa.Bitmap.GestionarBitmap; +import com.stonefacesoft.ottaa.CompartirArchivos; import com.stonefacesoft.ottaa.R; import com.stonefacesoft.ottaa.utils.Phrases.CustomFavoritePhrases; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; + public class Favorite_Phrases_recycler_view extends Custom_recyclerView { private CustomFavoritePhrasesAdapter adapter; private CustomFavoritePhrases customFavoritePhrases; @@ -87,6 +95,38 @@ public void talkAtPosition() { } + public void shareAudio(CompartirArchivos compartirArchivos){ + try { + if(createReturnPositionItem()){ + int value = getPositionItem.getPosition(); + if(validatePosition(value)) { + GestionarBitmap gestionarBitmap = new GestionarBitmap(mActivity); + JSONObject result = adapter.getPhrases().getPhrases().getJSONObject(value); + JSONArray child =gestionarBitmap.getJsonArray(result); + compartirArchivos.setHistorial(getJSonObjectList(child)); + compartirArchivos.seleccionarFormato(adapter.getPhrases().getPhrases().getJSONObject(value).getString("frase")); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private ArrayList getJSonObjectList(JSONArray array){ + ArrayList pictograms = new ArrayList<>(); + try { + for (int i = 0; i <= array.length()-1; i++) { + JSONObject picto = json.getPictoFromId2(array.getJSONObject(i).getInt("id")); + if(picto!=null){ + pictograms.add(picto); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + return pictograms; + } + } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/Grupo_Recycler_View_Game.java b/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/Grupo_Recycler_View_Game.java index c372a92d..4815deca 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/Grupo_Recycler_View_Game.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/Grupo_Recycler_View_Game.java @@ -100,7 +100,9 @@ private void initArray(){ array= new JSONArray(); int[] idPictos = TellAStoryUtils.getInstance().getItem().getOptions(); for (int i = 0; i < idPictos.length; i++) { - array.put(json.getGrupoFromId(idPictos[i])); + JSONObject group = json.getGrupoFromId(idPictos[i]); + if(group!=null) + array.put(group); } arrayAux = array; } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/MostUsedPhrases_Recycler_View.java b/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/MostUsedPhrases_Recycler_View.java index 97d511e4..6805f7e5 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/MostUsedPhrases_Recycler_View.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/RecyclerViews/MostUsedPhrases_Recycler_View.java @@ -1,12 +1,23 @@ package com.stonefacesoft.ottaa.RecyclerViews; +import android.util.Log; + import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; +import com.google.api.LogDescriptor; import com.google.firebase.auth.FirebaseAuth; import com.stonefacesoft.ottaa.Adapters.MostUsedFavoritePhrasesAdapter; +import com.stonefacesoft.ottaa.Bitmap.GestionarBitmap; +import com.stonefacesoft.ottaa.CompartirArchivos; import com.stonefacesoft.ottaa.Interfaces.ProgressBarListener; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; + public class MostUsedPhrases_Recycler_View extends Custom_recyclerView { private MostUsedFavoritePhrasesAdapter mostUsedFavoritePhrasesAdapter; @@ -88,4 +99,36 @@ public void talkAtPosition() { } } + public void shareAudio(CompartirArchivos compartirArchivos){ + try { + if(createReturnPositionItem()){ + int value = getPositionItem.getPosition(); + if(validatePosition(value)) { + GestionarBitmap gestionarBitmap = new GestionarBitmap(mActivity); + JSONObject result = mostUsedFavoritePhrasesAdapter.getmFavImagesArrayList().get(value).getPictogram(); + JSONArray child =gestionarBitmap.getJsonArray(result); + compartirArchivos.setHistorial(getJSonObjectList(child)); + compartirArchivos.seleccionarFormato(mostUsedFavoritePhrasesAdapter.getmFavImagesArrayList().get(value).getTexto()); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private ArrayList getJSonObjectList(JSONArray array){ + ArrayList pictograms = new ArrayList<>(); + try { + for (int i = 0; i <= array.length()-1; i++) { + JSONObject picto = json.getPictoFromId2(array.getJSONObject(i).getInt("id")); + if(picto!=null){ + pictograms.add(picto); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + return pictograms; + } + } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/Viewpagers/viewpager_game_filter_view.java b/app/src/main/java/com/stonefacesoft/ottaa/Viewpagers/viewpager_game_filter_view.java index ec11e5f3..ee5542e0 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/Viewpagers/viewpager_game_filter_view.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/Viewpagers/viewpager_game_filter_view.java @@ -84,7 +84,9 @@ protected void initArray(){ array= new JSONArray(); int[] idPictos = TellAStoryUtils.getInstance().getItem().getOptions(); for (int i = 0; i < idPictos.length; i++) { - array.put(json.getGrupoFromId(idPictos[i])); + JSONObject group = json.getGrupoFromId(idPictos[i]); + if(group!=null) + array.put(group); } } @@ -176,7 +178,9 @@ public void updateData() { array= new JSONArray(); int[] idPictos = TellAStoryUtils.getInstance().getItem().getOptions(); for (int i = 0; i < idPictos.length; i++) { - array.put(json.getGrupoFromId(idPictos[i])); + JSONObject object = json.getGrupoFromId(idPictos[i]); + if(object!=null) + array.put(object); } } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/Views/Phrases/PhrasesView.java b/app/src/main/java/com/stonefacesoft/ottaa/Views/Phrases/PhrasesView.java index 653539f4..8145d852 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/Views/Phrases/PhrasesView.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/Views/Phrases/PhrasesView.java @@ -1,6 +1,7 @@ package com.stonefacesoft.ottaa.Views.Phrases; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; import android.util.Log; import android.view.InputDevice; @@ -50,6 +51,7 @@ public class PhrasesView extends AppCompatActivity implements View.OnClickListen protected String TAG="PhraseView"; protected AnalyticsFirebase mAnalyticsFirebase; + protected SharedPreferences sharedPrefsDefault; @Override diff --git a/app/src/main/java/com/stonefacesoft/ottaa/prefs.java b/app/src/main/java/com/stonefacesoft/ottaa/prefs.java index ca8c17b9..88f1fde4 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/prefs.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/prefs.java @@ -47,6 +47,7 @@ import com.stonefacesoft.ottaa.utils.Handlers.HandlerComunicationClass; import com.stonefacesoft.ottaa.utils.IntentCode; import com.stonefacesoft.ottaa.utils.ObservableInteger; +import com.stonefacesoft.ottaa.utils.RequestPersmissionClass; import com.stonefacesoft.ottaa.utils.constants.Constants; import com.stonefacesoft.ottaa.utils.constants.ConstantsAnalyticsValues; import com.stonefacesoft.ottaa.utils.preferences.PersonalSwitchPreferences; @@ -99,6 +100,8 @@ public class prefs extends PreferenceActivity implements SharedPreferences.OnSha public static String STR_SIP_AND_PUFF; public static String BOOL_SAY_PICTOGRAM; + public static String ENABLE_SHARE_PHRASES; + public static String CHATGPT; public static String REPEATPHRASE; int permission = 0; @@ -121,6 +124,7 @@ public class prefs extends PreferenceActivity implements SharedPreferences.OnSha private PersonalSwitchPreferences mBoolSayPictogram; private PersonalSwitchPreferences mBoolChatGPT; private PersonalSwitchPreferences mBoolRepeatPhrase; + private PersonalSwitchPreferences mBoolSharePhrase; private StorageReference mStorageRef; // private ProgressDialog progressDialog,dialog; private Progress_dialog_options firebaseDialog; @@ -156,6 +160,8 @@ public class prefs extends PreferenceActivity implements SharedPreferences.OnSha private String message = ""; private FirebaseUtils firebaseUtils; + private RequestPersmissionClass requestPersmissionClass; + @Override @@ -163,6 +169,7 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); analyticsFirebase = new AnalyticsFirebase(this); + requestPersmissionClass = new RequestPersmissionClass(); initComponents(); isConnected(); habilitarFuncionesPremiun(sharedPrefsDefault.getInt("premium", 0)); @@ -231,6 +238,7 @@ private void initComponents() { BOOL_SAY_PICTOGRAM = getResources().getString(R.string.say_pictogram_name_key); CHATGPT =getResources().getString(R.string.mBoolChatGPT); REPEATPHRASE = getResources().getString(R.string.repeat_pictogram_name_key); + ENABLE_SHARE_PHRASES = getResources().getString(R.string.enable_share_phrases); //PersonalSwitchPreference @@ -252,6 +260,7 @@ private void initComponents() { mBoolSayPictogram = (PersonalSwitchPreferences) findPreference(BOOL_SAY_PICTOGRAM); mBoolChatGPT = (PersonalSwitchPreferences) findPreference(CHATGPT); mBoolRepeatPhrase = (PersonalSwitchPreferences) findPreference(CHATGPT); + mBoolSharePhrase = (PersonalSwitchPreferences) findPreference(ENABLE_SHARE_PHRASES); // preference mNumTono = findPreference(NUM_Tono); @@ -362,12 +371,8 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPrefs, String key) boolean b = sharedPrefs.getBoolean(key, false); if (b && mBoolUbicacion.getSummary() == getResources().getString(R.string.pref_desactivado)) { //Check si tenemoslos permisos necesarios para ejecutar el calendario. + if (!requestPersmissionClass.requestLocationPermission(getApplicationContext())) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat - .checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) - != PackageManager.PERMISSION_GRANTED && ContextCompat - .checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) - != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{ //Permisos para poder leer y escribir el calendar Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission @@ -404,6 +409,8 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPrefs, String key) boolean b = sharedPrefs.getBoolean(key, false); }else if(REPEATPHRASE.equals(key)){ boolean b = sharedPrefs.getBoolean(key, true); + }else if(ENABLE_SHARE_PHRASES.equals(key)){ + boolean b = sharedPrefs.getBoolean(key, false); } } @@ -428,6 +435,7 @@ public void onResume() { onSharedPreferenceChanged(sharedPrefsDefault, STR_SCROLL_FUNCTION); onSharedPreferenceChanged(sharedPrefsDefault, "hablar_borrar"); onSharedPreferenceChanged(sharedPrefsDefault,CHATGPT); + onSharedPreferenceChanged(sharedPrefsDefault,ENABLE_SHARE_PHRASES); sharedPrefsDefault.registerOnSharedPreferenceChangeListener(this); diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/ClickCounter.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/ClickCounter.java new file mode 100644 index 00000000..1f2fdb94 --- /dev/null +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/ClickCounter.java @@ -0,0 +1,30 @@ +package com.stonefacesoft.ottaa.utils; + +public class ClickCounter { + private int clickCounter=0; + private static ClickCounter _ClickCounter; + + public static ClickCounter getInstance(){ + if(_ClickCounter == null) + _ClickCounter = new ClickCounter(); + return _ClickCounter; + } + + public void incrementValue(){ + clickCounter=clickCounter+1; + } + + public void decrementValue(){ + clickCounter--; + } + + public int getClickCounter() { + return clickCounter; + } + + public void resetCounter(){ + clickCounter = 0; + } + + +} diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumImageView.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumImageView.java index 406c805b..e909abaf 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumImageView.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumImageView.java @@ -1,14 +1,19 @@ package com.stonefacesoft.ottaa.utils; +import android.widget.ImageButton; import android.widget.ImageView; -public enum EnumImageView { - ImageView1,ImageView2,ImageView3,ImageView4,ImageView5,ImageView6,ImageView7,ImageView8,ImageView9,ImageView10; - private ImageView imageview; - public ImageView getImageview() { - return imageview; +public class EnumImageView { + public ImageButton[] imageView = new ImageButton[10]; + public static EnumImageView _EnumImageView; + public static EnumImageView getInstance(){ + if(_EnumImageView == null) + _EnumImageView = new EnumImageView(); + return _EnumImageView; } - public void setImageview(ImageView imageview) { - this.imageview =imageview ; + public ImageButton[] getImageview() { + return imageView; + } + public void setImageview( ImageButton imgView,int child) {imageView[child] = imgView ; } } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumPictoOptions.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumPictoOptions.java new file mode 100644 index 00000000..e083f98c --- /dev/null +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumPictoOptions.java @@ -0,0 +1,17 @@ +package com.stonefacesoft.ottaa.utils; + +import org.json.JSONObject; + +public class EnumPictoOptions { + public static JSONObject pictoPadre, opcion1, opcion2, opcion3, opcion4, onLongOpcion; + + private JSONObject object; + + public void setObject(JSONObject object) { + this.object = object; + } + + public JSONObject getObject() { + return object; + } +} diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumPictoView.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumPictoView.java new file mode 100644 index 00000000..ef078e6e --- /dev/null +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/EnumPictoView.java @@ -0,0 +1,17 @@ +package com.stonefacesoft.ottaa.utils; + +import com.stonefacesoft.pictogramslibrary.view.PictoView; + +public enum EnumPictoView { + OPCION1,OPCION2,OPCION3,OPCION4; + + private PictoView pictoView; + + public void setPictoView(PictoView pictoView) { + this.pictoView = pictoView; + } + + public PictoView getPictoView() { + return pictoView; + } +} diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/FileActions/EnumActions.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/FileActions/EnumActions.java new file mode 100644 index 00000000..dfe238c3 --- /dev/null +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/FileActions/EnumActions.java @@ -0,0 +1,14 @@ +package com.stonefacesoft.ottaa.utils.FileActions; + +import static com.stonefacesoft.ottaa.utils.FileActions.EnumActions.Actions.ADDRELATIONSHIP; +import static com.stonefacesoft.ottaa.utils.FileActions.EnumActions.Actions.DELETE; + +import com.stonefacesoft.ottaa.JSONutils.Json; + +public class EnumActions { + public enum Actions{ + DELETE,TALK,ADDRELATIONSHIP; + } + + +} diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/Games/TellAStoryUtils.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/Games/TellAStoryUtils.java index d30a61ca..60ebab69 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/Games/TellAStoryUtils.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/Games/TellAStoryUtils.java @@ -14,7 +14,7 @@ public static synchronized TellAStoryUtils getInstance(){ }; public enum FilterGroups{ - Position0(new int[]{2,17,3,12}),Position1(new int[]{6,1,16,20}),Position2(new int[]{0,24}),Position3(new int[]{4,13,21}); + Position0(new int[]{2,17,3,12,24}),Position1(new int[]{6,1,16,20,24}),Position2(new int[]{0,24}),Position3(new int[]{4,13,21,24}); private final int[] options; FilterGroups(int[] list){ this.options = list; diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/JSONutils.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/JSONutils.java index 69e27aff..77aeadea 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/JSONutils.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/JSONutils.java @@ -284,6 +284,7 @@ public static void desvincularJson(JSONObject padre, int id) { JSONArray jsonArray; JSONArray list = new JSONArray(); + try { if(padre.has("relacion")){ jsonArray = padre.getJSONArray("relacion"); diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/PictogramPositionCounter.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/PictogramPositionCounter.java new file mode 100644 index 00000000..607ba2c9 --- /dev/null +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/PictogramPositionCounter.java @@ -0,0 +1,48 @@ +package com.stonefacesoft.ottaa.utils; + +import com.stonefacesoft.ottaa.utils.constants.Constants; + +public class PictogramPositionCounter { + private volatile int posChild; + private int limit= Constants.VUELTAS_CARRETE; + + private boolean useLimit = true; + + private static PictogramPositionCounter _pictogramPositionCounter; + public synchronized static PictogramPositionCounter getInstance(){ + if(_pictogramPositionCounter==null) + _pictogramPositionCounter = new PictogramPositionCounter(); + return _pictogramPositionCounter; + } + + public void incrementPosition(){ + posChild++; + } + + public void decrementPosition(){ + posChild--; + } + + public void resetPosition(){ + posChild = 0; + } + + public void setlessone(){ + posChild = -1; + } + + public int getPosChild() { + return posChild; + } + + public void setLimit(int value){ + if(!useLimit) + this.limit = value; + else + this.limit = Constants.VUELTAS_CARRETE; + } + + public int getLimit() { + return limit; + } +} diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/Pictures/DownloadFirebasePictures.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/Pictures/DownloadFirebasePictures.java index 682927fe..37b4b199 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/Pictures/DownloadFirebasePictures.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/Pictures/DownloadFirebasePictures.java @@ -3,7 +3,6 @@ import android.Manifest; import android.content.pm.PackageManager; import android.os.Build; -import android.util.Log; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; @@ -17,6 +16,7 @@ import com.stonefacesoft.ottaa.FirebaseRequests.FirebaseUtils; import com.stonefacesoft.ottaa.GaleriaGrupos2; import com.stonefacesoft.ottaa.Interfaces.FirebaseSuccessListener; +import com.stonefacesoft.ottaa.utils.RequestPersmissionClass; import com.stonefacesoft.ottaa.utils.constants.Constants; import com.stonefacesoft.ottaa.utils.preferences.User; @@ -80,8 +80,6 @@ public void requestPermission() { bajar = new bajarFotos(); bajar.setInterfaz(mFbSuccessListenerInterfaz); mDirectorio = new UriFiles(mActivity.getApplicationContext()).dir(); - String[] text = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}; - requestActivityPermission(); } public void setUpDirectory() { @@ -100,20 +98,6 @@ public bajarFotos getBajar() { return bajar; } - public void requestActivityPermission() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat - .checkSelfPermission(mActivity.getApplicationContext(), android.Manifest - .permission.WRITE_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission - (mActivity.getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - mActivity.requestPermissions(new String[]{ - android.Manifest.permission.WRITE_EXTERNAL_STORAGE - }, Constants.EXTERNAL_STORAGE); - - } - } - } + } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/RequestPersmissionClass.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/RequestPersmissionClass.java new file mode 100644 index 00000000..8ca9e516 --- /dev/null +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/RequestPersmissionClass.java @@ -0,0 +1,55 @@ +package com.stonefacesoft.ottaa.utils; + +import android.Manifest; +import android.content.Context; +import android.content.pm.PackageManager; +import android.os.Build; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +import com.stonefacesoft.ottaa.utils.constants.Constants; + +public class RequestPersmissionClass { + + + + public boolean requestImagePermission(Context mActivity){ + boolean result = false; + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.TIRAMISU){ + result = isGranted(mActivity,Manifest.permission.READ_MEDIA_IMAGES); + } + else{ + result =isGranted(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)&&!isGranted(mActivity,Manifest.permission.READ_EXTERNAL_STORAGE); + } + return result; + } + public boolean requestLocationPermission(Context mActivity){ + boolean result = false; + result = isGranted(mActivity,Manifest.permission.ACCESS_FINE_LOCATION)&& isGranted(mActivity,Manifest.permission.ACCESS_COARSE_LOCATION); + return result; + } + + public void makeRequestImagePermission(boolean request, AppCompatActivity mActivity){ + if(!request){ + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.TIRAMISU){ + if(!isGranted(mActivity,Manifest.permission.READ_MEDIA_IMAGES)) + ActivityCompat.requestPermissions(mActivity,new String[]{Manifest.permission.READ_MEDIA_IMAGES}, Constants.EXTERNAL_STORAGE); + }else{ + mActivity.requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, Constants.EXTERNAL_STORAGE); + } + } + } + + + private int requestPermision(Context appCompatActivity,String name){ + return ContextCompat.checkSelfPermission(appCompatActivity,name); + } + + private boolean isGranted(Context mActivity,String name){ + return requestPermision(mActivity,name)==PackageManager.PERMISSION_GRANTED; + } + + +} diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/TalkActions/Historial.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/TalkActions/Historial.java index f9df8cc2..a28eafe2 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/TalkActions/Historial.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/TalkActions/Historial.java @@ -144,7 +144,7 @@ private JSONObject chatGptObject(JSONArray word,String text){ try { String promt=chatGPTPrompt.replace("{AGE}",json.obtenerEdad().toLowerCase().replace("nino","Niño")).replace("{SEX}",json.obtenerSexo()).replace("{PHRASE}",text).replace("{LANG}",ConfigurarIdioma.getNormalLanguage()); Log.d(TAG, "chatGptObject: "+ promt); - object.put("model","text-davinci-003"); + object.put("model","gpt-3.5-turbo-instruct"); object.put("prompt",promt); object.put("temperature",0); object.put("max_tokens",word.length()*10); diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/TalkActions/TellStoryPhrase.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/TalkActions/TellStoryPhrase.java index 4fd56c04..4132f4cd 100644 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/TalkActions/TellStoryPhrase.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/TalkActions/TellStoryPhrase.java @@ -40,7 +40,7 @@ private JSONObject chatGptObject(String text){ try { String promt= text; Log.d(TAG, "chatGptObject: "+ promt); - object.put("model","text-davinci-003"); + object.put("model","gpt-3.5-turbo-instruct"); object.put("prompt",promt); object.put("temperature",0.7); object.put("max_tokens",1000); diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/UserLicence/LicenciaUsuario.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/UserLicence/LicenciaUsuario.java index 269e2daa..5a30f77c 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/UserLicence/LicenciaUsuario.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/UserLicence/LicenciaUsuario.java @@ -60,7 +60,7 @@ public LicenciaUsuario(Context mContext) { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { if (firebaseAuth.getCurrentUser() != null) { - new VerificarPagoUsuario(User.getInstance(mContext).getUserUid()).execute(); + new VerificarPagoUsuario(firebaseAuth.getUid()).execute(); } else { if (mContext != null) { Intent intent = new Intent(mContext, LoginActivity2.class); @@ -168,8 +168,8 @@ public void onDataChange(@NonNull DataSnapshot snapshot) { if (snapshot.hasChild(Constants.PRIMERACONEXION)) { Long primeraConexion = Long.parseLong(snapshot.child(Constants.PRIMERACONEXION).getValue().toString()); if (date.compareTo(primeraConexion) > 0) { - changePremiumState(0 + ""); - databaseReference.child(Constants.PAGO).child(mAuth.getCurrentUser().getUid()).child(Constants.PAGO).getRef().setValue(0); + changePremiumState(1 + ""); + databaseReference.child(Constants.PAGO).child(mAuth.getCurrentUser().getUid()).child(Constants.PAGO).getRef().setValue(1); } } } @@ -199,15 +199,15 @@ public void onDataChange(@NonNull DataSnapshot dataSnapshot) { int result = date.compareTo(tiempoPago); if(dataSnapshot.hasChild(Constants.PAGO)){ if(result >0 || dataSnapshot.child(Constants.PAGO).getValue().toString().contains("0")){ - dataSnapshot.child(Constants.PAGO).getRef().setValue(0); - changePremiumState(0+""); + dataSnapshot.child(Constants.PAGO).getRef().setValue(1); + changePremiumState(1+""); } else if(dataSnapshot.child(Constants.PAGO).getValue().toString().contains("1")){ changePremiumState(1+""); } }else{ - dataSnapshot.child(Constants.PAGO).getRef().setValue(0); - changePremiumState(0+""); + dataSnapshot.child(Constants.PAGO).getRef().setValue(1); + changePremiumState(1+""); } } @@ -227,14 +227,14 @@ public void onDataChange(@NonNull DataSnapshot dataSnapshot) { int result = date.compareTo(tiempoPago + Constants.UN_ANIO); if(dataSnapshot.hasChild(Constants.PAGO)){ if (result > 0 || dataSnapshot.child(Constants.PAGO).getValue().toString().contains("0")) { - dataSnapshot.child(Constants.PAGO).getRef().setValue(0); - changePremiumState(0 + ""); + dataSnapshot.child(Constants.PAGO).getRef().setValue(1); + changePremiumState(1 + ""); } else if (dataSnapshot.child(Constants.PAGO).getValue().toString().contains("1")) { changePremiumState(1 + ""); } }else{ - dataSnapshot.child(Constants.PAGO).getRef().setValue(0); - changePremiumState(0+""); + dataSnapshot.child(Constants.PAGO).getRef().setValue(1); + changePremiumState(1+""); } } diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/constants/Constants.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/constants/Constants.java index 1492fdcb..88df6bde 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/constants/Constants.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/constants/Constants.java @@ -86,7 +86,7 @@ private Constants() { public static final String ARCHIVO_JUEGO_DESCRIPCION="juegos_desc.txt"; public static int TODO_DESCARGADO = 366; - public static int VUELTAS_CARRETE = 5; + public static int VUELTAS_CARRETE = 10; //Tipo de tags public static final String HORA = "hora"; diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/shareActions/ShareAudio.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/shareActions/ShareAudio.java index 8e999dc2..dc613a35 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/shareActions/ShareAudio.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/shareActions/ShareAudio.java @@ -133,6 +133,7 @@ public void share() { else sentMessage.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(audioEncoder.getAux())); sentMessage.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + mContext.startActivity(Intent.createChooser(sentMessage,mContext.getResources().getString(R.string.pref_enviar))); }else{ myTTS.mostrarAlerta(mContext.getString(R.string.error_tts)); diff --git a/app/src/main/java/com/stonefacesoft/ottaa/utils/textToSpeech.java b/app/src/main/java/com/stonefacesoft/ottaa/utils/textToSpeech.java index 5f7618be..aff7edc1 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/utils/textToSpeech.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/utils/textToSpeech.java @@ -137,7 +137,7 @@ public TextToSpeech getTTS() { public void synthesizeToFile(String Oracion, Bundle params,File file,String id){ if(prepare.getmTTS()!=null) - getTTS().synthesizeToFile(Oracion,params,file,id); + getTTS().synthesizeToFile(Oracion,params,file,id); } public void shutdownTTS(){ diff --git a/app/src/main/java/com/stonefacesoft/ottaa/welcome/SplashActivity.java b/app/src/main/java/com/stonefacesoft/ottaa/welcome/SplashActivity.java index a0d31cef..d2991a0e 100755 --- a/app/src/main/java/com/stonefacesoft/ottaa/welcome/SplashActivity.java +++ b/app/src/main/java/com/stonefacesoft/ottaa/welcome/SplashActivity.java @@ -231,7 +231,7 @@ public class borrarPictos { public void execute(){ Executor executor = Executors.newSingleThreadExecutor(); Handler handler = new Handler(Looper.getMainLooper()); - executor.execute(() -> { + Thread thread = new Thread(()->{ borrarPictosViejos(); handler.post(() -> { mProgressBar.setVisibility(View.GONE); @@ -240,20 +240,20 @@ public void execute(){ finish(); }); }); + executor.execute(thread); } } public class preLoadSplashScreen { - - public void execute(){ Executor executor = Executors.newSingleThreadExecutor(); Handler handler = new Handler(Looper.getMainLooper()); - executor.execute(() -> { + Thread thread = new Thread(()->{ Json.getInstance().setmContext(getApplicationContext()).initJsonArrays(); handler.post(SplashActivity.this::accessDashboard); }); + executor.execute(thread); } } @@ -283,7 +283,7 @@ public sharedPreferencesLoad(Context mContext){ public void execute(){ Executor executor = Executors.newSingleThreadExecutor(); Handler handler = new Handler(Looper.getMainLooper()); - executor.execute(() -> { + Thread thread = new Thread(()->{ sharedPrefsDefault = PreferenceManager.getDefaultSharedPreferences(mContext); if (sharedPrefsDefault.getString(getApplicationContext().getResources().getString(R.string.str_idioma), "en").contains("mainTable")) { sharedPrefsDefault.edit().putString(getString(R.string.str_idioma), Locale.getDefault().getLanguage()).apply(); @@ -300,6 +300,7 @@ public void execute(){ changeName.cambiarPosicion(); handler.post(() -> cargarDatos()); }); + executor.execute(thread); } } @@ -356,6 +357,6 @@ public void hacerAccion(int position){ } public void setVisibleButton(){ if(txtCargando.getVisibility()==View.INVISIBLE||txtCargando.getVisibility()==View.GONE) - txtCargando.setVisibility(View.VISIBLE); + txtCargando.setVisibility(View.VISIBLE); } } diff --git a/app/src/main/res/layout-hdpi/activity_galeria_grupos2.xml b/app/src/main/res/layout-hdpi/activity_galeria_grupos2.xml index ff79e506..957329ec 100755 --- a/app/src/main/res/layout-hdpi/activity_galeria_grupos2.xml +++ b/app/src/main/res/layout-hdpi/activity_galeria_grupos2.xml @@ -283,6 +283,21 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout-ldrtl-sw600dp/activity_galeria_grupos2.xml b/app/src/main/res/layout-ldrtl-sw600dp/activity_galeria_grupos2.xml index 8e8b2b59..a871cb7f 100755 --- a/app/src/main/res/layout-ldrtl-sw600dp/activity_galeria_grupos2.xml +++ b/app/src/main/res/layout-ldrtl-sw600dp/activity_galeria_grupos2.xml @@ -277,6 +277,21 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + diff --git a/app/src/main/res/layout-ldrtl-sw600dp/activity_noti_games.xml b/app/src/main/res/layout-ldrtl-sw600dp/activity_noti_games.xml index 1f0456b8..b65001a9 100755 --- a/app/src/main/res/layout-ldrtl-sw600dp/activity_noti_games.xml +++ b/app/src/main/res/layout-ldrtl-sw600dp/activity_noti_games.xml @@ -122,6 +122,7 @@ android:layout_height="0dp" android:id="@+id/container" layout="@layout/pictos_container" + android:layout_marginTop="@dimen/interpicto_margin" app:layout_constraintTop_toBottomOf="@id/container0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout-ldrtl-sw600dp/activity_principal_v4.xml b/app/src/main/res/layout-ldrtl-sw600dp/activity_principal_v4.xml index ef98e073..f60af943 100755 --- a/app/src/main/res/layout-ldrtl-sw600dp/activity_principal_v4.xml +++ b/app/src/main/res/layout-ldrtl-sw600dp/activity_principal_v4.xml @@ -2,7 +2,6 @@ @@ -12,9 +11,9 @@ android:id="@+id/toolbar" android:layout_width="0dp" android:layout_height="?attr/actionBarSize" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" android:background="@color/NaranjaOTTAA" android:visibility="visible" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" @@ -26,15 +25,15 @@ android:layout_width="0dp" android:layout_height="0dp" android:id="@+id/horizontalScrollView2" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintTop_toBottomOf="@id/toolbar" - custom:layout_constraintBottom_toTopOf="@id/constraintPictos" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@id/toolbar" + app:layout_constraintBottom_toTopOf="@id/constraintPictos" android:layout_marginStart="@dimen/activity_horizontal_margin" android:layout_marginEnd="@dimen/activity_horizontal_margin" android:layout_marginTop="@dimen/activity_vertical_margin" android:layout_marginBottom="@dimen/activity_vertical_margin" - custom:layout_constraintVertical_weight="3"> + app:layout_constraintVertical_weight="3"> - - - - - - - + android:layout_height="0dp" + android:id="@+id/container" + layout="@layout/pictos_container" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintVertical_weight="4" + app:layout_constraintBottom_toBottomOf="parent" + > + @@ -275,12 +232,12 @@ android:layout_width="0dp" android:layout_height="0dp" android:background="@drawable/ic_shape_left_orange" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintHorizontal_weight="1" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintStart_toEndOf="@id/containerBottomMasPictos" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_weight="1" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/containerBottomMasPictos" android:layout_marginTop="120dp" - custom:layout_constraintTop_toTopOf="@id/constraintPictos"> + app:layout_constraintTop_toTopOf="@id/constraintPictos"> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/action_share" /> + app:layout_constraintHorizontal_weight="1"> + app:layout_constraintBottom_toTopOf="@id/btnTodosLosPictos" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/action_reiniciar" /> + app:layout_constraintEnd_toStartOf="@id/constraintRightButtons" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/constraintPictos" + app:layout_constraintHorizontal_weight="6" + app:layout_constraintStart_toEndOf="@id/constraintLeftButtons" + app:layout_constraintVertical_weight="2"> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@id/btn_borrar" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/btnMasPictos" + app:layout_constraintTop_toTopOf="parent" /> @@ -403,10 +360,10 @@ android:layout_height="0dp" android:background="@android:color/transparent" android:visibility="gone" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintTop_toBottomOf="@id/horizontalScrollView2" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/horizontalScrollView2" /> + app:layout_constraintBottom_toTopOf="@id/containerBottomMasPictos" + app:layout_constraintStart_toEndOf="@id/constraintLeftButtons" /> + app:layout_constraintBottom_toTopOf="@id/containerBottomMasPictos" + app:layout_constraintEnd_toStartOf="@id/constraintRightButtons" /> + app:backgroundTint="@color/FondoApp" + app:fabCustomSize="130dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@id/containerBottomMasPictos"> @@ -458,13 +415,13 @@ android:elevation="20dp" android:src="@drawable/icono_ottaa" android:tint="@color/White" - custom:backgroundTint="@color/NaranjaOTTAA" - custom:fabCustomSize="110dp" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintTop_toTopOf="@id/containerBottomMasPictos" - custom:maxImageSize="100dp"> + app:backgroundTint="@color/NaranjaOTTAA" + app:fabCustomSize="110dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@id/containerBottomMasPictos" + app:maxImageSize="100dp"> @@ -474,20 +431,20 @@ android:visibility="gone" android:id="@+id/floatting_button" android:src="@drawable/ic_touch_app_black_24dp" - custom:maxImageSize="@dimen/sizeFloattingButtonIconMed" + app:maxImageSize="@dimen/sizeFloattingButtonIconMed" android:backgroundTint="@color/color_blue_transparent" - custom:backgroundTint="@color/Black" - custom:borderWidth="2dp" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintTop_toTopOf="parent" /> + app:backgroundTint="@color/Black" + app:borderWidth="2dp" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> @@ -12,9 +11,9 @@ android:id="@+id/toolbar" android:layout_width="0dp" android:layout_height="?attr/actionBarSize" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" android:background="@color/NaranjaOTTAA" android:visibility="visible" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" @@ -26,15 +25,15 @@ android:layout_width="0dp" android:layout_height="0dp" android:id="@+id/horizontalScrollView2" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintTop_toBottomOf="@id/toolbar" - custom:layout_constraintBottom_toTopOf="@id/constraintPictos" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@id/toolbar" + app:layout_constraintBottom_toTopOf="@id/constraintPictos" android:layout_marginStart="@dimen/activity_horizontal_margin" android:layout_marginEnd="@dimen/activity_horizontal_margin" android:layout_marginTop="@dimen/activity_vertical_margin" android:layout_marginBottom="@dimen/activity_vertical_margin" - custom:layout_constraintVertical_weight="3"> + app:layout_constraintVertical_weight="3"> - - - - - - - + android:layout_height="0dp" + android:id="@+id/container" + layout="@layout/pictos_container" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintVertical_weight="4" + app:layout_constraintBottom_toBottomOf="parent" + > + @@ -275,12 +232,12 @@ android:layout_width="0dp" android:layout_height="0dp" android:background="@drawable/ic_shape_left_orange" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintHorizontal_weight="1" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintStart_toEndOf="@id/containerBottomMasPictos" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_weight="1" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/containerBottomMasPictos" android:layout_marginTop="120dp" - custom:layout_constraintTop_toTopOf="@id/constraintPictos"> + app:layout_constraintTop_toTopOf="@id/constraintPictos"> + app:layout_constraintBottom_toTopOf="@id/btnTodosLosPictos" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/action_reiniciar" /> + app:layout_constraintHorizontal_weight="1"> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/action_share" /> @@ -360,12 +317,12 @@ android:layout_height="0dp" android:id="@+id/containerBottomMasPictos" android:background="@drawable/ic_shape_bottom_orange" - custom:layout_constraintEnd_toStartOf="@id/constraintRightButtons" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintTop_toBottomOf="@id/constraintPictos" - custom:layout_constraintHorizontal_weight="6" - custom:layout_constraintStart_toEndOf="@id/constraintLeftButtons" - custom:layout_constraintVertical_weight="2"> + app:layout_constraintEnd_toStartOf="@id/constraintRightButtons" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/constraintPictos" + app:layout_constraintHorizontal_weight="6" + app:layout_constraintStart_toEndOf="@id/constraintLeftButtons" + app:layout_constraintVertical_weight="2"> @@ -391,10 +348,10 @@ android:scaleType="fitCenter" android:src="@drawable/ic_backspace_black_24dp" android:tint="@color/White" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintTop_toTopOf="parent" - custom:layout_constraintEnd_toStartOf="@id/btnMasPictos" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@id/btnMasPictos" /> @@ -406,10 +363,10 @@ android:layout_height="0dp" android:background="@android:color/transparent" android:visibility="gone" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintTop_toBottomOf="@id/horizontalScrollView2" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/horizontalScrollView2" /> + app:layout_constraintBottom_toTopOf="@id/containerBottomMasPictos" + app:layout_constraintStart_toEndOf="@id/constraintLeftButtons" /> + app:layout_constraintBottom_toTopOf="@id/containerBottomMasPictos" + app:layout_constraintEnd_toStartOf="@id/constraintRightButtons" /> + app:backgroundTint="@color/FondoApp" + app:fabCustomSize="130dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@id/containerBottomMasPictos"> @@ -461,13 +418,13 @@ android:elevation="20dp" android:src="@drawable/icono_ottaa" android:tint="@color/White" - custom:backgroundTint="@color/NaranjaOTTAA" - custom:fabCustomSize="110dp" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintTop_toTopOf="@id/containerBottomMasPictos" - custom:maxImageSize="100dp"> + app:backgroundTint="@color/NaranjaOTTAA" + app:fabCustomSize="110dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@id/containerBottomMasPictos" + app:maxImageSize="100dp"> @@ -477,19 +434,19 @@ android:visibility="gone" android:id="@+id/floatting_button" android:src="@drawable/ic_touch_app_black_24dp" - custom:maxImageSize="@dimen/sizeFloattingButtonIconMed" + app:maxImageSize="@dimen/sizeFloattingButtonIconMed" android:backgroundTint="@color/color_blue_transparent" - custom:backgroundTint="@color/Black" custom:borderWidth="0dp" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintTop_toTopOf="parent" /> + app:backgroundTint="@color/Black" app:borderWidth="0dp" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout-ldrtl/activity_principal_v4.xml b/app/src/main/res/layout-ldrtl/activity_principal_v4.xml index 27d54d52..b73c827d 100755 --- a/app/src/main/res/layout-ldrtl/activity_principal_v4.xml +++ b/app/src/main/res/layout-ldrtl/activity_principal_v4.xml @@ -184,60 +184,18 @@ android:layout_marginTop="@dimen/activity_vertical_margin" android:id="@+id/constraintPictos"> - - - - - - - + android:layout_height="0dp" + android:id="@+id/container" + layout="@layout/pictos_container" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintVertical_weight="4" + app:layout_constraintBottom_toBottomOf="parent" + > + + + - + android:layout_height="0dp" + android:id="@+id/container" + layout="@layout/pictos_container" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintVertical_weight="4" + app:layout_constraintBottom_toBottomOf="parent" - + > + - - - + + diff --git a/app/src/main/res/layout-sw600dp/activity_noti_games.xml b/app/src/main/res/layout-sw600dp/activity_noti_games.xml index baccfcc5..e83899eb 100755 --- a/app/src/main/res/layout-sw600dp/activity_noti_games.xml +++ b/app/src/main/res/layout-sw600dp/activity_noti_games.xml @@ -119,6 +119,7 @@ android:layout_height="0dp" android:id="@+id/container" layout="@layout/pictos_container" + android:layout_marginTop="@dimen/interpicto_margin" app:layout_constraintTop_toBottomOf="@id/container0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout-sw600dp/activity_principal_v4.xml b/app/src/main/res/layout-sw600dp/activity_principal_v4.xml index 18300aa6..7fe62d32 100755 --- a/app/src/main/res/layout-sw600dp/activity_principal_v4.xml +++ b/app/src/main/res/layout-sw600dp/activity_principal_v4.xml @@ -2,7 +2,6 @@ @@ -11,15 +10,15 @@ android:layout_width="0dp" android:layout_height="0dp" android:id="@+id/horizontalScrollView2" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintTop_toTopOf="parent" - custom:layout_constraintBottom_toTopOf="@id/constraintPictos" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toTopOf="@id/constraintPictos" android:layout_marginStart="@dimen/activity_horizontal_margin" android:layout_marginEnd="@dimen/activity_horizontal_margin" android:layout_marginTop="@dimen/activity_vertical_margin" android:layout_marginBottom="@dimen/activity_vertical_margin" - custom:layout_constraintVertical_weight="3"> + app:layout_constraintVertical_weight="3"> - - - - - - - + android:layout_height="0dp" + android:id="@+id/container" + layout="@layout/pictos_container" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintVertical_weight="4" + app:layout_constraintBottom_toBottomOf="parent" + > + @@ -260,12 +216,12 @@ android:layout_width="0dp" android:layout_height="0dp" android:background="@drawable/ic_shape_right_orange" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintHorizontal_weight="1" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintStart_toEndOf="@id/containerBottomMasPictos" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_weight="1" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/containerBottomMasPictos" android:layout_marginTop="120dp" - custom:layout_constraintTop_toTopOf="@id/constraintPictos"> + app:layout_constraintTop_toTopOf="@id/constraintPictos"> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/action_share" /> + app:layout_constraintHorizontal_weight="1"> + app:layout_constraintBottom_toTopOf="@id/btnTodosLosPictos" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/action_reiniciar" /> + app:layout_constraintEnd_toStartOf="@id/constraintRightButtons" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/constraintPictos" + app:layout_constraintHorizontal_weight="6" + app:layout_constraintStart_toEndOf="@id/constraintLeftButtons" + app:layout_constraintVertical_weight="2"> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@id/btn_borrar" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/btnMasPictos" + app:layout_constraintTop_toTopOf="parent" /> @@ -388,10 +344,10 @@ android:layout_height="0dp" android:background="@android:color/transparent" android:visibility="gone" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintTop_toBottomOf="@id/horizontalScrollView2" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/horizontalScrollView2" /> + app:layout_constraintBottom_toTopOf="@id/containerBottomMasPictos" + app:layout_constraintStart_toEndOf="@id/constraintLeftButtons" /> + app:layout_constraintBottom_toTopOf="@id/containerBottomMasPictos" + app:layout_constraintEnd_toStartOf="@id/constraintRightButtons" /> @@ -442,13 +398,13 @@ android:elevation="20dp" android:src="@drawable/icono_ottaa" android:tint="@color/White" - custom:backgroundTint="@color/NaranjaOTTAA" - custom:fabCustomSize="110dp" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintTop_toTopOf="@id/containerBottomMasPictos" - custom:maxImageSize="100dp"> + app:backgroundTint="@color/NaranjaOTTAA" + app:fabCustomSize="110dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@id/containerBottomMasPictos" + app:maxImageSize="100dp"> @@ -458,20 +414,20 @@ android:visibility="gone" android:id="@+id/floatting_button" android:src="@drawable/ic_touch_app_black_24dp" - custom:maxImageSize="@dimen/sizeFloattingButtonIconMed" + app:maxImageSize="@dimen/sizeFloattingButtonIconMed" android:backgroundTint="@color/color_blue_transparent" - custom:backgroundTint="@color/Black" - custom:borderWidth="2dp" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintTop_toTopOf="parent" /> + app:backgroundTint="@color/Black" + app:borderWidth="2dp" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintVertical_weight="3"> - - - - - - - + android:layout_height="0dp" + android:id="@+id/container" + layout="@layout/pictos_container" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintVertical_weight="4" + app:layout_constraintBottom_toBottomOf="parent" + > + @@ -263,12 +220,12 @@ android:layout_width="0dp" android:layout_height="0dp" android:background="@drawable/ic_shape_right_orange" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintHorizontal_weight="1" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintStart_toEndOf="@id/containerBottomMasPictos" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_weight="1" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/containerBottomMasPictos" android:layout_marginTop="20dp" - custom:layout_constraintTop_toTopOf="@id/constraintPictos"> + app:layout_constraintTop_toTopOf="@id/constraintPictos"> + app:layout_constraintBottom_toTopOf="@id/btnTodosLosPictos" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/action_reiniciar" /> @@ -305,21 +262,21 @@ android:layout_width="0dp" android:layout_height="0dp" android:background="@drawable/ic_shape_left_orange" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintTop_toTopOf="@id/constraintPictos" - custom:layout_constraintEnd_toStartOf="@id/containerBottomMasPictos" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toTopOf="@id/constraintPictos" + app:layout_constraintEnd_toStartOf="@id/containerBottomMasPictos" android:layout_marginTop="20dp" - custom:layout_constraintHorizontal_weight="1"> + app:layout_constraintHorizontal_weight="1"> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/action_share" /> @@ -347,12 +304,12 @@ android:layout_height="0dp" android:id="@+id/containerBottomMasPictos" android:background="@drawable/ic_shape_bottom_orange" - custom:layout_constraintEnd_toStartOf="@id/constraintRightButtons" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintTop_toBottomOf="@id/constraintPictos" - custom:layout_constraintHorizontal_weight="6" - custom:layout_constraintStart_toEndOf="@id/constraintLeftButtons" - custom:layout_constraintVertical_weight="2"> + app:layout_constraintEnd_toStartOf="@id/constraintRightButtons" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/constraintPictos" + app:layout_constraintHorizontal_weight="6" + app:layout_constraintStart_toEndOf="@id/constraintLeftButtons" + app:layout_constraintVertical_weight="2"> @@ -376,10 +333,10 @@ android:scaleType="fitCenter" android:src="@drawable/ic_backspace_black_24dp" android:tint="@color/White" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintTop_toTopOf="parent" - custom:layout_constraintEnd_toStartOf="@id/btnMasPictos" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@id/btnMasPictos" /> @@ -391,10 +348,10 @@ android:layout_height="0dp" android:background="@android:color/transparent" android:visibility="gone" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintTop_toBottomOf="@id/horizontalScrollView2" /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/horizontalScrollView2" /> + app:layout_constraintBottom_toTopOf="@id/containerBottomMasPictos" + app:layout_constraintStart_toEndOf="@id/constraintLeftButtons" /> + app:layout_constraintBottom_toTopOf="@id/containerBottomMasPictos" + app:layout_constraintEnd_toStartOf="@id/constraintRightButtons" /> + app:backgroundTint="@color/FondoApp" + app:fabCustomSize="130dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@id/containerBottomMasPictos"> @@ -445,13 +402,13 @@ android:elevation="20dp" app:srcCompat="@drawable/icono_ottaa" android:tint="@color/White" - custom:backgroundTint="@color/NaranjaOTTAA" - custom:fabCustomSize="110dp" - custom:layout_constraintBottom_toBottomOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintTop_toTopOf="@id/containerBottomMasPictos" - custom:maxImageSize="100dp"> + app:backgroundTint="@color/NaranjaOTTAA" + app:fabCustomSize="110dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@id/containerBottomMasPictos" + app:maxImageSize="100dp"> @@ -461,19 +418,19 @@ android:visibility="gone" android:id="@+id/floatting_button" android:src="@drawable/ic_touch_app_black_24dp" - custom:maxImageSize="@dimen/sizeFloattingButtonIconMed" + app:maxImageSize="@dimen/sizeFloattingButtonIconMed" android:backgroundTint="@color/color_blue_transparent" - custom:backgroundTint="@color/Black" - custom:borderWidth="2dp" - custom:layout_constraintStart_toStartOf="parent" - custom:layout_constraintEnd_toEndOf="parent" - custom:layout_constraintTop_toTopOf="parent" /> + app:backgroundTint="@color/Black" + app:borderWidth="2dp" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + >