mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-09-06 18:01:11 +00:00
Minor refactoring
This commit is contained in:
parent
849b75f345
commit
1b5ba0b28a
|
@ -12,22 +12,6 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
public class DavUtils {
|
||||
public static final int calendarGreen = 0xFFC3EA6E;
|
||||
|
||||
public static int CalDAVtoARGBColor(String davColor) {
|
||||
int color = calendarGreen; // fallback: "DAVdroid green"
|
||||
if (davColor != null) {
|
||||
Pattern p = Pattern.compile("#?(\\p{XDigit}{6})(\\p{XDigit}{2})?");
|
||||
Matcher m = p.matcher(davColor);
|
||||
if (m.find()) {
|
||||
int color_rgb = Integer.parseInt(m.group(1), 16);
|
||||
int color_alpha = m.group(2) != null ? (Integer.parseInt(m.group(2), 16) & 0xFF) : 0xFF;
|
||||
color = (color_alpha << 24) | color_rgb;
|
||||
} else
|
||||
App.log.warning("Couldn't parse color " + davColor + ", using DAVdroid green");
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public static String ARGBtoCalDAVColor(int colorWithAlpha) {
|
||||
byte alpha = (byte)(colorWithAlpha >> 24);
|
||||
|
|
|
@ -138,7 +138,7 @@ public class SSLSocketFactoryCompat extends SSLSocketFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
|
||||
public Socket createSocket(String host, int port) throws IOException {
|
||||
Socket ssl = delegate.createSocket(host, port);
|
||||
if (ssl instanceof SSLSocket)
|
||||
upgradeTLS((SSLSocket)ssl);
|
||||
|
@ -146,7 +146,7 @@ public class SSLSocketFactoryCompat extends SSLSocketFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException {
|
||||
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException {
|
||||
Socket ssl = delegate.createSocket(host, port, localHost, localPort);
|
||||
if (ssl instanceof SSLSocket)
|
||||
upgradeTLS((SSLSocket)ssl);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect
|
|||
SYNC_STATE_CTAG = "ctag",
|
||||
SYNC_STATE_URL = "url";
|
||||
|
||||
private Bundle syncState = new Bundle();
|
||||
private final Bundle syncState = new Bundle();
|
||||
|
||||
|
||||
public LocalAddressBook(Account account, ContentProviderClient provider) {
|
||||
|
@ -165,12 +165,12 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect
|
|||
protected void readSyncState() throws ContactsStorageException {
|
||||
@Cleanup("recycle") Parcel parcel = Parcel.obtain();
|
||||
byte[] raw = getSyncState();
|
||||
syncState.clear();
|
||||
if (raw != null) {
|
||||
parcel.unmarshall(raw, 0, raw.length);
|
||||
parcel.setDataPosition(0);
|
||||
syncState = parcel.readBundle();
|
||||
} else
|
||||
syncState.clear();
|
||||
syncState.putAll(parcel.readBundle());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("Recycle")
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.fortuna.ical4j.model.component.VTimeZone;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -128,8 +129,7 @@ public class LocalCalendar extends AndroidCalendar implements LocalCollection {
|
|||
List<LocalResource> dirty = new LinkedList<>();
|
||||
|
||||
// get dirty events which are not required to have an increased SEQUENCE value
|
||||
for (LocalEvent event : (LocalEvent[])queryEvents(Events.DIRTY + "=" + DIRTY_DONT_INCREASE_SEQUENCE + " AND " + Events.ORIGINAL_ID + " IS NULL", null))
|
||||
dirty.add(event);
|
||||
Collections.addAll(dirty, (LocalEvent[])queryEvents(Events.DIRTY + "=" + DIRTY_DONT_INCREASE_SEQUENCE + " AND " + Events.ORIGINAL_ID + " IS NULL", null));
|
||||
|
||||
// get dirty events which are required to have an increased SEQUENCE value
|
||||
for (LocalEvent event : (LocalEvent[])queryEvents(Events.DIRTY + "=" + DIRTY_INCREASE_SEQUENCE + " AND " + Events.ORIGINAL_ID + " IS NULL", null)) {
|
||||
|
@ -183,6 +183,8 @@ public class LocalCalendar extends AndroidCalendar implements LocalCollection {
|
|||
originalID = cursor.getLong(1); // can't be null (by query)
|
||||
int sequence = cursor.isNull(2) ? 0 : cursor.getInt(2);
|
||||
|
||||
// FIXME sequence / cursor2 not used
|
||||
|
||||
// get original event's SEQUENCE
|
||||
@Cleanup Cursor cursor2 = provider.query(
|
||||
syncAdapterURI(ContentUris.withAppendedId(Events.CONTENT_URI, originalID)),
|
||||
|
|
|
@ -121,7 +121,6 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
|
|||
requestSync();
|
||||
break;
|
||||
case R.id.settings:
|
||||
Bundle args = new Bundle(1);
|
||||
Intent intent = new Intent(this, AccountSettingsActivity.class);
|
||||
intent.putExtra(AccountSettingsActivity.EXTRA_ACCOUNT, account);
|
||||
startActivity(intent);
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.database.Cursor;
|
|||
import android.database.DatabaseUtils;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.app.NavUtils;
|
||||
|
@ -142,6 +143,7 @@ public class CreateAddressBookActivity extends AppCompatActivity implements Load
|
|||
getLoaderManager().initLoader(0, getArguments(), this);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Dialog dialog = new ProgressDialog.Builder(getActivity())
|
||||
|
@ -155,7 +157,7 @@ public class CreateAddressBookActivity extends AppCompatActivity implements Load
|
|||
|
||||
@Override
|
||||
public Loader<Exception> onCreateLoader(int id, Bundle args) {
|
||||
Account account = (Account)args.getParcelable(ARGS_ACCOUNT);
|
||||
Account account = args.getParcelable(ARGS_ACCOUNT);
|
||||
CollectionInfo info = (CollectionInfo)args.getSerializable(ARGS_COLLECTION_INFO);
|
||||
return new AddressBookCreator(getActivity(), account, info);
|
||||
}
|
||||
|
@ -263,7 +265,7 @@ public class CreateAddressBookActivity extends AppCompatActivity implements Load
|
|||
|
||||
List<HashMap<String, String>> adapterData = new LinkedList<>();
|
||||
for (HomeSet homeSet : data.homeSets) {
|
||||
HashMap<String, String> map = new HashMap();
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put(ServiceDB.HomeSets.ID, String.valueOf(homeSet.id));
|
||||
map.put(ServiceDB.HomeSets.URL, homeSet.URL);
|
||||
adapterData.add(map);
|
||||
|
|
|
@ -217,7 +217,7 @@ public class CreateCollectionFragment extends DialogFragment implements LoaderMa
|
|||
SQLiteDatabase db = dbHelper.getWritableDatabase();
|
||||
|
||||
// 1. find service ID
|
||||
String serviceType = null;
|
||||
String serviceType;
|
||||
if (info.type == CollectionInfo.Type.ADDRESS_BOOK)
|
||||
serviceType = ServiceDB.Services.SERVICE_CARDDAV;
|
||||
else if (info.type == CollectionInfo.Type.CALENDAR)
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.app.Dialog;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
|
@ -20,7 +21,6 @@ import java.io.IOException;
|
|||
|
||||
import at.bitfire.dav4android.exception.HttpException;
|
||||
import at.bitfire.davdroid.R;
|
||||
import lombok.NonNull;
|
||||
|
||||
public class ExceptionInfoFragment extends DialogFragment {
|
||||
protected static final String
|
||||
|
@ -36,6 +36,7 @@ public class ExceptionInfoFragment extends DialogFragment {
|
|||
return frag;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Bundle args = getArguments();
|
||||
|
|
|
@ -37,12 +37,11 @@ public class LoginCredentials implements Parcelable {
|
|||
public static final Creator CREATOR = new Creator<LoginCredentials>() {
|
||||
@Override
|
||||
public LoginCredentials createFromParcel(Parcel source) {
|
||||
LoginCredentials credentials = new LoginCredentials(
|
||||
return new LoginCredentials(
|
||||
(URI)source.readSerializable(),
|
||||
source.readString(), source.readString(),
|
||||
(boolean)source.readValue(null)
|
||||
);
|
||||
return credentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue