示例#1
0
 /** Updates the text fields that display which file is mapped to each action */
 public void updateFileNames() {
   TextView t = (TextView) rootView.findViewById(R.id.one_down_file);
   String str = Control.getFileMappedToTouch(TypeOfAction.OneDown);
   updateTextView(t, str);
   t = (TextView) rootView.findViewById(R.id.one_left_file);
   str = Control.getFileMappedToTouch(TypeOfAction.OneLeft);
   updateTextView(t, str);
   t = (TextView) rootView.findViewById(R.id.one_right_file);
   str = Control.getFileMappedToTouch(TypeOfAction.OneRight);
   updateTextView(t, str);
   t = (TextView) rootView.findViewById(R.id.one_up_file);
   str = Control.getFileMappedToTouch(TypeOfAction.OneUp);
   updateTextView(t, str);
   t = (TextView) rootView.findViewById(R.id.two_up_file);
   str = Control.getFileMappedToTouch(TypeOfAction.TwoUp);
   updateTextView(t, str);
   t = (TextView) rootView.findViewById(R.id.two_down_file);
   str = Control.getFileMappedToTouch(TypeOfAction.TwoDown);
   updateTextView(t, str);
   t = (TextView) rootView.findViewById(R.id.pinch_file);
   str = Control.getFileMappedToTouch(TypeOfAction.TwoPinch);
   updateTextView(t, str);
   t = (TextView) rootView.findViewById(R.id.expand_file);
   str = Control.getFileMappedToTouch(TypeOfAction.TwoExpand);
   updateTextView(t, str);
 }
示例#2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    String Language = preferences.getString("Lang", "no_find");
    Locale mylocale = new Locale(Language);
    if (Language == "no_find") mylocale = Resources.getSystem().getConfiguration().locale;
    Resources res1 = getResources();
    Configuration conf = res1.getConfiguration();
    conf.locale = mylocale;
    DisplayMetrics dm = res1.getDisplayMetrics();
    res1.updateConfiguration(conf, dm);
    Locale.setDefault(mylocale);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    // initializes the control object which serves as the interface between the gui and
    // the usb communication
    control = (Control) getLastCustomNonConfigurationInstance();
    if (control == null) {
      Resources res = getResources();
      String[] commands = res.getStringArray(R.array.command_select_options);
      control = new Control();
      Control.initialize(commands);
    }

    //        launchAboutActivity();
  }
示例#3
0
 /** This function updates the command display. */
 public static void updateOutput() {
   try {
     TextView t = (TextView) rootView.findViewById(R.id.Commands);
     t.setText(Control.getDisplayableText(rootView.getContext()));
   } catch (Exception e) {
     Log.e(TAG, "Exception caught in updateOutput");
   }
 }
示例#4
0
 /**
  * This function is called when the user clicks submit on a RoboAppDialogFragment. It sends the
  * command entered in the dialog to the RoboCat and updates the command display.
  *
  * @param dialog - the DialogFragment the user interacted with.
  */
 public void onCommandSubmitClick(DialogFragment dialog) {
   boolean success = true;
   RoboAppDialogFragment d = (RoboAppDialogFragment) dialog;
   try {
     Control.sendManualCommand(d.getData());
   } catch (NumberFormatException e) {
     success = false;
   }
   if (success) HWSectionFragment.updateOutput();
 }
示例#5
0
    /**
     * This function is called when an item in the command dropdown is selected. If the Manual
     * command is selected this function opens up a dialog for the user to enter the values to send
     * to the cat. Other wise it sends the command to the cat and updates the command display.
     *
     * @param parent - the AdapterView of the command dropdown.
     * @param view - the View of the spinner widget.
     * @param pos - the position in the array of selectable items that was accepted.
     * @param id - the id of the command dropdown
     */
    public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
      String command = parent.getItemAtPosition(pos).toString();

      if (command.equals("Manual")) {
        enterManualCommand();
      } else if (!command.equals("Select Command")) {
        Control.sendCommand(command);
        updateOutput();
      }

      parent.setSelection(0);
    }