Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template support for Android studio v3.6 #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions template/MVPActivity_AS_v3.6/globals.xml.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<globals>
<global id="hasNoActionBar" type="boolean" value="false" />
<global id="excludeMenu" type="boolean" value="true" />
<global id="generateActivityTitle" type="boolean" value="false" />
<#include "../common/common_globals.xml.ftl" />
</globals>
29 changes: 29 additions & 0 deletions template/MVPActivity_AS_v3.6/recipe.xml.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<#import "root://activities/common/kotlin_macros.ftl" as kt>
<recipe>
<#include "../common/recipe_manifest.xml.ftl" />
<@kt.addAllKotlinDependencies />

<dependency mavenUrl="com.android.support:appcompat-v7:${buildApi}.+"/>
<dependency mavenUrl="com.android.support.constraint:constraint-layout:+" />
<dependency mavenUrl="android.arch.lifecycle:extensions:+"/>
<#if generateKotlin && useAndroidX>
<dependency mavenUrl="androidx.lifecycle:lifecycle-viewmodel-ktx:+"/>
</#if>
<instantiate from="root/src/app_package/View.${ktOrJavaExt}.ftl"
to="${escapeXmlAttribute(srcOut)}/${folderName}/${className}MvpView.${ktOrJavaExt}" />
<instantiate from="root/src/app_package/Activity.${ktOrJavaExt}.ftl"
to="${escapeXmlAttribute(srcOut)}/${folderName}/${activityClass}.${ktOrJavaExt}" />
<instantiate from="root/src/app_package/Presenter.${ktOrJavaExt}.ftl"
to="${escapeXmlAttribute(srcOut)}/${folderName}/${className}Presenter.${ktOrJavaExt}" />
<instantiate from="root/src/app_package/MvpPresenter.${ktOrJavaExt}.ftl"
to="${escapeXmlAttribute(srcOut)}/${folderName}/${className}MvpPresenter.${ktOrJavaExt}" />

<instantiate from="root/res/layout/activity.xml.ftl"
to="${escapeXmlAttribute(resOut)}/layout/${escapeXmlAttribute(activityLayout)}.xml" />

<open file="${srcOut}/${folderName}/${className}MvpPresenter.${ktOrJavaExt}"/>
<open file="${srcOut}/${folderName}/${className}MvpView.${ktOrJavaExt}"/>
<open file="${srcOut}/${folderName}/${className}Presenter.${ktOrJavaExt}"/>
<open file="${srcOut}/${folderName}/${activityClass}.${ktOrJavaExt}"/>
</recipe>
9 changes: 9 additions & 0 deletions template/MVPActivity_AS_v3.6/root/res/layout/activity.xml.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${folderName}.${activityClass}">

</android.support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ${packageName}.${folderName};

import android.os.Bundle;
import javax.inject.Inject;
import butterknife.ButterKnife;
import com.mindorks.framework.mvp.ui.base.BaseActivity;
import android.content.Intent;
import android.content.Context;
import com.mindorks.framework.mvp.R;
public class ${className}Activity extends BaseActivity implements ${className}MvpView {

@Inject
${className}Presenter<${className}MvpView> mPresenter;

@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.${activityLayout});

getActivityComponent().inject(this);
setUnBinder(ButterKnife.bind(this));
mPresenter.onAttach(${className}Activity.this);
}

public static Intent getStartIntent(Context context) {
Intent intent = new Intent(context, ${className}Activity.class);
return intent;
}

@Override
protected void onDestroy() {
mPresenter.onDetach();
super.onDestroy();
}

@Override
protected void setUp() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ${packageName}.${folderName};

import com.mindorks.framework.mvp.ui.base.MvpPresenter;

public interface ${className}MvpPresenter<V extends ${className}MvpView> extends MvpPresenter<V> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ${packageName}.${folderName};


import com.mindorks.framework.mvp.ui.base.BasePresenter;
import com.mindorks.framework.mvp.utils.rx.SchedulerProvider;
import com.mindorks.framework.mvp.data.DataManager;
import io.reactivex.disposables.CompositeDisposable;

import javax.inject.Inject;

public class ${className}Presenter <V extends ${className}MvpView> extends BasePresenter<V> implements ${className}MvpPresenter<V> {

private static final String TAG = "${className}Presenter";

@Inject
public ${className}Presenter(DataManager dataManager,
SchedulerProvider schedulerProvider,
CompositeDisposable compositeDisposable) {
super(dataManager, schedulerProvider, compositeDisposable);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ${packageName}.${folderName};

import com.mindorks.framework.mvp.ui.base.MvpView;

public interface ${className}MvpView extends MvpView {
}
67 changes: 67 additions & 0 deletions template/MVPActivity_AS_v3.6/template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0"?>
<template
format="5"
revision="1"
name="MVP Activity"
minApi="14"
minBuildApi="14"
description="Creates a new MVP activity">

<category value="Activity" />
<formfactor value="Mobile" />

<parameter
id="folderName"
name="Folder Name"
type="string"
constraints="class|unique|nonempty"
default="demo"
help="MVP root folder" />

<parameter
id="className"
name="Class Name ** Do not suffix Activity **"
type="string"
constraints="class|unique|nonempty"
default="Demo"
help="The name of the class to create" />

<parameter
id="activityClass"
name="Activity Name"
type="string"
constraints="class|unique|nonempty"
suggest="${className}Activity"
default="DemoActivity"
help="The name of the activity class to create" />


<parameter
id="activityLayout"
name="Activity Layout Name"
type="string"
constraints="layout|unique|nonempty"
suggest="${classToResource(activityClass)}_activity"
default="main_activity"
help="The name of the layout to create for the activity" />


<parameter
id="isLauncher"
name="Launcher Activity"
type="boolean"
default="false"
help="If true, this activity will have a CATEGORY_LAUNCHER intent filter, making it visible in the launcher" />



<!-- 128x128 thumbnails relative to template.xml -->
<thumbs>
<!-- default thumbnail is required -->
<thumb>template_blank_activity.png</thumb>
</thumbs>

<globals file="globals.xml.ftl" />
<execute file="recipe.xml.ftl" />

</template>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.