1
0
mirror of https://github.com/nerzhul/ownCloud-SMS-App.git synced 2025-07-23 01:45:47 +00:00

Big commit: Android Studio + Re-enable ContactList view and make it working to prepare SMS restauration

This commit is contained in:
Loic Blot 2015-08-09 19:57:23 +02:00
parent 9bbd6d7632
commit 597044cdc8
80 changed files with 180 additions and 49 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/bin/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>

View File

@ -1,15 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-22
android.library.reference.1=../Owncloud-Android-Library

View File

@ -1,15 +1,20 @@
package fr.unix_experience.owncloud_sms.activities.remote_account;
import java.util.ArrayList;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.ListActivity;
import android.os.Bundle;
import fr.nrz.androidlib.adapters.AndroidAccountAdapter;
import fr.unix_experience.owncloud_sms.R;
import fr.unix_experience.owncloud_sms.adapters.ContactListAdapter;
import fr.unix_experience.owncloud_sms.engine.ASyncContactLoad;
public class ContactListActivity extends ListActivity implements ASyncContactLoad {
static AccountManager _accountMgr;
ContactListAdapter adapter;
@Override
protected void onCreate(final Bundle savedInstanceState) {
@ -25,10 +30,21 @@ public class ContactListActivity extends ListActivity implements ASyncContactLoa
_accountMgr = AccountManager.get(getBaseContext());
final Account[] myAccountList =
_accountMgr.getAccountsByType(getString(R.string.account_type));
// Init view
ArrayList<String> objects = new ArrayList<String>();
setContentView(R.layout.restore_activity_contactlist);
adapter = new ContactListAdapter(getBaseContext(),
android.R.layout.simple_list_item_1,
objects,
R.layout.contact_list_item,
R.id.contactname);
setListAdapter(adapter);
for (final Account element : myAccountList) {
if (element.name.equals(accountName)) {
new ContactLoadTask(element, getBaseContext()).execute();
new ContactLoadTask(element, getBaseContext(), adapter, objects).execute();
return;
}
}

View File

@ -0,0 +1,52 @@
package fr.unix_experience.owncloud_sms.adapters;
import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class ContactListAdapter extends ArrayAdapter<String> {
private final ArrayList<String> _objects;
private static int _itemLayout;
private static int _fieldId;
public ContactListAdapter(final Context context, final int resource,
final ArrayList<String> objects, final int itemLayout,
final int fieldId) {
super(context, resource, resource, objects);
_objects = objects;
_itemLayout = itemLayout;
_fieldId = fieldId;
}
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
View v = convertView;
if (v == null) {
final LayoutInflater inflater =
(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(_itemLayout, null);
}
final String element = _objects.get(position);
if (element != null) {
final TextView label = (TextView) v.findViewById(_fieldId);
if (label != null) {
label.setText(element + " >");
label.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
// @TODO
}
});
}
}
return v;
}
}

View File

