Ejemplo n.º 1
0
  /**
   * @see com.jdroid.android.fragment.AbstractFragment#onViewCreated(android.view.View,
   *     android.os.Bundle)
   */
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    View header = inflate(R.layout.about_header_fragment);
    TextView appName = (TextView) header.findViewById(R.id.appName);
    appName.setText(AbstractApplication.get().getAppName());

    TextView version = (TextView) header.findViewById(R.id.version);
    version.setText(getString(R.string.version, AndroidUtils.getVersionName()));

    TextView copyright = (TextView) header.findViewById(R.id.copyright);
    copyright.setText(getCopyRightLegend());

    if (getAppContext().displayDebugSettings()) {
      View debugSettings = header.findViewById(R.id.icon);
      debugSettings.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              AbstractApplication.get().getDebugContext().launchActivityDebugSettingsActivity();
            }
          });
    }

    if (getListView().getHeaderViewsCount() == 0) {
      if (getListAdapter() != null) {
        setListAdapter(null);
      }
      getListView().addHeaderView(header);
    }
    if (getListAdapter() == null) {
      setListAdapter(new AboutItemsAdapter(getActivity(), aboutItems));
    }
  }
Ejemplo n.º 2
0
  /** @see com.jdroid.android.fragment.AbstractListFragment#onCreate(android.os.Bundle) */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final String website = getWebsite();
    if (website != null) {
      aboutItems.add(
          new AboutItem(R.drawable.ic_website, R.string.website) {
            @Override
            public void onSelected(Activity activity) {
              IntentUtils.startUrl(activity, website);
            }
          });
    }

    final String contactUsEmailAddress = getContactUsEmail();
    if (contactUsEmailAddress != null) {
      aboutItems.add(
          new AboutItem(R.drawable.ic_contact_us, R.string.contactUs) {

            @Override
            public void onSelected(Activity activity) {
              Intent intent =
                  ShareUtils.createOpenMail(
                      contactUsEmailAddress, AbstractApplication.get().getAppName());
              if (IntentUtils.isIntentAvailable(intent)) {
                startActivity(intent);
                AbstractApplication.get().getAnalyticsSender().trackContactUs();
              } else {
                // TODO Improve this adding a toast or something
                AbstractApplication.get()
                    .getExceptionHandler()
                    .logWarningException("Error when sending email intent");
              }
            }
          });
    }

    if (AbstractApplication.get().getAboutContext().getSpreadTheLoveFragmentClass() != null) {
      aboutItems.add(
          new AboutItem(R.drawable.ic_spread_the_love, R.string.spreadTheLove) {

            @Override
            public void onSelected(Activity activity) {
              ActivityLauncher.launchActivity(SpreadTheLoveActivity.class);
            }
          });
    }
    aboutItems.add(
        new AboutItem(R.drawable.ic_rate_us, R.string.rateUs) {

          @Override
          public void onSelected(Activity activity) {
            RateAppView.rateMeClicked();
            GooglePlayUtils.launchAppDetails(getActivity());
            AbstractApplication.get().getAnalyticsSender().trackRateUs();
          }
        });
    aboutItems.add(
        new AboutItem(R.drawable.ic_libraries, R.string.libraries) {

          @Override
          public void onSelected(Activity activity) {
            ActivityLauncher.launchActivity(LibrariesActivity.class);
          }
        });
    aboutItems.addAll(getCustomAboutItems());
  }