// Check compatibility against SensorTypes
 void setCompatibility(TextView tv, CheckedTextView ctv, SensorTypes sensor) {
   if (sensors.isCompatible(sensor)) {
     tv.setTextColor(Color.parseColor("#00AA00"));
     tv.setText(R.string.compatible);
     ctv.setChecked(true);
   } else {
     tv.setTextColor(Color.parseColor("#AA0000"));
     tv.setText(R.string.incompatible);
     ctv.setChecked(false);
     ctv.setCheckMarkDrawable(R.drawable.red_x);
   }
 }
Пример #2
0
 public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) {
   View localView = paramView;
   if (paramView == null) {
     localView =
         LayoutInflater.from(paramViewGroup.getContext())
             .inflate(2130903372, paramViewGroup, false);
     localView.setTag(new a.a(localView));
   }
   paramView = (a.a) localView.getTag();
   paramViewGroup = (Category) getItem(paramInt);
   Object localObject = (Drawable) a.get(paramViewGroup.d());
   a.setCompoundDrawablesWithIntrinsicBounds((Drawable) localObject, null, null, null);
   if ((c) && (paramViewGroup.f() > 0)) {
     b.setVisibility(0);
     localObject = a;
     if ((!b.contains(paramViewGroup)) || (paramViewGroup.f() != 0)) {
       break label169;
     }
   }
   label169:
   for (boolean bool = true; ; bool = false) {
     ((CheckedTextView) localObject).setChecked(bool);
     a.setText(paramViewGroup.a());
     return localView;
     b.setVisibility(8);
     break;
   }
 }
 @Override
 public View getGroupView(
     final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
   if (convertView == null) {
     LayoutInflater inflater =
         (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     convertView = inflater.inflate(R.layout.group, null);
   }
   ImageButton btn = (ImageButton) convertView.findViewById(R.id.discardBtn);
   btn.setFocusable(false);
   btn.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Log.d(TAG, "group with time " + titles.get(groupPosition) + " clicked!");
         }
       });
   CheckedTextView tw = (CheckedTextView) convertView.findViewById(R.id.checkedTW);
   Title title = titles.get(groupPosition);
   tw.setText(title.getDate());
   tw.setChecked(isExpanded);
   TextView coordsView = (TextView) convertView.findViewById(R.id.coordsView);
   coordsView.setText(
       "Floor: " + title.getZ() + ". Position [" + title.getX() + ", " + title.getY() + "]");
   return convertView;
 }
  private void rebuildComplicationsList() {
    ViewGroup complicationsContainer = (ViewGroup) mRootView.findViewById(R.id.complications_list);
    complicationsContainer.removeAllViews();

    LayoutInflater inflater = LayoutInflater.from(getActivity());

    for (int i = 0; i < PREF_KEYS.length; i++) {
      final String prefKey = PREF_KEYS[i];

      ViewGroup itemContainer =
          (ViewGroup)
              inflater.inflate(R.layout.config_complications_item, complicationsContainer, false);
      final CheckedTextView titleView =
          (CheckedTextView) itemContainer.findViewById(android.R.id.text1);
      final View checkmarkView = itemContainer.findViewById(R.id.checkmark);

      titleView.setText(PREF_TITLE_IDS[i]);
      boolean isPrefOn = mSharedPreferences.getBoolean(prefKey, false);

      checkmarkView.setVisibility(isPrefOn ? View.VISIBLE : View.INVISIBLE);
      titleView.setChecked(isPrefOn);

      itemContainer.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              boolean isPrefOn = mSharedPreferences.getBoolean(prefKey, false);
              mSharedPreferences.edit().putBoolean(prefKey, !isPrefOn).apply();
              rebuildComplicationsList();
            }
          });

      complicationsContainer.addView(itemContainer);
    }
  }
