@Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        NavUtils.navigateUpTo(this, new Intent(this, Main.class));
        return true;

      case R.id.action_go_back:
        NavUtils.navigateUpTo(this, new Intent(this, Main.class));
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        /* This is called when the Home (Up) button is pressed
         * in the Action Bar. http://goo.gl/lJxjA */
        Intent upIntent = new Intent(this, MainActivity.class);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
          TaskStackBuilder.from(this).addNextIntent(upIntent).startActivities();
          finish();
        } else {
          NavUtils.navigateUpTo(this, upIntent);
        }
        return true;

      case R.id.menu_preferences:
        Intent preferencesActivity = new Intent(getBaseContext(), SettingsActivity.class);
        startActivity(preferencesActivity);
        return true;

      case R.id.menu_upload:
        if (Constants.PRO_VERSION) {
          Intent localPhotosActivity = new Intent(getBaseContext(), LocalPhotosActivity.class);
          startActivity(localPhotosActivity);
        } else {
          BuyProDialog.show(this);
        }
        return true;

      case R.id.menu_about:
        new AboutDialogFragment().show(getSupportFragmentManager(), "AboutDialogFragment");
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 3
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        // Navigate "up" the demo structure to the launchpad activity.
        // See http://developer.android.com/design/patterns/navigation.html for more.
        NavUtils.navigateUpTo(this, new Intent(this, ChooseFairyTale.class));
        return true;

        //            case R.id.action_previous:
        // Go to the previous step in the wizard. If there is no previous step,
        // setCurrentItem will do nothing.
        //                mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        //                return true;

        //            case R.id.action_next:
        //                // Advance to the next step in the wizard. If there is no next step,
        // setCurrentItem
        //                // will do nothing.
        //                mPager.setCurrentItem(mPager.getCurrentItem() + 1);
        //                return true;
    }

    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 4
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       Intent upIntent = new Intent(this, MainActivity.class);
       // This ID represents the Home or Up button. In the case of this
       // activity, the Up button is shown. Use NavUtils to allow users
       // to navigate up one level in the application structure. For
       // more details, see the Navigation pattern on Android Design:
       //
       // http://developer.android.com/design/patterns/navigation.html#up-vs-back
       //
       NavUtils.navigateUpTo(this, upIntent);
       return true;
     case R.id.frag1:
       if (!isfrag1) {
         getSupportFragmentManager().beginTransaction().replace(R.id.text_container, one).commit();
         isfrag1 = true;
         supportInvalidateOptionsMenu();
       }
       return true;
     case R.id.frag2:
       if (isfrag1) {
         getSupportFragmentManager().beginTransaction().replace(R.id.text_container, two).commit();
         isfrag1 = false;
         supportInvalidateOptionsMenu();
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 5
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       // This is called when the Home (Up) button is pressed in the action bar.
       // Create a simple intent that starts the hierarchical parent activity and
       // use NavUtils in the Support Package to ensure proper handling of Up.
       Intent upIntent = new Intent(this, MainActivity.class);
       if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
         // This activity is not part of the application's task, so create a new task
         // with a synthesized back stack.
         TaskStackBuilder.from(this)
             // If there are ancestor activities, they should be added here.
             .addNextIntent(upIntent)
             .startActivities();
         finish();
       } else {
         // This activity is part of the application's task, so simply
         // navigate up to the hierarchical parent activity.
         NavUtils.navigateUpTo(this, upIntent);
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 6
0
 public static boolean navigateUp(@NonNull final Activity activity) {
   // first check if there is a parent declared in the manifest
   Intent upIntent = NavUtils.getParentActivityIntent(activity);
   // if there is no parent, and if this was not a new task, then just go back to simulate going to
   // a parent
   if (upIntent == null && !activity.isTaskRoot()) {
     activity.finish();
     return true;
   }
   // use the main activity, if there was no back stack and no manifest based parent
   if (upIntent == null) {
     upIntent = new Intent(CgeoApplication.getInstance(), MainActivity.class);
   }
   if (NavUtils.shouldUpRecreateTask(activity, upIntent) || activity.isTaskRoot()) {
     // This activity is NOT part of this app's task, so create a new task
     // when navigating up, with a synthesized back stack.
     TaskStackBuilder.create(activity)
         // Add all of this activity's parents to the back stack
         .addNextIntentWithParentStack(upIntent)
         // Navigate up to the closest parent
         .startActivities();
   } else {
     // This activity is part of this app's task, so simply
     // navigate up to the logical parent activity.
     NavUtils.navigateUpTo(activity, upIntent);
   }
   return true;
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
      NavUtils.navigateUpTo(this, new Intent(this, ArticleListActivity.class));
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 8
0
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpTo(this, new Intent(this, RepairListActivity.class));
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Exemplo n.º 9
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == android.R.id.home) {
     Intent intent = new Intent(this, LicenseActivity.class);
     NavUtils.navigateUpTo(this, intent);
     return true;
   }
   return false;
 }
