API 11에서 제공하는 팝업 메뉴

메뉴에 서브메뉴가 가능해서 기존 노출되는 팝업 메뉴가 사라지고 서브메뉴가 나온다.


public void onPopupButtonClick(View button) {

    PopupMenu popup = new PopupMenu(this, button);

    popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());


    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        public boolean onMenuItemClick(MenuItem item) {

            Toast.makeText(PopupMenu1.this, "Clicked popup menu item " + item.getTitle(),

                    Toast.LENGTH_SHORT).show();

            return true;

        }

    });


    popup.show();

}


메뉴 xml

<?xml version="1.0" encoding="utf-8"?>

<!-- Copyright (C) 2010 Google Inc.


     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/search"

          android:icon="@android:drawable/ic_menu_search"

          android:title="@string/popup_menu_search" />

    <item android:id="@+id/add"

          android:icon="@android:drawable/ic_menu_add"

          android:title="@string/popup_menu_add" />

    <item android:id="@+id/edit"

          android:icon="@android:drawable/ic_menu_edit"

          android:title="@string/popup_menu_edit">

        <menu>

            <item android:id="@+id/share"

                  android:icon="@android:drawable/ic_menu_share"

                  android:title="@string/popup_menu_share" />

        </menu>

    </item>

</menu>






'Android > ApiDemo_Graphic' 카테고리의 다른 글

View/Full Screen Modes / Hide Navigation  (0) 2012.12.29

화면에 동적으로 제어하는 코드로써
특징적인 것은 Navigation을 숨기는 코드가 들어 있다.

네비게이션을 옮기는 설정은 SYSTEM_UI_FLAG_HIDE_NAVIGATION인데, 아래와 같은 사항에 주의해서 사용해야 하네요.

SYSTEM_UI_FLAG_HIDE_NAVIGATION은  FLAG_FULLSCREEN와 함께 사용해야 제대로 동작된다고 합니다.

Android 4 treat: View.SYSTEM_UI_FLAG_HIDE_NAVIGATION

"View has requested that the system navigation be temporarily hidden. This is an even less obtrusive state than that called for by SYSTEM_UI_FLAG_LOW_PROFILE; on devices that draw essential navigation controls (Home, Back, and the like) on screen, SYSTEM_UI_FLAG_HIDE_NAVIGATION will cause those to disappear. This is useful (in conjunction with the FLAG_FULLSCREEN and FLAG_LAYOUT_IN_SCREEN window flags) for displaying content using every last pixel on the display. There is a limitation: because navigation controls are so important, the least user interaction will cause them to reappear immediately."

This flag will allow to take over the entire screen, unlike Honeycomb where there was always a navigation bar at the bottom with room for the Back, Home, and Recents button. Unfortunately it won't work for games because of the last sentence.




/*
 * Copyright (C) 2011 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.apis.view;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.android.apis.R;

/**
 * This activity demonstrates some of the available ways to reduce the size or visual contrast of
 * the system decor, in order to better focus the user's attention or use available screen real
 * estate on the task at hand.
 */
public class OverscanActivity extends Activity {
    public static class IV extends ImageView {
        private OverscanActivity mActivity;
        public IV(Context context) {
            super(context);
        }
        public IV(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
        public void setActivity(OverscanActivity act) {
            mActivity = act;
        }
        public void onSizeChanged(int w, int h, int oldw, int oldh) {
            mActivity.refreshSizes();
        }
        public void onSystemUiVisibilityChanged(int visibility) {
            mActivity.getState().onSystemUiVisibilityChanged(visibility);
        }
    }

    private interface State {
        void apply();
        State next();
        void onSystemUiVisibilityChanged(int visibility);
    }
    private class NormalState implements State {
        public void apply() {
            display("Normal");
            setFullscreen(false);
            mImage.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        }
        public State next() {
            return new FullscreenState();
        }
        public void onSystemUiVisibilityChanged(int visibility) {
        }
    }
    private class FullscreenState implements State {
        public void apply() {
            display("FULLSCREEN");
            setFullscreen(true);
        }
        public State next() {
            return new FullscreenLightsOutState();
        }
        public void onSystemUiVisibilityChanged(int visibility) {
        }
    }
    private class FullscreenLightsOutState implements State {
        public void apply() {
            display("FULLSCREEN + LOW_PROFILE");
            mImage.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        }
        public State next() {
            return new OverscanState();
        }
        public void onSystemUiVisibilityChanged(int visibility) {
        }
    }
    private class OverscanState implements State {
        public void apply() {
            display("FULLSCREEN + HIDE_NAVIGATION");
            mImage.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        }
        public State next() {
            return new NormalState();
        }
        public void onSystemUiVisibilityChanged(int visibility) {
        }
    }

    private void setFullscreen(boolean on) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
        if (on) {
            winParams.flags |=  bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }

    private String getDisplaySize() {
        DisplayMetrics dm = getResources().getDisplayMetrics();
        return String.format("DisplayMetrics = (%d x %d)", dm.widthPixels, dm.heightPixels);
    }
    private String getViewSize() {
        return String.format("View = (%d,%d - %d,%d)",
                mImage.getLeft(), mImage.getTop(),
                mImage.getRight(), mImage.getBottom());
    }
    void refreshSizes() {
        mText2.setText(getDisplaySize() + " " + getViewSize());
    }
    private void display(String text) {
        mText1.setText(text);
        refreshSizes();
    }
    State getState() {
        return mState;
    }

