Skip to content

Commit 53a56b0

Browse files
Two place names, fastlane descriptions
1 parent 9da7776 commit 53a56b0

File tree

9 files changed

+190
-117
lines changed

9 files changed

+190
-117
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ android {
2222
minSdkVersion 19
2323
targetSdkVersion 30
2424
versionCode 19
25-
versionName '0.7.16.5'
25+
versionName '0.7.16.6'
2626
vectorDrawables.useSupportLibrary = true
2727
resConfigs "en", "cs", "de", "eo", "es", "fr", "hr", "it", "kn", "mr", "nb", "nl", "pl", "pt", "ru", "sk", "sr", "uk"
2828
def utenteAruba = ""

app/src/main/java/app/familygem/Anagrafe.java

Lines changed: 113 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
public class Anagrafe extends Fragment {
4040

41-
private List<Person> listaIndividui;
42-
public AdattatoreAnagrafe adattatore;
41+
List<Person> people;
42+
AdattatoreAnagrafe adapter;
4343
private Order order;
4444
private boolean gliIdsonoNumerici;
4545

@@ -59,45 +59,45 @@ public Order prev() {
5959
};
6060

6161
@Override
62-
public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle bandolo ) {
63-
View vista = inflater.inflate( R.layout.ricicla_vista, container, false );
62+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
63+
View vista = inflater.inflate(R.layout.ricicla_vista, container, false);
6464
if( gc != null ) {
65-
listaIndividui = gc.getPeople();
65+
people = gc.getPeople();
6666
arredaBarra();
67-
RecyclerView vistaLista = vista.findViewById( R.id.riciclatore );
68-
vistaLista.setPadding( 12, 12, 12, vistaLista.getPaddingBottom() );
69-
adattatore = new AdattatoreAnagrafe();
70-
vistaLista.setAdapter( adattatore );
67+
RecyclerView vistaLista = vista.findViewById(R.id.riciclatore);
68+
vistaLista.setPadding(12, 12, 12, vistaLista.getPaddingBottom());
69+
adapter = new AdattatoreAnagrafe();
70+
vistaLista.setAdapter(adapter);
7171
gliIdsonoNumerici = verificaIdNumerici();
72-
vista.findViewById( R.id.fab ).setOnClickListener( v -> {
73-
Intent intento = new Intent( getContext(), EditaIndividuo.class );
74-
intento.putExtra( "idIndividuo", "TIZIO_NUOVO" );
75-
startActivity( intento );
72+
vista.findViewById(R.id.fab).setOnClickListener(v -> {
73+
Intent intento = new Intent(getContext(), EditaIndividuo.class);
74+
intento.putExtra("idIndividuo", "TIZIO_NUOVO");
75+
startActivity(intento);
7676
});
7777
}
7878
return vista;
7979
}
8080

8181
void arredaBarra() {
82-
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle( listaIndividui.size() + " "
83-
+ getString(listaIndividui.size()==1 ? R.string.person : R.string.persons).toLowerCase() );
84-
if( listaIndividui.size() > 1 )
82+
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle(people.size() + " "
83+
+ getString(people.size() == 1 ? R.string.person : R.string.persons).toLowerCase());
84+
if( people.size() > 1 )
8585
setHasOptionsMenu(true);
8686
else
8787
setHasOptionsMenu(false);
8888
}
8989

9090
public class AdattatoreAnagrafe extends RecyclerView.Adapter<GestoreIndividuo> implements Filterable {
9191
@Override
92-
public GestoreIndividuo onCreateViewHolder( ViewGroup parent, int tipo ) {
93-
View vistaIndividuo = LayoutInflater.from( parent.getContext() )
92+
public GestoreIndividuo onCreateViewHolder(ViewGroup parent, int tipo) {
93+
View vistaIndividuo = LayoutInflater.from(parent.getContext())
9494
.inflate(R.layout.pezzo_individuo, parent, false);
95-
registerForContextMenu( vistaIndividuo );
96-
return new GestoreIndividuo( vistaIndividuo );
95+
registerForContextMenu(vistaIndividuo);
96+
return new GestoreIndividuo(vistaIndividuo);
9797
}
9898
@Override
9999
public void onBindViewHolder(GestoreIndividuo gestore, int posizione) {
100-
Person person = listaIndividui.get(posizione);
100+
Person person = people.get(posizione);
101101
View vistaIndi = gestore.vista;
102102

103103
String label = null;
@@ -147,19 +147,19 @@ public Filter getFilter() {
147147
protected FilterResults performFiltering(CharSequence charSequence) {
148148
String query = charSequence.toString();
149149
if (query.isEmpty()) {
150-
listaIndividui = gc.getPeople();
150+
people = gc.getPeople();
151151
} else {
152152
List<Person> filteredList = new ArrayList<>();
153153
for (Person pers : gc.getPeople()) {
154154
if( U.epiteto(pers).toLowerCase().contains(query.toLowerCase()) ) {
155155
filteredList.add(pers);
156156
}
157157
}
158-
listaIndividui = filteredList;
158+
people = filteredList;
159159
}
160160
sortPeople();
161161
FilterResults filterResults = new FilterResults();
162-
filterResults.values = listaIndividui;
162+
filterResults.values = people;
163163
return filterResults;
164164
}
165165
@Override
@@ -170,7 +170,7 @@ protected void publishResults(CharSequence cs, FilterResults fr) {
170170
}
171171
@Override
172172
public int getItemCount() {
173-
return listaIndividui.size();
173+
return people.size();
174174
}
175175
}
176176

@@ -256,7 +256,7 @@ boolean verificaIdNumerici() {
256256
}
257257

258258
private void sortPeople() {
259-
Collections.sort(listaIndividui, (p1, p2) -> {
259+
Collections.sort(people, (p1, p2) -> {
260260
switch( order ) {
261261
case ID_ASC: // Sort for GEDCOM ID
262262
if( gliIdsonoNumerici )
@@ -392,41 +392,98 @@ private int calcAge(Person person) {
392392
return days;
393393
}
394394

395-
// riceve una persona e restitusce i due luoghi: iniziale – finale
396-
static String dueLuoghi( Person p ) {
397-
String luoghi = "";
398-
List<EventFact> fatti = p.getEventsFacts();
399-
for( EventFact unFatto : fatti ) {
400-
if( unFatto.getPlace() != null ) {
401-
luoghi = togliVirgole( unFatto.getPlace() );
402-
break;
395+
// Write the two main places of a person (initial – final) or null
396+
static String twoPlaces(Person person) {
397+
List<EventFact> facts = person.getEventsFacts();
398+
// One single event
399+
if( facts.size() == 1 ) {
400+
String place = facts.get(0).getPlace();
401+
if( place != null )
402+
return stripCommas(place);
403+
} // Sex and another event
404+
else if( facts.size() == 2 && ("SEX".equals(facts.get(0).getTag()) || "SEX".equals(facts.get(1).getTag())) ) {
405+
String place;
406+
if( "SEX".equals(facts.get(0).getTag()) )
407+
place = facts.get(1).getPlace();
408+
else
409+
place = facts.get(0).getPlace();
410+
if( place != null )
411+
return stripCommas(place);
412+
} // Multiple events
413+
else if( facts.size() >= 2 ) {
414+
String[] places = new String[7];
415+
for( EventFact ef : facts ) {
416+
String place = ef.getPlace();
417+
if( place != null ) {
418+
switch( ef.getTag() ) {
419+
case "BIRT":
420+
places[0] = place;
421+
break;
422+
case "BAPM":
423+
places[1] = place;
424+
break;
425+
case "DEAT":
426+
places[4] = place;
427+
break;
428+
case "CREM":
429+
places[5] = place;
430+
break;
431+
case "BURI":
432+
places[6] = place;
433+
break;
434+
default:
435+
if( places[2] == null ) // First of other events
436+
places[2] = place;
437+
if( !place.equals(places[2]) )
438+
places[3] = place; // Last of other events
439+
}
440+
}
403441
}
404-
}
405-
for(int i=fatti.size()-1; i>=0; i-- ) {
406-
String secondoLuogo = fatti.get(i).getPlace();
407-
if( secondoLuogo != null ) {
408-
secondoLuogo = togliVirgole(secondoLuogo);
409-
if( !secondoLuogo.equals(luoghi) )
410-
luoghi = luoghi.concat(" – ").concat(secondoLuogo);
411-
break;
442+
String text = null;
443+
int i;
444+
// Write initial place
445+
for( i = 0; i < places.length; i++ ) {
446+
String place = places[i];
447+
if( place != null ) {
448+
text = stripCommas(place);
449+
break;
450+
}
451+
}
452+
// Priority to death event as final place
453+
if( text != null && i < 4 && places[4] != null ) {
454+
String place = stripCommas(places[4]);
455+
if( !place.equals(text) )
456+
text += " – " + place;
457+
} else {
458+
for( int j = places.length - 1; j > i; j-- ) {
459+
String place = places[j];
460+
if( place != null ) {
461+
place = stripCommas(place);
462+
if( !place.equals(text) ) {
463+
text += " – " + place;
464+
break;
465+
}
466+
}
467+
}
412468
}
469+
return text;
413470
}
414-
return luoghi;
471+
return null;
415472
}
416473

417474
// riceve un luogo stile Gedcom e restituisce il primo nome tra le virgole
418-
private static String togliVirgole( String luogo ) {
475+
private static String stripCommas(String place) {
419476
// salta le virgole iniziali per luoghi tipo ',,,England'
420-
int iniz = 0;
421-
for( char c : luogo.toCharArray() ) {
422-
if( c!=',' && c!=' ' )
477+
int start = 0;
478+
for( char c : place.toCharArray() ) {
479+
if( c != ',' && c != ' ' )
423480
break;
424-
iniz++;
481+
start++;
425482
}
426-
luogo = luogo.substring(iniz);
427-
if( luogo.indexOf(",") > 0 )
428-
luogo = luogo.substring( 0, luogo.indexOf(",") );
429-
return luogo;
483+
place = place.substring(start);
484+
if( place.indexOf(",") > 0 )
485+
place = place.substring(0, place.indexOf(","));
486+
return place;
430487
}
431488

432489
/** Count how many near relatives a person has: parents, siblings, step-siblings, spouses and children.
@@ -491,7 +548,7 @@ public void onCreateOptionsMenu( Menu menu, MenuInflater inflater ) {
491548
vistaCerca.setOnQueryTextListener( new SearchView.OnQueryTextListener() {
492549
@Override
493550
public boolean onQueryTextChange( String query ) {
494-
adattatore.getFilter().filter(query);
551+
adapter.getFilter().filter(query);
495552
return true;
496553
}
497554
@Override
@@ -513,7 +570,7 @@ else if( order == Order.values()[id * 2] )
513570
else
514571
order = Order.values()[id * 2 - 1];
515572
sortPeople();
516-
adattatore.notifyDataSetChanged();
573+
adapter.notifyDataSetChanged();
517574
//U.salvaJson( false ); // dubbio se metterlo per salvare subito il riordino delle persone...
518575
return true;
519576
}
@@ -551,7 +608,7 @@ public boolean onContextItemSelected( MenuItem item ) {
551608
new AlertDialog.Builder(getContext()).setMessage( R.string.really_delete_person )
552609
.setPositiveButton( R.string.delete, (dialog, i) -> {
553610
Family[] famiglie = eliminaPersona(getContext(), idIndi);
554-
adattatore.notifyDataSetChanged();
611+
adapter.notifyDataSetChanged();
555612
arredaBarra();
556613
U.controllaFamiglieVuote(getContext(), null, false, famiglie);
557614
}).setNeutralButton( R.string.cancel, null ).show();
@@ -603,4 +660,4 @@ static Family[] eliminaPersona(Context contesto, String idEliminando) {
603660
U.salvaJson( true, (Object[])famiglie );
604661
return famiglie;
605662
}
606-
}
663+
}

app/src/main/java/app/familygem/Dettaglio.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -307,62 +307,62 @@ PopupMenu menuFAB(View vista) {
307307

308308
// Imposta ciò che è stato scelto nelle liste
309309
@Override
310-
public void onActivityResult( int requestCode, int resultCode, Intent data ) {
311-
super.onActivityResult( requestCode, resultCode, data );
310+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
311+
super.onActivityResult(requestCode, resultCode, data);
312312
if( resultCode == RESULT_OK ) {
313313
// Dal submenu 'Collega...' in FAB
314314
if( requestCode == 34417 ) { // Familiare scelto in Anagrafe
315315
Person aggiungendo = gc.getPerson(data.getStringExtra("idParente"));
316-
Famiglia.aggrega( aggiungendo, (Family)object, data.getIntExtra("relazione",0) );
317-
U.salvaJson( true, Memoria.oggettoCapo() );
316+
Famiglia.aggrega(aggiungendo, (Family)object, data.getIntExtra("relazione", 0));
317+
U.salvaJson(true, Memoria.oggettoCapo());
318318
return;
319319
} else if( requestCode == 5065 ) { // Fonte scelta in Biblioteca
320320
SourceCitation citaFonte = new SourceCitation();
321-
citaFonte.setRef( data.getStringExtra("idFonte") );
322-
if( object instanceof Note ) ((Note)object).addSourceCitation( citaFonte );
323-
else ((SourceCitationContainer)object).addSourceCitation( citaFonte );
324-
} else if( requestCode == 7074 ) { // Nota condivisa
321+
citaFonte.setRef(data.getStringExtra("idFonte"));
322+
if( object instanceof Note ) ((Note)object).addSourceCitation(citaFonte);
323+
else ((SourceCitationContainer)object).addSourceCitation(citaFonte);
324+
} else if( requestCode == 7074 ) { // Nota condivisa
325325
NoteRef rifNota = new NoteRef();
326-
rifNota.setRef( data.getStringExtra( "idNota" ) );
327-
((NoteContainer)object).addNoteRef( rifNota );
326+
rifNota.setRef(data.getStringExtra("idNota"));
327+
((NoteContainer)object).addNoteRef(rifNota);
328328
} else if( requestCode == 4173 ) { // File preso dal file manager o altra app diventa media locale
329329
Media media = new Media();
330330
media.setFileTag("FILE");
331-
((MediaContainer)object).addMedia( media );
332-
if( F.proponiRitaglio( this, null, data, media ) ) {
333-
U.salvaJson( false, Memoria.oggettoCapo() );
331+
((MediaContainer)object).addMedia(media);
332+
if( F.proponiRitaglio(this, null, data, media) ) {
333+
U.salvaJson(false, Memoria.oggettoCapo());
334334
return;
335335
}
336336
} else if( requestCode == 4174 ) { // File preso dal file manager diventa media condiviso
337337
Media media = Galleria.nuovoMedia(object);
338-
if( F.proponiRitaglio( this, null, data, media ) ) {
339-
U.salvaJson( false, media, Memoria.oggettoCapo() );
338+
if( F.proponiRitaglio(this, null, data, media) ) {
339+
U.salvaJson(false, media, Memoria.oggettoCapo());
340340
return;
341341
}
342342
} else if( requestCode == 43616 ) { // Media da Galleria
343343
MediaRef rifMedia = new MediaRef();
344-
rifMedia.setRef( data.getStringExtra("idMedia") );
345-
((MediaContainer)object).addMediaRef( rifMedia );
346-
} else if( requestCode == 4562 ) { // Archivio scelto in Magazzino da Fonte
344+
rifMedia.setRef(data.getStringExtra("idMedia"));
345+
((MediaContainer)object).addMediaRef(rifMedia);
346+
} else if( requestCode == 4562 ) { // Archivio scelto in Magazzino da Fonte
347347
RepositoryRef archRef = new RepositoryRef();
348-
archRef.setRef( data.getStringExtra("idArchivio") );
349-
((Source)object).setRepositoryRef( archRef );
348+
archRef.setRef(data.getStringExtra("idArchivio"));
349+
((Source)object).setRepositoryRef(archRef);
350350
} else if( requestCode == 5173 ) { // Salva in Media un file scelto con le app da Immagine
351-
if( F.proponiRitaglio( this, null, data, (Media)object) ) {
352-
U.salvaJson( false, Memoria.oggettoCapo() );
351+
if( F.proponiRitaglio(this, null, data, (Media)object) ) {
352+
U.salvaJson(false, Memoria.oggettoCapo());
353353
return;
354354
}
355355
} else if( requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE ) {
356-
F.fineRitaglioImmagine( data );
356+
F.fineRitaglioImmagine(data);
357357
}
358358
// da menu contestuale 'Scegli...'
359-
if( requestCode == 5390 ) { // Imposta l'archivio che è stato scelto in Magazzino da ArchivioRef
360-
((RepositoryRef)object).setRef( data.getStringExtra("idArchivio") );
361-
} else if( requestCode == 7047 ) { // Imposta la fonte che è stata scelta in Biblioteca da CitazioneFonte
362-
((SourceCitation)object).setRef( data.getStringExtra("idFonte") );
359+
if( requestCode == 5390 ) { // Imposta l'archivio che è stato scelto in Magazzino da ArchivioRef
360+
((RepositoryRef)object).setRef(data.getStringExtra("idArchivio"));
361+
} else if( requestCode == 7047 ) { // Imposta la fonte che è stata scelta in Biblioteca da CitazioneFonte
362+
((SourceCitation)object).setRef(data.getStringExtra("idFonte"));
363363
}
364-
U.salvaJson( true, Memoria.oggettoCapo() );
365-
// indica di ricaricare sia questo Dettaglio grazie al seguente onRestart(), sia Individuo o Famiglia
364+
U.salvaJson(true, Memoria.oggettoCapo());
365+
// 'true' indica di ricaricare sia questo Dettaglio grazie al seguente onRestart(), sia Individuo o Famiglia
366366
} else if( requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE )
367367
Global.edited = true;
368368
}

0 commit comments

Comments
 (0)