Пример #5
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    AlarmPre alarmPreference = (AlarmPre) getItem(position);
    LayoutInflater layoutInflater = LayoutInflater.from(getContext());
    switch (alarmPreference.getType()) {
      case BOOLEAN:
        if (null == convertView || convertView.getId() != android.R.layout.simple_list_item_checked)
          convertView = layoutInflater.inflate(android.R.layout.simple_list_item_checked, null);

        CheckedTextView checkedTextView =
            (CheckedTextView) convertView.findViewById(android.R.id.text1);
        checkedTextView.setText(alarmPreference.getTitle());
        checkedTextView.setChecked((Boolean) alarmPreference.getValue());
        break;

      case INTEGER:
      case STRING:
      case LIST:
      case MULTIPLE_LIST:
      case TIME:
      default:
        if (null == convertView || convertView.getId() != android.R.layout.simple_list_item_2)
          convertView = layoutInflater.inflate(android.R.layout.simple_list_item_2, null);

        TextView text1 = (TextView) convertView.findViewById(android.R.id.text1);
        text1.setTextSize(18);
        text1.setText(alarmPreference.getTitle());

        TextView text2 = (TextView) convertView.findViewById(android.R.id.text2);
        text2.setText(alarmPreference.getSummary());
        break;
    }

    return convertView;
  }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   CheckedTextView view = (CheckedTextView) super.getView(position, convertView, parent);
   DialogOption option = mOptions[position];
   view.setChecked(mSelectedOptions.contains(option));
   view.setEnabled(!mDisabledOptions.contains(option));
   return view;
 }
