Skip to content
Snippets Groups Projects
Commit 0202fbf1 authored by Loïc Siret's avatar Loïc Siret Committed by Adrien Béraud
Browse files

refresh copyright, reformat and remove unused

This patch refresh copyrights to 2017, add a reformatting code coming
from android studio, and the removal of a unused class.

Change-Id: If1bc42c79d710d74647ff94010c5cad2197ef770
parent 6d16f60e
No related branches found
No related tags found
No related merge requests found
Showing
with 184 additions and 225 deletions
......@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.about;
import android.app.Dialog;
......
/*
* Copyright (C) 2016 Savoir-faire Linux Inc.
* Copyright (C) 2017 Savoir-faire Linux Inc.
*
* Author: Thibault Wittemberg <thibault.wittemberg@savoirfairelinux.com>
*
......
/*
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
* Copyright (C) 2004-2017 Savoir-faire Linux Inc.
*
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Alexandre Savard <alexandre.savard@savoirfairelinux.com>
......@@ -19,7 +19,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cx.ring.account;
import android.app.Activity;
......@@ -258,6 +257,36 @@ public class AccountEditionActivity extends AppCompatActivity implements Account
this.isRing = isRing;
}
@StringRes
private static int getRingPanelTitle(int position) {
switch (position) {
case 0:
return R.string.account_preferences_basic_tab;
case 1:
return R.string.account_preferences_media_tab;
case 2:
return R.string.account_preferences_advanced_tab;
default:
return -1;
}
}
@StringRes
private static int getSIPPanelTitle(int position) {
switch (position) {
case 0:
return R.string.account_preferences_basic_tab;
case 1:
return R.string.account_preferences_media_tab;
case 2:
return R.string.account_preferences_advanced_tab;
case 3:
return R.string.account_preferences_security_tab;
default:
return -1;
}
}
@Override
public int getCount() {
return isRing ? 3 : 4;
......@@ -310,35 +339,5 @@ public class AccountEditionActivity extends AppCompatActivity implements Account
result.setArguments(args);
return result;
}
@StringRes
private static int getRingPanelTitle(int position) {
switch (position) {
case 0:
return R.string.account_preferences_basic_tab;
case 1:
return R.string.account_preferences_media_tab;
case 2:
return R.string.account_preferences_advanced_tab;
default:
return -1;
}
}
@StringRes
private static int getSIPPanelTitle(int position) {
switch (position) {
case 0:
return R.string.account_preferences_basic_tab;
case 1:
return R.string.account_preferences_media_tab;
case 2:
return R.string.account_preferences_advanced_tab;
case 3:
return R.string.account_preferences_security_tab;
default:
return -1;
}
}
}
}
......@@ -16,7 +16,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cx.ring.account;
import javax.inject.Inject;
......
......@@ -16,7 +16,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cx.ring.account;
public interface AccountEditionView {
......
/*
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
* Copyright (C) 2004-2017 Savoir-faire Linux Inc.
*
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
......@@ -18,7 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.account;
import android.app.Activity;
......
......@@ -16,7 +16,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cx.ring.account;
import android.graphics.Color;
......@@ -143,6 +142,17 @@ public class AccountsAdapter extends BaseAdapter {
return rowView;
}
public void replaceAll(List<Account> results) {
Log.d(TAG, "AccountsAdapter replaceAll " + results.size());
accounts.clear();
accounts.addAll(results);
notifyDataSetChanged();
}
public interface AccountListeners {
void onItemClicked(String accountId, HashMap<String, String> details);
}
/**
* ******************
* ViewHolder Pattern
......@@ -155,15 +165,4 @@ public class AccountsAdapter extends BaseAdapter {
public ImageView errorIndicator;
public CheckBox enabled;
}
public void replaceAll(List<Account> results) {
Log.d(TAG, "AccountsAdapter replaceAll " + results.size());
accounts.clear();
accounts.addAll(results);
notifyDataSetChanged();
}
public interface AccountListeners {
void onItemClicked(String accountId, HashMap<String, String> details);
}
}
......@@ -39,27 +39,17 @@ import butterknife.OnEditorAction;
import cx.ring.R;
public class ConfirmRevocationDialog extends DialogFragment {
static final String TAG = ConfirmRevocationDialog.class.getSimpleName();
public static final String DEVICEID_KEY = "deviceid_key";
private String mDeviceId;
public interface ConfirmRevocationListener {
void onConfirmRevocation(String deviceId, String password);
}
static final String TAG = ConfirmRevocationDialog.class.getSimpleName();
@BindView(R.id.ring_password_txt_box)
protected TextInputLayout mPasswordTxtBox;
@BindView(R.id.ring_password_txt)
protected EditText mPasswordTxt;
@BindString(R.string.enter_password)
protected String mPromptPassword;
@BindString(R.string.revoke_device_title)
protected String mRegisterTitle;
private String mDeviceId;
private ConfirmRevocationListener mListener = null;
public void setListener(ConfirmRevocationListener listener) {
......@@ -139,4 +129,8 @@ public class ConfirmRevocationDialog extends DialogFragment {
}
return false;
}
public interface ConfirmRevocationListener {
void onConfirmRevocation(String deviceId, String password);
}
}
/*
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
* Copyright (C) 2004-2017 Savoir-faire Linux Inc.
*
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
......@@ -38,11 +38,6 @@ public class DeviceAdapter extends BaseAdapter {
private String mCurrentDeviceId;
private DeviceRevocationListener mListener;
public interface DeviceRevocationListener {
void onDeviceRevocationAsked(String deviceId);
void onDeviceRename();
}
public DeviceAdapter(Context c, Map<String, String> devices, String currentDeviceId,
DeviceRevocationListener listener) {
mContext = c;
......@@ -117,4 +112,10 @@ public class DeviceAdapter extends BaseAdapter {
return view;
}
public interface DeviceRevocationListener {
void onDeviceRevocationAsked(String deviceId);
void onDeviceRename();
}
}
/*
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
* Copyright (C) 2004-2017 Savoir-faire Linux Inc.
*
* Author: Aline Bonnet <aline.bonnet@savoirfairelinux.com>
*
......@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.account;
import android.app.Fragment;
......
/*
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
* Copyright (C) 2004-2017 Savoir-faire Linux Inc.
*
* Author: Aline Bonnet <aline.bonnet@savoirfairelinux.com>
*
......@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.account;
import android.Manifest;
......
/*
* Copyright (C) 2016 Savoir-faire Linux Inc.
* Copyright (C) 2016-2017 Savoir-faire Linux Inc.
*
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
*
......@@ -52,46 +52,29 @@ import cx.ring.utils.RegisteredNameTextWatcher;
public class RegisterNameDialog extends DialogFragment implements Observer<ServiceEvent> {
static final String TAG = RegisterNameDialog.class.getSimpleName();
public interface RegisterNameDialogListener {
void onRegisterName(String name, String password);
}
@Inject
AccountService mAccountService;
@BindString(R.string.username_already_taken)
String mUserNameAlreadyTaken;
@BindString(R.string.invalid_username)
String mInvalidUsername;
@BindView(R.id.ring_username_txt_box)
public TextInputLayout mUsernameTxtBox;
@BindView(R.id.ring_username)
public EditText mUsernameTxt;
@BindView(R.id.ring_password_txt_box)
public TextInputLayout mPasswordTxtBox;
@BindView(R.id.ring_password_txt)
public EditText mPasswordTxt;
@BindString(R.string.register_name)
public String mRegisterTitle;
@BindString(R.string.register_username)
public String mRegisterMessage;
@BindString(R.string.prompt_new_username)
public String mPromptUsername;
@BindString(R.string.prompt_password)
public String mPromptPassword;
@Inject
AccountService mAccountService;
@BindString(R.string.username_already_taken)
String mUserNameAlreadyTaken;
@BindString(R.string.invalid_username)
String mInvalidUsername;
private TextWatcher mUsernameTextWatcher;
private RegisterNameDialogListener mListener = null;
public void setListener(RegisterNameDialogListener l) {
......@@ -296,4 +279,8 @@ public class RegisterNameDialog extends DialogFragment implements Observer<Servi
}
return false;
}
public interface RegisterNameDialogListener {
void onRegisterName(String name, String password);
}
}
......@@ -38,22 +38,14 @@ import butterknife.OnEditorAction;
import cx.ring.R;
public class RenameDeviceDialog extends DialogFragment {
static final String TAG = RenameDeviceDialog.class.getSimpleName();
public static final String DEVICENAME_KEY = "devicename_key";
public interface RenameDeviceListener {
void onDeviceRename(String newName);
}
static final String TAG = RenameDeviceDialog.class.getSimpleName();
@BindView(R.id.ring_device_name_txt_box)
public TextInputLayout mDeviceNameTxtBox;
@BindString(R.string.account_device_name_empty)
protected String mPromptDeviceName;
@BindView(R.id.ring_device_name_txt)
public EditText mDeviceNameTxt;
@BindString(R.string.account_device_name_empty)
protected String mPromptDeviceName;
private RenameDeviceListener mListener = null;
public void setListener(RenameDeviceListener listener) {
......@@ -126,4 +118,8 @@ public class RenameDeviceDialog extends DialogFragment {
}
return false;
}
public interface RenameDeviceListener {
void onDeviceRename(String newName);
}
}
......@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.account;
import android.app.Activity;
......
/*
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
* Copyright (C) 2004-2017 Savoir-faire Linux Inc.
*
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
* Loïc Siret <loic.siret@savoirfairelinux.com>
......
......@@ -27,8 +27,31 @@ import cx.ring.mvp.RingAccountViewModel;
public class RingAccountViewModelImpl extends RingAccountViewModel implements Parcelable {
public static final Creator<RingAccountViewModelImpl> CREATOR = new Creator<RingAccountViewModelImpl>() {
@Override
public RingAccountViewModelImpl createFromParcel(Parcel source) {
return new RingAccountViewModelImpl(source);
}
@Override
public RingAccountViewModelImpl[] newArray(int size) {
return new RingAccountViewModelImpl[size];
}
};
private Bitmap photo;
public RingAccountViewModelImpl() {
}
protected RingAccountViewModelImpl(Parcel in) {
this.photo = in.readParcelable(Bitmap.class.getClassLoader());
this.mFullName = in.readString();
this.mUsername = in.readString();
this.mPassword = in.readString();
this.mPin = in.readString();
this.link = in.readByte() != 0;
}
public Bitmap getPhoto() {
return photo;
}
......@@ -51,28 +74,4 @@ public class RingAccountViewModelImpl extends RingAccountViewModel implements Pa
dest.writeString(this.mPin);
dest.writeByte(this.link ? (byte) 1 : (byte) 0);
}
public RingAccountViewModelImpl() {
}
protected RingAccountViewModelImpl(Parcel in) {
this.photo = in.readParcelable(Bitmap.class.getClassLoader());
this.mFullName = in.readString();
this.mUsername = in.readString();
this.mPassword = in.readString();
this.mPin = in.readString();
this.link = in.readByte() != 0;
}
public static final Creator<RingAccountViewModelImpl> CREATOR = new Creator<RingAccountViewModelImpl>() {
@Override
public RingAccountViewModelImpl createFromParcel(Parcel source) {
return new RingAccountViewModelImpl(source);
}
@Override
public RingAccountViewModelImpl[] newArray(int size) {
return new RingAccountViewModelImpl[size];
}
};
}
......@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.account;
import android.os.Bundle;
......
/*
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
* Copyright (C) 2004-2017 Savoir-faire Linux Inc.
*
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
......@@ -18,7 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.adapters;
import android.content.ContentResolver;
......@@ -46,34 +45,16 @@ import ezvcard.VCard;
public class ContactDetailsTask implements Runnable {
static final String TAG = ContactDetailsTask.class.getSimpleName();
private final CallContact mContact;
private Context mContext;
private final ArrayList<DetailsLoadedCallback> mCallbacks = new ArrayList<>(1);
private final int mViewWidth, mViewHeight;
private final static String MIME_TYPE_JPG = "image/jpg";
private final static String MIME_TYPE_JPEG = "image/jpeg";
private final static String MIME_TYPE_PNG = "image/png";
private final static int ORIENTATION_LEFT = 270;
private final static int ORIENTATION_RIGHT = 90;
private final static int MAX_IMAGE_DIMENSION = 200;
public void addCallback(DetailsLoadedCallback cb) {
synchronized (mCallbacks) {
if (cb == null) {
return;
}
mCallbacks.add(cb);
}
}
public interface DetailsLoadedCallback {
void onDetailsLoaded(Bitmap bmp, String formattedName, String username);
}
private final CallContact mContact;
private final ArrayList<DetailsLoadedCallback> mCallbacks = new ArrayList<>(1);
private final int mViewWidth, mViewHeight;
private Context mContext;
public ContactDetailsTask(Context context, CallContact item, DetailsLoadedCallback cb) {
mViewWidth = 0;
......@@ -96,53 +77,6 @@ public class ContactDetailsTask implements Runnable {
return BitmapFactory.decodeStream(input);
}
@Override
public void run() {
if (mContact == null) {
return;
}
Log.i(TAG, "ContactDetailsTask run " + mContact.getId() + " " + mContact.getDisplayName());
final Bitmap externalBMP;
if (!mContact.detailsLoaded && !mContact.getPhones().isEmpty()) {
String username = mContact.getPhones().get(0).getNumber().getRawRingId();
Log.d(TAG, "getPhones not empty. Username : " + username);
VCard vcard = VCardUtils.loadPeerProfileFromDisk(mContext.getFilesDir(), username + ".vcf");
mContact.setVCardProfile(vcard);
}
byte[] photo = mContact.getPhoto();
if (photo != null) {
externalBMP = BitmapUtils.cropImageToCircle(photo);
} else if (mContact.getId() > 0) {
Bitmap photoBmp;
try {
photoBmp = loadContactPhoto(mContext.getContentResolver(), mContact.getId());
} catch (IllegalArgumentException e) {
photoBmp = null;
}
if (photoBmp == null) {
photoBmp = decodeSampledBitmapFromResource(mContext.getResources(), R.drawable.ic_contact_picture, mViewWidth, mViewHeight);
}
mContact.setPhoto(BitmapUtils.bitmapToBytes(photoBmp));
externalBMP = BitmapUtils.cropImageToCircle(photoBmp);
photoBmp.recycle();
} else {
externalBMP = decodeSampledBitmapFromResource(mContext.getResources(), R.drawable.ic_contact_picture, mViewWidth, mViewHeight);
}
synchronized (mCallbacks) {
for (DetailsLoadedCallback cb : mCallbacks) {
cb.onDetailsLoaded(externalBMP, mContact.getDisplayName(), mContact.getRingUsername());
}
mCallbacks.clear();
}
}
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight) {
final BitmapFactory.Options options = new BitmapFactory.Options();
......@@ -246,4 +180,64 @@ public class ContactDetailsTask implements Runnable {
cursor.moveToFirst();
return cursor.getInt(0);
}
public void addCallback(DetailsLoadedCallback cb) {
synchronized (mCallbacks) {
if (cb == null) {
return;
}
mCallbacks.add(cb);
}
}
@Override
public void run() {
if (mContact == null) {
return;
}
Log.i(TAG, "ContactDetailsTask run " + mContact.getId() + " " + mContact.getDisplayName());
final Bitmap externalBMP;
if (!mContact.detailsLoaded && !mContact.getPhones().isEmpty()) {
String username = mContact.getPhones().get(0).getNumber().getRawRingId();
Log.d(TAG, "getPhones not empty. Username : " + username);
VCard vcard = VCardUtils.loadPeerProfileFromDisk(mContext.getFilesDir(), username + ".vcf");
mContact.setVCardProfile(vcard);
}
byte[] photo = mContact.getPhoto();
if (photo != null) {
externalBMP = BitmapUtils.cropImageToCircle(photo);
} else if (mContact.getId() > 0) {
Bitmap photoBmp;
try {
photoBmp = loadContactPhoto(mContext.getContentResolver(), mContact.getId());
} catch (IllegalArgumentException e) {
photoBmp = null;
}
if (photoBmp == null) {
photoBmp = decodeSampledBitmapFromResource(mContext.getResources(), R.drawable.ic_contact_picture, mViewWidth, mViewHeight);
}
mContact.setPhoto(BitmapUtils.bitmapToBytes(photoBmp));
externalBMP = BitmapUtils.cropImageToCircle(photoBmp);
photoBmp.recycle();
} else {
externalBMP = decodeSampledBitmapFromResource(mContext.getResources(), R.drawable.ic_contact_picture, mViewWidth, mViewHeight);
}
synchronized (mCallbacks) {
for (DetailsLoadedCallback cb : mCallbacks) {
cb.onDetailsLoaded(externalBMP, mContact.getDisplayName(), mContact.getRingUsername());
}
mCallbacks.clear();
}
}
public interface DetailsLoadedCallback {
void onDetailsLoaded(Bitmap bmp, String formattedName, String username);
}
}
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Copyright (C) 2015-2017 Savoir-faire Linux Inc.
*
* Authors: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
* Romain Bertozzi <romain.bertozzi@savoirfairelinux.com>
......@@ -18,7 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.adapters;
import android.content.Context;
......@@ -52,22 +51,6 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationViewHo
private final ArrayList<Conversation.ConversationElement> mTexts = new ArrayList<>();
private byte[] mPhoto;
public enum ConversationMessageType {
INCOMING_TEXT_MESSAGE(0),
OUTGOING_TEXT_MESSAGE(1),
CALL_INFORMATION_TEXT_MESSAGE(2);
int type;
ConversationMessageType(int p) {
type = p;
}
public int getType() {
return type;
}
}
/**
* Refreshes the data and notifies the changes
*
......@@ -337,4 +320,20 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationViewHo
}
return sameConfig;
}
public enum ConversationMessageType {
INCOMING_TEXT_MESSAGE(0),
OUTGOING_TEXT_MESSAGE(1),
CALL_INFORMATION_TEXT_MESSAGE(2);
int type;
ConversationMessageType(int p) {
type = p;
}
public int getType() {
return type;
}
}
}
\ No newline at end of file
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Copyright (C) 2015-2017 Savoir-faire Linux Inc.
*
* Authors: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
* Romain Bertozzi <romain.bertozzi@savoirfairelinux.com>
......@@ -18,7 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.adapters;
import android.content.Context;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment