mirror of
				https://github.com/nerzhul/ownCloud-SMS-App.git
				synced 2025-10-31 02:17:53 +00:00 
			
		
		
		
	Improve french translation + contact view
This commit is contained in:
		
							parent
							
								
									1a6feec7ee
								
							
						
					
					
						commit
						40a40f800d
					
				| @ -2,23 +2,35 @@ package fr.unix_experience.owncloud_sms.activities.remote_account; | |||||||
| 
 | 
 | ||||||
| import java.lang.reflect.Array; | import java.lang.reflect.Array; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
|  | import java.util.Vector; | ||||||
| 
 | 
 | ||||||
| import android.accounts.Account; | import android.accounts.Account; | ||||||
| import android.accounts.AccountManager; | import android.accounts.AccountManager; | ||||||
| import android.app.Activity; | import android.app.Activity; | ||||||
| import android.app.ListActivity; | import android.app.ListActivity; | ||||||
|  | import android.content.ContentResolver; | ||||||
|  | import android.database.Cursor; | ||||||
|  | import android.net.Uri; | ||||||
| import android.os.Bundle; | import android.os.Bundle; | ||||||
| import android.os.Handler; | import android.os.Handler; | ||||||
|  | import android.provider.ContactsContract; | ||||||
| import android.support.v4.widget.SwipeRefreshLayout; | import android.support.v4.widget.SwipeRefreshLayout; | ||||||
|  | import android.util.Log; | ||||||
| import android.view.View; | import android.view.View; | ||||||
|  | import android.widget.AdapterView; | ||||||
|  | import android.widget.LinearLayout; | ||||||
| import android.widget.ProgressBar; | import android.widget.ProgressBar; | ||||||
| import android.widget.SeekBar; | import android.widget.SeekBar; | ||||||
| import android.widget.Spinner; | import android.widget.Spinner; | ||||||
|  | import android.widget.TextView; | ||||||
|  | 
 | ||||||
|  | import org.w3c.dom.Text; | ||||||
| 
 | 
 | ||||||
| import fr.nrz.androidlib.adapters.AndroidAccountAdapter; | import fr.nrz.androidlib.adapters.AndroidAccountAdapter; | ||||||
| import fr.unix_experience.owncloud_sms.R; | import fr.unix_experience.owncloud_sms.R; | ||||||
| import fr.unix_experience.owncloud_sms.adapters.ContactListAdapter; | import fr.unix_experience.owncloud_sms.adapters.ContactListAdapter; | ||||||
| import fr.unix_experience.owncloud_sms.engine.ASyncContactLoad; | import fr.unix_experience.owncloud_sms.engine.ASyncContactLoad; | ||||||
|  | import fr.unix_experience.owncloud_sms.engine.OCSMSOwnCloudClient; | ||||||
| 
 | 
 | ||||||
