Search in sources :

Example 1 with ConfigurationSettings

use of com.morristaedt.mirror.configuration.ConfigurationSettings in project HomeMirror by HannahMitt.

the class SetUpActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_configuration);
    mConfigSettings = new ConfigurationSettings(this);
    mTemperatureChoice = (RadioGroup) findViewById(R.id.temperature_group);
    mTemperatureChoice.check(mConfigSettings.getIsCelsius() ? R.id.celsius : R.id.farenheit);
    mColorPickerRed = (SeekBar) findViewById(R.id.ColorPickerRed);
    mColorPickerRed.setProgress(Color.red(mConfigSettings.getTextColor()));
    mColorPickerGreen = (SeekBar) findViewById(R.id.ColorPickerGreen);
    mColorPickerGreen.setProgress(Color.green(mConfigSettings.getTextColor()));
    mColorPickerBlue = (SeekBar) findViewById(R.id.ColorPickerBlue);
    mColorPickerBlue.setProgress(Color.blue(mConfigSettings.getTextColor()));
    mColorShowerRed = (TextView) findViewById(R.id.ColorShowerRed);
    mColorShowerRed.setText(String.format("%d", Color.red(mConfigSettings.getTextColor())));
    mColorShowerGreen = (TextView) findViewById(R.id.ColorShowerGreen);
    mColorShowerGreen.setText(String.format("%d", Color.green(mConfigSettings.getTextColor())));
    mColorShowerBlue = (TextView) findViewById(R.id.ColorShowerBlue);
    mColorShowerBlue.setText(String.format("%d", Color.blue(mConfigSettings.getTextColor())));
    mColorShowView = findViewById(R.id.colored_bar);
    mColorShowView.setBackgroundColor(mConfigSettings.getTextColor());
    mColorPickerRed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mConfigSettings.setTextColorRed(progress);
            mColorShowerRed.setText(String.format("%d", progress));
            mColorShowView.setBackgroundColor(mConfigSettings.getTextColor());
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mColorPickerGreen.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mConfigSettings.setTextColorGreen(progress);
            mColorShowerGreen.setText(String.format("%d", progress));
            mColorShowView.setBackgroundColor(mConfigSettings.getTextColor());
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mColorPickerBlue.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mConfigSettings.setTextColorBlue(progress);
            mColorShowerBlue.setText(String.format("%d", progress));
            mColorShowView.setBackgroundColor(mConfigSettings.getTextColor());
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mBikingCheckbox = (CheckBox) findViewById(R.id.biking_checkbox);
    mBikingCheckbox.setChecked(mConfigSettings.showBikingHint());
    mMoodDetectionCheckbox = (CheckBox) findViewById(R.id.mood_detection_checkbox);
    mMoodDetectionCheckbox.setChecked(mConfigSettings.showMoodDetection());
    mShowNextCaledarEventCheckbox = (CheckBox) findViewById(R.id.calendar_checkbox);
    mShowNextCaledarEventCheckbox.setChecked(mConfigSettings.showNextCalendarEvent());
    mShowNewsHeadlineCheckbox = (CheckBox) findViewById(R.id.headline_checkbox);
    mShowNewsHeadlineCheckbox.setChecked(mConfigSettings.showNewsHeadline());
    mXKCDCheckbox = (CheckBox) findViewById(R.id.xkcd_checkbox);
    mXKCDCheckbox.setChecked(mConfigSettings.showXKCD());
    mXKCDInvertCheckbox = (CheckBox) findViewById(R.id.xkcd_invert_checkbox);
    mXKCDInvertCheckbox.setChecked(mConfigSettings.invertXKCD());
    mLatitude = (EditText) findViewById(R.id.latitude);
    mLongitude = (EditText) findViewById(R.id.longitude);
    mLatitude.setText(String.valueOf(mConfigSettings.getLatitude()));
    mLongitude.setText(String.valueOf(mConfigSettings.getLongitude()));
    mLocationView = findViewById(R.id.location_view);
    setUpLocationMonitoring();
    mStockTickerSymbol = (EditText) findViewById(R.id.stock_name);
    mStockTickerSymbol.setText(mConfigSettings.getStockTickerSymbol());
    mCountdownCheckbox = (CheckBox) findViewById(R.id.countdown_checkbox);
    mCountdownCheckbox.setChecked(mConfigSettings.showCountdown());
    mNewCountdownCheckbox = (CheckBox) findViewById(R.id.countdown_new_checkbox);
    mNewCountdownCheckbox.setChecked(false);
    if (!mConfigSettings.showCountdown()) {
        mNewCountdownCheckbox.setVisibility(View.GONE);
    }
    mNewCountdownView = findViewById(R.id.new_countdown_view);
    mNewCountdownView.setVisibility(View.GONE);
    mCountdownDays = (EditText) findViewById(R.id.countdown_days);
    mCountdownHours = (EditText) findViewById(R.id.countdown_hours);
    mCountdownMins = (EditText) findViewById(R.id.countdown_mins);
    mCountdownSecs = (EditText) findViewById(R.id.countdown_secs);
    mCountdownCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                mNewCountdownCheckbox.setVisibility(View.VISIBLE);
            } else {
                mNewCountdownCheckbox.setChecked(false);
                mNewCountdownCheckbox.setVisibility(View.GONE);
                mNewCountdownView.setVisibility(View.GONE);
            }
        }
    });
    mNewCountdownCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                mNewCountdownView.setVisibility(View.VISIBLE);
            } else {
                mNewCountdownView.setVisibility(View.GONE);
            }
        }
    });
    findViewById(R.id.launch_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            saveFields();
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mStockTickerSymbol.getWindowToken(), 0);
            Intent intent = new Intent(SetUpActivity.this, MirrorActivity.class);
            startActivity(intent);
        }
    });
}
Also used : SeekBar(android.widget.SeekBar) InputMethodManager(android.view.inputmethod.InputMethodManager) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) ConfigurationSettings(com.morristaedt.mirror.configuration.ConfigurationSettings) CompoundButton(android.widget.CompoundButton)

