Skip to content

Commit a486f2f

Browse files
committed
Merge branch 'hotfix-3.3.1' into develop
2 parents a9deed6 + f3757d9 commit a486f2f

30 files changed

Lines changed: 274 additions & 21 deletions

File tree

‎AndroidAnnotations/androidannotations-api/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>androidannotations-parent</artifactId>
2424
<groupId>org.androidannotations</groupId>
25-
<version>3.4-SNAPSHOT</version>
25+
<version>4.0-SNAPSHOT</version>
2626
</parent>
2727

2828
<artifactId>androidannotations-api</artifactId>

‎AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/PreferenceChange.java‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@
4141
* <ul>
4242
* <li>A {@link android.preference.Preference Preference} parameter to know
4343
* which preference was targeted by this event</li>
44-
* <li>An {@link Object} or {@link java.util.Set Set of strings} or
45-
* {@link Boolean} or {@link String} to obtain the new value of the
46-
* {@link android.preference.Preference Preference}</li>
44+
* <li>An {@link Object}, {@link String}, {@link java.util.Set Set of strings}
45+
* and also a {@link Boolean}, {@link Float}, {@link Integer}, {@link Long} or
46+
* their corresponding primitive types to obtain the new value of the
47+
* {@link android.preference.Preference Preference}. Please note with number
48+
* types, we assume that the <code>newValue</code> parameter coming from the
49+
* {@link android.preference.Preference Preference} is a {@link String}, so we
50+
* parse it to a number object (Android {@link android.preference.Preference
51+
* Preference} classes use {@link String}s instead of number objects).</li>
4752
* </ul>
4853
* <blockquote>
4954
*

‎AndroidAnnotations/androidannotations-bundle/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>androidannotations-parent</artifactId>
2424
<groupId>org.androidannotations</groupId>
25-
<version>3.4-SNAPSHOT</version>
25+
<version>4.0-SNAPSHOT</version>
2626
</parent>
2727

2828
<artifactId>androidannotations-bundle</artifactId>

‎AndroidAnnotations/androidannotations-with-codemodel/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>androidannotations-parent</artifactId>
2424
<groupId>org.androidannotations</groupId>
25-
<version>3.4-SNAPSHOT</version>
25+
<version>4.0-SNAPSHOT</version>
2626
</parent>
2727

2828
<artifactId>androidannotations-with-codemodel</artifactId>

‎AndroidAnnotations/androidannotations/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.androidannotations</groupId>
2424
<artifactId>androidannotations-parent</artifactId>
25-
<version>3.4-SNAPSHOT</version>
25+
<version>4.0-SNAPSHOT</version>
2626
</parent>
2727

2828
<artifactId>androidannotations</artifactId>

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/handler/PreferenceChangeHandler.java‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.sun.codemodel.JInvocation;
3939
import com.sun.codemodel.JMethod;
4040
import com.sun.codemodel.JMod;
41+
import com.sun.codemodel.JType;
4142
import com.sun.codemodel.JVar;
4243