    static int TOAST_LENGTH = 500;
    IV mImage;
    TextView mText1, mText2;
    State mState;

    public OverscanActivity() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // we need to ask for LAYOUT_IN_SCREEN before the window decor appears
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        winParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
        win.setAttributes(winParams);

        setContentView(R.layout.overscan);
        mImage = (IV) findViewById(R.id.image);
        mImage.setActivity(this);
        mText1 = (TextView) findViewById(R.id.text1);
        mText2 = (TextView) findViewById(R.id.text2);
    }

    @Override
    public void onAttachedToWindow() {
        mState = new NormalState();
        mState.apply();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    public void clicked(View v) {
        mState = mState.next();
        mState.apply();
    }
}














'Android > ApiDemo_Graphic' 카테고리의 다른 글

View PopupMenu  (0) 2012.12.29
런처 아이콘 사이즈 Android 2012. 12. 3. 15:13

Size and Format


Launcher icons should be 32-bit PNGs with an alpha channel for transparency. The finished launcher icon dimensions corresponding to a given generalized screen density are shown in the table below.

Table 1. Summary of finished launcher icon dimensions for each generalized screen density.

ldpi (120 dpi)
(Low density screen)
mdpi (160 dpi)
(Medium density screen)
hdpi (240 dpi)
(High density screen)
xhdpi (320 dpi)
(Extra-high density screen)
Launcher Icon Size36 x 36 px48 x 48 px72 x 72 px96 x 96 px

You can also include a few pixels of padding in launcher icons to maintain a consistent visual weight with adjacent icons. For example, a 96 x 96 pixel xhdpi launcher icon can contain a 88 x 88 pixel shape with 4 pixels on each side for padding. This padding can also be used to make room for a subtle drop shadow, which can help ensure that launcher icons are legible across on any background color.


http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html

아직 정확히 어떤 기능을 하는지 확인되지 않고 있음

android:freezesText

If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. By default this is disabled; it can be useful when the contents of a text view is not stored in a persistent place such as a content provider.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol freezesText.

android:inputType

The type of data being placed in a text field, used to help an input method decide how to let the user enter text. The constants here correspond to those defined by InputType. Generally you can select a single value, though some can be combined together as indicated. Setting this attribute to anything besides none also implies that the text is editable.

Must be one or more (separated by '|') of the following constant values.

ConstantValueDescription
none0x00000000There is no content type. The text is not editable.
text0x00000001

멀티라인을 지원하지 않아서 키보드에서 Enter 키 입력이 무시된다.
Just plain old text. Corresponds to 

TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_NORMAL.
textCapCharacters0x00001001Can be combined with text and its variations to request capitalization of all characters. Corresponds to TYPE_TEXT_FLAG_CAP_CHARACTERS.
textCapWords0x00002001Can be combined with text and its variations to request capitalization of the first character of every word. Corresponds toTYPE_TEXT_FLAG_CAP_WORDS.
textCapSentences0x00004001Can be combined with text and its variations to request capitalization of the first character of every sentence. Corresponds toTYPE_TEXT_FLAG_CAP_SENTENCES.
textAutoCorrect0x00008001Can be combined with text and its variations to request auto-correction of text being input. Corresponds to TYPE_TEXT_FLAG_AUTO_CORRECT.
textAutoComplete0x00010001Can be combined with text and its variations to specify that this field will be doing its own auto-completion and talking with the input method appropriately. Corresponds toTYPE_TEXT_FLAG_AUTO_COMPLETE.
textMultiLine0x00020001

문자 입력시 멀티 라인입력이 가능하다.
Can be combined with 

text and its variations to allow multiple lines of text in the field. If this flag is not set, the text field will be constrained to a single line. Corresponds to TYPE_TEXT_FLAG_MULTI_LINE.
textImeMultiLine0x00040001Can be combined with text and its variations to indicate that though the regular text view should not be multiple lines, the IME should provide multiple lines if it can. Corresponds toTYPE_TEXT_FLAG_IME_MULTI_LINE.
textNoSuggestions0x00080001Can be combined with text and its variations to indicate that the IME should not show any dictionary-based word suggestions. Corresponds to TYPE_TEXT_FLAG_NO_SUGGESTIONS.
textUri0x00000011Text that will be used as a URI. Corresponds to TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_URI.
textEmailAddress0x00000021Text that will be used as an e-mail address. Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS.
textEmailSubject0x00000031Text that is being supplied as the subject of an e-mail. Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_SUBJECT.
textShortMessage0x00000041Text that is the content of a short message. Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_SHORT_MESSAGE.
textLongMessage0x00000051Text that is the content of a long message. Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_LONG_MESSAGE.
textPersonName0x00000061Text that is the name of a person. Corresponds to TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_PERSON_NAME.
textPostalAddress0x00000071Text that is being supplied as a postal mailing address. Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_POSTAL_ADDRESS.
textPassword0x00000081Text that is a password. Corresponds to TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_PASSWORD.
textVisiblePassword0x00000091Text that is a password that should be visible. Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD.
textWebEditText0x000000a1Text that is being supplied as text in a web form. Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_WEB_EDIT_TEXT.
textFilter0x000000b1Text that is filtering some other data. Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_FILTER.
textPhonetic0x000000c1Text that is for phonetic pronunciation, such as a phonetic name field in a contact entry. Corresponds to TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_PHONETIC.
textWebEmailAddress0x000000d1Text that will be used as an e-mail address on a web form. Corresponds to TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS.
textWebPassword0x000000e1Text that will be used as a password on a web form. Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_WEB_PASSWORD.
number0x00000002A numeric only field. Corresponds to TYPE_CLASS_NUMBER |TYPE_NUMBER_VARIATION_NORMAL.
numberSigned0x00001002Can be combined with number and its other options to allow a signed number. Corresponds to TYPE_CLASS_NUMBER |TYPE_NUMBER_FLAG_SIGNED.
numberDecimal0x00002002Can be combined with number and its other options to allow a decimal (fractional) number. Corresponds to TYPE_CLASS_NUMBER |TYPE_NUMBER_FLAG_DECIMAL.
numberPassword0x00000012A numeric password field. Corresponds to TYPE_CLASS_NUMBER |TYPE_NUMBER_VARIATION_PASSWORD.
phone0x00000003For entering a phone number. Corresponds to TYPE_CLASS_PHONE.
datetime0x00000004For entering a date and time. Corresponds to TYPE_CLASS_DATETIME |TYPE_DATETIME_VARIATION_NORMAL.
date0x00000014For entering a date. Corresponds to TYPE_CLASS_DATETIME |TYPE_DATETIME_VARIATION_DATE.
time0x00000024For entering a time. Corresponds to TYPE_CLASS_DATETIME |TYPE_DATETIME_VARIATION_TIME.

This corresponds to the global attribute resource symbol inputType.


2012년 11월 22일 목요일

게임 개발자를 위한 유튜브 세미나 동영상


지난 11월 15일에 있었던 게임 개발자를 위한 유튜브 세미나의 동영상이 업로드되었습니다. 많은 분들이 참석해 주셔서 즐거운 시간을 보냈구요. 여러모로 유익한 시간이었습니다. 관심 가지고 참석 지원해 주신 분들, 참석해 주신 분들 그리고 동영상을 시청하시는 분들 모두에게 감사드립니다.

세미나 자료: https://docs.google.com/file/d/0B4sGAlXaZCXNUzdGRW94S1BoelE/edit

http://googledevkr.blogspot.kr/2012/11/blog-post_12.html

Published - 유튜브를 활용한 게임 확산 전략 (Start Playing The Distribution Game on YouTube) v00.03.01.pdf .pdf

2012년 11월 7일 수요일

게임 개발자를 위한 유튜브 소개 시간을 마련했습니다~

게임 개발자를 위한 유튜브 소개 시간을 마련했습니다. 여러분의 게임에 유튜브를 결합할 수 있는 다양한 방법들과 성공 사례들을 공유합니다. 그동안 유튜브를 이용자 관점에서 동영상 시청 용도로만 생각하고 계신 분들이 많으실 텐데 유튜브에서 제공되는 다양한 API들이 어떤 기능을 가지고 있으며 어떻게 이용될 수 있는지를 직접 확인하실 수 있습니다.

일시: 2012년 11월 15일 오후 6시 30분 ~ 9시
장소: 구글코리아 사무실

- 제목: Start Playing the Distribution Game on YouTube (Jarek Wilkiewicz, Sang Kim)
- 내용: YouTube has over 800M unique visitors who watch 4 billion hours of video each month. One of the top categories on YouTube is gaming. By integrating your game with YouTube you can share rich and authentic game experiences that are more likely to convert viewers into gamers than any other medium. In this session, we will highlight fun and enlightening integration examples in PC, console and mobile areas. We will cover best practices from both the technical and business perspective. Last but not least, we will share our favorite gameplay videos with you!

관심있는 게임 개발자 여러분들의 많은 참여 부탁드립니다~!

참고
- 저녁 식사가 제공됩니다.
- 본 세션은 영어로 진행되며 별도의 통역은 제공되지 않습니다.
- 주차는 제공되지 않으니 대중교통을 이용해 주시기를 부탁드립니다.

참가 신청하기! - 참가 신청은 11월 13일 오전 10시까지 부탁드립니다. 선착순이 아니며 좌석이 한정되어 있어 참석 대상자로 선정되신 분께는 별도로 연락을 드리겠습니다.

Using the new Build System Android 2012. 11. 19. 18:01

http://tools.android.com/tech-docs/new-build-system 
We are working on a new build system to replace both the build system inside ADT and Ant.


Using the new Build System

Using the new Build System

The new build system is based on Gradle.
If you are not familiar with Gradle, it is recommended to read at least the first few chapters ofhttp://gradle.org/docs/current/userguide/userguide_single.html

The location of the SDK folder is still needed and is provided by one of the following methods:
  • local.properties file with a sdk.dir property, similar to the current build system. This is located in the project root directory. In multi-project setup, this is next to settings.gradle.
  • ANDROID_HOME environment variable
All other configuration goes in the standard build.gradle file.

Using the new Android plugin for Gradle

The android plugin for gradle is available through Maven:
  • groupId: com.android.tools.build
  • artifactId: gradle
  • version (current milestone): 0.1
Requirements:
Gradle 1.2.
The Android Platform-Tools component in version 15 rc7. To download it, you will need to enable the preview channel in the SDK Manager. Read more about it here.

To use it in your build.gradle file, put at the top:
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.1'
    }
}
apply plugin: 'android'

