aboutsummaryrefslogtreecommitdiffstats
path: root/templates/activities/BlankActivity/root/src/app_package
diff options
context:
space:
mode:
authorRoman Nurik <romannurik@google.com>2013-01-07 09:15:12 -0800
committerRoman Nurik <romannurik@google.com>2013-01-22 12:50:29 -0800
commit346bcb15e420aeafd192e75e269c97c0a53a6382 (patch)
tree869bc2773cde04fd0caeb22d705f39487b308ab9 /templates/activities/BlankActivity/root/src/app_package
parent4d69200e272697b788963c7f516d868c95d22634 (diff)
downloadsdk-346bcb15e420aeafd192e75e269c97c0a53a6382.zip
sdk-346bcb15e420aeafd192e75e269c97c0a53a6382.tar.gz
sdk-346bcb15e420aeafd192e75e269c97c0a53a6382.tar.bz2
ADT templates: BlankActivity and LoginActivity cleanup.
- BlankActivity: fix a bug where 'none' navtype + minApi < 11 didn't check for API 11 before using ActionBar APIs - BlankActivity: add horizontal and vertical padding, customized for sw720dp-land - BlankActivity: remove navtype that allowed tabs without swipe - change naming convention R.menu.activity_foo to R.menu.foo - change naming convention R.id.menu_foo to R.id.action_foo - add simple XXHDPI icon (scaled up from XHDPI... to be replaced in a future update) Change-Id: Ic5bf3dcfb13e714df505dcbf7c1227b610f0a36e
Diffstat (limited to 'templates/activities/BlankActivity/root/src/app_package')
-rw-r--r--templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl18
-rw-r--r--templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl10
2 files changed, 21 insertions, 7 deletions
diff --git a/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl b/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl
index feae824..7edd647 100644
--- a/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl
+++ b/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl
@@ -6,6 +6,10 @@ import android.view.Menu;
<#if parentActivityClass != "">
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
+<#if minApiLevel < 11>
+import android.annotation.TargetApi;
+import android.os.Build;
+</#if>
</#if>
public class ${activityClass} extends Activity {
@@ -16,10 +20,22 @@ public class ${activityClass} extends Activity {
setContentView(R.layout.${layoutName});
<#if parentActivityClass != "">
// Show the Up button in the action bar.
- getActionBar().setDisplayHomeAsUpEnabled(true);
+ setupActionBar();
</#if>
}
+ <#if parentActivityClass != "">
+ /**
+ * Set up the {@link android.app.ActionBar}<#if minApiLevel < 11>, if the API is available</#if>.
+ */
+ <#if minApiLevel < 11>@TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ </#if>private void setupActionBar() {
+ <#if minApiLevel < 11>if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {</#if>
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ <#if minApiLevel < 11>}</#if>
+ }
+ </#if>
+
<#include "include_onCreateOptionsMenu.java.ftl">
<#include "include_onOptionsItemSelected.java.ftl">
diff --git a/templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl b/templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl
index c455fc5..8eb1399 100644
--- a/templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl
+++ b/templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl
@@ -15,11 +15,9 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- // Create a new TextView and set its text to the fragment's section
- // number argument value.
- TextView textView = new TextView(getActivity());
- textView.setGravity(Gravity.CENTER);
- textView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
- return textView;
+ View rootView = inflater.inflate(R.layout.fragment_${classToResource(activityClass)}_dummy, container, false);
+ TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);
+ dummyTextView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
+ return rootView;
}
}