mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-19 05:46:16 +00:00
Improve restore activity a little, not perfect but better
This commit is contained in:
parent
3895b8cf0b
commit
c132837aac
@ -11,15 +11,16 @@ import android.support.v4.widget.SwipeRefreshLayout;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
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.adapters.RecoveryPhoneNumberListViewAdapter;
|
||||||
import fr.unix_experience.owncloud_sms.engine.ASyncContactLoad;
|
import fr.unix_experience.owncloud_sms.engine.ASyncContactLoad;
|
||||||
|
|
||||||
public class ContactListActivity extends Activity implements ASyncContactLoad {
|
public class ContactListActivity extends Activity implements ASyncContactLoad {
|
||||||
@ -55,16 +56,15 @@ public class ContactListActivity extends Activity implements ASyncContactLoad {
|
|||||||
android.R.color.holo_orange_light,
|
android.R.color.holo_orange_light,
|
||||||
android.R.color.holo_red_light);
|
android.R.color.holo_red_light);
|
||||||
|
|
||||||
adapter = new ContactListAdapter(getBaseContext(),
|
adapter = new ContactListAdapter(getBaseContext(), objects);
|
||||||
android.R.layout.simple_spinner_item,
|
|
||||||
objects,
|
|
||||||
R.layout.contact_list_item,
|
|
||||||
R.id.contactname, this);
|
|
||||||
|
|
||||||
final Spinner sp = (Spinner) findViewById(R.id.contact_spinner);
|
final Spinner sp = (Spinner) findViewById(R.id.contact_spinner);
|
||||||
final LinearLayout contactInfos = (LinearLayout) findViewById(R.id.contactinfos_layout);
|
final LinearLayout contactInfos = (LinearLayout) findViewById(R.id.contactinfos_layout);
|
||||||
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);
|
final ListView contactPhoneListView = (ListView) findViewById(R.id.contact_phonelistView);
|
||||||
|
final RecoveryPhoneNumberListViewAdapter contactPhoneListAdapter =
|
||||||
|
new RecoveryPhoneNumberListViewAdapter(getBaseContext());
|
||||||
|
contactPhoneListView.setAdapter(contactPhoneListAdapter);
|
||||||
|
|
||||||
contactInfos.setVisibility(View.INVISIBLE);
|
contactInfos.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
@ -72,6 +72,7 @@ public class ContactListActivity extends Activity implements ASyncContactLoad {
|
|||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
contactInfos.setVisibility(View.INVISIBLE);
|
contactInfos.setVisibility(View.INVISIBLE);
|
||||||
|
contactPhoneListAdapter.clear();
|
||||||
|
|
||||||
String contactName = sp.getSelectedItem().toString();
|
String contactName = sp.getSelectedItem().toString();
|
||||||
Vector<String> phoneList = fetchContact(contactName);
|
Vector<String> phoneList = fetchContact(contactName);
|
||||||
@ -79,16 +80,15 @@ public class ContactListActivity extends Activity implements ASyncContactLoad {
|
|||||||
// @TODO asynctask to load more datas
|
// @TODO asynctask to load more datas
|
||||||
|
|
||||||
if (!phoneList.isEmpty()) {
|
if (!phoneList.isEmpty()) {
|
||||||
String res = "";
|
|
||||||
for (String pn: phoneList) {
|
for (String pn: phoneList) {
|
||||||
res += "- " + pn + "\n";
|
contactPhoneListAdapter.add(pn);
|
||||||
}
|
}
|
||||||
contactPhoneList.setText(res);
|
|
||||||
} else {
|
} else {
|
||||||
contactPhoneList.setText(contactName);
|
contactPhoneListAdapter.add(contactName);
|
||||||
}
|
}
|
||||||
|
|
||||||
contactInfos.setVisibility(View.VISIBLE);
|
contactInfos.setVisibility(View.VISIBLE);
|
||||||
|
contactPhoneListAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.unix_experience.owncloud_sms.adapters;
|
package fr.unix_experience.owncloud_sms.adapters;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -10,20 +9,18 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import fr.unix_experience.owncloud_sms.R;
|
||||||
|
|
||||||
public class ContactListAdapter extends ArrayAdapter<String> {
|
public class ContactListAdapter extends ArrayAdapter<String> {
|
||||||
private final ArrayList<String> _objects;
|
private final ArrayList<String> _objects;
|
||||||
private static int _itemLayout;
|
|
||||||
private static int _fieldId;
|
|
||||||
private final Activity _activity;
|
|
||||||
|
|
||||||
public ContactListAdapter(Context context, int resource,
|
// Design
|
||||||
ArrayList<String> objects, int itemLayout,
|
private final static int _itemLayout = R.layout.contact_list_item;
|
||||||
int fieldId, Activity activity) {
|
private final static int _fieldId = R.id.contactname;
|
||||||
super(context, resource, objects);
|
|
||||||
|
public ContactListAdapter(Context context, ArrayList<String> objects) {
|
||||||
|
super(context, android.R.layout.simple_spinner_item, objects);
|
||||||
_objects = objects;
|
_objects = objects;
|
||||||
ContactListAdapter._itemLayout = itemLayout;
|
|
||||||
ContactListAdapter._fieldId = fieldId;
|
|
||||||
_activity = activity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package fr.unix_experience.owncloud_sms.adapters;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import fr.unix_experience.owncloud_sms.R;
|
||||||
|
|
||||||
|
public class RecoveryPhoneNumberListViewAdapter extends ArrayAdapter<String> {
|
||||||
|
private static final String TAG = "RecPhoneNumberListVAdp";
|
||||||
|
private static int _fieldId = R.id.recovery_phone;
|
||||||
|
private static int _itemLayout = R.layout.recovery_phone_list_item;
|
||||||
|
private static int resource = android.R.layout.simple_list_item_2;
|
||||||
|
|
||||||
|
public RecoveryPhoneNumberListViewAdapter(Context context) {
|
||||||
|
super(context, resource, new ArrayList<String>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View v = convertView;
|
||||||
|
if (v == null) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
v = inflater.inflate(RecoveryPhoneNumberListViewAdapter._itemLayout, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView label = (TextView) v.findViewById(RecoveryPhoneNumberListViewAdapter._fieldId);
|
||||||
|
if (label != null) {
|
||||||
|
final String l = getItem(position).toString();
|
||||||
|
label.setText(getItem(position).toString());
|
||||||
|
v.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Log.d(TAG, "Clicked on phone " + l);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
v.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
Log.d(TAG, "Long clicked on phone " + l);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="20dp"
|
android:padding="20dp"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp" />
|
||||||
/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -7,7 +7,5 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="20dp"
|
android:padding="20dp"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp" />
|
||||||
/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
11
src/main/res/layout/recovery_phone_list_item.xml
Normal file
11
src/main/res/layout/recovery_phone_list_item.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/recovery_phone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
</RelativeLayout>
|
@ -34,6 +34,6 @@
|
|||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:drawSelectorOnTop="false" />
|
android:drawSelectorOnTop="true" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -27,9 +27,11 @@
|
|||||||
|
|
||||||
<android.support.v4.widget.SwipeRefreshLayout
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/contactlist_swipe_container"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/contactlist_swipe_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".activities.remote_account.ContactListActivity">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@ -54,6 +56,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/contact_spinner"
|
android:id="@+id/contact_spinner"
|
||||||
|
android:listSelector="@android:color/holo_blue_light"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -73,15 +76,21 @@
|
|||||||
android:id="@+id/subtitle_contact_phones"
|
android:id="@+id/subtitle_contact_phones"
|
||||||
android:autoText="false"
|
android:autoText="false"
|
||||||
android:paddingLeft="20dp"/>
|
android:paddingLeft="20dp"/>
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:orientation="vertical"
|
||||||
android:text="Medium Text"
|
android:layout_width="wrap_content"
|
||||||
android:id="@+id/contact_phonelist"
|
android:layout_height="wrap_content" >
|
||||||
android:autoText="false"
|
<ListView
|
||||||
android:paddingLeft="40dp"/>
|
android:layout_width="match_parent"
|
||||||
</LinearLayout>
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/contact_phonelistView"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:drawSelectorOnTop="true"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="?android:attr/progressBarStyleLarge"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
8
src/main/res/menu/menu_contact_restore_actions.xml
Normal file
8
src/main/res/menu/menu_contact_restore_actions.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:context="fr.unix_experience.owncloud_sms.activities.remote_account.ContactRestoreActionsActivity">
|
||||||
|
<item android:id="@+id/action_settings"
|
||||||
|
android:title="@string/action_settings"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:showAsAction="never"/>
|
||||||
|
</menu>
|
@ -158,5 +158,5 @@
|
|||||||
<string name="err_fetch_phonelist">Přijat neplatný seznam telefoních čísel ze serveru.</string>
|
<string name="err_fetch_phonelist">Přijat neplatný seznam telefoních čísel ze serveru.</string>
|
||||||
<string name="err_proto_v2">Server nepodporuje tuto funkci. Zajistěte verzi na serveru alespoň 1.6.</string>
|
<string name="err_proto_v2">Server nepodporuje tuto funkci. Zajistěte verzi na serveru alespoň 1.6.</string>
|
||||||
<string name="contactinfos_title">Informace kontaktu</string>
|
<string name="contactinfos_title">Informace kontaktu</string>
|
||||||
<string name="subtitle_contact_phones">> Telefony kontaktu</string>
|
<string name="subtitle_contact_phones">- Telefony kontaktu</string>
|
||||||
</resources>
|
</resources>
|
@ -162,7 +162,7 @@ Contributors and issue\'s reporters</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="contactinfos_title">Contact informations</string>
|
||||||
<string name="choose_account">Choose account</string>
|
<string name="choose_account">Choose account</string>
|
||||||
<string name="subtitle_contact_phones">> Contact phones</string>
|
<string name="subtitle_contact_phones">- Contact phones</string>
|
||||||
<string name="pref_title_bulk_messages">Max messages to send per sync</string>
|
<string name="pref_title_bulk_messages">Max messages to send per sync</string>
|
||||||
<string name="contactinfos_list">Contact list</string>
|
<string name="contactinfos_list">Contact list</string>
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ Les contributeurs et rapporteurs de bugs</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_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_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="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>
|
<string name="subtitle_contact_phones">- Numéros de téléphone associés</string>
|
||||||
<string name="choose_account">Choisissez un compte</string>
|
<string name="choose_account">Choisissez un compte</string>
|
||||||
<string name="ma_title_remote_account">Compte distant</string>
|
<string name="ma_title_remote_account">Compte distant</string>
|
||||||
<string name="title_activity_select_account">Chosissez un compte</string>
|
<string name="title_activity_select_account">Chosissez un compte</string>
|
||||||
|
@ -191,7 +191,7 @@ Contributors and issue\'s reporters</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="contactinfos_title">Contact informations</string>
|
||||||
<string name="subtitle_contact_phones">> Contact phones</string>
|
<string name="subtitle_contact_phones">- Contact phones</string>
|
||||||
<string name="pref_title_bulk_messages">Max messages to send per sync</string>
|
<string name="pref_title_bulk_messages">Max messages to send per sync</string>
|
||||||
<string name="contactinfos_list">Contact list</string>
|
<string name="contactinfos_list">Contact list</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user