For library project, the plugin to apply is ‘android-library

In the future we will investigate how to simplify this step.

Basic Project Setup

All configuration related to the Android plugin is done inside the android namespace:
android {
    ...
}

The most important setting is the build target (previously found in project.properties):
android {
    target = ‘android-15’
}

Changing the default configuration is done using the defaultConfig object:
android {
    target = ‘android-15’
    defaultConfig {
        versionCode = 12
        versionName = “2.0”
    }
}

Default Config can be configured with the following properties:
  • packageName (String)
  • versionCode (int)
  • versionName (String)
  • minSdkVersion (int)
  • targetSdkVersion (int)
  • testPackageName (String)
  • testInstrumentationRunner (String)
  • signingStoreLocation (String)
  • signingStorePassword (String)
  • signingKeyAlias (String)
  • signingKeyPassword (String)
  • buildConfig (String...)
Note: it is best not to put signing passwords in the build script, and instead have your CI server does the signing itself, or use a local gradle.properties file.
However, you can use these signing properties if you share a single debug keystore across developers.

Build Types and Product Flavors

Creating new build types or editing the built-in debug and release is done with the buildTypes element. This configures the debug build type and adds another one called “staging”:
android {
    buildTypes {
        debug {
            packageNameSuffix = “.debug”
        }
        staging {
            packageNameSuffix = “.staging”
            debuggable = true
            debugSigned = true
        }
    }
}