@ -1,33 +1,46 @@
package fr.unix_experience.owncloud_sms.engine;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import fr.unix_experience.owncloud_sms.adapters.ContactListAdapter;
import fr.unix_experience.owncloud_sms.exceptions.OCSyncException;
public interface ASyncContactLoad {
class ContactLoadTask extends AsyncTask<Void, Void, Void> {
class ContactLoadTask extends AsyncTask<Void, Void, Boolean> {
private static AccountManager _accountMgr = null;
private static Account _account;
private final Context _context;
private ContactListAdapter _adapter;
private ArrayList<String> _objects;
public ContactLoadTask(final Account account, final Context context) {
public ContactLoadTask(final Account account, final Context context,
ContactListAdapter adapter, ArrayList<String> objects) {
if (_accountMgr == null) {
_accountMgr = AccountManager.get(context);
}
_account = account;
_context = context;
_adapter = adapter;
_objects = objects;
}
@Override
protected Void doInBackground(final Void... params) {
protected Boolean doInBackground(final Void... params) {
// Create client
final String ocURI = _accountMgr.getUserData(_account, "ocURI");
if (ocURI == null) {
// @TODO: Handle the problem
return null;
return false;
}
final Uri serverURI = Uri.parse(ocURI);
@ -39,15 +52,33 @@ public interface ASyncContactLoad {
try {
if (_client.getServerAPIVersion() < 2) {
// @TODO: handle error
return false;
}
_client.getServerPhoneNumbers();
JSONArray phoneNumbers = _client.getServerPhoneNumbers();
Log.d(TAG, phoneNumbers.toString());
for (int i = 0; i < phoneNumbers.length(); i++) {
String phone = phoneNumbers.getString(i);
_objects.add(phone);
}
} catch (JSONException e) {
// @TODO: handle error
e.printStackTrace();
return false;
} catch (final OCSyncException e) {
// @TODO: handle error
e.printStackTrace();
return false;
}
return null;
return true;
}
protected void onPostExecute(final Boolean success) {
_adapter.notifyDataSetChanged();
}
}
static final String TAG = ASyncSMSSync.class.getSimpleName();
static final String TAG = ASyncContactLoad.class.getSimpleName();
}

View File

@ -44,6 +44,7 @@ import fr.unix_experience.owncloud_sms.enums.OCSyncErrorType;
import fr.unix_experience.owncloud_sms.exceptions.OCSyncException;
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
@SuppressWarnings("deprecation")
public class OCSMSOwnCloudClient {
public OCSMSOwnCloudClient(final Context context, final Uri serverURI, final String accountName, final String accountPassword) {
@ -86,8 +87,9 @@ public class OCSMSOwnCloudClient {
return null;
}
Log.d(TAG, obj.toString());
try {
return obj.getJSONArray("phonelist");
return obj.getJSONArray("phoneList");
} catch (final JSONException e) {
Log.e(TAG, "No phonelist received from server, empty it", e);
return null;
@ -99,7 +101,6 @@ public class OCSMSOwnCloudClient {
* If we need other API push, set it here
*/
switch (_serverAPIVersion) {
case 2: doPushRequestV2(smsList); break;
case 1:
default: doPushRequestV1(smsList); break;
}
@ -192,10 +193,6 @@ public class OCSMSOwnCloudClient {
Log.d(TAG, "SMS Push request said: status " + pushStatus + " - " + pushMessage);
}
public void doPushRequestV2(final JSONArray smsList) throws OCSyncException {
}
public GetMethod createGetVersionRequest() {
return createGetRequest(OC_GET_VERSION);
}

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 916 B

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 821 B

After

Width:  |  Height:  |  Size: 821 B

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>

View File

@ -0,0 +1,13 @@
<?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/contactname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:textSize="18sp"
/>
</RelativeLayout>

View File

@ -103,7 +103,7 @@
style="@style/StandardButton"
android:text="@string/ma_button_sync_accounts_now" />
<!-- <TextView
<TextView
android:id="@+id/tv_remoteaccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -125,7 +125,7 @@
android:background="@drawable/standard_button"
style="@style/StandardButton"
android:text="@string/choose_account" />
-->
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"

View File

@ -0,0 +1,39 @@
<!--
/*
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false" />
</LinearLayout>

View File

@ -27,7 +27,7 @@
-->
<resources>
<!-- Translation version, reference for translators -->
<string name="translation_version">3</string>
<string name="gp_translation_version">3</string>
<!-- Translations must begin here -->
<string name="gp_short_description">ownCloud SMS synchronizuje vaše lokální SMS zprávy na váš server ownCloud</string>

View File

@ -27,7 +27,7 @@
-->
<resources>
<!-- Translation version, reference for translators -->
<string name="translation_version">3</string>
<string name="gp_translation_version">3</string>
<!-- Translations must begin there -->
<string name="gp_short_description">Mit ownCloud SMS kannst Du Deine SMS mit Deiner ownCloud synchronisieren</string>

View File

@ -27,7 +27,7 @@
-->
<resources>
<!-- Translation version, reference for translators -->
<string name="translation_version">3</string>
<string name="gp_translation_version">3</string>
<!-- Translations must begin here -->
<string name="gp_short_description">ownCloud SMS synchronize your local SMS on your ownCloud instance</string>

View File

@ -27,13 +27,13 @@
-->
<resources>
<!-- Translation version, reference for translators -->
<string name="translation_version">0</string>
<string name="gp_short_description">ownCloud SMS sincroniza sus mensajes SMS locales en su servidor ownCloud</string>
<string name="gp_description">
La aplicación ownCloud SMS sincroniza sus mensajes SMS en un servidor ownCloud remoto y le permite leer sus mensajes desde él.
<string name="gp_translation_version">0</string>
<string name="gp_short_description">ownCloud SMS sincroniza sus mensajes SMS locales en su servidor ownCloud</string>
<string name="gp_description">
La aplicación ownCloud SMS sincroniza sus mensajes SMS en un servidor ownCloud remoto y le permite leer sus mensajes desde él.
El envio de SMS desde el servidor ownCloud será implementado en futuras versiones.
El envio de SMS desde el servidor ownCloud será implementado en futuras versiones.
La aplicación es totalmente compatible con Android 4.0 a 5.0
</string>
La aplicación es totalmente compatible con Android 4.0 a 5.0
</string>
</resources>

View File

@ -27,7 +27,7 @@
-->
<resources>
<!-- Translation version, reference for translators -->
<string name="translation_version">3</string>
<string name="gp_translation_version">3</string>
<!-- Translations must begin there -->
<string name="gp_short_description">ownCloud SMS permet de synchroniser vos SMS sur votre instance ownCloud</string>

View File

@ -27,7 +27,7 @@
-->
<resources>
<!-- Translation version, reference for translators -->
<string name="translation_version">3</string>
<string name="gp_translation_version">3</string>
<!-- Translations must begin here -->
<string name="gp_short_description">Оунклауд СМС синхронизује ваше локалне СМС поруке на ваш Оунклауд налог</string>

View File

@ -28,7 +28,7 @@
-->
<resources>
<!-- Translation version, reference for translators -->
<string name="translation_version">4</string>
<string name="gp_translation_version">4</string>
<!-- Translations must begin here -->
<string name="gp_short_description">ownCloud SMS synkroniserar dina lokala SMS till din ownCloudinstans.</string>
<string name="gp_description">

View File

@ -27,7 +27,7 @@
-->
<resources>
<!-- Translation version, reference for translators -->
<string name="translation_version">3</string>
<string name="gp_translation_version">3</string>
<!-- Translations must begin here -->
<string name="gp_short_description">ownCloud SMS synchronize your local SMS on your ownCloud instance</string>