Пример #7
0
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Task task = mAdapter.getItem(position);
    CheckedTextView taskDescription = (CheckedTextView) view.findViewById(R.id.task_description);

    task.setCompleted(!task.isCompleted());

    if (task.isCompleted()) {
      taskDescription.setPaintFlags(taskDescription.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
      taskDescription.setChecked(true);
    } else {
      taskDescription.setPaintFlags(
          taskDescription.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
      taskDescription.setChecked(false);
    }

    task.saveEventually();
  }
 @Override
 public View getGroupView(
     int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
   if (convertView == null) {
     convertView = inflater.inflate(R.layout.listrow_group, null);
   }
   amarre group = (amarre) getGroup(groupPosition);
   ((CheckedTextView) convertView).setText(group.string);
   ((CheckedTextView) convertView).setChecked(isExpanded);
   return convertView;
 }
Пример #9
0
  @Override
  public View getGroupView(
      int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {

    if (convertView == null) {
      convertView = inflater.inflate(R.layout.layout_for_diary_group, null);
    }

    ((CheckedTextView) convertView).setText(parentItems.get(groupPosition));
    ((CheckedTextView) convertView).setChecked(isExpanded);

    return convertView;
  }
 @Override
 public View getView(final int position, final View convertView, final ViewGroup parent) {
   CheckedTextView tv = (CheckedTextView) convertView;
   if (tv == null) {
     tv =
         (CheckedTextView)
             LayoutInflater.from(AnimateDismissActivity.this)
                 .inflate(R.layout.item_animateremoval_row, parent, false);
   }
   tv.setText(String.valueOf(getItem(position)));
   tv.setChecked(mSelectedPositions.contains(position));
   return tv;
 }
  @Override
  public View getGroupView(
      int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {

    if (convertView == null) {
      convertView = inflater.inflate(R.layout.activity_terms_parent_expandablelist, null);
    }

    ((CheckedTextView) convertView).setText(parentItems.get(groupPosition));
    ((CheckedTextView) convertView).setChecked(isExpanded);

    return convertView;
  }
Пример #12
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;

    if (row == null) {
      //            LayoutInflater inflater = getLayoutInflater();
      row = inflater.inflate(R.layout.play_list_item, parent, false);
    }

    CheckedTextView checkedTextView = (CheckedTextView) row.findViewById(R.id.play_list_item);
    checkedTextView.setText(this.playlist.get(position));

    Boolean checked = cds.myChecked.get(position);
    if (checked != null) {
      checkedTextView.setChecked(checked);
    }

    return row;
  }
Пример #13
0
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   super.onListItemClick(l, v, position, id);
   Log.i(LOG_TAG, id + " is clicked at position " + position);
   if (v instanceof CheckedTextView) {
     // doing asynchronous view changes, because the cursor still has old data while the database
     // and the view are changed
     // because we force refresh on every resume, the synchronization after we leave the Activity
     // is taken care of
     CheckedTextView ctv = (CheckedTextView) v;
     // this check view at the certain position, rather than the item, hence the asynchrony
     ctv.setChecked(!ctv.isChecked());
     mAdapter.flipCheckedStatus(id, mNoteId, ctv.isChecked());
     ctv.setPaintFlags(
         ctv.isChecked()
             ? ctv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG
             : ctv.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
     ((HoloNoteCursorAdapter) this.getListAdapter()).getCursor().requery();
   }
 }
Пример #14
0
    @Override
    public void onItemClick(AdapterView<?> arrayAdapter, View view, int position, long arg3) {
      // TODO Auto-generated method stub
      clickedListItem = (String) lv.getItemAtPosition(position);
      Log.i("", "this is the clickedListItem: " + clickedListItem);
      CheckedTextView check = (CheckedTextView) view;
      check.setChecked(check.isChecked());
      workout.addExercise(clickedListItem);
      workout.addSpotClicked(position);
      // isSelected[position] = true;

      if (weightArray[
          position]) { // this will always make a cardio becasue they are both SETUPEXERCISE.class
        Intent newWeightActivity = new Intent(ClickableCreateWorkOutList.this, SetUpExercise.class);
        newWeightActivity.putExtra("theExtra", workout);
        startActivity(newWeightActivity);
      } else {
        Intent newCardioActivity = new Intent(ClickableCreateWorkOutList.this, SetUpExercise.class);
        newCardioActivity.putExtra("theExtra", workout);
        startActivity(newCardioActivity);
      }
    }
 private void onClickMenuItem(int menuId) {
   final Settings settings = Settings.instance();
   if (mOpenedMenuId == menuId) {
     mOpenedMenuId = -1;
     // close menu
     mSubMenuContrainer.setVisibility(View.INVISIBLE);
     mSubMenuContrainer.removeAllViews();
   } else {
     mOpenedMenuId = menuId;
     // open menu here
     ArrayList<String> values = new ArrayList<String>();
     int chosenIndex = 0;
     if (menuId == R.id.resolution_menu) {
       values = settings.getAvailResList();
       chosenIndex = settings.getChosenResIndex();
     } else if (menuId == R.id.bitrate_menu) {
       int[] bitrates = settings.getBitrates();
       for (int bitrate : bitrates) {
         values.add(Formatter.formatShortFileSize(getActivity(), bitrate));
       }
       chosenIndex = settings.getChosenBitrateIndex();
     } else if (menuId == R.id.rotate_menu) {
       values.add(getActivity().getString(R.string.rotate_on));
       values.add(getActivity().getString(R.string.rotate_off));
       chosenIndex = settings.isRotate() ? 0 : 1;
     }
     if (values != null) {
       mSubMenuContrainer.removeAllViews();
       for (int index = 0; index < values.size(); ++index) {
         CheckedTextView ctv = mSubMenuItems.get(index);
         ctv.setText(values.get(index));
         ctv.setChecked(chosenIndex == index);
         mSubMenuContrainer.addView(ctv);
       }
       mSubMenuContrainer.setVisibility(View.VISIBLE);
     }
   }
 }
Пример #16
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == REQUEST_ENABLE_BT) {

      if (resultCode == RESULT_OK) {
        Toast.makeText(PairingActivity.this, "블루투스를 켰습니다\n작업을 시작하세요", Toast.LENGTH_SHORT).show();
      } else if (resultCode == RESULT_CANCELED) {
        Toast.makeText(this, "블루투스를 반드시 켜야만 합니다.", Toast.LENGTH_SHORT).show();
        finish();
      }

      // 내 장치 검색모드
    } else if (requestCode == REQUEST_DISCOVERABLE) {

      if (resultCode == RESULT_OK) {
        Toast.makeText(PairingActivity.this, "검색을 허용합니다.", Toast.LENGTH_SHORT).show();
      } else if (resultCode == RESULT_CANCELED) {
        Toast.makeText(this, "검색을 허용하지 않습니다.", Toast.LENGTH_SHORT).show();
        checkedTextView.setChecked(false);
      }
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
Пример #17
0
 @Override
 public void setChecked(boolean b) {
   checkedTextView.setChecked(b);
 }
 public void onEvent(RecorderEvent event) {
   LogUtil.i(
       MODULE_TAG, "onEvent isRecording:" + event.isRecording + ", fileName:" + event.fileName);
   mShutter.setEnabled(true);
   mShutter.setChecked(event.isRecording);
 }
Пример #19
0
 private void setIndex(CheckedTextView indexTv, boolean isChecked) {
   indexTv.setChecked(isChecked);
 }
Пример #20
0
 public void setTask(Task task) {
   this.task = task;
   checkbox.setText(task.getName());
   checkbox.setChecked(task.isComplete());
 }
Пример #21
0
    @Override
    public View getGroupView(
        int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
      LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View row = inflater.inflate(R.layout.restrictionentry, parent, false);
      ImageView imgIndicator = (ImageView) row.findViewById(R.id.imgIndicator);
      ImageView imgUsed = (ImageView) row.findViewById(R.id.imgUsed);
      ImageView imgGranted = (ImageView) row.findViewById(R.id.imgGranted);
      ImageView imgInfo = (ImageView) row.findViewById(R.id.imgInfo);
      final CheckedTextView ctvRestriction = (CheckedTextView) row.findViewById(R.id.ctvName);

      // Indicator state
      imgIndicator.setImageResource(
          isExpanded ? R.drawable.expander_ic_maximized : R.drawable.expander_ic_minimized);

      // Disable indicator for empty groups
      if (mExpert) {
        if (getChildrenCount(groupPosition) == 0) imgIndicator.setVisibility(View.INVISIBLE);
      } else imgIndicator.setVisibility(View.GONE);

      // Get entry
      final String restrictionName = (String) getGroup(groupPosition);

      // Display if restriction granted
      if (!PrivacyManager.hasPermission(
          row.getContext(), mAppInfo.getPackageName(), restrictionName))
        imgGranted.setVisibility(View.INVISIBLE);

      // Display if used
      if (PrivacyManager.getUsed(row.getContext(), mAppInfo.getUid(), restrictionName, null) != 0)
        ctvRestriction.setTypeface(null, Typeface.BOLD_ITALIC);
      else imgUsed.setVisibility(View.INVISIBLE);

      // Handle info
      imgInfo.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              Intent infoIntent = new Intent(Intent.ACTION_VIEW);
              infoIntent.setData(
                  Uri.parse(
                      String.format(
                          "http://wiki.faircode.eu/index.php?title=%s", restrictionName)));
              startActivity(infoIntent);
            }
          });

      // Display localized name
      ctvRestriction.setText(PrivacyManager.getLocalizedName(row.getContext(), restrictionName));

      // Display restriction
      boolean restricted =
          PrivacyManager.getRestricted(
              null, row.getContext(), mAppInfo.getUid(), restrictionName, null, false, false);
      ctvRestriction.setChecked(restricted);

      // Listen for restriction changes
      ctvRestriction.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              boolean restricted =
                  PrivacyManager.getRestricted(
                      null,
                      view.getContext(),
                      mAppInfo.getUid(),
                      restrictionName,
                      null,
                      false,
                      false);
              restricted = !restricted;
              ctvRestriction.setChecked(restricted);
              PrivacyManager.setRestricted(
                  null, view.getContext(), mAppInfo.getUid(), restrictionName, null, restricted);
              notifyDataSetChanged();
            }
          });

      return row;
    }
 // Automatically Compatible
 void setCompatibility(TextView tv, CheckedTextView ctv) {
   tv.setTextColor(Color.parseColor("#00AA00"));
   tv.setText(R.string.compatible);
   ctv.setChecked(true);
 }