Build Types can be configured with the following properties:
  • debuggable (bool; default:false; true for debug)
  • debugSigned (bool; default:false; true for debug)
  • debugJniBuild (bool; default:false; true for debug)
  • packageNameSuffix (String; default:null)
  • runProguard (bool; default:false) // unused right now.
  • zipAlign (bool; default:true; false for debug)
  • buildConfig (String...)
Creating product flavors is done with the productFlavors element:
android {
    defaultConfig {
        versionCode = 12
        minSdkVersion = 8
    }
    productFlavors {
        freeapp {
            packageName = “com.example.myapp.free”
            minSdkVersion = 10
        }
        paidapp {
            packageName = “com.example.myapp.paid”
            versionCode = 14
        }
    }
}

Flavors can be configured with the same properties as the default config. If both define a properties, then the flavor overrides the default config.

Flavor Groups

Using multi-flavor variants is done with the following two steps:

  • Defining the flavors groups. The order is important, they are defined higher priority first.
  • Assigning a group to each flavor.
android {
    flavorGroups “abi”, “version”

    productFlavors {
        freeapp {
            group = “version”
            ...
        }
        x86 {
            group = “abi”
            ...
        }
    }
}

Other Options

BuildConfig

BuildConfig is a class that is generated automatically at build time.
Similar to the old build system, the class is generated with a DEBUG boolean field. In this case it maps to the value ofBuildType.debuggable.

On top of this you can now insert new items in the class. This is done by providing full Java lines.
This is possible from the defaultConfig, any flavors, any build types. All lines are aggregated together in the same class for a given variant.

For instance: 
android {
    target = "android-15"

    defaultConfig {
        buildConfig "private final static boolean DEFAULT = true;", \
                "private final static String FOO = \"foo\";"
    }

    buildTypes {
        debug {
            packageNameSuffix = ".debug"
            buildConfig "private final static boolean STAGING = false;"
        }
        staging {
            packageNameSuffix = ".staging"
            buildConfig "private final static boolean STAGING = true;"
        }
        release {
            buildConfig "private final static boolean STAGING = false;"
        }
    }
}

Aapt Options

To provide options to aapt, the aaptOptions element is used. Right now two options are supported (more will come later):
  • noCompress (String list): list of extension to not compress
  • ignoreAssetsPattern: Assets to be ignored. Default pattern is: !.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~
android {
    target = "android-15"

    aaptOptions {
        ignoreAssetsPattern = “!.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~”
        noCompress "txt", “foo”
    }
}

Using Library Projects

As mentioned above, the plugin for library projects is android-library. It uses the same Maven artifact.

Libraries don’t have flavors, and only two build types. They can be configured this way:
android {
    target = “android-15”
    debug {
        ...
    }
    release {
        ...
    }
}

Using a library is done one of the following way:
Uploading to a maven repo is done the same way a regular Java library is uploaded. See more information here:http://www.gradle.org/docs/current/userguide/maven_plugin.html

Using a library through a repo is the same as a regular Java library, using the groupIdartifactId and version.

Standard Tasks

Java projects built with Gradle use 4 main tasks:
  • assemble -- assemble the software
  • check -- builds and run the checks and tests
  • build -- runs assemble and check
  • clean
The Android plugin use the same tasks but extends the first two to handle build variants.

For instance, a project with flavor1 and flavor2 and the two default build types will have the following 4 tasks:
  • assembleFlavor1Debug
  • assembleFlavor2Debug
  • assembleFlavor1Release
  • assembleFlavor2Release
On top of these, 4 other assemble tasks are available
  • assembleDebug -- builds all debug variants (for all flavors)
  • assembleRelease -- builds all release variants (for all flavors)
  • assembleFlavor1-- builds all flavor1 variants (for all build types)
  • assembleFlavor2-- builds all flavor2 variants (for all build types)