4344
public class PreferenceChangeHandler extends AbstractPreferenceListenerHandler {
@@ -59,7 +60,11 @@ public void validate(Element element, AnnotationElements validatedElements, IsVa
5960

6061
validatorHelper.param.anyOrder() //
6162
.type(CanonicalNameConstants.PREFERENCE).optional() //
62-
.anyOfTypes(CanonicalNameConstants.STRING, CanonicalNameConstants.BOOLEAN, boolean.class.getName(), CanonicalNameConstants.OBJECT, CanonicalNameConstants.SET).optional() //
63+
.anyOfTypes(CanonicalNameConstants.OBJECT, CanonicalNameConstants.STRING_SET, CanonicalNameConstants.STRING, //
64+
CanonicalNameConstants.BOOLEAN, boolean.class.getName(), //
65+
CanonicalNameConstants.INTEGER, int.class.getName(), //
66+
CanonicalNameConstants.LONG, long.class.getName(), //
67+
CanonicalNameConstants.FLOAT, float.class.getName()).optional() //
6368
.validate(executableElement, valid);
6469
}
6570

@@ -80,13 +85,24 @@ protected void processParameters(HasPreferences holder, JMethod listenerMethod,
8085
JVar newValueParam = listenerMethod.param(classes().OBJECT, "newValue");
8186

8287
for (VariableElement variableElement : userParameters) {
83-
if (variableElement.asType().toString().equals(CanonicalNameConstants.PREFERENCE)) {
88+
String type = variableElement.asType().toString();
89+
90+
if (type.equals(CanonicalNameConstants.PREFERENCE)) {
8491
call.arg(preferenceParam);
85-
} else if (variableElement.asType().toString().equals(CanonicalNameConstants.OBJECT)) {
92+
} else if (type.equals(CanonicalNameConstants.OBJECT)) {
8693
call.arg(newValueParam);
94+
} else if (type.equals(CanonicalNameConstants.INTEGER) || type.equals(int.class.getName()) || //
95+
type.equals(CanonicalNameConstants.FLOAT) || type.equals(float.class.getName()) || //
96+
type.equals(CanonicalNameConstants.LONG) || type.equals(long.class.getName())) {
97+
JClass wrapperClass = type.startsWith("java") ? holder.refClass(type) : JType.parse(holder.codeModel(), type.replace(".class", "")).boxify();
98+
call.arg(wrapperClass.staticInvoke("valueOf").arg(JExpr.cast(holder.classes().STRING, newValueParam)));
8799
} else {
88100
JClass userParamClass = codeModelHelper.typeMirrorToJClass(variableElement.asType(), holder);
89101
call.arg(JExpr.cast(userParamClass, newValueParam));
102+
103+
if (type.equals(CanonicalNameConstants.STRING_SET)) {
104+
codeModelHelper.addSuppressWarnings(listenerMethod, "unchecked");
105+
}
90106
}
91107
}
92108
}
@@ -105,5 +121,4 @@ protected String getSetterName() {
105121
protected JClass getListenerClass() {
106122
return classes().PREFERENCE_CHANGE_LISTENER;
107123
}
108-
109124
}

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/CanonicalNameConstants.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public final class CanonicalNameConstants {
4444
public static final String SQL_EXCEPTION = SQLException.class.getCanonicalName();
4545
public static final String INTEGER = Integer.class.getCanonicalName();
4646
public static final String BOOLEAN = Boolean.class.getCanonicalName();
47+
public static final String FLOAT = Float.class.getCanonicalName();
48+
public static final String LONG = Long.class.getCanonicalName();
4749
public static final String ARRAYLIST = ArrayList.class.getCanonicalName();
4850
public static final String SERIALIZABLE = Serializable.class.getCanonicalName();
4951

@@ -111,6 +113,8 @@ public final class CanonicalNameConstants {
111113
public static final String BUILD_VERSION_CODES = "android.os.Build.VERSION_CODES";
112114
public static final String PREFERENCE_ACTIVITY = "android.preference.PreferenceActivity";
113115
public static final String PREFERENCE_FRAGMENT = "android.preference.PreferenceFragment";
116+
public static final String SUPPORT_V4_PREFERENCE_FRAGMENT = "android.support.v4.preference.PreferenceFragment";
117+
public static final String MACHINARIUS_V4_PREFERENCE_FRAGMENT = "com.github.machinarius.preferencefragment.PreferenceFragment";
114118
public static final String ACTIVITY_COMPAT = "android.support.v4.app.ActivityCompat";
115119
public static final String PREFERENCE = "android.preference.Preference";
116120
public static final String PREFERENCE_CHANGE_LISTENER = "android.preference.Preference.OnPreferenceChangeListener";

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/ValidatorHelper.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public class ValidatorHelper {
118118
private static final List<Receiver.RegisterAt> VALID_SERVICE_REGISTER_AT = Arrays.asList(Receiver.RegisterAt.OnCreateOnDestroy);
119119
private static final List<Receiver.RegisterAt> VALID_FRAGMENT_REGISTER_AT = Arrays.asList(Receiver.RegisterAt.OnCreateOnDestroy, Receiver.RegisterAt.OnResumeOnPause, Receiver.RegisterAt.OnStartOnStop, Receiver.RegisterAt.OnAttachOnDetach);
120120

121-
private static final List<String> VALID_PREFERENCE_CLASSES = asList(CanonicalNameConstants.PREFERENCE_ACTIVITY, CanonicalNameConstants.PREFERENCE_FRAGMENT);
121+
private static final List<String> VALID_PREFERENCE_CLASSES = asList(CanonicalNameConstants.PREFERENCE_ACTIVITY, CanonicalNameConstants.PREFERENCE_FRAGMENT, CanonicalNameConstants.SUPPORT_V4_PREFERENCE_FRAGMENT, CanonicalNameConstants.MACHINARIUS_V4_PREFERENCE_FRAGMENT);
122122

123123
protected final TargetAnnotationHelper annotationHelper;
124124

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/EActivityHolder.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ protected JFieldVar setDatabaseHelperRef(TypeMirror databaseHelperTypeMirror) {
778778

779779
@Override
780780
public JBlock getPreferenceScreenInitializationBlock() {
781-
return getInitBody();
781+
return getOnCreate().body();
782782
}
783783

784784
@Override
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (C) 2010-2015 eBusiness Information, Excilys Group
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed To in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package android.support.v4.preference;
17+
18+
import android.app.Fragment; // for the test it is OK to extend normal Fragment
19+
20+
public abstract class PreferenceFragment extends Fragment {
21+
22+
public void addPreferencesFromResource(int preferencesResId) {
23+
24+
}
25+
}

0 commit comments

Comments
 (0)