Android Open Source - campus Legal Info Activity






From Project

Back to project page campus.

License

The source code is released under:

GNU General Public License

If you think the Android project campus listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package lecho.app.campus.activity;
/*from  w  w w .j a  v a 2  s .  c o  m*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import lecho.app.campus.R;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.google.android.gms.common.GooglePlayServicesUtil;

public class LegalInfoActivity extends SherlockActivity {
  private static final String TAG = "LegalInfoActivity";
  public static final String EXTRA_LEGAL_INFO_LIBRARY = "lecho.app.campus:LEGAL_INFO_LIBRARY";
  public static final int EXTRA_LEGAL_INFO_PLAY_SERVICES = 1;
  public static final int EXTRA_LEGAL_INFO_ACTIONBARSHERLOCK = 2;
  public static final int EXTRA_LEGAL_INFO_VIEWPAGERINDICATOR = 3;
  public static final int EXTRA_LEGAL_INFO_MESSAGEBAR = 4;
  public static final int EXTRA_LEGAL_INFO_ZOOMIMAGEVIEW = 5;
  public static final int EXTRA_LEGAL_INFO_GREENDAO = 6;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_legal_info);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    TextView legalInfo = (TextView) findViewById(R.id.legal_info);
    String legalInfoText = "";
    int legalInfoLibrary = getIntent().getIntExtra(EXTRA_LEGAL_INFO_LIBRARY, 0);
    switch (legalInfoLibrary) {
    case EXTRA_LEGAL_INFO_PLAY_SERVICES:
      String openSourceSoftwareLicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this);
      if (openSourceSoftwareLicenseInfo != null) {
        legalInfoText = openSourceSoftwareLicenseInfo;
      } else {
        legalInfoText = getResources().getString(R.string.about_play_services_missing);
      }
      break;
    case EXTRA_LEGAL_INFO_ACTIONBARSHERLOCK:
      legalInfoText = readLicence(R.raw.licence_abs);
      break;
    case EXTRA_LEGAL_INFO_VIEWPAGERINDICATOR:
      legalInfoText = readLicence(R.raw.licence_vpi);
      break;
    case EXTRA_LEGAL_INFO_MESSAGEBAR:
      legalInfoText = readLicence(R.raw.licence_mb);
      break;
    case EXTRA_LEGAL_INFO_ZOOMIMAGEVIEW:
      legalInfoText = readLicence(R.raw.licence_ziv);
      break;
    case EXTRA_LEGAL_INFO_GREENDAO:
      legalInfoText = readLicence(R.raw.licence_gd);
      break;
    }

    legalInfo.setText(legalInfoText);

  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    return super.onCreateOptionsMenu(menu);
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
      finish();
    }
    return super.onOptionsItemSelected(item);
  }

  private String readLicence(int rawResource) {
    InputStream in = getResources().openRawResource(rawResource);
    InputStreamReader inReader = new InputStreamReader(in);
    BufferedReader bInReader = new BufferedReader(inReader);
    try {
      StringBuilder text = new StringBuilder();
      String line = null;
      while ((line = bInReader.readLine()) != null) {
        text.append(line);
        text.append("\n");
      }
      return text.toString();
    } catch (IOException e) {
      Log.e(TAG, "Could not read licence", e);
      return "";
    } finally {
      try {
        bInReader.close();
      } catch (IOException e) {
        Log.e(TAG, "Could not close licence stream reader", e);
      }
    }
  }
}




Java Source Code List

lecho.app.campus.activity.AboutAppActivity.java
lecho.app.campus.activity.CampusMapActivity.java
lecho.app.campus.activity.GalleryActivity.java
lecho.app.campus.activity.LegalInfoActivity.java
lecho.app.campus.activity.PlaceDetailsActivity.java
lecho.app.campus.adapter.GalleryPagesFragmentAdapter.java
lecho.app.campus.adapter.MarkerInfoWindowAdapter.java
lecho.app.campus.adapter.NavigationDrawerAdapter.java
lecho.app.campus.adapter.PlaceDetailsFragmentAdapter.java
lecho.app.campus.adapter.SearchResultViewAdapter.java
lecho.app.campus.adapter.SearchSuggestionAdapter.java
lecho.app.campus.dao.CategoryDao.java
lecho.app.campus.dao.CategoryDao.java
lecho.app.campus.dao.Category.java
lecho.app.campus.dao.Category.java
lecho.app.campus.dao.DaoMaster.java
lecho.app.campus.dao.DaoMaster.java
lecho.app.campus.dao.DaoSession.java
lecho.app.campus.dao.DaoSession.java
lecho.app.campus.dao.FacultyDao.java
lecho.app.campus.dao.FacultyDao.java
lecho.app.campus.dao.Faculty.java
lecho.app.campus.dao.Faculty.java
lecho.app.campus.dao.Main.java
lecho.app.campus.dao.PlaceCategoryDao.java
lecho.app.campus.dao.PlaceCategoryDao.java
lecho.app.campus.dao.PlaceCategory.java
lecho.app.campus.dao.PlaceCategory.java
lecho.app.campus.dao.PlaceDao.java
lecho.app.campus.dao.PlaceDao.java
lecho.app.campus.dao.PlaceFacultyDao.java
lecho.app.campus.dao.PlaceFacultyDao.java
lecho.app.campus.dao.PlaceFaculty.java
lecho.app.campus.dao.PlaceFaculty.java
lecho.app.campus.dao.PlaceUnitDao.java
lecho.app.campus.dao.PlaceUnitDao.java
lecho.app.campus.dao.PlaceUnit.java
lecho.app.campus.dao.PlaceUnit.java
lecho.app.campus.dao.Place.java
lecho.app.campus.dao.Place.java
lecho.app.campus.dao.UnitDao.java
lecho.app.campus.dao.UnitDao.java
lecho.app.campus.dao.Unit.java
lecho.app.campus.dao.Unit.java
lecho.app.campus.fragment.GalleryPageFragment.java
lecho.app.campus.fragment.PlaceDetailsFragment.java
lecho.app.campus.fragment.dialog.NoInternetConnectionDialogFragment.java
lecho.app.campus.fragment.dialog.PlayServicesErrorDialogFragment.java
lecho.app.campus.loader.PlaceDetailsLoader.java
lecho.app.campus.loader.PlacesLoader.java
lecho.app.campus.provider.SearchSuggestionProvider.java
lecho.app.campus.service.PopulateDBIntentService.java
lecho.app.campus.utils.ABSMenuItemConverter.java
lecho.app.campus.utils.BitmapAsyncTask.java
lecho.app.campus.utils.Config.java
lecho.app.campus.utils.DataParser.java
lecho.app.campus.utils.DatabaseHelper.java
lecho.app.campus.utils.ImagesDirAsyncTask.java
lecho.app.campus.utils.NavigationDrawerItem.java
lecho.app.campus.utils.PlaceDetails.java
lecho.app.campus.utils.PlacesList.java
lecho.app.campus.utils.UnitsGroup.java
lecho.app.campus.utils.Utils.java
lecho.app.campus.view.CheckableDrawerItem.java
lecho.app.campus.view.UnitsGroupLayout.java
lecho.app.campus.view.ZoomImageView.java
lecho.app.campus.view.ZoomViewPager.java