Adding new flavors and new build types will automatically create new assemble type tasks.

Additionally, assemble tasks for test apps are created:
  • assembleFlavor1Test -- builds the test app for the flavor1 app.
  • assembleFlavor2Test -- builds the test app for the flavor2 app.
  • assembleTest -- builds all test apps.
The default assemble tasks will call all (non test) assemble<flavors><buildtypes> tasks to build all variants of the application.

The check task is augmented similarly:
  • checkFlavor1Debug -- tests the flavor1 variant
  • checkFlavor2Debug -- tests the flavor2 variant
The default check tasks calls all check<flavor> tasks.

Checks are run by doing the following
  1. Install apps (if testing a library, only the test app)
  2. run tests
  3. Uninstall apps
Install / uninstall is done with the following tasks
  • install<flavors><type> for each variant
  • uninstall<flavor><type> for each variant
Additionally uninstallAll attempts to uninstall all variants.

Building an android application takes a lot of steps and each are available to be run on demand.
Here’s a full list of tasks used to build an application:
  • prepare<Variant>Dependencies
  • process<Variant>Manifest
  • generate<Variant>BuildConfig
  • crunch<Variant>Res
  • process<Variant>Res
  • compile<Variant>Aidl
  • compile<Variant>
  • dex<Variant>
  • package<Variant>

Customizing the tasks

Gradle provides an API to query for tasks by name or by classes.

The classes used by the Android tasks are the following:
  • Compile -- java compilation
  • CrunchResourcesTask
  • ProcessManifestTask
  • GenerateBuildConfigTask
  • ProcessResourcesTask
  • CompileAidlTask
  • DexTask
  • PackageApplicationTask
  • ZipAlignTask
In the future we intend to provide a custom API to access flavors, build types, and variants, as well as task inputs/output to do easier manipulation of the tasks.

Working with and Customizing SourceSets

Starting with 0.2, the build system uses its own SourceSet objects intead of the ones provided by the Java plugin.
You can use them to configure the location of all source elements as well as (in the case of the java source and resource folders) customize filters and exclusion.

The default config creates two sourcesets: "main" and "test". All flavors and build types automatically create their own sourceset, named after the flavor/build type name. Additionally, all flavors create a corresponding test flavor named "test<Flavorname>"

Default sourceset location is under src/<sourceset>
Sourceset have the following properties:
  • manifest, type AndroidSourceFile, default location src/<sourceset>/AndroidManifest.xml
  • res, type AndroidSourceDirectory, default location src/<sourceset>/res/
  • assets, type AndroidSourceDirectory, default location src/<sourceset>/assets/
  • aidl, type AndroidSourceDirectory, default location src/<sourceset>/aidl/
  • renderscript, type AndroidSourceDirectory, default location src/<sourceset>/renderscript/
  • jni, type AndroidSourceDirectory, default location src/<sourceset>/jni/
as well as the normal java project sourceset properties:

AndroidSourceFile and AndroidSourceDirectory have a single configurable property, respectively srcFile andsrcDir.

Example of reconfiguring the sourcesets to match an existing project structure:
android {
    sourceSets {
        main {
            manifest {
                srcFile 'AndroidManifest.xml'
            }
            java {
                srcDir 'src'
                exclude 'some/unwanted/package/**'
            }
            res {
                srcDir 'res'
            }
            assets {
                srcDir 'assets'
            }
            resources {
                srcDir 'src'
            }
        }
        test {
            java {
                srcDir 'tests/src'
            }
        }
    }
}

For more information about working with Sourceset, see: http://gradle.org/docs/current/userguide/java_plugin.html#sec:source_sets
Note that for Android projects, the sourceSets container must be modified inside the android container.

세로 프로그래스바와 씨크바 예제이다. 

[xml 구성시 주의 사항]

1. Thumb 이미지 보다 크게 layout_width 폭을 지정하면 프로그래스바 폭이 두껍게 된다.

2. 프로그래바 폭을 조절하려면 android:maxWidht에 값을 넣어 준다.


        <com.tokaracamara.android.verticalslidevar.VerticalSeekBar

            android:id="@+id/SeekBar02"

            android:layout_width="56px"

            android:layout_height="fill_parent"

            android:maxWidth="10px"

            android:progressDrawable="@drawable/progress_vertical"

            android:thumb="@drawable/seek_thumb_wide" />


[샘플 소스]

아래 프로젝트에 AbsVerticalSeekBar파일의 한 곳이 오류가 잇어서 수정했다. 

썸브 바운데리 설정시 LeftBounday가 -1로 되는 것을 방지했다. gap 부분

VerticalSlidebarExample.zip


[참고 사이트]

http://code.google.com/p/trimirror-task/source/checkout

http://560b.sakura.ne.jp/android/VerticalSlidebarExample.zip

쓸만한 위젯 lib Android 2012. 11. 16. 09:44



http://d.hatena.ne.jp/thorikawa/20101130/p1

Android 응용 프로그램에서 사용할 수있는 편리한 UI 라이브러리Add StarrgfxshepherdMastershepherdMastergabuchancanotnanatsumaKazzzdeg84jmab

Android 애플 리케이션 말하면 UI 생명! 라는 것으로 괴짜 분들이 만들어지는 편리한 UI 라이브러리를 찾아낸 한 스크린 샷과 함께 정리해 있습니다 .

