Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (C) 2010-2012 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;

/**
* Use it on activities to set a custom title layout.
*
* The activity must be annotated with {@link EActivity}.
*
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface CustomTitle {
int value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.androidannotations.annotations.ItemSelect;
import org.androidannotations.annotations.LongClick;
import org.androidannotations.annotations.NoTitle;
import org.androidannotations.annotations.CustomTitle;
import org.androidannotations.annotations.NonConfigurationInstance;
import org.androidannotations.annotations.OnActivityResult;
import org.androidannotations.annotations.OptionsItem;
Expand Down Expand Up @@ -148,6 +149,7 @@
import org.androidannotations.processing.ModelProcessor;
import org.androidannotations.processing.ModelProcessor.ProcessResult;
import org.androidannotations.processing.NoTitleProcessor;
import org.androidannotations.processing.CustomTitleProcessor;
import org.androidannotations.processing.NonConfigurationInstanceProcessor;
import org.androidannotations.processing.OnActivityResultProcessor;
import org.androidannotations.processing.OptionsItemProcessor;
Expand Down Expand Up @@ -211,6 +213,7 @@
import org.androidannotations.validation.LongClickValidator;
import org.androidannotations.validation.ModelValidator;
import org.androidannotations.validation.NoTitleValidator;
import org.androidannotations.validation.CustomTitleValidator;
import org.androidannotations.validation.NonConfigurationInstanceValidator;
import org.androidannotations.validation.OnActivityResultValidator;
import org.androidannotations.validation.OptionsItemValidator;
Expand Down Expand Up @@ -290,6 +293,7 @@
OptionsItem.class, //
HtmlRes.class, //
NoTitle.class, //
CustomTitle.class, //
Fullscreen.class, //
RestService.class, //
EBean.class, //
Expand Down Expand Up @@ -462,6 +466,7 @@ private ModelValidator buildModelValidator(IRClass rClass, AndroidSystemServices
modelValidator.register(new OptionsMenuValidator(processingEnv, rClass));
modelValidator.register(new OptionsItemValidator(processingEnv, rClass));
modelValidator.register(new NoTitleValidator(processingEnv));
modelValidator.register(new CustomTitleValidator(processingEnv, rClass));
modelValidator.register(new FullscreenValidator(processingEnv));
modelValidator.register(new RestServiceValidator(processingEnv));
modelValidator.register(new RootContextValidator(processingEnv));
Expand Down Expand Up @@ -550,6 +555,7 @@ private ModelProcessor buildModelProcessor(IRClass rClass, AndroidSystemServices
modelProcessor.register(new OptionsMenuProcessor(processingEnv, rClass));
modelProcessor.register(new OptionsItemProcessor(processingEnv, rClass));
modelProcessor.register(new NoTitleProcessor());
modelProcessor.register(new CustomTitleProcessor(processingEnv, rClass));
modelProcessor.register(new FullscreenProcessor());
modelProcessor.register(new RestServiceProcessor());
modelProcessor.register(new OrmLiteDaoProcessor(processingEnv));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (C) 2010-2012 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 org.androidannotations.annotations.CustomTitle;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JFieldRef;
import org.androidannotations.helper.AnnotationHelper;
import org.androidannotations.rclass.IRClass;
import org.androidannotations.rclass.IRClass.Res;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import java.lang.annotation.Annotation;

public class CustomTitleProcessor implements DecoratingElementProcessor {
private final AnnotationHelper annotationHelper;
private final IRClass rClass;

public CustomTitleProcessor(ProcessingEnvironment processingEnv, IRClass rClass) {
annotationHelper = new AnnotationHelper(processingEnv);
this.rClass = rClass;
}

@Override
public Class<? extends Annotation> getTarget() {
return CustomTitle.class;
}

@Override
public void process(Element element, JCodeModel codeModel, EBeanHolder holder) {
JFieldRef customTitleFeature = holder.classes().WINDOW.staticRef("FEATURE_CUSTOM_TITLE");

holder.init.body().invoke("requestWindowFeature").arg(customTitleFeature);
JFieldRef contentViewId = annotationHelper.extractAnnotationFieldRefs(holder, element, CustomTitle.class, rClass.get(Res.LAYOUT), false).get(0);
holder.afterSetContentView.body().add(holder.contextRef.invoke("getWindow").invoke("setFeatureInt").arg(customTitleFeature).arg(contentViewId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (C) 2010-2012 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 org.androidannotations.annotations.CustomTitle;
import org.androidannotations.helper.IdAnnotationHelper;
import org.androidannotations.helper.IdValidatorHelper;
import org.androidannotations.model.AnnotationElements;
import org.androidannotations.rclass.IRClass;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import java.lang.annotation.Annotation;

public class CustomTitleValidator implements ElementValidator {

private IdValidatorHelper validatorHelper;

public CustomTitleValidator(ProcessingEnvironment processingEnv, IRClass rClass) {
IdAnnotationHelper annotationHelper = new IdAnnotationHelper(processingEnv, getTarget(), rClass);
validatorHelper = new IdValidatorHelper(annotationHelper);
}

@Override
public Class<? extends Annotation> getTarget() {
return CustomTitle.class;
}

@Override
public boolean validate(Element element, AnnotationElements validatedElements) {
IsValid valid = new IsValid();

validatorHelper.hasEActivity(element, validatedElements, valid);

validatorHelper.resIdsExist(element, IRClass.Res.LAYOUT, IdValidatorHelper.FallbackStrategy.NEED_RES_ID, valid);

return valid.isValid();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (C) 2010-2012 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 android.app.Activity;

import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.CustomTitle;

@EActivity
@CustomTitle(R.layout.component)
public class CustomTitleActivity extends Activity {
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.