package test.pkg;

import android.app.Activity;
import android.os.Bundle;

public class StringFormatActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String target = "World";
        String hello = getResources().getString(R.string.hello);
        String output1 = String.format(hello, target);
        String hello2 = getResources().getString(R.string.hello2);
        String output2 = String.format(hello2, target, "How are you");
        setContentView(R.layout.main);
        String score = getResources().getString(R.string.score);
        int points = 50;
        boolean won = true;
        String output3 = String.format(score, points);
        String output4 = String.format(score, true);  // wrong
        String output  = String.format(score, won);   // wrong
        String output5 = String.format(score, 75);
        String.format(getResources().getString(R.string.hello2), target, "How are you");
        //getResources().getString(R.string.hello, target, "How are you");
        getResources().getString(R.string.hello2, target, "How are you");
    }

    // Test constructor handling (issue 35588)
    public StringFormatActivity() {
        String target = "World";
        String hello = getResources().getString(R.string.hello);
        String output1 = String.format(hello, target);
    }

    public void testPrimitiveWrappers() {
        Boolean won = true;
        Integer value = 1;
        String score = getResources().getString(R.string.score);
        String score2 = getResources().getString(R.string.score2);
        String output1  = String.format(score, won);   // wrong
        String output2  = String.format(score, value);   // ok
        String output3  = String.format(score2, won);   // ok
    }

    private static class R {
        private static class string {
            public static final int hello = 1;
            public static final int hello2 = 2;
            public static final int score = 3;
            public static final int score2 = 5;
        }
        private static class layout {
            public static final int main = 4;
        }
    }
}