| public class ContactListActivity extends Activity implements ASyncContactLoad { | public class ContactListActivity extends Activity implements ASyncContactLoad { | ||||||
| 
 | 
 | ||||||
| @ -60,10 +72,71 @@ public class ContactListActivity extends Activity implements ASyncContactLoad { | |||||||
| 				R.id.contactname, this); | 				R.id.contactname, this); | ||||||
| 		 | 		 | ||||||
| 		final Spinner sp = (Spinner) findViewById(R.id.contact_spinner); | 		final Spinner sp = (Spinner) findViewById(R.id.contact_spinner); | ||||||
| 		sp.setVisibility(View.INVISIBLE); | 		final LinearLayout contactInfos = (LinearLayout) findViewById(R.id.contactinfos_layout); | ||||||
| 		sp.setAdapter(adapter); |  | ||||||
| 
 |  | ||||||
| 		final ProgressBar contactProgressBar = (ProgressBar) findViewById(R.id.contactlist_pgbar); | 		final ProgressBar contactProgressBar = (ProgressBar) findViewById(R.id.contactlist_pgbar); | ||||||
|  | 		final TextView contactPhoneList = (TextView) findViewById(R.id.contact_phonelist); | ||||||
|  | 
 | ||||||
|  | 		sp.setVisibility(View.INVISIBLE); | ||||||
|  | 		contactInfos.setVisibility(View.INVISIBLE); | ||||||
|  | 
 | ||||||
|  | 		sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||||||
|  | 			@Override | ||||||
|  | 			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||||||
|  | 				contactInfos.setVisibility(View.INVISIBLE); | ||||||
|  | 
 | ||||||
|  | 				String contactName = sp.getSelectedItem().toString(); | ||||||
|  | 				Vector<String> phoneList = fetchContact(contactName); | ||||||
|  | 				Integer smsCount = 0; | ||||||
|  | 				// @TODO asynctask to load more datas | ||||||
|  | 
 | ||||||
|  | 				if (phoneList.size() > 0) { | ||||||
|  | 					String res = new String(""); | ||||||
|  | 					for (String pn: phoneList) { | ||||||
|  | 						res += "- " + pn + "\n"; | ||||||
|  | 					} | ||||||
|  | 					contactPhoneList.setText(res); | ||||||
|  | 				} else { | ||||||
|  | 					contactPhoneList.setText(contactName); | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 				contactInfos.setVisibility(View.VISIBLE); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			@Override | ||||||
|  | 			public void onNothingSelected(AdapterView<?> parent) { | ||||||
|  | 				// Nothing to do there | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			private Vector<String> fetchContact(String name) { | ||||||
|  | 				Cursor people = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, | ||||||
|  | 						null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " = ?", | ||||||
|  | 						new String[]{name}, null); | ||||||
|  | 				people.moveToFirst(); | ||||||
|  | 
 | ||||||
|  | 				Vector<String> r = new Vector<>(); | ||||||
|  | 				if (people.getCount() == 0) { | ||||||
|  | 					return r; | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 				String contactId = people.getString(people.getColumnIndex(ContactsContract.Contacts._ID)); | ||||||
|  | 
 | ||||||
|  | 				if (people.getString(people.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)) | ||||||
|  | 						.equalsIgnoreCase("1")) { | ||||||
|  | 					Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, | ||||||
|  | 							null, | ||||||
|  | 							ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", | ||||||
|  | 							new String[]{contactId}, null); | ||||||
|  | 					while (phones.moveToNext()) { | ||||||
|  | 						String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)) | ||||||
|  | 								.replaceAll(" ", ""); | ||||||
|  | 						r.add(phoneNumber); | ||||||
|  | 					} | ||||||
|  | 					phones.close(); | ||||||
|  | 				} | ||||||
|  | 				return r; | ||||||
|  | 			} | ||||||
|  | 		}); | ||||||
|  | 		sp.setAdapter(adapter); | ||||||
| 
 | 
 | ||||||
