diff --git a/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/NoTitle.java b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/NoTitle.java index f800661e80..5f29c999a2 100644 --- a/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/NoTitle.java +++ b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/NoTitle.java @@ -22,10 +22,15 @@ /** * Should be used on Activity classes that must have no title. - * + *

* The activity must be annotated with {@link EActivity}. + *

+ * Note: This annotation has been deprecated. Please use + * {@code WindowFeature(Window.FEATURE_NO_TITLE})} instead * + * @see WindowFeature */ +@Deprecated @Retention(RetentionPolicy.CLASS) @Target(ElementType.TYPE) public @interface NoTitle { diff --git a/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/WindowFeature.java b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/WindowFeature.java new file mode 100644 index 0000000000..1f3c9c5842 --- /dev/null +++ b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/WindowFeature.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2010-2013 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.androidannotations.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Should be used on Activity classes that must have no title. + * + * The activity must be annotated with {@link EActivity}. + * + */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface WindowFeature { + + int[] value(); + +} diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java index 4f7de7646c..355828169c 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java +++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java @@ -89,6 +89,7 @@ import org.androidannotations.annotations.Transactional; import org.androidannotations.annotations.UiThread; import org.androidannotations.annotations.ViewById; +import org.androidannotations.annotations.WindowFeature; import org.androidannotations.annotations.res.AnimationRes; import org.androidannotations.annotations.res.BooleanRes; import org.androidannotations.annotations.res.ColorRes; @@ -187,6 +188,7 @@ import org.androidannotations.processing.TransactionalProcessor; import org.androidannotations.processing.UiThreadProcessor; import org.androidannotations.processing.ViewByIdProcessor; +import org.androidannotations.processing.WindowFeatureProcessor; import org.androidannotations.processing.rest.DeleteProcessor; import org.androidannotations.processing.rest.GetProcessor; import org.androidannotations.processing.rest.HeadProcessor; @@ -257,6 +259,7 @@ import org.androidannotations.validation.TraceValidator; import org.androidannotations.validation.TransactionalValidator; import org.androidannotations.validation.ViewByIdValidator; +import org.androidannotations.validation.WindowFeatureValidator; import org.androidannotations.validation.rest.AcceptValidator; import org.androidannotations.validation.rest.DeleteValidator; import org.androidannotations.validation.rest.GetValidator; @@ -426,6 +429,7 @@ private ModelValidator buildModelValidator(IRClass rClass, AndroidSystemServices modelValidator.register(new OptionsMenuItemValidator(processingEnv, rClass)); modelValidator.register(new OptionsItemValidator(processingEnv, rClass)); modelValidator.register(new NoTitleValidator(processingEnv)); + modelValidator.register(new WindowFeatureValidator(processingEnv)); modelValidator.register(new CustomTitleValidator(processingEnv, rClass)); modelValidator.register(new FullscreenValidator(processingEnv)); modelValidator.register(new RestServiceValidator(processingEnv)); @@ -522,6 +526,7 @@ private ModelProcessor buildModelProcessor(IRClass rClass, AndroidSystemServices modelProcessor.register(new OptionsMenuItemProcessor(processingEnv, rClass)); modelProcessor.register(new OptionsItemProcessor(processingEnv, rClass)); modelProcessor.register(new NoTitleProcessor()); + modelProcessor.register(new WindowFeatureProcessor()); modelProcessor.register(new CustomTitleProcessor(processingEnv, rClass)); modelProcessor.register(new FullscreenProcessor()); modelProcessor.register(new RestServiceProcessor()); @@ -642,6 +647,7 @@ public Set getSupportedAnnotationTypes() { OptionsItem.class, // HtmlRes.class, // NoTitle.class, // + WindowFeature.class, // CustomTitle.class, // Fullscreen.class, // RestService.class, // diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/WindowFeatureProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/WindowFeatureProcessor.java new file mode 100644 index 0000000000..b1107b356b --- /dev/null +++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/WindowFeatureProcessor.java @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2010-2013 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.androidannotations.processing; + +import javax.lang.model.element.Element; + +import org.androidannotations.annotations.WindowFeature; + +import com.sun.codemodel.JCodeModel; +import com.sun.codemodel.JExpr; + +public class WindowFeatureProcessor implements DecoratingElementProcessor { + + @Override + public String getTarget() { + return WindowFeature.class.getName(); + } + + @Override + public void process(Element element, JCodeModel codeModel, EBeanHolder holder) { + WindowFeature annotation = element.getAnnotation(WindowFeature.class); + int[] features = annotation.value(); + + for (int feature : features) { + holder.initBody.invoke("requestWindowFeature").arg(JExpr.lit(feature)); + } + } + +} diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/validation/WindowFeatureValidator.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/validation/WindowFeatureValidator.java new file mode 100644 index 0000000000..644b00236b --- /dev/null +++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/validation/WindowFeatureValidator.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2010-2013 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.androidannotations.validation; + +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; + +import org.androidannotations.annotations.WindowFeature; +import org.androidannotations.helper.TargetAnnotationHelper; +import org.androidannotations.helper.ValidatorHelper; +import org.androidannotations.model.AnnotationElements; + +public class WindowFeatureValidator implements ElementValidator { + + private ValidatorHelper validatorHelper; + + public WindowFeatureValidator(ProcessingEnvironment processingEnv) { + TargetAnnotationHelper annotationHelper = new TargetAnnotationHelper(processingEnv, getTarget()); + validatorHelper = new ValidatorHelper(annotationHelper); + } + + @Override + public String getTarget() { + return WindowFeature.class.getName(); + } + + @Override + public boolean validate(Element element, AnnotationElements validatedElements) { + IsValid valid = new IsValid(); + + validatorHelper.hasEActivity(element, validatedElements, valid); + + return valid.isValid(); + } + +} diff --git a/AndroidAnnotations/functional-test-1-5/AndroidManifest.xml b/AndroidAnnotations/functional-test-1-5/AndroidManifest.xml index 9ac6259141..209067cb91 100644 --- a/AndroidAnnotations/functional-test-1-5/AndroidManifest.xml +++ b/AndroidAnnotations/functional-test-1-5/AndroidManifest.xml @@ -65,6 +65,7 @@ + diff --git a/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/WindowFeatureActivity.java b/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/WindowFeatureActivity.java new file mode 100644 index 0000000000..4e4f58f210 --- /dev/null +++ b/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/WindowFeatureActivity.java @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2010-2013 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.androidannotations.test15; + +import org.androidannotations.annotations.EActivity; +import org.androidannotations.annotations.Fullscreen; +import org.androidannotations.annotations.WindowFeature; + +import android.app.Activity; +import android.view.Window; + +@EActivity +@Fullscreen +@WindowFeature({ Window.FEATURE_NO_TITLE, Window.FEATURE_INDETERMINATE_PROGRESS }) +public class WindowFeatureActivity extends Activity { + +}