diff options
Diffstat (limited to 'templates/SimpleView/_MODULE_/src/template')
5 files changed, 214 insertions, 0 deletions
diff --git a/templates/SimpleView/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl b/templates/SimpleView/_MODULE_/src/template/java/_PACKAGE_/MainActivity.java.ftl new file mode 100644 index 00000000..0d6e6840 --- /dev/null +++ b/templates/SimpleView/_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/templates/SimpleView/_MODULE_/src/template/res/layout/activity_main.xml b/templates/SimpleView/_MODULE_/src/template/res/layout/activity_main.xml new file mode 100644 index 00000000..bc5a5759 --- /dev/null +++ b/templates/SimpleView/_MODULE_/src/template/res/layout/activity_main.xml @@ -0,0 +1,38 @@ +<!-- + 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" + android:id="@+id/sample_main_layout"> + <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/templates/SimpleView/_MODULE_/src/template/res/values-sw600dp/template-dimens.xml b/templates/SimpleView/_MODULE_/src/template/res/values-sw600dp/template-dimens.xml new file mode 100644 index 00000000..22074a2b --- /dev/null +++ b/templates/SimpleView/_MODULE_/src/template/res/values-sw600dp/template-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/templates/SimpleView/_MODULE_/src/template/res/values-sw600dp/template-styles.xml b/templates/SimpleView/_MODULE_/src/template/res/values-sw600dp/template-styles.xml new file mode 100644 index 00000000..03d19741 --- /dev/null +++ b/templates/SimpleView/_MODULE_/src/template/res/values-sw600dp/template-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/templates/SimpleView/_MODULE_/src/template/res/values/template-styles.xml b/templates/SimpleView/_MODULE_/src/template/res/values/template-styles.xml new file mode 100644 index 00000000..d3f82ff6 --- /dev/null +++ b/templates/SimpleView/_MODULE_/src/template/res/values/template-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> |