Пример #23
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SensorManager lSenMan = (SensorManager) getSystemService(SENSOR_SERVICE);
    LocationManager lLocMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mSenMan = lSenMan;
    mLocMan = lLocMan;

    // Get the names of all sources
    mSenStates = new CSensorStates(lSenMan.getSensorList(Sensor.TYPE_ALL));
    mLPStates = new CLocProvStates(lLocMan.getAllProviders());
    mGPSState = false;
    mSenStates.setRate(
        SensorManager.SENSOR_DELAY_FASTEST); // Set the sensor rate to the maximum (default is UI)
    CSensorStates lSenStates = mSenStates;
    CLocProvStates lLPStates = mLPStates;

    // Read the prefs
    read_prefs();

    // Construct the view
    setContentView(R.layout.datlog);
    // Main Tab (tab0)
    mLV = (CLogView) findViewById(R.id.DLtv1);
    Button lbtn_start = (Button) findViewById(R.id.DLbtn0);
    Button lbtn_event = (Button) findViewById(R.id.DLbtn1);
    Button lbtn_stop = (Button) findViewById(R.id.DLbtn2);
    Button lbtn_erec = (Button) findViewById(R.id.DLbtn3);
    Button lbtn_show = (Button) findViewById(R.id.DLbtn4);

    lbtn_start.setOnClickListener(this);
    lbtn_event.setOnClickListener(this);
    lbtn_stop.setOnClickListener(this);
    lbtn_erec.setOnClickListener(this);
    lbtn_show.setOnClickListener(this);

    lbtn_stop.setEnabled(false);
    mbtn_start = lbtn_start;
    mbtn_stop = lbtn_stop;

    // The sensor selection tab
    ListView llistview1 = (ListView) findViewById(R.id.DLtab2);
    ArrayAdapter<String> ladapter1 =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_multiple_choice, lSenStates.getNames());
    llistview1.setAdapter(ladapter1);
    // Show the current sensor selection
    for (int i = 0; i < lSenStates.getNum(); i++) {
      llistview1.setItemChecked(i, lSenStates.getActive(i));
    }
    llistview1.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          public void onItemClick(AdapterView<?> arg0, View aview, int position, long arg3) {
            mSenStates.setActToggle(position);
          }
        });

    // Location Provider Selection Tab
    ListView llistview2 = (ListView) findViewById(R.id.DLtab3);
    llistview2.setAdapter(
        new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_multiple_choice, lLPStates.getNames()));
    // Show the current sensor selection
    for (int i = 0; i < lLPStates.getNum(); i++) {
      llistview2.setItemChecked(i, lLPStates.getActive(i));
    }
    llistview2.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          public void onItemClick(AdapterView<?> arg0, View aview, int position, long arg3) {
            mLPStates.setActToggle(position);
          }
        });

    // Gps Status selection tab
    CheckedTextView lcheckview = (CheckedTextView) findViewById(R.id.DLck1);
    lcheckview.setChecked(mGPSState);
    lcheckview.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            mGPSState = !mGPSState;
            ((CheckedTextView) v).setChecked(mGPSState);
          };
        });

    // Create the tabs
    TabHost lTabHost = getTabHost();
    lTabHost.addTab(lTabHost.newTabSpec("tab1").setIndicator("Control").setContent(R.id.DLtab1));
    lTabHost.addTab(lTabHost.newTabSpec("tab2").setIndicator("Sensors").setContent(R.id.DLtab2));
    lTabHost.addTab(lTabHost.newTabSpec("tab3").setIndicator("Providers").setContent(R.id.DLtab3));
    if (mLPStates.isExist(LocationManager.GPS_PROVIDER))
      lTabHost.addTab(
          lTabHost.newTabSpec("tab4").setIndicator("GPS Status").setContent(R.id.DLtab4));

    lTabHost.setCurrentTab(0);
    mTabWidget = lTabHost.getTabWidget();
  }
 @Override
 public void setChecked(boolean checked) {
   if (checkbox != null) {
     checkbox.setChecked(checked);
   }
 }
 @Override
 public void setChecked(boolean checked) {
   // TODO Auto-generated method stub
   checked_text_view.setChecked(checked);
 }
