aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorIan Ni-Lewis <ilewis@google.com>2013-09-06 17:59:07 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-06 17:59:08 +0000
commite12ebe2e9b63d9e4b075e26d785f9211529808df (patch)
tree2269fcd0e3a3ca7c92926b5bce7c607656595f73 /common
parent38d2eb626bbe92e50830f455b082887eb9b28683 (diff)
parentbcbb958aeb9ae6248f6f6865dca506be6d1a1bde (diff)
downloadandroid-e12ebe2e9b63d9e4b075e26d785f9211529808df.tar.gz
Merge "Added SingleView template, and corresponding singleViewSample which is powered by it" into developers-dev
Diffstat (limited to 'common')
-rw-r--r--common/build/templates/SingleView/_MODULE_/README-singleview.txt31
-rwxr-xr-xcommon/build/templates/SingleView/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl76
-rwxr-xr-xcommon/build/templates/SingleView/_MODULE_/src/template/res/layout/activity_main.xml37
-rw-r--r--common/build/templates/SingleView/_MODULE_/src/template/res/menu/main.xml21
-rw-r--r--common/build/templates/SingleView/_MODULE_/src/template/res/values-sw600dp/dimens.xml24
-rw-r--r--common/build/templates/SingleView/_MODULE_/src/template/res/values-sw600dp/styles.xml25
-rwxr-xr-xcommon/build/templates/SingleView/_MODULE_/src/template/res/values/strings.xml.ftl8
-rw-r--r--common/build/templates/SingleView/_MODULE_/src/template/res/values/styles.xml51
-rw-r--r--common/build/templates/base/_MODULE_/build.gradle.ftl18
-rwxr-xr-xcommon/build/templates/base/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl34
-rwxr-xr-xcommon/build/templates/base/_MODULE_/src/template/res/values/base-strings.xml.ftl6
-rw-r--r--common/build/templates/create/_MODULE_/project.properties14
-rw-r--r--common/build/templates/create/template-params.xml.ftl16
-rw-r--r--common/src/java/com/example/android/common/activities/SampleActivityBase.java52
-rw-r--r--common/src/java/com/example/android/common/logger/LogFragment.java109
15 files changed, 450 insertions, 72 deletions
diff --git a/common/build/templates/SingleView/_MODULE_/README-singleview.txt b/common/build/templates/SingleView/_MODULE_/README-singleview.txt
new file mode 100644
index 00000000..d91cfbf0
--- /dev/null
+++ b/common/build/templates/SingleView/_MODULE_/README-singleview.txt
@@ -0,0 +1,31 @@
+Steps to implement SingleView template:
+-in template-params.xml.ftl:
+ -add the following line to common imports
+ <common src="activities"/>
+
+ -add a string for the action button's text using the element name "sample_action". This element should be a child
+ of <strings>:
+ <strings>
+ ...
+ <sample_action>ButtonText</sample_action>
+ ...
+ </strings>
+
+
+
+-Add a Fragment to handle behavior. In your MainActivity.java class, it will reference a Fragment called
+ (yourProjectName)Fragment.java. Create that file in your project, using the "main" source folder instead of
+ "common" or "templates".
+ for instance, if your package name is com.example.foo, create the file
+ src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/singleViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/common/build/templates/SingleView/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl b/common/build/templates/SingleView/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl
new file mode 100755
index 00000000..0d6e6840
--- /dev/null
+++ b/common/build/templates/SingleView/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl
@@ -0,0 +1,76 @@
+<#ftl>
+<#--
+ Copyright 2013 The Android Open Source Project
+
+ 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 ${sample.package};
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentTransaction;
+import android.view.Menu;
+
+import com.example.android.common.activities.SampleActivityBase;
+import com.example.android.common.logger.Log;
+import com.example.android.common.logger.LogFragment;
+import com.example.android.common.logger.LogWrapper;
+import com.example.android.common.logger.MessageOnlyLogFilter;
+
+/**
+ * A simple launcher activity containing a summary sample description
+ * and a few action bar buttons.
+ */
+public class MainActivity extends SampleActivityBase {
+
+ public static final String TAG = "MainActivity";
+
+ public static final String FRAGTAG = "${sample.name?cap_first}Fragment";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ ${sample.name?cap_first}Fragment fragment = new ${sample.name?cap_first}Fragment();
+ transaction.add(fragment, FRAGTAG);
+ transaction.commit();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ /** Create a chain of targets that will receive log data */
+ @Override
+ public void initializeLogging() {
+ // Wraps Android's native log framework.
+ LogWrapper logWrapper = new LogWrapper();
+ // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
+ Log.setLogNode(logWrapper);
+
+ // Filter strips out everything except the message text.
+ MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
+ logWrapper.setNext(msgFilter);
+
+ // On screen logging via a fragment with a TextView.
+ LogFragment logFragment = (LogFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.log_fragment);
+ msgFilter.setNext(logFragment.getLogView());
+
+ Log.i(TAG, "Ready");
+ }
+} \ No newline at end of file
diff --git a/common/build/templates/SingleView/_MODULE_/src/template/res/layout/activity_main.xml b/common/build/templates/SingleView/_MODULE_/src/template/res/layout/activity_main.xml
new file mode 100755
index 00000000..3c4777cb
--- /dev/null
+++ b/common/build/templates/SingleView/_MODULE_/src/template/res/layout/activity_main.xml
@@ -0,0 +1,37 @@
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ 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.
+ -->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <TextView android:id="@+id/sample_output"
+ style="@style/Widget.SampleMessage"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="@string/intro_message" />
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dp"
+ android:background="@android:color/darker_gray"/>
+ <fragment
+ android:name="com.example.android.common.logger.LogFragment"
+ android:id="@+id/log_fragment"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+</LinearLayout>
diff --git a/common/build/templates/SingleView/_MODULE_/src/template/res/menu/main.xml b/common/build/templates/SingleView/_MODULE_/src/template/res/menu/main.xml
new file mode 100644
index 00000000..2c3515dd
--- /dev/null
+++ b/common/build/templates/SingleView/_MODULE_/src/template/res/menu/main.xml
@@ -0,0 +1,21 @@
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ 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.
+ -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/sample_action"
+ android:showAsAction="ifRoom|withText"
+ android:title="@string/sample_action" />
+</menu>
diff --git a/common/build/templates/SingleView/_MODULE_/src/template/res/values-sw600dp/dimens.xml b/common/build/templates/SingleView/_MODULE_/src/template/res/values-sw600dp/dimens.xml
new file mode 100644
index 00000000..22074a2b
--- /dev/null
+++ b/common/build/templates/SingleView/_MODULE_/src/template/res/values-sw600dp/dimens.xml
@@ -0,0 +1,24 @@
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ 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.
+ -->
+
+<resources>
+
+ <!-- Semantic definitions -->
+
+ <dimen name="horizontal_page_margin">@dimen/margin_huge</dimen>
+ <dimen name="vertical_page_margin">@dimen/margin_medium</dimen>
+
+</resources>
diff --git a/common/build/templates/SingleView/_MODULE_/src/template/res/values-sw600dp/styles.xml b/common/build/templates/SingleView/_MODULE_/src/template/res/values-sw600dp/styles.xml
new file mode 100644
index 00000000..03d19741
--- /dev/null
+++ b/common/build/templates/SingleView/_MODULE_/src/template/res/values-sw600dp/styles.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ 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.
+ -->
+
+<resources>
+
+ <style name="Widget.SampleMessage">
+ <item name="android:textAppearance">?android:textAppearanceLarge</item>
+ <item name="android:lineSpacingMultiplier">1.2</item>
+ <item name="android:shadowDy">-6.5</item>
+ </style>
+
+</resources>
diff --git a/common/build/templates/SingleView/_MODULE_/src/template/res/values/strings.xml.ftl b/common/build/templates/SingleView/_MODULE_/src/template/res/values/strings.xml.ftl
new file mode 100755
index 00000000..985dd5c9
--- /dev/null
+++ b/common/build/templates/SingleView/_MODULE_/src/template/res/values/strings.xml.ftl
@@ -0,0 +1,8 @@
+<resources>
+ <string name="intro_message">
+ <![CDATA[
+ ${sample.strings.intro}
+ ]]>
+ </string>
+ <string name="sample_action">${sample.strings.sample_action}</string>
+</resources>
diff --git a/common/build/templates/SingleView/_MODULE_/src/template/res/values/styles.xml b/common/build/templates/SingleView/_MODULE_/src/template/res/values/styles.xml
new file mode 100644
index 00000000..d3f82ff6
--- /dev/null
+++ b/common/build/templates/SingleView/_MODULE_/src/template/res/values/styles.xml
@@ -0,0 +1,51 @@
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ 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.
+ -->
+
+<resources>
+
+ <!-- Activity themes -->
+
+ <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+
+ <style name="AppTheme" parent="Theme.Base" />
+ <!-- Widget styling -->
+
+ <style name="Widget" />
+
+ <style name="Widget.SampleMessage">
+ <item name="android:textAppearance">?android:textAppearanceMedium</item>
+ <item name="android:lineSpacingMultiplier">1.1</item>
+ </style>
+
+ <style name="Widget.SampleMessageTile">
+ <item name="android:background">@drawable/tile</item>
+ <item name="android:shadowColor">#7F000000</item>
+ <item name="android:shadowDy">-3.5</item>
+ <item name="android:shadowRadius">2</item>
+ </style>
+
+
+ <style name="Widget.SampleOutput">
+ <item name="android:padding">@dimen/margin_medium</item>
+ <item name="android:textAppearance">?android:textAppearanceMedium</item>
+ <item name="android:lineSpacingMultiplier">1.1</item>
+ </style>
+
+ <style name="Log" parent="Widget.SampleOutput">
+ <item name="android:typeface">monospace</item>
+ </style>
+
+</resources>
diff --git a/common/build/templates/base/_MODULE_/build.gradle.ftl b/common/build/templates/base/_MODULE_/build.gradle.ftl
index 5ba77437..d8309edb 100644
--- a/common/build/templates/base/_MODULE_/build.gradle.ftl
+++ b/common/build/templates/base/_MODULE_/build.gradle.ftl
@@ -25,16 +25,15 @@ buildscript {
apply plugin: 'android'
-
dependencies {
// Add the support lib that is appropriate for SDK ${sample.minSdk}
<#if sample.minSdk?number < 7>
- compile "com.android.support:support-v4:13.0.+"
+ compile "com.android.support:support-v4:18.0.+"
<#elseif sample.minSdk?number < 13>
- compile "com.android.support:support-v4:13.0.+"
- compile "com.android.support:gridlayout-v7:13.0.+"
+ compile "com.android.support:support-v4:18.0.+"
+ compile "com.android.support:gridlayout-v7:18.0.+"
<#else>
- compile "com.android.support:support-v13:13.0.+"
+ compile "com.android.support:support-v13:18.0.+"
</#if>
}
@@ -49,13 +48,10 @@ List<String> dirs = [
android {
<#-- Note that target SDK is hardcoded in this template. We expect all samples
to always use the most current SDK as their target. -->
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.1"
+
- defaultConfig {
- minSdkVersion ${sample.minSdk}
- targetSdkVersion 17
- }
<#noparse>
sourceSets {
main {
diff --git a/common/build/templates/base/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl b/common/build/templates/base/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl
deleted file mode 100755
index 2ae93d2f..00000000
--- a/common/build/templates/base/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl
+++ /dev/null
@@ -1,34 +0,0 @@
-<#ftl>
-<#--
- Copyright 2013 The Android Open Source Project
-
- 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 ${sample.package};
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-
-/**
- * A simple launcher activity describing the alternative action bar presentations and allowing the
- * user to navigate to a demo of each.
- */
-public class MainActivity extends Activity {
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- }
-}
diff --git a/common/build/templates/base/_MODULE_/src/template/res/values/base-strings.xml.ftl b/common/build/templates/base/_MODULE_/src/template/res/values/base-strings.xml.ftl
index 9a15a37b..ed596b43 100755
--- a/common/build/templates/base/_MODULE_/src/template/res/values/base-strings.xml.ftl
+++ b/common/build/templates/base/_MODULE_/src/template/res/values/base-strings.xml.ftl
@@ -1,9 +1,3 @@
<resources>
<string name="app_name">${sample.name}</string>
-
- <string name="intro_message">
- <![CDATA[
- ${sample.intro}
- ]]>
- </string>
</resources>
diff --git a/common/build/templates/create/_MODULE_/project.properties b/common/build/templates/create/_MODULE_/project.properties
deleted file mode 100644
index 0c9830a3..00000000
--- a/common/build/templates/create/_MODULE_/project.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=Google Inc.:Google APIs:17
diff --git a/common/build/templates/create/template-params.xml.ftl b/common/build/templates/create/template-params.xml.ftl
index 2f1c9897..40857302 100644
--- a/common/build/templates/create/template-params.xml.ftl
+++ b/common/build/templates/create/template-params.xml.ftl
@@ -4,16 +4,18 @@
<package>${sample.package}</package>
- <!--TODO: change minSdk if needed-->
+ <!-- change minSdk if needed-->
<minSdk>${sample.minSdk}</minSdk>
- <intro>
- <![CDATA[
- Introductory text that explains what the sample is intended to demonstrate. Edit
- in template-params.xml.
- ]]>
- </intro>
+ <strings>
+ <intro>
+ <![CDATA[
+ Introductory text that explains what the sample is intended to demonstrate. Edit
+ in template-params.xml.
+ ]]>
+ </intro>
+ </strings>
<template src="base"/>
<common src="logger"/>
diff --git a/common/src/java/com/example/android/common/activities/SampleActivityBase.java b/common/src/java/com/example/android/common/activities/SampleActivityBase.java
new file mode 100644
index 00000000..3228927b
--- /dev/null
+++ b/common/src/java/com/example/android/common/activities/SampleActivityBase.java
@@ -0,0 +1,52 @@
+/*
+* Copyright 2013 The Android Open Source Project
+*
+* 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 com.example.android.common.activities;
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+
+import com.example.android.common.logger.Log;
+import com.example.android.common.logger.LogWrapper;
+
+/**
+ * Base launcher activity, to handle most of the common plumbing for samples.
+ */
+public class SampleActivityBase extends FragmentActivity {
+
+ public static final String TAG = "SampleActivityBase";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ initializeLogging();
+ }
+
+ /** Set up targets to receive log data */
+ public void initializeLogging() {
+ // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
+ // Wraps Android's native log framework
+ LogWrapper logWrapper = new LogWrapper();
+ Log.setLogNode(logWrapper);
+
+ Log.i(TAG, "Ready");
+ }
+}
diff --git a/common/src/java/com/example/android/common/logger/LogFragment.java b/common/src/java/com/example/android/common/logger/LogFragment.java
new file mode 100644
index 00000000..b302acd4
--- /dev/null
+++ b/common/src/java/com/example/android/common/logger/LogFragment.java
@@ -0,0 +1,109 @@
+/*
+* Copyright 2013 The Android Open Source Project
+*
+* 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.
+*/
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * 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 com.example.android.common.logger;
+
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ScrollView;
+
+/**
+ * Simple fraggment which contains a LogView and uses is to output log data it receives
+ * through the LogNode interface.
+ */
+public class LogFragment extends Fragment {
+
+ private LogView mLogView;
+ private ScrollView mScrollView;
+
+ public LogFragment() {}
+
+ public View inflateViews() {
+ mScrollView = new ScrollView(getActivity());
+ ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT);
+ mScrollView.setLayoutParams(scrollParams);
+
+ mLogView = new LogView(getActivity());
+ ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
+ logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
+ mLogView.setLayoutParams(logParams);
+ mLogView.setClickable(true);
+ mLogView.setFocusable(true);
+ mLogView.setTypeface(Typeface.MONOSPACE);
+
+ // Want to set padding as 16 dips, setPadding takes pixels. Hooray math!
+ int paddingDips = 16;
+ double scale = getResources().getDisplayMetrics().density;
+ int paddingPixels = (int) ((paddingDips * (scale)) + .5);
+ mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
+ mLogView.setCompoundDrawablePadding(paddingPixels);
+
+ mLogView.setGravity(Gravity.BOTTOM);
+ mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);
+
+ mScrollView.addView(mLogView);
+ return mScrollView;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ View result = inflateViews();
+
+ mLogView.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {}
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
+ }
+ });
+ return result;
+ }
+
+ public LogView getLogView() {
+ return mLogView;
+ }
+} \ No newline at end of file