Example 2 with ConfigurationSettings

use of com.morristaedt.mirror.configuration.ConfigurationSettings in project HomeMirror by HannahMitt.

the class MirrorActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mirror);
    mConfigSettings = new ConfigurationSettings(this);
    AlarmReceiver.startMirrorUpdates(this);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_IMMERSIVE;
        decorView.setSystemUiVisibility(uiOptions);
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
    }
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mBirthdayText = (TextView) findViewById(R.id.birthday_text);
    mDayText = (TextView) findViewById(R.id.day_text);
    mWeatherSummary = (TextView) findViewById(R.id.weather_summary);
    mHelloText = (TextView) findViewById(R.id.hello_text);
    mWaterPlants = findViewById(R.id.water_plants);
    mGroceryList = findViewById(R.id.grocery_list);
    mBikeTodayText = (TextView) findViewById(R.id.can_bike);
    mStockText = (TextView) findViewById(R.id.stock_text);
    mMoodText = (TextView) findViewById(R.id.mood_text);
    mXKCDImage = (ImageView) findViewById(R.id.xkcd_image);
    mNewsHeadline = (TextView) findViewById(R.id.news_headline);
    mCalendarTitleText = (TextView) findViewById(R.id.calendar_title);
    mCalendarDetailsText = (TextView) findViewById(R.id.calendar_details);
    mCountdownText = (TextView) findViewById(R.id.countdown_text);
    if (mConfigSettings.invertXKCD()) {
        // Negative of XKCD image
        float[] colorMatrixNegative = { // red
        -1.0f, // red
        0, // red
        0, // red
        0, // red
        255, // green
        0, // green
        -1.0f, // green
        0, // green
        0, // green
        255, // blue
        0, // blue
        0, // blue
        -1.0f, // blue
        0, // blue
        255, // alpha
        0, // alpha
        0, // alpha
        0, // alpha
        1.0f, // alpha
        0 };
        ColorFilter colorFilterNegative = new ColorMatrixColorFilter(colorMatrixNegative);
        // not inverting for now
        mXKCDImage.setColorFilter(colorFilterNegative);
    }
    setViewState();
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ColorFilter(android.graphics.ColorFilter) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ConfigurationSettings(com.morristaedt.mirror.configuration.ConfigurationSettings) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar)

Aggregations

View (android.view.View)2 TextView (android.widget.TextView)2 ConfigurationSettings (com.morristaedt.mirror.configuration.ConfigurationSettings)2 Intent (android.content.Intent)1 ColorFilter (android.graphics.ColorFilter)1 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)1 ActionBar (android.support.v7.app.ActionBar)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 SeekBar (android.widget.SeekBar)1