List of usage examples for android.widget TableLayout setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:net.vexelon.myglob.fragments.InvoiceFragment.java
@SuppressWarnings("unchecked") private void initInvoiceView() { View v = getView();/*from ww w.ja v a2s . c o m*/ TableLayout table_invoice = (TableLayout) v.findViewById(R.id.table_invoice); table_invoice.setVisibility(View.GONE); TextView tv = (TextView) v.findViewById(R.id.tv_invoice_status_nodata); tv.setVisibility(View.VISIBLE); try { User user = UsersManager.getInstance() .getUserByPhoneNumber(GlobalSettings.getInstance().getLastSelectedPhoneNumber()); if (user != null) { ActionResult actionResult = new InvoiceLoadCachedAction(this.getActivity(), user).execute(); updateInvoiceView(user, (List<Map<String, String>>) actionResult.getListResult()); } } catch (ActionExecuteException e) { if (Defs.LOG_ENABLED) { Log.d(Defs.LOG_TAG, "Failed loading invoice cache!", e); } // Simply skip view updates until user updates manually ... } }
From source file:net.vexelon.myglob.fragments.InvoiceFragment.java
private void updateInvoiceView(User user, List<Map<String, String>> results) { if (Defs.LOG_ENABLED) Log.v(Defs.LOG_TAG, "Updating invoice for: " + user.getPhoneNumber()); View v = getView();//from ww w.ja va2 s.c om boolean found = false; for (Map<String, String> map : results) { if (map.containsKey(GLBInvoiceXMLParser.TAG_MSISDN)) { String value = map.get(GLBInvoiceXMLParser.TAG_MSISDN); // String userPhone = user.getPhoneNumber(); // if (value.endsWith(userPhone.substring(userPhone.length() - 6, userPhone.length()))) { if (value.trim().length() == 0) { // invoice info setText(v, R.id.tv_invoice_num, map.get(GLBInvoiceXMLParser.TAG_INVNUM)); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(Long.parseLong(map.get(GLBInvoiceXMLParser.TAG_DATE))); setText(v, R.id.tv_invoice_date, Defs.globalDateFormat.format(calendar.getTime())); // costs BigDecimal servicesCharge = new BigDecimal("0.00"); BigDecimal discounts = new BigDecimal("0.00"); try { // solve discounts amount BigDecimal discount = valOrZero(map.get(GLBInvoiceXMLParser.TAG_DISCOUNT)); BigDecimal discountPackage = valOrZero(map.get(GLBInvoiceXMLParser.TAG_DISCOUNT_PACKAGE)); BigDecimal discountLoyality = valOrZero(map.get(GLBInvoiceXMLParser.TAG_DISCOUNT_LOYALITY)); BigDecimal discountUBB = valOrZero(map.get(GLBInvoiceXMLParser.TAG_DISCOUNT_GLOBUL_UBB)); discounts = discounts.add(discount).add(discountPackage).add(discountLoyality) .add(discountUBB); // solve services costs BigDecimal fixedCharge = valOrZero(map.get(GLBInvoiceXMLParser.TAG_FIXED_CHARGE)); // BigDecimal discounts = new BigDecimal(map.get(GLBInvoiceXMLParser.TAG_DISCOUNT)); BigDecimal totalNoVAT = valOrZero(map.get(GLBInvoiceXMLParser.TAG_TOTAL_NO_VAT)); servicesCharge = totalNoVAT.subtract(discounts).subtract(fixedCharge); } catch (Exception e) { Log.e(Defs.LOG_TAG, "Failed to get decimal prices info!", e); /* * XXX * It would be better to throw exception at this point! */ discounts = new BigDecimal(map.get(GLBInvoiceXMLParser.TAG_DISCOUNT)); } setText(v, R.id.tv_invoice_services, servicesCharge.toPlainString()); setText(v, R.id.tv_invoice_fixed_charge, map.get(GLBInvoiceXMLParser.TAG_FIXED_CHARGE)); setText(v, R.id.tv_invoice_discount, discounts.toPlainString()); // totals setText(v, R.id.tv_invoice_tot_no_vat, map.get(GLBInvoiceXMLParser.TAG_TOTAL_NO_VAT)); setText(v, R.id.tv_invoice_vat, map.get(GLBInvoiceXMLParser.TAG_VAT)); setText(v, R.id.tv_invoice_totvat, map.get(GLBInvoiceXMLParser.TAG_TOTALVAT)); // amount dues setText(v, R.id.tv_invoice_prev_amountdue, map.get(GLBInvoiceXMLParser.TAG_PREV_AMOUNTDUE)); setText(v, R.id.tv_invoice_paied_amountdue, map.get(GLBInvoiceXMLParser.TAG_PAID_AMOUNTDUE)); setText(v, R.id.tv_invoice_total_dueamount, map.get(GLBInvoiceXMLParser.TAG_TOTAL_DUEAMOUNT)); found = true; break; } } } if (!found) { // empty MSISDN was not found! setText(v, R.id.tv_invoice_status_nodata, R.string.text_invoice_invalid); } else { TextView tv = (TextView) v.findViewById(R.id.tv_invoice_status_nodata); tv.setVisibility(View.GONE); TableLayout table_invoice = (TableLayout) v.findViewById(R.id.table_invoice); table_invoice.setVisibility(View.VISIBLE); } setUpdated(true); }
From source file:com.neuron.fantecremote.FantecActivity.java
@Override protected void onResume() { super.onResume(); /**// ww w. j ava 2 s. c o m * Check if the API server has been set. */ TextView infoText = (TextView) findViewById(R.id.infotext); TableLayout tableLayout = (TableLayout) findViewById(R.id.tableLayout); if (Settings.GetApiUrl(prefs) == null) { infoText.setVisibility(View.VISIBLE); tableLayout.setVisibility(View.GONE); } else { infoText.setVisibility(View.GONE); tableLayout.setVisibility(View.VISIBLE); } }
From source file:com.samknows.measurement.activity.SamKnowsTestViewerActivity.java
private void launchTest(int testID) { final ManualTest mt; boolean run = true; // create a new thread if (testID != -1) { mt = ManualTest.create(this, handler, testID); if (testID == 2) { // download // hide others TableLayout tl = (TableLayout) findViewById(R.id.upload_test_panel); tl.setVisibility(View.GONE); TableLayout tl2 = (TableLayout) findViewById(R.id.latency_test_panel); tl2.setVisibility(View.GONE); TableLayout tl3 = (TableLayout) findViewById(R.id.packetloss_test_panel); tl3.setVisibility(View.GONE); }/*www. j a v a 2 s . c o m*/ if (testID == 4) { // loss / latency // hide others TableLayout tl = (TableLayout) findViewById(R.id.download_test_panel); tl.setVisibility(View.GONE); TableLayout tl2 = (TableLayout) findViewById(R.id.upload_test_panel); tl2.setVisibility(View.GONE); } if (testID == 3) { // upload // hide others TableLayout tl = (TableLayout) findViewById(R.id.download_test_panel); tl.setVisibility(View.GONE); TableLayout tl2 = (TableLayout) findViewById(R.id.latency_test_panel); tl2.setVisibility(View.GONE); TableLayout tl3 = (TableLayout) findViewById(R.id.packetloss_test_panel); tl3.setVisibility(View.GONE); } } else { mt = ManualTest.create(this, handler); } if (mt == null) { Logger.d(SamKnowsTestViewerActivity.class, "Impossible to run manual tests"); new AlertDialog.Builder(this).setMessage(getString(R.string.manual_test_error)) .setPositiveButton(R.string.ok_dialog, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { result = 0; SamKnowsTestViewerActivity.this.finish(); overridePendingTransition(0, 0); } }).show(); } else if (AppSettings.getInstance().isDataCapReached(mt.getNetUsage())) { Logger.d(SamKnowsTestViewerActivity.class, "Data cap exceeded"); new AlertDialog.Builder(this).setMessage(getString(R.string.data_cap_exceeded)) .setPositiveButton(R.string.ok_dialog, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { startTest(mt); } }).setNegativeButton(R.string.no_dialog, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { result = 0; SamKnowsTestViewerActivity.this.finish(); overridePendingTransition(0, 0); } }).show(); } else { startTest(mt); } }
From source file:org.smilec.smile.ui.GeneralActivity.java
private void showResults() { TableLayout tlTotal = (TableLayout) findViewById(R.id.tl_total); tlTotal.setVisibility(View.GONE); TextView tvTotal = (TextView) findViewById(R.id.tv_total); tvTotal.setVisibility(View.GONE); View vTotal = findViewById(R.id.view_separator_total); vTotal.setVisibility(View.GONE); TableLayout.LayoutParams layoutParams = new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 315); ListView lvListStudents = (ListView) GeneralActivity.this.findViewById(R.id.lv_students); lvListStudents.setLayoutParams(layoutParams); lvListStudents.setPadding(5, 0, 0, 0); TextView tvTopTitle = (TextView) GeneralActivity.this.findViewById(R.id.tv_top_scorers); tvTopTitle.setVisibility(View.VISIBLE); // View vSeparatorScore = findViewById(R.id.view_separator_score); // vSeparatorScore.setVisibility(View.VISIBLE); RelativeLayout rlTopScorersContainer = (RelativeLayout) GeneralActivity.this .findViewById(R.id.rl_top_scorers); rlTopScorersContainer.setVisibility(View.VISIBLE); spLimitToSucceed = (Spinner) findViewById(R.id.sp_limit_to_succeed); ArrayAdapter<?> adapterLimit = ArrayAdapter.createFromResource(this, R.array.percent_correct, android.R.layout.simple_spinner_item); adapterLimit.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spLimitToSucceed.setAdapter(adapterLimit); // Initialize the spinner to 70% spLimitToSucceed.setSelection(2);/*from w ww . j a v a 2 s .c om*/ // If the teacher clicks on the spinner to set a different limit to succeed spLimitToSucceed.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String[] bases = getResources().getStringArray(R.array.percent_correct); if (activeFragment instanceof StudentsFragment) { ((StudentsFragment) activeFragment).updatePercentCorrect(Integer.parseInt(bases[position])); } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); // If the teacher clicks on "Send results" button Button btSendResults = (Button) GeneralActivity.this.findViewById(R.id.bt_send_results); btSendResults.setVisibility(View.VISIBLE); btSendResults.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SendEmailResultsUtil.send(board, ip, GeneralActivity.this); } }); }
From source file:com.samknows.measurement.activity.SamKnowsTestViewerActivity.java
/** Called when the activity is first created. */ @Override/*from w w w . j av a2s. c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); cxt = this; Bundle b = getIntent().getExtras(); int testID = -1; if (b != null) { testID = b.getInt("testID"); } storage = CachingStorage.getInstance(); config = storage.loadScheduleConfig(); if (config == null) { config = new ScheduleConfig(); } testList = config.manual_tests; array_spinner = new String[testList.size() + 1]; array_spinner_int = new int[testList.size() + 1]; this.setTitle(R.string.running_test); // choose which test to run setContentView(R.layout.individual_stat_test); Util.initializeFonts(this); Util.overrideFonts(this, findViewById(android.R.id.content)); try { handler = new Handler() { @Override public void handleMessage(Message msg) { TextView tv = null; JSONObject message_json; message_json = (JSONObject) msg.obj; String value; int success; int testname; int status_complete; int metric; try { String type = message_json.getString(TestResult.JSON_TYPE_ID); if (type == "completed") { result = 1; SamKnowsTestViewerActivity.this.finish(); overridePendingTransition(0, 0); } if (type == "test") { testname = message_json.getInt(TestResult.JSON_TESTNUMBER); status_complete = message_json.getInt(TestResult.JSON_STATUS_COMPLETE); value = message_json.getString(TestResult.JSON_HRRESULT); if (status_complete == 100 && message_json.has(TestResult.JSON_SUCCESS)) { success = message_json.getInt(TestResult.JSON_SUCCESS); if (success == 0) { value = getString(R.string.failed); } } switch (testname) { // active metrics case TestResult.DOWNLOAD_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel1); tv = (TextView) findViewById(R.id.download_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.download) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.UPLOAD_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel2); tv = (TextView) findViewById(R.id.upload_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.upload) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.PACKETLOSS_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel3); tv = (TextView) findViewById(R.id.packetloss_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.packet_loss) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.LATENCY_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel4); tv = (TextView) findViewById(R.id.latency_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.latency) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.JITTER_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel5); tv = (TextView) findViewById(R.id.jitter_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.jitter) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; } } if (type == "passivemetric") { metric = message_json.getInt("metric"); value = message_json.getString("value"); switch (metric) { // passive metrics case 1: tv = (TextView) findViewById(R.id.passivemetric1); tv.setText(value); break; case 2: tv = (TextView) findViewById(R.id.passivemetric2); tv.setText(value); break; case 3: tv = (TextView) findViewById(R.id.passivemetric3); tv.setText(value); break; case 4: tv = (TextView) findViewById(R.id.passivemetric4); tv.setText(value); break; case 5: tv = (TextView) findViewById(R.id.passivemetric5); tv.setText(value); break; case 6: tv = (TextView) findViewById(R.id.passivemetric6); tv.setText(value); break; case 7: tv = (TextView) findViewById(R.id.passivemetric7); tv.setText(value); break; case 8: tv = (TextView) findViewById(R.id.passivemetric8); tv.setText(value); break; case 9: tv = (TextView) findViewById(R.id.passivemetric9); tv.setText(value); break; case 10: tv = (TextView) findViewById(R.id.passivemetric10); tv.setText(value); break; case 11: tv = (TextView) findViewById(R.id.passivemetric11); tv.setText(value); break; case 12: tv = (TextView) findViewById(R.id.passivemetric12); tv.setText(value); break; case 13: tv = (TextView) findViewById(R.id.passivemetric13); tv.setText(value); break; case 14: tv = (TextView) findViewById(R.id.passivemetric14); tv.setText(value); break; case 15: tv = (TextView) findViewById(R.id.passivemetric15); tv.setText(value); break; case 16: tv = (TextView) findViewById(R.id.passivemetric16); tv.setText(value); break; case 17: tv = (TextView) findViewById(R.id.passivemetric17); tv.setText(value); break; case 18: tv = (TextView) findViewById(R.id.passivemetric18); tv.setText(value); break; case 19: tv = (TextView) findViewById(R.id.passivemetric19); tv.setText(value); break; case 20: tv = (TextView) findViewById(R.id.passivemetric20); tv.setText(value); break; case 21: tv = (TextView) findViewById(R.id.passivemetric21); tv.setText(value); break; case 22: tv = (TextView) findViewById(R.id.passivemetric22); tv.setText(value); break; case 23: tv = (TextView) findViewById(R.id.passivemetric23); tv.setText(value); break; case 24: tv = (TextView) findViewById(R.id.passivemetric24); tv.setText(value); break; case 25: tv = (TextView) findViewById(R.id.passivemetric25); tv.setText(value); break; case 26: tv = (TextView) findViewById(R.id.passivemetric26); tv.setText(value); break; case 27: tv = (TextView) findViewById(R.id.passivemetric27); tv.setText(value); break; case 28: tv = (TextView) findViewById(R.id.passivemetric28); tv.setText(value); break; case 29: tv = (TextView) findViewById(R.id.passivemetric29); tv.setText(value); break; case 30: tv = (TextView) findViewById(R.id.passivemetric30); tv.setText(value); break; case 31: tv = (TextView) findViewById(R.id.passivemetric31); tv.setText(value); break; case 32: tv = (TextView) findViewById(R.id.passivemetric32); tv.setText(value); break; default: // } if (!value.equals("") && tv != null) { TableLayout tl1 = (TableLayout) findViewById(R.id.passive_metrics_status); tl1.setVisibility(View.GONE); TableLayout tl = (TableLayout) tv.getParent().getParent(); tl.setVisibility(View.VISIBLE); } if (value.equals("") && tv != null) { TableLayout tl = (TableLayout) tv.getParent().getParent(); tl.setVisibility(View.GONE); } } } catch (JSONException e) { Logger.e(this, e.getMessage()); } } }; launchTest(testID); } catch (Throwable t) { Logger.e(this, "handler or test failure", t); } }
From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java
@Override protected void onCreate(final @Nullable Bundle state) { super.onCreate(state); final Bundle extras = getIntent().getExtras(); if (extras != null) { this.account = new AccountsRegistry(this).getAccount(extras.getInt("selected_account")); } else {//from w ww. j a va2s. co m this.account = Simplified.getCurrentAccount(); } final ActionBar bar = this.getActionBar(); if (android.os.Build.VERSION.SDK_INT < 21) { bar.setDisplayHomeAsUpEnabled(false); bar.setHomeButtonEnabled(true); bar.setIcon(R.drawable.ic_arrow_back); } else { bar.setHomeAsUpIndicator(R.drawable.ic_arrow_back); bar.setDisplayHomeAsUpEnabled(true); bar.setHomeButtonEnabled(false); } final DocumentStoreType docs = Simplified.getDocumentStore(this.account, getResources()); final LayoutInflater inflater = NullCheck.notNull(this.getLayoutInflater()); final FrameLayout content_area = this.getContentFrame(); final ViewGroup layout = NullCheck .notNull((ViewGroup) inflater.inflate(R.layout.settings_account, content_area, false)); content_area.addView(layout); content_area.requestLayout(); final TextView in_barcode_label = NullCheck.notNull(this.findViewById(R.id.settings_barcode_label)); final TextView in_barcode_text = NullCheck.notNull(this.findViewById(R.id.settings_barcode_text)); final TextView in_pin_label = NullCheck.notNull(this.findViewById(R.id.settings_pin_label)); final ImageView in_barcode_image = NullCheck.notNull(this.findViewById(R.id.settings_barcode_image)); final TextView in_barcode_image_toggle = NullCheck .notNull(this.findViewById(R.id.settings_barcode_toggle_barcode)); final TextView in_pin_text = NullCheck.notNull(this.findViewById(R.id.settings_pin_text)); final CheckBox in_pin_reveal = NullCheck.notNull(this.findViewById(R.id.settings_reveal_password)); if (!this.account.pinRequired()) { in_pin_label.setVisibility(View.INVISIBLE); in_pin_text.setVisibility(View.INVISIBLE); in_pin_reveal.setVisibility(View.INVISIBLE); } final Button in_login = NullCheck.notNull(this.findViewById(R.id.settings_login)); final Button in_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup)); this.sync_switch = findViewById(R.id.sync_switch); this.sync_table_row = findViewById(R.id.sync_table_row); this.sync_table_row.setVisibility(View.GONE); this.advanced_table_row = findViewById(R.id.link_advanced); this.advanced_table_row.setVisibility(View.GONE); this.advanced_table_row.setOnClickListener(view -> { final FragmentManager mgr = getFragmentManager(); final FragmentTransaction transaction = mgr.beginTransaction(); final SettingsAccountAdvancedFragment fragment = new SettingsAccountAdvancedFragment(); transaction.add(R.id.settings_account_container, fragment).addToBackStack("advanced").commit(); }); final TableRow in_privacy = findViewById(R.id.link_privacy); final TableRow in_license = findViewById(R.id.link_license); final TextView account_name = NullCheck.notNull(this.findViewById(android.R.id.text1)); final TextView account_subtitle = NullCheck.notNull(this.findViewById(android.R.id.text2)); final ImageView in_account_icon = NullCheck.notNull(this.findViewById(R.id.account_icon)); in_pin_text.setTransformationMethod(PasswordTransformationMethod.getInstance()); if (android.os.Build.VERSION.SDK_INT >= 21) { this.handle_pin_reveal(in_pin_text, in_pin_reveal); } else { in_pin_reveal.setVisibility(View.GONE); } final TableRow in_report_issue = findViewById(R.id.report_issue); if (this.account.getSupportEmail() == null) { in_report_issue.setVisibility(View.GONE); } else { in_report_issue.setVisibility(View.VISIBLE); in_report_issue.setOnClickListener(view -> { final Intent intent = new Intent(this, ReportIssueActivity.class); final Bundle b = new Bundle(); b.putInt("selected_account", this.account.getId()); intent.putExtras(b); startActivity(intent); }); } final TableRow in_support_center = findViewById(R.id.support_center); if (this.account.supportsHelpCenter()) { in_support_center.setVisibility(View.VISIBLE); in_support_center.setOnClickListener(view -> { final HSHelpStack stack = HSHelpStack.getInstance(this); final HSDeskGear gear = new HSDeskGear("https://nypl.desk.com/", "4GBRmMv8ZKG8fGehhA", null); stack.setGear(gear); stack.showHelp(this); }); } else { in_support_center.setVisibility(View.GONE); } //Get labels from the current authentication document. final AuthenticationDocumentType auth_doc = docs.getAuthenticationDocument(); in_barcode_label.setText(auth_doc.getLabelLoginUserID()); in_pin_label.setText(auth_doc.getLabelLoginPassword()); final TableLayout in_table_with_code = NullCheck .notNull(this.findViewById(R.id.settings_login_table_with_code)); in_table_with_code.setVisibility(View.GONE); final TableLayout in_table_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup_table)); // boolean locationpermission = false; // if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { // locationpermission = true; // } // else // { // ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1); // } if (this.account.supportsCardCreator() || this.account.getCardCreatorUrl() != null) { in_table_signup.setVisibility(View.VISIBLE); } else { in_table_signup.setVisibility(View.GONE); } in_login.setOnClickListener(v -> this.onLoginWithBarcode()); final CheckBox in_age13_checkbox = NullCheck.notNull(this.findViewById(R.id.age13_checkbox)); if (Simplified.getSharedPrefs().contains("age13")) { in_age13_checkbox.setChecked(Simplified.getSharedPrefs().getBoolean("age13")); } else if (account.getId() == 2) { showAgeGateOptionsDialog(in_age13_checkbox); } in_age13_checkbox.setOnCheckedChangeListener(this::showAgeChangeConfirmation); if (this.account.needsAuth()) { in_login.setVisibility(View.VISIBLE); in_age13_checkbox.setVisibility(View.GONE); } else { in_login.setVisibility(View.GONE); in_age13_checkbox.setVisibility(View.VISIBLE); } if (this.account.supportsCardCreator()) { in_signup.setOnClickListener(v -> { final Intent cardcreator = new Intent(this, CardCreatorActivity.class); startActivity(cardcreator); }); in_signup.setText(R.string.need_card_button); } else if (this.account.getCardCreatorUrl() != null) { in_signup.setOnClickListener(v -> { final Intent e_card = new Intent(Intent.ACTION_VIEW); e_card.setData(Uri.parse(this.account.getCardCreatorUrl())); startActivity(e_card); }); in_signup.setText(R.string.need_card_button); } final boolean permission = Simplified.getSharedPrefs().getBoolean("syncPermissionGranted", this.account.getId()); this.sync_switch.setChecked(permission); /* If switching on, disable user interaction until server has responded. If switching off, disable applicable network requests by updating shared prefs flags. */ this.sync_switch.setOnCheckedChangeListener((buttonView, isChecked) -> { if (isChecked) { buttonView.setEnabled(false); annotationsManager.updateServerSyncPermissionStatus(true, (success) -> { if (success) { Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), true); this.sync_switch.setChecked(true); } else { Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), false); this.sync_switch.setChecked(false); } this.sync_switch.setEnabled(true); return kotlin.Unit.INSTANCE; }); } else { Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), false); this.sync_switch.setChecked(false); } }); if (this.account.getPrivacyPolicy() != null) { in_privacy.setVisibility(View.VISIBLE); } else { in_privacy.setVisibility(View.GONE); } if (this.account.getContentLicense() != null) { in_license.setVisibility(View.VISIBLE); } else { in_license.setVisibility(View.GONE); } in_license.setOnClickListener(view -> { final Intent intent = new Intent(this, WebViewActivity.class); final Bundle b = new Bundle(); WebViewActivity.setActivityArguments(b, this.account.getContentLicense(), "Content Licenses", SimplifiedPart.PART_SETTINGS); intent.putExtras(b); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); }); in_privacy.setOnClickListener(view -> { final Intent intent = new Intent(this, WebViewActivity.class); final Bundle b = new Bundle(); WebViewActivity.setActivityArguments(b, this.account.getPrivacyPolicy(), "Privacy Policy", SimplifiedPart.PART_SETTINGS); intent.putExtras(b); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); }); this.navigationDrawerSetActionBarTitle(); this.account_name_text = account_name; this.account_subtitle_text = account_subtitle; this.account_icon = in_account_icon; this.barcode_text = in_barcode_text; this.pin_text = in_pin_text; this.barcode_image_toggle = in_barcode_image_toggle; this.barcode_image = in_barcode_image; this.login = in_login; this.table_with_code = in_table_with_code; this.table_signup = in_table_signup; final CheckBox in_eula_checkbox = NullCheck.notNull(this.findViewById(R.id.eula_checkbox)); final OptionType<EULAType> eula_opt = docs.getEULA(); if (eula_opt.isSome()) { final Some<EULAType> some_eula = (Some<EULAType>) eula_opt; final EULAType eula = some_eula.get(); in_eula_checkbox.setChecked(eula.eulaHasAgreed()); in_eula_checkbox.setEnabled(true); in_eula_checkbox.setOnCheckedChangeListener((button, checked) -> eula.eulaSetHasAgreed(checked)); if (eula.eulaHasAgreed()) { LOG.debug("EULA: agreed"); } else { LOG.debug("EULA: not agreed"); } } else { LOG.debug("EULA: unavailable"); } this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); }
From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java
@Override public void onAccountIsLoggedIn(final AccountCredentials creds) { LOG.debug("account is logged in: {}", creds); final SimplifiedCatalogAppServicesType app = Simplified.getCatalogAppServices(); final BooksType books = app.getBooks(); final Resources rr = NullCheck.notNull(this.getResources()); final TableLayout in_table_with_code = NullCheck.notNull(this.table_with_code); final TableLayout in_table_signup = NullCheck.notNull(this.table_signup); final TextView in_account_name_text = NullCheck.notNull(this.account_name_text); final TextView in_account_subtitle_text = NullCheck.notNull(this.account_subtitle_text); final ImageView in_account_icon = NullCheck.notNull(this.account_icon); final TextView in_barcode_text = NullCheck.notNull(this.barcode_text); final TextView in_pin_text = NullCheck.notNull(this.pin_text); final ImageView in_barcode_image = NullCheck.notNull(this.barcode_image); final TextView in_barcode_image_toggle = NullCheck.notNull(this.barcode_image_toggle); final Button in_login = NullCheck.notNull(this.login); UIThread.runOnUIThread(() -> {/*w ww . ja v a 2 s .c o m*/ in_table_with_code.setVisibility(View.VISIBLE); in_table_signup.setVisibility(View.GONE); in_account_name_text.setText(this.account.getName()); in_account_subtitle_text.setText(this.account.getSubtitle()); try { in_account_icon.setImageBitmap(this.account.getLogoBitmap()); } catch (IllegalArgumentException e) { in_account_icon.setImageResource(R.drawable.librarylogomagic); } in_barcode_text.setText(creds.getBarcode().toString()); in_barcode_text.setContentDescription(creds.getBarcode().toString().replaceAll(".(?=.)", "$0,")); in_pin_text.setText(creds.getPin().toString()); in_pin_text.setContentDescription(creds.getPin().toString().replaceAll(".(?=.)", "$0,")); if (account.supportsBarcodeDisplay()) { Bitmap barcodeBitmap = generateBarcodeImage(creds.getBarcode().toString()); if (barcodeBitmap != null) { in_barcode_image.setImageBitmap(barcodeBitmap); in_barcode_image_toggle.setVisibility(View.VISIBLE); in_barcode_image_toggle.setOnClickListener(v -> { if (in_barcode_image_toggle.getText() == getText(R.string.settings_toggle_barcode_show)) { in_barcode_image.setVisibility(View.VISIBLE); in_barcode_image_toggle.setText(R.string.settings_toggle_barcode_hide); } else { in_barcode_image.setVisibility(View.GONE); in_barcode_image_toggle.setText(R.string.settings_toggle_barcode_show); } }); } } in_login.setText(rr.getString(R.string.settings_log_out)); in_login.setOnClickListener(v -> { final LogoutDialog d = LogoutDialog.newDialog(); d.setOnConfirmListener(() -> books.accountLogout(creds, this, this, this)); final FragmentManager fm = this.getFragmentManager(); d.show(fm, "logout-confirm"); }); }); }
From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java
@Override protected void onResume() { super.onResume(); final Resources rr = NullCheck.notNull(this.getResources()); final TableLayout in_table_with_code = NullCheck.notNull(this.table_with_code); final TableLayout in_table_signup = NullCheck.notNull(this.table_signup); final TextView in_account_name_text = NullCheck.notNull(this.account_name_text); final TextView in_account_subtitle_text = NullCheck.notNull(this.account_subtitle_text); final ImageView in_account_icon = NullCheck.notNull(this.account_icon); final TextView in_barcode_text = NullCheck.notNull(this.barcode_text); final TextView in_pin_text = NullCheck.notNull(this.pin_text); final ImageView in_barcode_image = NullCheck.notNull(this.barcode_image); final TextView in_barcode_image_toggle = NullCheck.notNull(this.barcode_image_toggle); final Button in_login = NullCheck.notNull(this.login); final CheckBox in_eula_checkbox = NullCheck.notNull(this.findViewById(R.id.eula_checkbox)); in_account_name_text.setText(this.account.getName()); in_account_subtitle_text.setText(this.account.getSubtitle()); try {/* w w w. j a v a 2s . com*/ in_account_icon.setImageBitmap(this.account.getLogoBitmap()); } catch (IllegalArgumentException e) { in_account_icon.setImageResource(R.drawable.librarylogomagic); } final BooksType userAccount; if (this.account == null) { userAccount = Simplified.getCatalogAppServices().getBooks(); } else { userAccount = Simplified.getBooks(this.account, this, Simplified.getCatalogAppServices().getAdobeDRMExecutor()); } final AccountsDatabaseType accounts_database = Simplified.getAccountsDatabase(this.account, this); if (!accounts_database.accountGetCredentials().isSome()) { this.sync_table_row.setVisibility(View.GONE); LOG.debug("No user currently signed in, bypassing UI update and Sync Status Initiation."); return; } final AccountCredentials creds = ((Some<AccountCredentials>) accounts_database.accountGetCredentials()) .get(); if (syncButtonShouldBeVisible()) { if (this.annotationsManager == null) { this.annotationsManager = new AnnotationsManager(this.account, creds, this); checkServerSyncPermission(userAccount); } this.sync_table_row.setVisibility(View.VISIBLE); this.advanced_table_row.setVisibility(View.VISIBLE); } else { this.sync_table_row.setVisibility(View.GONE); this.advanced_table_row.setVisibility(View.GONE); } if (account.supportsBarcodeDisplay()) { Bitmap barcodeBitmap = generateBarcodeImage(creds.getBarcode().toString()); if (barcodeBitmap != null) { in_barcode_image.setImageBitmap(barcodeBitmap); in_barcode_image_toggle.setVisibility(View.VISIBLE); in_barcode_image_toggle.setOnClickListener(view -> { if (in_barcode_image_toggle.getText() == getText(R.string.settings_toggle_barcode_show)) { in_barcode_image.setVisibility(View.VISIBLE); in_barcode_image_toggle.setText(R.string.settings_toggle_barcode_hide); } else { in_barcode_image.setVisibility(View.GONE); in_barcode_image_toggle.setText(R.string.settings_toggle_barcode_show); } }); } } in_table_with_code.setVisibility(View.VISIBLE); in_table_signup.setVisibility(View.GONE); in_barcode_text.setText(creds.getBarcode().toString()); in_barcode_text.setContentDescription(creds.getBarcode().toString().replaceAll(".(?=.)", "$0,")); in_pin_text.setText(creds.getPin().toString()); in_pin_text.setContentDescription(creds.getPin().toString().replaceAll(".(?=.)", "$0,")); in_eula_checkbox.setEnabled(false); in_login.setText(rr.getString(R.string.settings_log_out)); in_login.setOnClickListener(view -> { final LogoutDialog dialog = LogoutDialog.newDialog(); dialog.setOnConfirmListener(() -> { //Delete cache if logging out of current active library account userAccount.accountLogout(creds, this, this, this); if (this.account == Simplified.getCurrentAccount()) { userAccount.destroyBookStatusCache(); } }); final FragmentManager fm = this.getFragmentManager(); dialog.show(fm, "logout-confirm"); }); }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
public void setupBaseBarButtons(Menu menu, boolean flush) { if (flush)// w ww .ja v a2 s .c o m mLastMenuClass = ""; TableLayout mBaseBar = (TableLayout) findViewById(R.id.base_bar); mToolbarButtons = (ViewGroup) findViewById(R.id.base_row); mStaticButtons = (ViewGroup) findViewById(R.id.title_static_buttons); OpenFragment f = getSelectedFragment(); boolean topButtons = false; if (!getResources().getBoolean(R.bool.allow_split_actionbar) || !(getSetting(null, "pref_basebar", true) || mBaseBar == null || mToolbarButtons == null) && findViewById(R.id.title_buttons) != null) { mToolbarButtons = (ViewGroup) findViewById(R.id.title_buttons); if (mToolbarButtons == null && !BEFORE_HONEYCOMB) mToolbarButtons = (ViewGroup) getActionBar().getCustomView().findViewById(R.id.title_buttons); if (mBaseBar != null) mBaseBar.setVisibility(View.GONE); topButtons = true; } if (!shouldFlushMenu(menu)) return; USE_SPLIT_ACTION_BAR = !topButtons; if (mToolbarButtons != null) { mToolbarButtons.removeAllViews(); //if(!topButtons) mToolbarButtons.measure(LayoutParams.MATCH_PARENT, getResources().getDimensionPixelSize(R.dimen.actionbar_compat_height)); int i = -1; int btnWidth = getResources().getDimensionPixelSize(R.dimen.actionbar_compat_button_width) + (getResources().getDimensionPixelSize(R.dimen.vpi_padding_horizontal) * 2); // (int)(16 * getResources().getDimension(R.dimen.one_dp)); int tblWidth = mToolbarButtons.getWidth(); if (tblWidth <= 0 && !topButtons) tblWidth = getWindowWidth(); if (topButtons || tblWidth <= 0 || tblWidth > getWindowWidth() || !getResources().getBoolean(R.bool.ignore_max_base_buttons)) tblWidth = btnWidth * getResources().getInteger(R.integer.max_base_buttons); ArrayList<View> buttons = new ArrayList<View>(); buttons.addAll(ViewUtils.findChildByClass(mToolbarButtons, ImageButton.class)); boolean maxedOut = false; while (++i < menu.size()) { if (buttons.size() * btnWidth >= tblWidth) { maxedOut = true; Logger.LogDebug("Base bar full after #" + i + " ~ " + buttons.size() + " (" + (buttons.size() * btnWidth) + ">" + tblWidth + ")!"); break; } else if (menu.getItem(i) instanceof MenuItemImpl) { final MenuItemImpl item = (MenuItemImpl) menu.getItem(i); //if(item.getItemId() == R.id.title_menu) break; if (!item.isCheckable() && item.isVisible()) { View btn = makeMenuButton(item, mToolbarButtons); if (item.hasSubMenu()) btn.setTag(item.getSubMenu()); else if (!BEFORE_HONEYCOMB && item.getActionView() != null) { if (DEBUG) Logger.LogDebug("ACTION VIEW!!!"); btn = item.getActionView(); //ActionBarHelper h = ActionBarHelper.createInstance(this); } buttons.add(btn); if (i > 0) btn.setNextFocusLeftId(menu.getItem(i - 1).getItemId()); if (i < menu.size() - 1) btn.setNextFocusRightId(menu.getItem(i + 1).getItemId()); if (!USE_PRETTY_MENUS || topButtons) btn.setOnCreateContextMenuListener(this); menu.getItem(i).setVisible(false); btn.setOnClickListener(this); btn.setOnFocusChangeListener(this); btn.setOnKeyListener(this); if (mToolbarButtons.findViewById(menu.getItem(i).getItemId()) == null) mToolbarButtons.addView(btn); //menu.removeItem(item.getItemId()); if (DEBUG) Logger.LogDebug("Added " + item.getTitle() + " to base bar."); } //else Logger.LogWarning(item.getTitle() + " should not show. " + item.getShowAsAction() + " :: " + item.getFlags()); } } mToolbarButtons.setVisibility(View.VISIBLE); mLastMenuClass = f.getClassName(); if (MenuUtils.countVisibleMenus(mMainMenu) > 0) { if (maxedOut && buttons.size() > 0) { View old = buttons.remove(buttons.size() - 1); MenuUtils.setMenuVisible(mMainMenu, true, old.getId()); mToolbarButtons.removeView(old); } final ImageButton btn = (ImageButton) getLayoutInflater().inflate(R.layout.toolbar_button, mToolbarButtons); btn.setImageResource(R.drawable.ic_menu_more); //btn.measure(getResources().getDimensionPixelSize(R.dimen.actionbar_compat_button_home_width), getResources().getDimensionPixelSize(R.dimen.actionbar_compat_height)); btn.setId(R.id.menu_more); if (buttons.size() > 0) { buttons.get(buttons.size() - 1).setNextFocusRightId(R.id.menu_more); btn.setNextFocusLeftId(buttons.get(buttons.size() - 1).getId()); } btn.setOnKeyListener(this); btn.setOnClickListener(this); btn.setOnLongClickListener(this); btn.setFocusable(true); btn.setOnFocusChangeListener(this); buttons.add(btn); mToolbarButtons.addView(btn); } if (buttons.size() > 0) { View last = buttons.get(buttons.size() - 1); last.setNextFocusRightId(android.R.id.home); if (findViewById(android.R.id.home) != null) findViewById(android.R.id.home).setNextFocusLeftId(last.getId()); } Logger.LogDebug("Added " + buttons.size() + " children to Base Bar."); if (mBaseBar != null) { if (buttons.size() < 1) mBaseBar.setVisibility(View.GONE); else mBaseBar.setStretchAllColumns(true); } } else if (BEFORE_HONEYCOMB) Logger.LogWarning("No Base Row!?"); }