Exemplo n.º 10
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == android.R.id.home) {
     Intent upIntent = NavUtils.getParentActivityIntent(this);
     NavUtils.navigateUpTo(this, upIntent);
     return true;
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpTo(this, new Intent(this, CalendarMaintenanceActivity.class));
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    // If user pick "home" from the action bar, we bring him back
    if (item.getItemId() == android.R.id.home) {
      NavUtils.navigateUpTo(this, new Intent(this, PageListActivity.class));
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 13
0
 public static void navigateUpFromSameTask(Activity paramActivity) {
   Intent localIntent = getParentActivityIntent(paramActivity);
   if (localIntent == null) {
     throw new IllegalArgumentException(
         "Activity "
             + paramActivity.getClass().getSimpleName()
             + " does not have a parent activity name specified."
             + " (Did you forget to add the android.support.PARENT_ACTIVITY <meta-data> "
             + " element in your manifest?)");
   }
   navigateUpTo(paramActivity, localIntent);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpTo(this, new Intent(this, NetworksListActivity.class));
       return true;
     case R.id.pref:
       startActivity(new Intent(this, Preferences.class));
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 15
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        Intent upIntent = NavUtils.getParentActivityIntent(this);
        if (upIntent != null)
          if (NavUtils.shouldUpRecreateTask(this, upIntent))
            TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent).startActivities();
          else NavUtils.navigateUpTo(this, upIntent);

        return true;
      case R.id.menu_all:
        List<String> listRestriction = PrivacyManager.getRestrictions();

        // Get toggle
        boolean restricted = false;
        for (String restrictionName : listRestriction)
          if (PrivacyManager.getRestricted(
              null, this, mAppInfo.getUid(), restrictionName, null, false, false)) {
            restricted = true;
            break;
          }

        // Do toggle
        restricted = !restricted;
        for (String restrictionName : listRestriction)
          PrivacyManager.setRestricted(
              null, this, mAppInfo.getUid(), restrictionName, null, restricted);

        // Refresh display
        if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged();

        return true;
      case R.id.menu_app_launch:
        Intent LaunchIntent =
            getPackageManager().getLaunchIntentForPackage(mAppInfo.getPackageName());
        startActivity(LaunchIntent);
        return true;
      case R.id.menu_app_settings:
        startActivity(
            new Intent(
                android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                Uri.parse("package:" + mAppInfo.getPackageName())));
        return true;
      case R.id.menu_app_store:
        startActivity(
            new Intent(
                Intent.ACTION_VIEW, Uri.parse("market://details?id=" + mAppInfo.getPackageName())));
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       {
         Intent viewIntent = NavUtils.getParentActivityIntent(this);
         viewIntent.setData(KeyRings.buildGenericKeyRingUri(mDataUri));
         NavUtils.navigateUpTo(this, viewIntent);
         return true;
       }
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 17
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int id = item.getItemId();
   if (id == android.R.id.home) {
     Intent intent = NavUtils.getParentActivityIntent(this);
     Bundle bundle = new Bundle();
     bundle.putParcelable(ARG_POTENTIAL_HABIT_EDIT, detailFragment.getHabit());
     intent.putExtras(bundle);
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
     NavUtils.navigateUpTo(this, intent);
     return true;
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 18
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.

    // switch statement to navigate up back to the fragment. Pops from stack.
    switch (item.getItemId()) {
      case android.R.id.home:
        NavUtils.navigateUpTo(this, new Intent(this, ShopActivity.class));
        return true;
    }

    return super.onOptionsItemSelected(item);
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int id = item.getItemId();
   if (id == android.R.id.home) {
     // This ID represents the Home or Up button. In the case of this
     // activity, the Up button is shown. Use NavUtils to allow users
     // to navigate up one level in the application structure. For
     // more details, see the Navigation pattern on Android Design:
     //
     // http://developer.android.com/design/patterns/navigation.html#up-vs-back
     //
     NavUtils.navigateUpTo(this, new Intent(this, sleepChooserListActivity.class));
     return true;
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 20
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        // Navigate "up" the demo structure to the launchpad activity.
        // See http://developer.android.com/design/patterns/navigation.html for more.
        NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
        return true;

      case R.id.action_flip:
        flipCard();
        return true;
    }

    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 21
0
 private void backToPictureMenu() {
   Intent upIntent = NavUtils.getParentActivityIntent(this);
   upIntent.putExtra("REDIRECT", true);
   if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
     // This activity is NOT part of this app's task, so create a new task
     // when navigating up, with a synthesized back stack.
     TaskStackBuilder.create(this)
         // Add all of this activity's parents to the back stack
         .addNextIntentWithParentStack(upIntent)
         // Navigate up to the closest parent
         .startActivities();
   } else {
     // This activity is part of this app's task, so simply
     // navigate up to the logical parent activity.
     NavUtils.navigateUpTo(this, upIntent);
   }
 }
  @SuppressWarnings("unchecked")
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        Intent upIntent = new Intent(this, SelectAccountActivity.class);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
          TaskStackBuilder.create(this).addNextIntent(upIntent).startActivities();
        } else {
          NavUtils.navigateUpTo(this, upIntent);
        }
        return true;

      case R.id.menu_sync_now:

        // This is a convenient way of enabling and running the contact photo
        // sync.

        Account a = new Account(account, ACCOUNT_TYPE);
        ContentResolver.setSyncAutomatically(a, CONTACT_PHOTO_AUTHORITY, true);
        ContentResolver.requestSync(a, CONTACT_PHOTO_AUTHORITY, new Bundle());
        Toast.makeText(this, getResources().getString(R.string.sync_requested), Toast.LENGTH_LONG)
            .show();
        break;

      case R.id.menu_download_all:
      case R.id.menu_upload_all:
        new DownloadUploadTask(
                item.getItemId() == R.id.menu_download_all
                    ? DownloadUploadTask.TYPE_DOWNLOAD
                    : DownloadUploadTask.TYPE_UPLOAD)
            .execute(((ContactAdapter) contactList.getAdapter()).getBackingList());

        break;

      case R.id.menu_refresh:

        // XXX This is ugly and hackish. This of course doesn't stop us from being
        // lazy and using it here.

        onPause();
        onResume();
        break;
    }
    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
      return true;
    } else if (id == android.R.id.home) {
      NavUtils.navigateUpTo(this, new Intent(this, HomeActivity.class));
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 24
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case android.R.id.home:
        NavUtils.navigateUpTo(
            this,
            new Intent(this, PrincipalActivity.class)
                .putExtra(Constants.EXTRA_COLOR, this.currentColor));

        finish();

        break;
    }

    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 25
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       if (templateStory) {
         NavUtils.navigateUpTo(this, new Intent(this, StoryTemplateActivity.class));
       } else {
         NavUtils.navigateUpFromSameTask(this);
       }
       return true;
     case R.id.itemForward:
       int idx = getSupportActionBar().getSelectedNavigationIndex();
       getSupportActionBar().setSelectedNavigationItem(Math.min(2, idx + 1));
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 26
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        Intent upIntent = new Intent(this, MainActivity.class);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {

          TaskStackBuilder.from(this).addNextIntent(upIntent).startActivities();

          finish();
        } else {

          NavUtils.navigateUpTo(this, upIntent);
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 27
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       // This ID represents the Home or Up button. In the case of this
       // activity, the Up button is shown. Use NavUtils to allow users
       // to navigate up one level in the application structure. For
       // more details, see the Navigation pattern on Android Design:
       //
       // http://developer.android.com/design/patterns/navigation.html#up-vs-back
       //
       Intent upIntent = NavUtils.getParentActivityIntent(this);
       upIntent.putExtra(SingleUnitActivity.EXTRA_DEVICE_ID, mDeviceId);
       upIntent.putExtra(SingleUnitActivity.EXTRA_HARDWARE_UNIT_ID, mHardwareUnit.getId());
       NavUtils.navigateUpTo(this, upIntent);
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 28
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       Intent i = new Intent(this, ElectorateActivity.class);
       i.putExtra("poll", (Serializable) poll);
       NavUtils.navigateUpTo(this, i);
       return true;
     case R.id.help:
       HelpDialogFragment hdf =
           HelpDialogFragment.newInstance(
               getString(R.string.help_title_review), getString(R.string.help_text_review_admin));
       hdf.show(getFragmentManager(), "help");
       return true;
     case R.id.action_start_voteperiod:
       startVotePeriod();
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 29
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    switch (id) {
      case R.id.action_settings:
        return true;
      case R.id.home:
        Intent upIntent = NavUtils.getParentActivityIntent(this);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
          TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent).startActivities();
        } else {
          NavUtils.navigateUpTo(this, upIntent);
        }
        return true;
    }

    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 30
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   // TODO Auto-generated method stub
   switch (item.getItemId()) {
     case android.R.id.home:
       Intent upIntent = new Intent(this, MainActivity.class);
       if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
         TaskStackBuilder.from(this)
             // 如果这里有很多原始的Activity,它们应该被添加在这里
             .addNextIntent(upIntent)
             .startActivities();
         finish();
       } else {
         NavUtils.navigateUpTo(this, upIntent);
       }
       break;
   }
   return super.onOptionsItemSelected(item);
 }