여러분 모두 소스와 일부 샘플 응용 프로그램을 게시되어 있으므로 당장이라도 시도 할 수 있습니다.

(작가 분들, 싣기로 문제가있는 것 같다면 수고 스럽겠지만 연락해주십시오)

Quick Action

  • 공식 Twitter 어플 바람에 터치 한 부분에 풍선을 볼 수
  • 레이아웃도 지정 가능

YAM의 잡기장 : Android Quick Action의 Android 라이브러리 프로​​젝트를 만들어 보았다

f : id : thorikawa : 20101130005022p : image

Drag and Drop ListView

  • 드래그 앤 드롭으로 정렬 가능한 목록 보기
  • 비슷한 같은 것은 여러가지 있지만 이것이 가장 사용하기 쉬웠다!

사용자가 정렬 가능한 ListView를 조금 리치에 해 보았다 - 내일의 열쇠

f : id : thorikawa : 20101130005750p : image

Calendar

  • 뷰에서 공휴일 을 판별 표시 가능한 달력 보기
  • 상하 좌우 톡에서 월을 전환 할 수도 있으므로, 제스처 조작을 실현하고 싶은 사람은 그 부분 만이라도 참고가 될지도

CalendarView 공개했습니다 - Kazzz의 일기

f : id : Kazzz : 20101112133610p : image

3D ListView

  • 3D 로 회전하면서 스크롤 하는 목록 보기
  • 개인적으로 좋아 합니다만, 사용 장소가 떠오르지 않는다 w

Android Tutorial : Making your own 3D list - Part 3 (final part) | Developer World

f : id : thorikawa : 20101130005020p : image

CoverFlow

Interfuser : Android Coverflow Widget V2

f : id : thorikawa : 20101130005019p : image

ChartLibrary

afreechart - Project Hosting on Google Code

f : id : thorikawa : 20101130005446p : image : left

f : id : thorikawa : 20101130005447p : image : left

f : id : thorikawa : 20101130005540p : image

Zoomable ImageView

  • 길게 누르면 터치로 확대 · 축소 할 수있게된다 ImageView
  • 이미지 가 화면보다 클 것으로 표시 위치를 이동할 수있게된다
  • 이동시 후치까지 가면 바운드 애니메이션 된

Android one finger zoom tutorial - Part 4 | Developer World

Drag and Drop ImageView

  • 이미지 를 드래그 앤 드롭하여 버튼 을 두드리는
  • 아래의 스크린 샷이라고 분 에서 아니지만, 이미지 를 드롭 할 때 회전하는 것입니다. 그 애니메이션이 멋진

Android에서 드래그 앤 드롭 - hidecheck의 일기

f : id : thorikawa : 20101130010017p : image

NumberPicker

  • 증가 · 감소의 간격을 조정 가능한 수치 피커

사용자 NumberPicker 만들기 - 냐ン다후루 일기

f : id : thorikawa : 20101130084357p : image

Color Picker

  • 색상 선택기
  • 이쪽은 구형

Android에서 색상 선택기를 만들자 - 내일의 열쇠

f : id : thorikawa : 20101130005917p : image


Color Picker 11 / 30 추가)

YAM의 잡기장 : Android ColorPickerDialog을 만든

f : id : thorikawa : 20101130233733p : image

Vertical Slider 11 / 30 추가)

Vertical Seekbar - Android Developers | Google 그룹

f : id : thorikawa : 20101130233734p : image

그 밖에도

이런 편리한있어! 라고하는 것이 있으면 가르쳐주세요


간단한 기술 서적을 읽고 내용을 공유합니다.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

제목: 스마트폰과 태블릿 호환을 위한 안드로이드 앱 프로그래밍

저자: 고강태

출판사: 한빛미디어

스마트폰과 태블릿 호환을 위한 안드로이드 앱 프로그래밍

이 책은 eBook, Free DRM  형태로  발행된 책으로 아래 사이트에서 구입할 수 있다.

http://bit.ly/SQIFc6

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


[도입 글]

최근 앱을 개발하면서 노이로제 처럼 다가오는 것이 멀티 해상도 지원이다.

그냥 480x800 해상도만 개발하고 앱을 출시하까해도 뭔가 캥기는 것이

최신 스마트폰들이 고행도를 지원하기 때문이다.

더욱이 구글에서 내놓은 넥서스 7과 같이 태블릿도 다양한 형태로 출시되고 있기에

멀티 해상도에 대한 지원을 간과할 수 없는 부분이 되고 있다.


그래서 개발 초기부터 멀티 해상도를 위한 레이아웃이나 이미지 컷을 준비하고

마지막에 레이아웃별로 포팅 작업을 하게된다...


이런 시점에 이 책은 한번 정도 주의 깊게 읽어볼 필요가 있다.

이런 멀티해상도와 태블릿용과 호환되는 앱을 개발하기 위해서 가추어야 할 것을 핵심만 요약해서 알려주기에 좋다. 

1부에서는 스마트폰 앱과 태블릿 앱 개발의 차이점

2부에서는 태블릿 앱 개발을 위한 안드로이드 프로그래밍

3부에서는 스마트폰과 태블릿 호환 앱 개발


목차 내용을 보다시피, 내용이 상당히 깔끔하다.

