<commit_before>// modulator android project
// by me

package com.timseal.modulator;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

import java.util.ArrayList;

public class MainActivity extends Activity {

    private static final String TAG = "Modulator.MainActivity";
    public static final int MAX_CHORDS = 20;
    public static final String CHORDS_LIST = "chords_list";
    ArrayList<Integer> chords = new ArrayList<Integer>(MAX_CHORDS);


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        if(savedInstanceState != null) {
//            chords = savedInstanceState.getIntegerArrayList(CHORDS_LIST);
//        }
        //TODO: keep state on orientation changes!!
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    public void modulateUp(View v) {

        //loop over all chords
        //  +1 to each
        // except 12, which becomes 1.
        // so no mod 12 stuff is even needed!

        ArrayList<Integer> newChords = new ArrayList<Integer>(MAX_CHORDS);

        for (Integer chord : chords) {
            Integer newChord;
            if (chord >= 1 && chord <= 11) {
                newChord = chord + 1;
            } else if (chord == 12) {
                newChord = 1;
            } else {
                Log.d(TAG, "invalid chord number");
                newChord = -1;
                ///ARGH! error.
            }
            Log.d(TAG, "chord was " + chord + ", changed to " + newChord);
            newChords.add(newChord);
        }
        Log.d(TAG, newChords.toString());
        chords = newChords; //possible sync bug
        //Toast.makeText(getApplicationContext(), chordNamesFromNumbers(), Toast.LENGTH_LONG).show();
        showNewChords();
    }


    public void modulateDown(View v) {
        // loop over all chords
        // -1 to each
        // except 1, which becomes 12.
        ArrayList<Integer> newChords = new ArrayList<Integer>(MAX_CHORDS);

        for (Integer chord : chords) {
            Integer newChord;
            if (chord >= 2 && chord <= 12) {
                newChord = chord - 1;
            } else if (chord == 1) {
                newChord = 12;
            } else {
                Log.d(TAG, "invalid chord number");
                newChord = -1;
                ///ARGH! error.
            }
            Log.d(TAG, "chord was " + chord + ", changed to " + newChord);
            newChords.add(newChord);
        }
        Log.d(TAG, newChords.toString());
        chords = newChords; //possible sync bug
        //Toast.makeText(getApplicationContext(), chordNamesFromNumbers(), Toast.LENGTH_LONG).show();
        showNewChords();
    }


    private CharSequence chordNamesFromNumbers() {
        String chordNames = "";
        //loop over all chords
        // change the number into the chord name
        // append the chord name to our output
        for (Integer chordNum : chords) {
            chordNames = chordNames + getChordName(chordNum) + " ";
        }
        return (CharSequence) chordNames;
    }

    private CharSequence getChordName(Integer chordNum) {
        //No breaks because they are return statements.

        // When showing a sharp/flat, I have preferences.
        // they are F#, G#, Bb, C#, Eb.
        //Probably because I mostly play in certain keys - or I might be just strange.
        switch (chordNum) {
            case 1:
                return "A";
            case 2:
                return "Bb";
            case 3:
                return "B";
            case 4:
                return "C";
            case 5:
                return "C#";
            case 6:
                return "D";
            case 7:
                return "Eb";
            case 8:
                return "E";
            case 9:
                return "F";
            case 10:
                return "F#";
            case 11:
                return "G";
            case 12:
                return "G#";
            default:
                return "error";
        }
    }


    public void delete(View v) {
//        Toast.makeText(getApplicationContext(), "delete not done yet", Toast.LENGTH_LONG).show();
        int size = chords.size();
        if (size > 0) {
            chords.remove(size - 1);
            updateChordDisplay();
            showNewChords();
        }
        // if size is zero, then do nothing.
    }

    public void clear(View v) {
//        Toast.makeText(getApplicationContext(), "clear not done yet", Toast.LENGTH_LONG).show();
        chords.clear();
        updateChordDisplay();
        // showNewChords();  not really, it's probably nicer to keep them there
    }
<commit_msg>When we hit 'clear', clear the changed chords as well<commit_after>// modulator android project
// by me

package com.timseal.modulator;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

import java.util.ArrayList;

public class MainActivity extends Activity {

    private static final String TAG = "Modulator.MainActivity";
    public static final int MAX_CHORDS = 20;
    public static final String CHORDS_LIST = "chords_list";
    ArrayList<Integer> chords = new ArrayList<Integer>(MAX_CHORDS);


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        if(savedInstanceState != null) {
//            chords = savedInstanceState.getIntegerArrayList(CHORDS_LIST);
//        }
        //TODO: keep state on orientation changes!!
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    public void modulateUp(View v) {

        //loop over all chords
        //  +1 to each
        // except 12, which becomes 1.
        // so no mod 12 stuff is even needed!

        ArrayList<Integer> newChords = new ArrayList<Integer>(MAX_CHORDS);

        for (Integer chord : chords) {
            Integer newChord;
            if (chord >= 1 && chord <= 11) {
                newChord = chord + 1;
            } else if (chord == 12) {
                newChord = 1;
            } else {
                Log.d(TAG, "invalid chord number");
                newChord = -1;
                ///ARGH! error.
            }
            Log.d(TAG, "chord was " + chord + ", changed to " + newChord);
            newChords.add(newChord);
        }
        Log.d(TAG, newChords.toString());
        chords = newChords; //possible sync bug
        //Toast.makeText(getApplicationContext(), chordNamesFromNumbers(), Toast.LENGTH_LONG).show();
        showNewChords();
    }


    public void modulateDown(View v) {
        // loop over all chords
        // -1 to each
        // except 1, which becomes 12.
        ArrayList<Integer> newChords = new ArrayList<Integer>(MAX_CHORDS);

        for (Integer chord : chords) {
            Integer newChord;
            if (chord >= 2 && chord <= 12) {
                newChord = chord - 1;
            } else if (chord == 1) {
                newChord = 12;
            } else {
                Log.d(TAG, "invalid chord number");
                newChord = -1;
                ///ARGH! error.
            }
            Log.d(TAG, "chord was " + chord + ", changed to " + newChord);
            newChords.add(newChord);
        }
        Log.d(TAG, newChords.toString());
        chords = newChords; //possible sync bug
        //Toast.makeText(getApplicationContext(), chordNamesFromNumbers(), Toast.LENGTH_LONG).show();
        showNewChords();
    }


    private CharSequence chordNamesFromNumbers() {
        String chordNames = "";
        //loop over all chords
        // change the number into the chord name
        // append the chord name to our output
        for (Integer chordNum : chords) {
            chordNames = chordNames + getChordName(chordNum) + " ";
        }
        return (CharSequence) chordNames;
    }

    private CharSequence getChordName(Integer chordNum) {
        //No breaks because they are return statements.

        // When showing a sharp/flat, I have preferences.
        // they are F#, G#, Bb, C#, Eb.
        //Probably because I mostly play in certain keys - or I might be just strange.
        switch (chordNum) {
            case 1:
                return "A";
            case 2:
                return "Bb";
            case 3:
                return "B";
            case 4:
                return "C";
            case 5:
                return "C#";
            case 6:
                return "D";
            case 7:
                return "Eb";
            case 8:
                return "E";
            case 9:
                return "F";
            case 10:
                return "F#";
            case 11:
                return "G";
            case 12:
                return "G#";
            default:
                return "error";
        }
    }


    public void delete(View v) {
//        Toast.makeText(getApplicationContext(), "delete not done yet", Toast.LENGTH_LONG).show();
        int size = chords.size();
        if (size > 0) {
            chords.remove(size - 1);
            updateChordDisplay();
            showNewChords();
        }
        // if size is zero, then do nothing.
    }

    public void clear(View v) {
//        Toast.makeText(getApplicationContext(), "clear not done yet", Toast.LENGTH_LONG).show();
        chords.clear();
        updateChordDisplay();
        showNewChords();
    }

{'fraction_non_alphanumeric': 0.10495482077251514, 'fraction_numerical': 0.008936550491510277, 'mean_word_length': 1.6277067571093138, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3749544', 'n_tokens_mistral': 2960, 'n_tokens_neox': 2701, 'n_words': 814}