Пример #26
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View row = inflater.inflate(R.layout.xmainentry, parent, false);
      LinearLayout llIcon = (LinearLayout) row.findViewById(R.id.llIcon);
      ImageView imgIcon = (ImageView) row.findViewById(R.id.imgIcon);
      ImageView imgInternet = (ImageView) row.findViewById(R.id.imgInternet);
      ImageView imgUsed = (ImageView) row.findViewById(R.id.imgUsed);
      final CheckedTextView ctvApp = (CheckedTextView) row.findViewById(R.id.ctvName);

      // Get entry
      final XApplicationInfo xAppInfo = getItem(position);

      // Set background color
      if (xAppInfo.getIsSystem())
        if (mThemeId == android.R.style.Theme_Holo_Light)
          row.setBackgroundColor(Color.parseColor("#FFFDD0"));
        else row.setBackgroundColor(Color.DKGRAY);

      // Click handler
      llIcon.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              Intent intentSettings = new Intent(view.getContext(), ActivityApp.class);
              intentSettings.putExtra(ActivityApp.cPackageName, xAppInfo.getPackageName());
              intentSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              view.getContext().startActivity(intentSettings);
            }
          });

      // Set icon
      imgIcon.setImageDrawable(xAppInfo.getDrawable());

      // Set title
      ctvApp.setText(xAppInfo.toString());

      // Check if internet access
      imgInternet.setVisibility(xAppInfo.hasInternet() ? View.VISIBLE : View.INVISIBLE);

      // Check if used
      boolean used =
          XRestriction.isUsed(row.getContext(), xAppInfo.getUid(), mRestrictionName, null);
      ctvApp.setTypeface(null, used ? Typeface.BOLD_ITALIC : Typeface.NORMAL);
      imgUsed.setVisibility(used ? View.VISIBLE : View.INVISIBLE);

      // Display restriction
      boolean restricted =
          XRestriction.getRestricted(
              null, row.getContext(), xAppInfo.getUid(), mRestrictionName, null, false, false);
      ctvApp.setChecked(restricted);

      // Listen for restriction changes
      ctvApp.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              boolean restricted =
                  XRestriction.getRestricted(
                      null,
                      view.getContext(),
                      xAppInfo.getUid(),
                      mRestrictionName,
                      null,
                      false,
                      false);
              restricted = !restricted;
              ctvApp.setChecked(restricted);
              XRestriction.setRestricted(
                  null, view.getContext(), xAppInfo.getUid(), mRestrictionName, null, restricted);
            }
          });

      row.refreshDrawableState();
      return row;
    }
