diff --git a/app/src/main/java/at/bitfire/davdroid/DavUtils.java b/app/src/main/java/at/bitfire/davdroid/DavUtils.java index 628c050d..274f9672 100644 --- a/app/src/main/java/at/bitfire/davdroid/DavUtils.java +++ b/app/src/main/java/at/bitfire/davdroid/DavUtils.java @@ -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); diff --git a/app/src/main/java/at/bitfire/davdroid/SSLSocketFactoryCompat.java b/app/src/main/java/at/bitfire/davdroid/SSLSocketFactoryCompat.java index a4e2e6df..637d70c0 100644 --- a/app/src/main/java/at/bitfire/davdroid/SSLSocketFactoryCompat.java +++ b/app/src/main/java/at/bitfire/davdroid/SSLSocketFactoryCompat.java @@ -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); diff --git a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java index d43b0206..a89a3b10 100644 --- a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java +++ b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java @@ -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") diff --git a/app/src/main/java/at/bitfire/davdroid/resource/LocalCalendar.java b/app/src/main/java/at/bitfire/davdroid/resource/LocalCalendar.java index 8a14f58e..76b0a85b 100644 --- a/app/src/main/java/at/bitfire/davdroid/resource/LocalCalendar.java +++ b/app/src/main/java/at/bitfire/davdroid/resource/LocalCalendar.java @@ -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 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)), diff --git a/app/src/main/java/at/bitfire/davdroid/ui/AccountActivity.java b/app/src/main/java/at/bitfire/davdroid/ui/AccountActivity.java index 53b63ad1..38c93f39 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/AccountActivity.java +++ b/app/src/main/java/at/bitfire/davdroid/ui/AccountActivity.java @@ -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); diff --git a/app/src/main/java/at/bitfire/davdroid/ui/CreateAddressBookActivity.java b/app/src/main/java/at/bitfire/davdroid/ui/CreateAddressBookActivity.java index e0529fb1..67626980 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/CreateAddressBookActivity.java +++ b/app/src/main/java/at/bitfire/davdroid/ui/CreateAddressBookActivity.java @@ -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 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> adapterData = new LinkedList<>(); for (HomeSet homeSet : data.homeSets) { - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); map.put(ServiceDB.HomeSets.ID, String.valueOf(homeSet.id)); map.put(ServiceDB.HomeSets.URL, homeSet.URL); adapterData.add(map); diff --git a/app/src/main/java/at/bitfire/davdroid/ui/CreateCollectionFragment.java b/app/src/main/java/at/bitfire/davdroid/ui/CreateCollectionFragment.java index 387f015f..d86e7c3b 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/CreateCollectionFragment.java +++ b/app/src/main/java/at/bitfire/davdroid/ui/CreateCollectionFragment.java @@ -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) diff --git a/app/src/main/java/at/bitfire/davdroid/ui/ExceptionInfoFragment.java b/app/src/main/java/at/bitfire/davdroid/ui/ExceptionInfoFragment.java index 548fabad..02993709 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/ExceptionInfoFragment.java +++ b/app/src/main/java/at/bitfire/davdroid/ui/ExceptionInfoFragment.java @@ -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(); diff --git a/app/src/main/java/at/bitfire/davdroid/ui/setup/LoginCredentials.java b/app/src/main/java/at/bitfire/davdroid/ui/setup/LoginCredentials.java index d1edd32a..648d51a0 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/setup/LoginCredentials.java +++ b/app/src/main/java/at/bitfire/davdroid/ui/setup/LoginCredentials.java @@ -37,12 +37,11 @@ public class LoginCredentials implements Parcelable { public static final Creator CREATOR = new Creator() { @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