Ejemplo n.º 1
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set layout
    String sTheme =
        PrivacyManager.getSetting(null, this, PrivacyManager.cSettingTheme, null, false);
    int themeId = (sTheme == null ? android.R.style.Theme_Holo_Light : Integer.parseInt(sTheme));
    setTheme(themeId);
    setContentView(R.layout.restrictionlist);

    // Get package name
    Bundle extras = getIntent().getExtras();
    final String packageName = extras.getString(cPackageName);

    // Get app info
    mAppInfo = new ApplicationInfoEx(this, packageName);
    if (!mAppInfo.getIsInstalled()) {
      finish();
      return;
    }

    // Background color
    if (mAppInfo.getIsSystem()) {
      LinearLayout llInfo = (LinearLayout) findViewById(R.id.llInfo);
      if (themeId == android.R.style.Theme_Holo_Light)
        llInfo.setBackgroundColor(Color.parseColor("#FFFDD0"));
      else llInfo.setBackgroundColor(Color.DKGRAY);
    }

    // Display app name
    TextView tvAppName = (TextView) findViewById(R.id.tvApp);
    tvAppName.setText(mAppInfo.toString());

    // Display version
    TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
    tvVersion.setText(mAppInfo.getVersion());

    // Display package name / uid
    TextView tvPackageName = (TextView) findViewById(R.id.tvPackageName);
    tvPackageName.setText(String.format("%s %d", packageName, mAppInfo.getUid()));

    // Handle help
    tvAppName.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Dialog dialog = new Dialog(ActivityApp.this);
            dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
            dialog.setTitle(getString(R.string.help_application));
            dialog.setContentView(R.layout.help);
            dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_launcher);
            dialog.setCancelable(true);
            dialog.show();
          }
        });

    // Display app icon
    ImageView imgIcon = (ImageView) findViewById(R.id.imgAppEntryIcon);
    imgIcon.setImageDrawable(mAppInfo.getDrawable());

    // Handle icon click
    imgIcon.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intentApp = getPackageManager().getLaunchIntentForPackage(packageName);
            if (intentApp != null) {
              intentApp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              view.getContext().startActivity(intentApp);
            }
          }
        });

    // Check if internet access
    ImageView imgInternet = (ImageView) findViewById(R.id.imgAppEntryInternet);
    if (!PrivacyManager.hasInternet(this, packageName)) imgInternet.setVisibility(View.INVISIBLE);

    // Fill privacy list view adapter
    final ExpandableListView lvRestriction = (ExpandableListView) findViewById(R.id.elvRestriction);
    lvRestriction.setGroupIndicator(null);
    mPrivacyListAdapter =
        new RestrictionAdapter(
            R.layout.restrictionentry, mAppInfo, PrivacyManager.getRestrictions());
    lvRestriction.setAdapter(mPrivacyListAdapter);

    // Up navigation
    getActionBar().setDisplayHomeAsUpEnabled(true);
  }