| 		for (final Account element : myAccountList) { | 		for (final Account element : myAccountList) { | ||||||
| 			if (element.name.equals(accountName)) { | 			if (element.name.equals(accountName)) { | ||||||
|  | |||||||
| @ -98,8 +98,8 @@ public interface ASyncContactLoad { | |||||||
| 									ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", | 									ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", | ||||||
| 									new String[]{id}, null); | 									new String[]{id}, null); | ||||||
| 							while (pCur.moveToNext()) { | 							while (pCur.moveToNext()) { | ||||||
| 								String phoneNo = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); | 								String phoneNo = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)) | ||||||
| 								phoneNo = phoneNo.replaceAll(" ", ""); | 										.replaceAll(" ", ""); | ||||||
| 								if (serverPhoneList.contains(phoneNo)) { | 								if (serverPhoneList.contains(phoneNo)) { | ||||||
| 									if (!_objects.contains(name)) { | 									if (!_objects.contains(name)) { | ||||||
| 										_objects.add(name); | 										_objects.add(name); | ||||||
|  | |||||||
| @ -51,6 +51,39 @@ | |||||||
| 			android:indeterminate="true" | 			android:indeterminate="true" | ||||||
| 			android:layout_height="wrap_content"/> | 			android:layout_height="wrap_content"/> | ||||||
| 
 | 
 | ||||||
|  | 		<LinearLayout | ||||||
|  | 			android:orientation="vertical" | ||||||
|  | 			android:layout_width="match_parent" | ||||||
|  | 			android:layout_height="wrap_content" | ||||||
|  | 			android:id="@+id/contactinfos_layout"> | ||||||
|  | 
 | ||||||
|  | 			<TextView | ||||||
|  |                 android:layout_width="wrap_content" | ||||||
|  |                 android:layout_height="wrap_content" | ||||||
|  |                 android:textAppearance="?android:attr/textAppearanceLarge" | ||||||
|  |                 android:text="@string/contactinfos_title" | ||||||
|  |                 android:id="@+id/contactinfo_title" | ||||||
|  |                 android:paddingLeft="10dp" | ||||||
|  | 				android:textColor="@android:color/holo_blue_dark"/> | ||||||
|  | 
 | ||||||
|  | 			<TextView | ||||||
|  |                 android:layout_width="match_parent" | ||||||
|  |                 android:layout_height="wrap_content" | ||||||
|  |                 android:textAppearance="?android:attr/textAppearanceMedium" | ||||||
|  |                 android:text="@string/subtitle_contact_phones" | ||||||
|  |                 android:id="@+id/subtitle_contact_phones" | ||||||
|  |                 android:autoText="false" | ||||||
|  |                 android:paddingLeft="20dp"/> | ||||||
|  | 			<TextView | ||||||
|  | 				android:layout_width="match_parent" | ||||||
|  | 				android:layout_height="wrap_content" | ||||||
|  | 				android:textAppearance="?android:attr/textAppearanceMedium" | ||||||
|  | 				android:text="Medium Text" | ||||||
|  | 				android:id="@+id/contact_phonelist" | ||||||
|  | 				android:autoText="false" | ||||||
|  | 				android:paddingLeft="40dp"/> | ||||||
|  | 		</LinearLayout> | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 	</LinearLayout> | 	</LinearLayout> | ||||||
| </android.support.v4.widget.SwipeRefreshLayout> | </android.support.v4.widget.SwipeRefreshLayout> | ||||||
| @ -160,5 +160,8 @@ Contributors and issue\'s reporters</string> | |||||||
|     <string name="err_sync_ocsms_not_installed_or_oc_upgrade_required">Error #18: OcSMS app is not installed or ownCloud awaiting for an upgrade</string> |     <string name="err_sync_ocsms_not_installed_or_oc_upgrade_required">Error #18: OcSMS app is not installed or ownCloud awaiting for an upgrade</string> | ||||||
|     <string name="err_fetch_phonelist">Invalid phonelist received from server.</string> |     <string name="err_fetch_phonelist">Invalid phonelist received from server.</string> | ||||||
|     <string name="err_proto_v2">Server doesn\'t support this feature. Ensure server version is at least 1.6.</string> |     <string name="err_proto_v2">Server doesn\'t support this feature. Ensure server version is at least 1.6.</string> | ||||||
|  |     <string name="contactinfos_title">Contact informations</string> | ||||||
|  |     <string name="choose_account">Choose account</string> | ||||||
|  |     <string name="subtitle_contact_phones">> Contact phones</string> | ||||||
| 
 | 
 | ||||||
| </resources> | </resources> | ||||||
|  | |||||||
| @ -91,4 +91,6 @@ | |||||||
| 	<string name="sync_title">Proceso de sincronización</string> | 	<string name="sync_title">Proceso de sincronización</string> | ||||||
| 	<string name="sync_inprogress">Sincronización en progreso...</string> | 	<string name="sync_inprogress">Sincronización en progreso...</string> | ||||||
| 	<string name="fatal_error">Error Fatal ! </string> | 	<string name="fatal_error">Error Fatal ! </string> | ||||||
|  | 	<string name="choose_account">Choisissez un compte</string> | ||||||
|  | 	<string name="contactinfos_title">Informations sur le contact</string> | ||||||
| </resources> | </resources> | ||||||
|  | |||||||
| @ -120,4 +120,16 @@ Les contributeurs et rapporteurs de bugs</string> | |||||||
|     <string name="err_sync_ocsms_not_installed_or_oc_upgrade_required">Error #18: L\'application OcSMS n\'est pas installée ou ownCloud attend d\'être mis à niveau.</string> |     <string name="err_sync_ocsms_not_installed_or_oc_upgrade_required">Error #18: L\'application OcSMS n\'est pas installée ou ownCloud attend d\'être mis à niveau.</string> | ||||||
|     <string name="err_fetch_phonelist">La liste de numéros reçue depuis le serveur est invalide.</string> |     <string name="err_fetch_phonelist">La liste de numéros reçue depuis le serveur est invalide.</string> | ||||||
|     <string name="err_proto_v2">Le serveur ne supporte pas cette fonctionnalité. Assurez vous que le serveur est au moins en version 1.6.</string> |     <string name="err_proto_v2">Le serveur ne supporte pas cette fonctionnalité. Assurez vous que le serveur est au moins en version 1.6.</string> | ||||||
|  |     <string name="contactinfos_title">Informations sur le contact</string> | ||||||
|  |     <string name="err_sync_create_json_null_smslist">Erreur #6: Liste SMS Nulle</string> | ||||||
|  |     <string name="err_sync_create_json_put_smslist">Erreur #6: Echec de la création de la requête PUSH</string> | ||||||
|  |     <string name="err_sync_http_request_connect">Erreur #11: Impossible de se connecter à l\'instance ownCloud</string> | ||||||
|  |     <string name="err_sync_auth_failed">Erreur #8: Echec de l\'authentification</string> | ||||||
|  |     <string name="err_sync_push_request">Erreur #3: Echec du push de la requête</string> | ||||||
|  |     <string name="err_sync_http_request_returncode_unhandled">Erreur #9: Le serveur a renvoyé un code de retour HTTP non géré</string> | ||||||
|  |     <string name="err_sync_http_request_resp">Erreur #14: Impossible d\'interpréter la réponse du serveur</string> | ||||||
|  |     <string name="err_sync_http_request_parse_resp">Erreur #15: Impossible d\'interpréter la réponse du serveur</string> | ||||||
|  |     <string name="err_sync_http_request_httpexception">Erreur #12: Impossible de se connecter à l\'instance ownCloud</string> | ||||||
|  |     <string name="err_sync_http_request_ioexception">Erreur #13: Impossible de se connecter à l\'instance ownCloud</string> | ||||||
|  |     <string name="subtitle_contact_phones">> Numéros de téléphone associés</string> | ||||||
| </resources> | </resources> | ||||||
|  | |||||||
| @ -170,4 +170,6 @@ Contributors and issue\'s reporters</string> | |||||||
|     <string name="err_sync_ocsms_not_installed_or_oc_upgrade_required">Error #18: OcSMS app is not installed or ownCloud awaiting for an upgrade</string> |     <string name="err_sync_ocsms_not_installed_or_oc_upgrade_required">Error #18: OcSMS app is not installed or ownCloud awaiting for an upgrade</string> | ||||||
|     <string name="err_fetch_phonelist">Invalid phonelist received from server.</string> |     <string name="err_fetch_phonelist">Invalid phonelist received from server.</string> | ||||||
|     <string name="err_proto_v2">Server doesn\'t support this feature. Ensure server version is at least 1.6.</string> |     <string name="err_proto_v2">Server doesn\'t support this feature. Ensure server version is at least 1.6.</string> | ||||||
|  |     <string name="contactinfos_title">Contact informations</string> | ||||||
|  |     <string name="subtitle_contact_phones">> Contact phones</string> | ||||||
| </resources> | </resources> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user