List of usage examples for android.widget LinearLayout setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.lkunic.lib.activityaddonlib.twopane.fragments.showcase.ItemShowcaseFragment.java
/** * Sets up the fragment and it's views.//from ww w . jav a 2 s . co m * @param view The layout view. */ @Override protected void setupContent(View view) { // Make sure item data is available before setting up content. getItemData(); // Populate the view holder if needed if (viewHolder == null) { viewHolder = new ViewHolder(); viewHolder.showcaseItemImage = (ImageView) view.findViewById(R.id.showcase_image); viewHolder.showcaseItemTitle = (TextView) view.findViewById(R.id.showcase_title); viewHolder.viewPager = (ViewPager) view.findViewById(R.id.pager); viewHolder.pagerButtonBar = (LinearLayout) view.findViewById(R.id.pager_button_bar); } // Set the item image viewHolder.showcaseItemImage.setImageBitmap(getShowcaseImage()); // Set the item title viewHolder.showcaseItemTitle.setText(getShowcaseItemTitle()); // Set up the view pager ItemShowcaseInfoFragment[] infoFragments = getInfoFragments(); if (viewHolder.viewPager.getAdapter() == null) { // The ViewPager doesn't have an adapter yet, create it and populate with info fragments viewHolder.viewPager.setAdapter(new ShowcasePagerAdapter(getChildFragmentManager(), infoFragments)); viewHolder.viewPager.setOnPageChangeListener(showcasePageChangeListener); } else { // The ViewPager already has an adapter, populate it with new info fragments ShowcasePagerAdapter adapter = (ShowcasePagerAdapter) viewHolder.viewPager.getAdapter(); adapter.setPagerItems(infoFragments); adapter.notifyDataSetChanged(); } // Build the button bar for controlling the view pager ShowcaseButton showcaseButton; LinearLayout showcaseButtonContainer; LayoutParams showcaseButtonParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1); // Remove all buttons that could have been populated by previous item viewHolder.pagerButtonBar.removeAllViews(); for (int i = 0, n = infoFragments.length; i < n; i++) { // Create a new showcase button and populate it with data from corresponding fragment showcaseButton = new ShowcaseButton(getActivity(), infoFragments[i].getQuantity(), infoFragments[i].getQuantityName()); // Setup the showcase view so that it can be used as a tab button showcaseButtonContainer = (LinearLayout) showcaseButton.findViewById(R.id.container); showcaseButtonContainer.setTag(i); showcaseButtonContainer.setOnClickListener(showcaseButtonClickListener); showcaseButtonContainer.setBackgroundResource(i % 2 == 0 ? R.drawable.showcase_button_background_light : R.drawable.showcase_button_background_dark); // Add the button to the button bar showcaseButton.setLayoutParams(showcaseButtonParams); viewHolder.pagerButtonBar.addView(showcaseButton); } viewHolder.viewPager.setCurrentItem(0, true); selectPageButton(0); }
From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java
private void addRedDotTab(final int position, String title, int resId) { LinearLayout tabLayout = new LinearLayout(getContext()); tabLayout.setOrientation(LinearLayout.HORIZONTAL); tabLayout.setGravity(Gravity.CENTER); TextView tab = new TextView(getContext()); tab.setText(title);/* w w w . j a v a 2 s. c om*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextColor(getResources().getColorStateList(R.color.pst_tab_text_selector)); tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f); tabLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (null != mOnPageClickedLisener) { mOnPageClickedLisener.onPageClicked(position); } pager.setCurrentItem(position); } }); tabLayout.addView(tab, 0); ImageView tabImg = new ImageView(getContext()); LinearLayout.LayoutParams tabImgParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); tabImgParams.setMargins(DeviceUtils.dip2px(getContext(), 5), DeviceUtils.dip2px(getContext(), 10), 0, 0); tabImgParams.gravity = Gravity.TOP; tabImg.setLayoutParams(tabImgParams); tabLayout.addView(tabImg, 1); tabsContainer.addView(tabLayout); }
From source file:com.example.zf_android.trade.ApplyDetailActivity.java
/** * firstly init the merchant category with item keys, * and after user select the merchant the values will be set *///www . j a va2s .c om private void initMerchantDetailKeys() { // the first category mMerchantKeys = getResources().getStringArray(R.array.apply_detail_merchant_keys); mMerchantContainer.addView(getDetailItem(ITEM_CHOOSE, mMerchantKeys[0], null)); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[1], null)); LinearLayout ll = getDetailItem(ITEM_EDIT, mMerchantKeys[2], null); etMerchantName = (EditText) ll.findViewById(R.id.apply_detail_value); etMerchantName.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { etBankMerchantName.setText(s.toString()); } @Override public void afterTextChanged(Editable s) { etBankMerchantName.setText(s.toString()); } }); mMerchantContainer.addView(ll); View merchantGender = getDetailItem(ITEM_CHOOSE, mMerchantKeys[3], null); merchantGender.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(ApplyDetailActivity.this); final String[] items = getResources().getStringArray(R.array.apply_detail_gender); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setItemValue(mMerchantKeys[3], items[which]); } }); builder.show(); } }); mMerchantContainer.addView(merchantGender); View merchantBirthday = getDetailItem(ITEM_CHOOSE, mMerchantKeys[4], null); merchantBirthday.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CommonUtil.showDatePicker(ApplyDetailActivity.this, mMerchantBirthday, new CommonUtil.OnDateSetListener() { @Override public void onDateSet(String date) { setItemValue(mMerchantKeys[4], date); } }); } }); mMerchantContainer.addView(merchantBirthday); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[5], null)); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[6], null)); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[7], null)); View merchantCity = getDetailItem(ITEM_CHOOSE, mMerchantKeys[8], null); merchantCity.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ApplyDetailActivity.this, CityProvinceActivity.class); intent.putExtra(SELECTED_PROVINCE, mMerchantProvince); intent.putExtra(SELECTED_CITY, mMerchantCity); startActivityForResult(intent, REQUEST_CHOOSE_CITY); } }); mMerchantContainer.addView(merchantCity); // the second category mBankKeys = getResources().getStringArray(R.array.apply_detail_bank_keys); mCustomerContainer.addView(getDetailItem(ITEM_CHOOSE, mBankKeys[0], null)); LinearLayout tmpll = (LinearLayout) mContainer.findViewWithTag(mBankKeys[0]); tmpll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { customTag = mBankKeys[0]; Intent intent = new Intent(ApplyDetailActivity.this, BankList.class); intent.putExtra(AGENT_NAME, mBankName); intent.putExtra("terminalId", mTerminalId); startActivityForResult(intent, REQUEST_CHOOSE_BANK); } }); View bankAccountName = getDetailItem(ITEM_EDIT, mBankKeys[1], null); etBankMerchantName = (EditText) bankAccountName.findViewById(R.id.apply_detail_value); etBankMerchantName.setEnabled(false); mCustomerContainer.addView(bankAccountName); mCustomerContainer.addView(getDetailItem(ITEM_EDIT, mBankKeys[2], null)); mCustomerContainer.addView(getDetailItem(ITEM_EDIT, mBankKeys[3], null)); mCustomerContainer.addView(getDetailItem(ITEM_EDIT, mBankKeys[4], null)); View chooseChannel = getDetailItem(ITEM_CHOOSE, getString(R.string.apply_detail_channel), null); chooseChannel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ApplyDetailActivity.this, ChannelSelecter.class); startActivityForResult(intent, REQUEST_CHOOSE_CHANNEL); } }); mCustomerContainer.addView(chooseChannel); }
From source file:com.lkunic.libs.apptoolbox.twopane.fragments.ShowcaseFragment.java
/** * Sets up the fragment and it's views.//w w w.j a va 2 s .c o m * @param view The layout view. */ @Override protected void setupContent(View view) { // Make sure item data is available before setting up content. getItemData(); // Populate the view holder if needed if (viewHolder == null) { viewHolder = new ViewHolder(); viewHolder.showcaseItemImage = (ImageView) view.findViewById(R.id.item_image); viewHolder.showcaseItemTitle = (TextView) view.findViewById(R.id.item_title); viewHolder.viewPager = (ViewPager) view.findViewById(R.id.pager); viewHolder.pagerButtonBar = (LinearLayout) view.findViewById(R.id.pager_button_bar); } // Set the item image viewHolder.showcaseItemImage.setImageBitmap(getShowcaseImage()); // Set the item title viewHolder.showcaseItemTitle.setText(getShowcaseItemTitle()); // Set up the view pager ShowcaseInfoFragment[] infoFragments = getInfoFragments(); if (viewHolder.viewPager.getAdapter() == null) { // The ViewPager doesn't have an adapter yet, create it and populate with info fragments viewHolder.viewPager.setAdapter(new ShowcasePagerAdapter(getChildFragmentManager(), infoFragments)); viewHolder.viewPager.addOnPageChangeListener(showcasePageChangeListener); } else { // The ViewPager already has an adapter, populate it with new info fragments ShowcasePagerAdapter adapter = (ShowcasePagerAdapter) viewHolder.viewPager.getAdapter(); adapter.setPagerItems(infoFragments); adapter.notifyDataSetChanged(); } // Build the button bar for controlling the view pager TextButton textButton; LinearLayout showcaseButtonContainer; LinearLayout.LayoutParams showcaseButtonParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1); // Remove all buttons that could have been populated by previous item viewHolder.pagerButtonBar.removeAllViews(); for (int i = 0, n = infoFragments.length; i < n; i++) { // Create a new showcase button and populate it with data from corresponding fragment textButton = new TextButton(getContext(), infoFragments[i].getPrimaryText(), infoFragments[i].getSecondaryText()); // Setup the showcase view so that it can be used as a tab button showcaseButtonContainer = (LinearLayout) textButton.findViewById(R.id.container); showcaseButtonContainer.setTag(i); showcaseButtonContainer.setOnClickListener(showcaseButtonClickListener); showcaseButtonContainer.setBackgroundResource(i % 2 == 0 ? R.drawable.pager_tab_control_background_1 : R.drawable.pager_tab_control_background_2); // Add the button to the button bar textButton.setLayoutParams(showcaseButtonParams); viewHolder.pagerButtonBar.addView(textButton); } viewHolder.viewPager.setCurrentItem(0, true); selectPageButton(0); }
From source file:org.tomahawk.tomahawk_android.dialogs.ResolverRedirectConfigDialog.java
/** * Called when this {@link android.support.v4.app.DialogFragment} is being created *///ww w .j a va 2 s.c o m @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (getArguments() != null && getArguments().containsKey(TomahawkFragment.PREFERENCEID)) { String id = getArguments().getString(TomahawkFragment.PREFERENCEID); mScriptResolver = (ScriptResolver) PipeLine.get().getResolver(id); } TextView headerTextView = (TextView) addScrollingViewToFrame(R.layout.config_textview); headerTextView.setText(mScriptResolver.getDescription()); int buttonBackgroundResId = R.drawable.selectable_background_tomahawk_rectangle_gray; int buttonTextColor = getResources().getColor(R.color.primary_textcolor); View.OnClickListener onClickListener = new RedirectButtonListener(); View buttonLayout = addScrollingViewToFrame(R.layout.config_redirect_button); LinearLayout button = ((LinearLayout) buttonLayout.findViewById(R.id.config_redirect_button)); button.setBackgroundResource(buttonBackgroundResId); ImageView buttonImage = (ImageView) buttonLayout.findViewById(R.id.config_redirect_button_image); mScriptResolver.loadIcon(buttonImage, false); mRedirectButtonTextView = (TextView) button.findViewById(R.id.config_redirect_button_text); mRedirectButtonTextView.setTextColor(buttonTextColor); if (isPluginInstalled()) { mRedirectButtonTextView.setText(mScriptResolver.isEnabled() ? getString(R.string.resolver_config_redirect_button_text_log_out_of) : getString(R.string.resolver_config_redirect_button_text_log_into)); } else { mRedirectButtonTextView .setText(getString(R.string.resolver_config_redirect_button_text_download_plugin)); } button.setOnClickListener(onClickListener); setDialogTitle(mScriptResolver.getName()); hideNegativeButton(); setStatus(mScriptResolver); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(getDialogView()); return builder.create(); }
From source file:com.todoroo.astrid.timers.TimerActionControlSet.java
public TimerActionControlSet(final NotificationManager notificationManager, final TaskService taskService, final FragmentActivity activity, View parent) { super(activity, -1); LinearLayout timerContainer = (LinearLayout) parent.findViewById(R.id.timer_container); timerButton = (ImageView) parent.findViewById(R.id.timer_button); OnClickListener timerListener = new OnClickListener() { @Override/*from w ww . j av a 2s . co m*/ public void onClick(View v) { if (timerActive) { TimerPlugin.updateTimer(notificationManager, taskService, activity, model, false); for (TimerActionListener listener : listeners) { listener.timerStopped(model); } chronometer.stop(); } else { TimerPlugin.updateTimer(notificationManager, taskService, activity, model, true); for (TimerActionListener listener : listeners) { listener.timerStarted(model); } chronometer.start(); } timerActive = !timerActive; updateDisplay(); } }; timerContainer.setOnClickListener(timerListener); chronometer = (Chronometer) parent.findViewById(R.id.timer); }
From source file:hu.fnf.devel.atlas.Atlas.java
private void setDetailProperties(int page_id) { LinearLayout root = (LinearLayout) findViewById(R.id.detailcatRoot); root.setOrientation(android.widget.LinearLayout.VERTICAL); LinearLayout in = new LinearLayout(getApplicationContext()); in.setId(AtlasData.INCOME);//from w w w .j av a 2s . c om in.setOnClickListener(onCatClick); LinearLayout out = new LinearLayout(getApplicationContext()); out.setId(AtlasData.OUTCOME); out.setOnClickListener(onCatClick); TextView intext = new TextView(getApplicationContext()); intext.setText(getResources().getString(R.string.income)); intext.setOnClickListener(onCatClick); intext.setId(AtlasData.INCOME); intext.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Medium_Inverse); TextView outtext = new TextView(getApplicationContext()); outtext.setText(getResources().getString(R.string.outcome)); outtext.setOnClickListener(onCatClick); outtext.setId(AtlasData.OUTCOME); outtext.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Medium_Inverse); in.addView(intext); out.addView(outtext); root.addView(in); addChilds(in, root); root.addView(out); addChilds(out, root); }
From source file:com.amaze.filemanager.adapters.TabSpinnerAdapter.java
@Override public View getDropDownView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.spinner_dropdown_layout, parent, false); ma = ((Main) fragmentTransaction.findFragmentById(R.id.content_frame)); final TextView textView = (TextView) row.findViewById(R.id.spinnerText); LinearLayout linearLayout = (LinearLayout) row.findViewById(R.id.textParent); final SharedPreferences sharedPreferences1 = PreferenceManager.getDefaultSharedPreferences(context); String skin = sharedPreferences1.getString("skin_color", "#5677fc"); final int spinner_current = sharedPreferences1.getInt("spinner_selected", 0); ImageButton imageButton = (ImageButton) row.findViewById(R.id.spinnerButton); if (items.get(position).equals("/")) textView.setText(R.string.rootdirectory); else/*from w w w . jav a 2 s.c om*/ textView.setText(new File(items.get(position)).getName()); imageButton.setBackgroundColor(Color.parseColor(skin)); if (position == spinner_current) { textView.setTextColor(Color.parseColor(skin)); textView.setTypeface(null, Typeface.BOLD); } linearLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { hideSpinnerDropDown(spinner); if (position == spinner_current) { } else { TabHandler tabHandler1 = new TabHandler(context, null, null, 1); Tab tab = tabHandler1.findTab(position); String name = tab.getPath(); //Toast.makeText(getActivity(), name, Toast.LENGTH_SHORT).show(); sharedPreferences1.edit().putString("current", name).apply(); sharedPreferences1.edit().putInt("spinner_selected", position).apply(); Main ma = ((Main) fragmentTransaction.findFragmentById(R.id.content_frame)); ma.loadlist(new File(tab.getPath()), false); Animation animationLeft = AnimationUtils.loadAnimation(getContext(), R.anim.tab_selection_left); Animation animationRight = AnimationUtils.loadAnimation(getContext(), R.anim.tab_selection_right); if (position < spinner_current) { ma.listView.setAnimation(animationLeft); ma.gridView.setAnimation(animationLeft); } else { ma.listView.setAnimation(animationRight); ma.gridView.setAnimation(animationRight); } } } }); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TabHandler tabHandler = new TabHandler(context, null, null, 1); Tab tab = tabHandler.findTab(position); if (position > spinner_current) { //Toast.makeText(getContext(), "Closed", Toast.LENGTH_SHORT).show(); items.remove(position); int old_tab = tab.getTab(); int a; for (a = old_tab; a < tabHandler.getTabsCount() - 1; a++) { int new_tab = a + 1; Tab tab1 = tabHandler.findTab(new_tab); String next_label = tab1.getLabel(); String next_path = tab1.getPath(); tabHandler.updateTab(new Tab(a, next_label, next_path)); } tabHandler.deleteTab(tabHandler.getTabsCount() - 1); hideSpinnerDropDown(spinner); } else if (position < spinner_current) { // Toast.makeText(getContext(), "Closed", Toast.LENGTH_SHORT).show(); items.remove(position); int old_tab = tab.getTab(); int a; for (a = old_tab; a < tabHandler.getTabsCount() - 1; a++) { int new_tab = a + 1; Tab tab1 = tabHandler.findTab(new_tab); String next_label = tab1.getLabel(); String next_path = tab1.getPath(); tabHandler.updateTab(new Tab(a, next_label, next_path)); } tabHandler.deleteTab(tabHandler.getTabsCount() - 1); int older_spinner_selected = sharedPreferences1.getInt("spinner_selected", 0); older_spinner_selected--; sharedPreferences1.edit().putInt("spinner_selected", older_spinner_selected).apply(); hideSpinnerDropDown(spinner); } else if (position == spinner_current) { if (tabHandler.getTabsCount() == 1) { // Toast.makeText(getContext(), "exits the app", Toast.LENGTH_SHORT).show(); ma.home(); } else if (tabHandler.getTabsCount() - 1 > position) { items.remove(position); int old_tab = tab.getTab(); int a; for (a = old_tab; a < tabHandler.getTabsCount() - 1; a++) { int new_tab = a + 1; Tab tab1 = tabHandler.findTab(new_tab); String next_label = tab1.getLabel(); String next_path = tab1.getPath(); tabHandler.updateTab(new Tab(a, next_label, next_path)); } tabHandler.deleteTab(tabHandler.getTabsCount() - 1); Tab tab1 = tabHandler.findTab(spinner_current); ma.loadlist(new File(tab1.getPath()), false); } else if (tabHandler.getTabsCount() - 1 == position) { items.remove(position); tabHandler.deleteTab(tabHandler.getTabsCount() - 1); int older_spinner_selected = sharedPreferences1.getInt("spinner_selected", 0); older_spinner_selected--; sharedPreferences1.edit().putInt("spinner_selected", older_spinner_selected).apply(); Tab tab1 = tabHandler.findTab(older_spinner_selected); Main ma = ((Main) fragmentTransaction.findFragmentById(R.id.content_frame)); ma.loadlist(new File(tab1.getPath()), false); } } } }); return row; }
From source file:layout.BeaconTabFragment.java
/** * Sets up the advertising tx power view. It is initially disabled. It is enabled by clicking * on the radio button in the UI. This opens a dialog to confirm that the user really wants to * change the advertising radio tx power. After this the advertising interval can be configured. * A list pops up where the user can choose which value they want to be broadcast as the * advertising tx power.//from ww w. ja va 2s.c o m */ private void setUpAdvertisedTxPower(final View v) { if (advTxPower != null) { LinearLayout advTxPowerContainer = (LinearLayout) v.findViewById(R.id.change_adv_tx_slot); final TextView advTxPowerView = (TextView) v.findViewById(R.id.adv_tx_power); advTxPowerView.setText(advTxPower); advTxPowerView.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (!hasFocus) { String newAdvTxPower = advTxPowerView.getText().toString(); if (newAdvTxPower.length() == 0) { advTxPowerView.setText(advTxPower); } } else { advTxPowerChanged = true; } } }); advTxPowerContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { advTxPowerChanged = true; final String[] possibleValues = Utils.generateArrayWithStringValuesInRange( Utils.findMinValue(capabilities.getSupportedTxPowers()) - 5, Utils.findMaxValue(capabilities.getSupportedTxPowers()) + 5); new AlertDialog.Builder(getActivity()).setTitle("Choose advertising tx power:") .setItems(possibleValues, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { advTxPower = possibleValues[i]; advTxPowerView.setText(possibleValues[i]); } }).show(); } }); UiUtils.disableAllChildren(advTxPowerContainer); final RadioButton enableChangeAdvTxPowerButton = (RadioButton) v .findViewById(R.id.change_slot_adv_tx_power); enableChangeAdvTxPowerButton.setChecked(false); enableChangeAdvTxPowerButton.setOnClickListener(new View.OnClickListener() { private boolean enabled = false; @Override public void onClick(View view) { if (enabled) { UiUtils.disableAllChildren(v.findViewById(R.id.change_adv_tx_slot)); enableChangeAdvTxPowerButton.setChecked(false); enabled = false; } else { ConfirmationDialog.confirm("Change Advertising Interval", "Are you sure " + "you want to change the advertising interval of this beacon?", "YES", "NO", getActivity(), new ConfirmationDialog.ConfirmationListener() { @Override public void confirm() { UiUtils.enableAllChildren(v.findViewById(R.id.change_adv_tx_slot)); enableChangeAdvTxPowerButton.setChecked(true); enabled = true; } @Override public void cancel() { enableChangeAdvTxPowerButton.setChecked(false); enabled = false; } }); } } }); } }
From source file:com.koushikdutta.superuser.FragmentLog.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //header = (LinearLayout) getActivity().findViewById(R.id.header); ImageView icon = (ImageView) getActivity().findViewById(R.id.icon); TextView title, subtitle, request, command; title = (TextView) getActivity().findViewById(R.id.title); subtitle = (TextView) getActivity().findViewById(R.id.subtitle); request = (TextView) getActivity().findViewById(R.id.request); command = (TextView) getActivity().findViewById(R.id.command); Intent intent = getActivity().getIntent(); if (intent != null) { Bundle bundle = intent.getBundleExtra("bundle"); if (bundle != null) { String cmd = bundle.getString("command"); int uid = bundle.getInt("uid", -1); int desiredUid = bundle.getInt("desiredUid", -1); if (uid != -1 && desiredUid != -1) up = SuDatabaseHelper.get(getContext(), uid, desiredUid, cmd); }/*from www . java 2 s. c om*/ } if (up != null) { String app = up.username; if (app == null || app.length() == 0) app = String.valueOf(up.uid); icon.setImageDrawable(Util.loadPackageIcon(getActivity(), up.packageName)); title.setTextColor(((ActivityLog) getActivity()).textToolbar); subtitle.setTextColor(((ActivityLog) getActivity()).textToolbar); request.setTextColor(((ActivityLog) getActivity()).textToolbar); command.setTextColor(((ActivityLog) getActivity()).textToolbar); title.setText(up.getName()); subtitle.setText(up.packageName + ", " + app); request.setText("Requested UID: " + up.desiredUid); command.setText( "Command: " + (TextUtils.isEmpty(up.command) ? getString(R.string.all_commands) : up.command)); //getListView().setSelector(android.R.color.transparent); } else { callback = (LogCallback) getActivity(); } LinearLayout logParent = (LinearLayout) getActivity().findViewById(R.id.log); LinearLayout notiParent = (LinearLayout) getActivity().findViewById(R.id.noti); int accent = ThemeStore.accentColor(getContext()); TintHelper.setTint(log, accent, false); TintHelper.setTint(notification, accent, false); if (up == null) { log.setChecked(Settings.getLogging(getActivity())); notiParent.setVisibility(View.GONE); notification.setChecked(false); } else { log.setChecked(up.logging); notification.setChecked(up.notification); } logParent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { log.setChecked(!log.isChecked()); } }); log.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (up == null) { Settings.setLogging(getActivity(), b); } else { up.logging = b; SuDatabaseHelper.setPolicy(getActivity(), up); } } }); notiParent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { notification.setChecked(!notification.isChecked()); } }); notification.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (up == null) { } else { up.notification = notification.isChecked(); SuDatabaseHelper.setPolicy(getActivity(), up); } } }); load(); LocalBroadcastManager.getInstance(getContext()).registerReceiver(receiver, new IntentFilter(Common.INTENT_FILTER_LOG)); }