Пример #27
0
    @Override
    public View getChildView(
        int groupPosition,
        int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View row = inflater.inflate(R.layout.restrictionchild, parent, false);
      final CheckedTextView ctvMethodName = (CheckedTextView) row.findViewById(R.id.ctvMethodName);

      // Get entry
      final String restrictionName = (String) getGroup(groupPosition);
      final String methodName = (String) getChild(groupPosition, childPosition);
      long lastUsage =
          PrivacyManager.getUsed(row.getContext(), mAppInfo.getUid(), restrictionName, methodName);

      // Display method name
      if (lastUsage == 0) ctvMethodName.setText(methodName);
      else {
        Date date = new Date(lastUsage);
        SimpleDateFormat format = new SimpleDateFormat("dd/HH:mm", Locale.US);
        ctvMethodName.setText(String.format("%s %s", methodName, format.format(date)));
      }

      boolean parentRestricted =
          PrivacyManager.getRestricted(
              null, row.getContext(), mAppInfo.getUid(), restrictionName, null, false, false);
      ctvMethodName.setEnabled(parentRestricted);

      // Display if used
      if (lastUsage != 0) ctvMethodName.setTypeface(null, Typeface.BOLD_ITALIC);

      // Display restriction
      boolean restricted =
          PrivacyManager.getRestricted(
              null, row.getContext(), mAppInfo.getUid(), restrictionName, methodName, false, false);
      ctvMethodName.setChecked(restricted);

      // Listen for restriction changes
      ctvMethodName.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              boolean restricted =
                  PrivacyManager.getRestricted(
                      null,
                      view.getContext(),
                      mAppInfo.getUid(),
                      restrictionName,
                      methodName,
                      false,
                      false);
              restricted = !restricted;
              ctvMethodName.setChecked(restricted);
              PrivacyManager.setRestricted(
                  null,
                  view.getContext(),
                  mAppInfo.getUid(),
                  restrictionName,
                  methodName,
                  restricted);
            }
          });

      return row;
    }