역사, 필요성등 군더더기가 없이 필요한 내용을 바로 볼 수 있다.

이것은 한빛 미니어가 내 세우는 eBook에 특징이라고 한다. 

500페이지의 내용 대신 핵심만 들어있는 100페이지의 책..

이런 점은 잘 선택한 편집 방향이라고 생각한다. 


이 책은 스마트폰과 태블릿의 호환성 관점에서 글을 기록하지만,

최신 안드로이드 OS가 4.0으로 어찌보면 최신 OS가 요구하는 개발방식을 

사용하는 안드로이드 개발을 소개한다고 봐도 될 듯하다.

그러면서 구형 OS에서 최신 기술을 적용하는 방법을 소개하는 것과 같은 개념으로

인식해도 되는 것이다. 


[책을 구체적으로 들여다 보자]

책의 내용을 보려면 목차를 보는 것이 빠르다 

목차는 다음과 같다.


1부 스마트폰 앱과 태블릿 앱 개발의 차이점

0 1 태블릿 앱 개발의 필요성 2

0 2 다양한 단말기에 호환 가능한 앱 개발 3

2.1 태블릿 앱 개발 시 고려할 사항 3

2.1.1 안드로이드가 지원하는 화면 크기 5

2.1.2 레이아웃 최적화를 위한 기본적인 프로그래밍 방법 6

2.1.3 설정 식별자를 이용한 레이아웃 최적화 7

2.1.4 앱이 지원할 화면 크기를 정확하게 manifest에 정의 9

2.2 화면호환 가이드 10

2.2.1 화면호환 모드 버전 11

2.2.2 화면호환 모드 사용 안 하기 12

2.2.3 화면호환 모드 사용하기 13

2.3 프래그먼트 가이드 14

2.3.1 프래그먼트 사용 시 주의사항 16

2.4 태블릿 레이아웃 가이드 17

2.4.1 새로운 크기 식별자 18

2.4.2 새로운 식별자 사용 예 19

2.4.3 화면 크기 선언 20

2부 태블릿 앱 개발을 위한 안드로이드 프로그래밍

0 3 태블릿 UI/UX의 특징 22

3.1.1 홀로그래픽 UI 22

3.1.2 기존 데스크톱 OS와 유사한 UX 24

3.1.3 편리한 입력 24

3.1.4 큰 화면에 적합한 레이아웃 25

0 4 태블릿 앱 프로그래밍 27

4.1 액티비티 27

4.2 액티비티 생명주기 32

4.3 프래그먼트 37

4.3.1 프래그먼트를 이용한 앱 개발 39

4.4 프래그먼트 동적 처리 45

4.4.1 main.xml 수정 45

4.4.2 분할된 프래그먼트를 하나로 전환 46

4.5 프래그먼트 생명주기 49

4.5.1 프래그먼트 생명주기 순환 49

4.6 프래그먼트 사이의 통신 58

4.6.1 Fragment2에 버튼 추가 58

4.6.2 Fragment2 클래스 수정 59

4.6.3 프래그먼트 동작 61

4.7 인터페이스를 통한 상호 통신 61

4.7.1 Fragment1에 인터페이스 선언 62

4.7.2 Fragment2 구현 65

4.7.3 HoneyActivity 수정 67

4.8 액션 바 69

4.8.1 액션 바 보이기/숨기기 69

4.8.2 액션 바에 액션 아이템 추가하기 72

4.8.3 액션 아이템과 앱 아이콘 수정 78

3부 스마트폰과 태블릿 호환 앱 개발

0 5 Support Library Package를 이용한 앱 개발 82

5.1.1 Android Support Library 사용 84

5.1.2 HoneyActivity 변경 89

5.1.3 Fragment1 변경 92

5.1.4 Fragment2 수정 94

0 6 멀티팬과 싱글팬을 이용한 앱 개발 99

6.1.1 레이아웃 재배치 100

6.1.2 Fragment2Activity 추가 104

6.1.3 Fragment2 클래스 수정 106

6.1.4 HoneyMessage 리스너 개선 108


책의 전체적인 흐름의 해상도 편화에 대한 대응을 위하여 필요한 내용을 여러 단계를 통해서 설명을 하게된다.

1. 레이아웃을 사용되는 속성값 들의 소개

- wrap_content, fill_parent,, match_parent, dp, sp

- 사이즈, 밀도, 해상도, 비율

- 프로젝트 res 폴더를 통해서 다양한 이미지 적재 방법

* 절대로 px과 같은 값을 레이아웃에 직접 정의하지 말것을 당부한다.


2. 메니페스트에 다양한 옵션들

- 화면모드

- support-screens, minSdk, TargetSdk

- 태블릿을 위한 새로운 식별자, sw<N>dp, w<N>dp, h<N>dp


4.Fragment

- 태블릿 또는 스마트폰에서 사용할 수 있는 프래그먼트 개발 방법 및 데이터 전송방법

   액티비가 중계 역활을 하는 프레그먼트간의 통신 방식 (아래에 좀더 내용을 기록했다.)

- 스마트폰, 태블릿 구분이 최신 개발 기술이다. 


5. 액션바 

- 허니컴 이상에서 지원하는 액션바 개발 방법

- 액션바 꾸미기 등

6. Support Library Package 

- 절대적으로 중요한 부분으로 최신 OS기능 특히 프래그먼트를 구현 OS에서 사용할 때 필수적인 lib로 

  이것을 사용방법을 안내한다.

