Android Open Source - PlanningPokerPlusPlus Main Activity






From Project

Back to project page PlanningPokerPlusPlus.

License

The source code is released under:

Planning Poker++ for Android, copyright (c) 2011-2014 Richard Everett No specific license, but please don't rip off this codebase for use in your own similar app.

If you think the Android project PlanningPokerPlusPlus listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

// Planning Poker++ for Android, copyright (c) Richard Everett 2012
// Full source available on GitHub at http://richev.github.com/PlanningPokerPlusPlus
/*  w w  w.j  a va  2  s.c o m*/
package com.richev.planningpokerplusplus;

import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

/**
 * The main entry point activity for the application, which shows a list of card value buttons
 * 
 * @author Rich
 * 
 */
public class MainActivity extends MenuedActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        showCardButtons();

        SettingsActivity.mainActivity = this;
        
        Startup startup = new Startup(this);
        
        if (!startup.getHasRun())
        {
            startup.setHasRun();
            showAboutDialog();
        }
    }

    /**
     * Displays the buttons on the activity. Needs to be called when the activity is first started,
     * and also if the buttons ever change (due to user settings
     * changes invoked from SettingsActivity, for example)
     */
    public void showCardButtons()
    {
        final LinearLayout buttonsLayout = (LinearLayout)findViewById(R.id.buttonsLayout);

        String[] cardValues = Utils.getCardValues(getResources(), new Preferences(PreferenceManager.getDefaultSharedPreferences(this)));

        buttonsLayout.removeAllViews();

        for (int i = 0; i < cardValues.length; i++)
        {
            Button button = new Button(this);
            button.setText(cardValues[i]);
            button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
            button.setPadding(0, 0, 0, 2);
            button.setOnClickListener(new OnCardSelectListener(cardValues[i])
            {
                public void onClick(View v)
                {
                    Intent myIntent = new Intent(v.getContext(), CardActivity.class);
                    myIntent.putExtra("cardValue", this.getCardValue()); // this will be read in CardActivity
                    startActivityForResult(myIntent, 0);
                }
            });

            buttonsLayout.addView(button);
        }
    }
}




Java Source Code List

com.richev.planningpokerplusplus.AboutActivity.java
com.richev.planningpokerplusplus.CardActivity.java
com.richev.planningpokerplusplus.MainActivity.java
com.richev.planningpokerplusplus.MenuedActivity.java
com.richev.planningpokerplusplus.OnCardSelectListener.java
com.richev.planningpokerplusplus.Preferences.java
com.richev.planningpokerplusplus.SettingsActivity.java
com.richev.planningpokerplusplus.Startup.java
com.richev.planningpokerplusplus.UpsideDownImageView.java
com.richev.planningpokerplusplus.UpsideDownTextView.java
com.richev.planningpokerplusplus.Utils.java