- 최신 기능을 모두 포함하는 것은 아니지만, 프래그먼트 등 주요한 것이 OS 구분없이 사용 가능하게 해준다.


7. 멀티팬 처리

- 화면을 분활해서 구성할 수 있다.

- 작은 화면과 큰화면에 대응이 용이하다. 


[내용중에 기억할 사항들]

Fragment간에 통신 방식은 Activity가 중계해 주는 인테페이스 방식을 사용한다. 

(4.7 인터페이스를 통한 상호 통신)


<pre class="brush: java">

Fragment1 fragment1;

Fragment2 fragment2;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

fragment1 = (Fragment1)getFragmentManager()

.findFragmentById(R.id.fragment1);

fragment2 = (Fragment2)getFragmentManager()

.findFragmentById(R.id.fragment2);

fragment1.setHoneyListener(this);

fragment2..setHoneyListener(this);

}

@Override

public void sendMessage(CharSequence msg) {

fragment2.setMessage(msg);

}

@Override

public String getNextMessage() {

return null;

}

</pre>


2.3.1 프래그먼트 사용 시 주의사항

다음은 프래그먼트 사용 시 주의해야 할 사항들입니다.

● 프래그먼트 클래스를 XML에 지정하면 교체가 안 됩니다.

● 프래그먼트는 FrameLayout의 ID를 지정하고 FrameTransaction을 사용해서

add, replace해야 합니다.

● 프래그먼트 사이의 데이터 전송에는 매개변수로 번들Bundle 객체를 사용합니다.

● FragmentTransaction을 사용할 때 반드시 commit()을 사용해야 합니다.

● FragmentTransation을 사용해서 프래그먼트를 추가할 때 애니메이션은 add,

replace를 지정하기 이전에 선언해야 합니다.

● FragmentTransaction의 addToBackStack() 메소드를 지정하지 않으면, Back

CHAPTER 02 다양한 단말기에 호환 가능한 앱 개발 가이드 17

Key 사용 시 해당 액티비티가 종료됩니다.

● 프래그먼트 하나가 다른 프래그먼트를 직접 컨트롤하도록 구현해서는 안 됩니다.

● 프래그먼트 내용을 변경하는 코드는 모두 해당 프래그먼트 클래스 내에 있어야

합니다.

● 프래그먼트와 액티비티의 통신을 위해 프래그먼트에서 리스너 인터페이스를 제

공하고, 이것을 액티비티에서 구현해서 사용합니다.

● 프래그먼트를 내장하고 있는 액티비티와 콜백 인터페이스를 통해서 앱 내부의

프래그먼트와 통신합니다.

● 이벤트 발생 시 콜백 인터페이스를 통해 자신을 호스팅하는 엑티비티에 내용을

전달하도록 구현합니다.


이상으로 책의 내용을 간단히 기록해 보았다.


어찌보면 책의 내용을 모두 기록한 것이 아니니, 소개 내용 자체가 부족할 수 있겠지만,

책 차제에는 충분한 설명, 코드 예제, 설명에 해당하는 그림등 이해하는데 부족함 없이 내용이 들어 있다.


끝으로 

이북이 장점이 Free PDF라서 DRM이 없기에, PC에서 스마트폰에서 넣고 다니면서 볼 수 있기에

매우 좋은 듯하다.

이렇게 eBook으로 소개되는 책이 점점 더 많이 늘어 나길 기대해 본다. 










'Android' 카테고리의 다른 글

Using the new Build System  (0) 2012.11.19
세로 SeekBar 예제 소스  (0) 2012.11.16
쓸만한 위젯 lib  (0) 2012.11.16
MIV에 대해서  (0) 2011.07.21
Application Class에 대해서  (0) 2011.07.15
MIV에 대해서 Android 2011. 7. 21. 09:54

MIV는 Mobile In Vechicel의 약자로 자동차에 모발일 기술이 접목되어 자동차 상태 및 제어를 스마트폰에서 할 수 있도록 하는 기술이다. 

- Application Class는 Context를 상속받는다.
- Application Class는 singletone 형태로 모든 컨포넌트와 클래스에서 접근이 용이하다.
- Application Class를 상속 받아서 정의하는 것과 사용이 매우 간단하다.
- 다른 SingleTone은 공통의 인스턴스로 사용하는 것을 보장하지 않는다.
- Process가 다르면 Application Class라 할지라도 다른 인스턴스를 갖게된다. 


[생성]
Application Class를 상속 받아서 클래스를 만든다.

Class MyClass extended Applicaiton {

}


[정의]
androidmenifast.xml에 등록한다.

<application 

      android:icon="@drawable/icon" 

      android:label="@string/app_name"

      android:name=".MyClass"

      >
---- 

 

[사용] 
인스턴스를 확보해서 사용하면 된다.

MyClass ACN = (MyClass)getApplicationContext();



 

'Android' 카테고리의 다른 글

Using the new Build System  (0) 2012.11.19
세로 SeekBar 예제 소스  (0) 2012.11.16
쓸만한 위젯 lib  (0) 2012.11.16
[책] 스마트폰과 태블릿 호환을 위한 안드로이드 앱 프로그래밍  (0) 2012.09.16
MIV에 대해서  (0) 2011.07.21