List of usage examples for android.widget FrameLayout addView
public void addView(View child)
Adds a child view.
From source file:com.ehelp.home.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/* w w w. j a v a2 s. c om*/ //fl.setBackgroundColor(0x666666); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setGravity(Gravity.TOP); System.out.println(position); if (position == 0) { fl.removeAllViews(); mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; mMapView = new MapView(getActivity()); mMapView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); fl.addView(mMapView); mBaiduMap = mMapView.getMap(); // ?? mBaiduMap.setMyLocationEnabled(true); // ?? mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(myListener); LocationClientOption option = new LocationClientOption(); option.setOpenGps(true);// gps option.setCoorType("bd09ll"); // ?? option.setScanSpan(1000); mLocClient.setLocOption(option); mLocClient.start(); int count = mMapView.getChildCount(); for (int i = 0; i < count; i++) { View child = mMapView.getChildAt(i); if (child instanceof ZoomControls || child instanceof ImageView) { child.setVisibility(View.INVISIBLE); } } setLocation(); } else if (position == 1) { fl.removeAllViews(); ListView queList = new ListView(getActivity()); queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1)); HomeAdapter que = new HomeAdapter(getActivity(), user_id, 2, eventCache); queList.setAdapter(que); queList.setDividerHeight(20); fl.addView(queList); events = que.getEvent(); //? queList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) { Intent intent = new Intent(getActivity(), recievesos_map.class); int eventid = events.get(index).getEventId(); intent.putExtra(EXTRA_MESSAGE, eventid); startActivity(intent); } }); } else if (position == 2) { fl.removeAllViews(); ListView queList = new ListView(getActivity()); queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1)); //queList.setBackgroundColor(0x666666); //queList.setAlpha(125); queList.setDividerHeight(20); HomeAdapter que = new HomeAdapter(getActivity(), user_id, 1, eventCache); queList.setAdapter(que); fl.addView(queList); events = que.getEvent(); //? queList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) { Intent intent = new Intent(getActivity(), recieve_help_ans_map.class); intent.putExtra(EXTRA_MESSAGE, events.get(index)); startActivity(intent); } }); } else if (position == 3) { fl.removeAllViews(); ListView queList = new ListView(getActivity()); queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1)); HomeAdapter que = new HomeAdapter(getActivity(), user_id, 0, eventCache); queList.setAdapter(que); queList.setDividerHeight(20); fl.addView(queList); events = que.getEvent(); //? queList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) { Intent intent = new Intent(getActivity(), QuestionDetail.class); intent.putExtra("qusetiondatail", events.get(index)); startActivity(intent); } }); } return fl; }
From source file:com.kai.uGuide.ui.fragment.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/*from w w w. j a va 2 s .c o m*/ // final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources() // .getDisplayMetrics()); // // TextView v = new TextView(getActivity()); // params.setMargins(margin, margin, margin, margin); // v.setLayoutParams(params); // v.setLayoutParams(params); // v.setGravity(Gravity.CENTER); // v.setBackgroundResource(R.drawable.background_card); // v.setText("CARD " + (position + 1)); // // fl.addView(v); LinearLayout pagerlayout = new LinearLayout(getActivity()); pagerlayout.setOrientation(LinearLayout.HORIZONTAL); pagerlayout.setId(300 + position); if (page == 0) adapter = AdapterTransitionFragment.newInstance(position); else adapter = ResultAdapterTransitionFragment.newInstance(position); getFragmentManager().beginTransaction().add(pagerlayout.getId(), adapter, "someTag" + position).commit(); fl.addView(pagerlayout); return fl; }
From source file:com.softanalle.scma.MainActivity.java
@Override protected void onResume() { super.onResume(); logger.debug("MainActivity.onResume()"); if (mPreview != null) { mPreview.reclaimCamera();/*from w ww .j a v a2 s .com*/ } else { try { mPreview = new Preview(this); FrameLayout tmp = (FrameLayout) findViewById(R.id.camera_preview); tmp.addView(mPreview); } catch (Exception e) { logger.error("onResume: " + e.toString()); } } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); sp.registerOnSharedPreferenceChangeListener(this); getSettings(); this.getWindow().addFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
From source file:com.nttec.everychan.http.recaptcha.Recaptcha2fallback.java
@Override public void handle(final Activity activity, final CancellableTask task, final Callback callback) { try {//www. j a va 2s . c o m final HttpClient httpClient = ((HttpChanModule) MainApplication.getInstance().getChanModule(chanName)) .getHttpClient(); final String usingURL = scheme + RECAPTCHA_FALLBACK_URL + publicKey + (sToken != null && sToken.length() > 0 ? ("&stoken=" + sToken) : ""); String refererURL = baseUrl != null && baseUrl.length() > 0 ? baseUrl : usingURL; Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, refererURL) }; String htmlChallenge; if (lastChallenge != null && lastChallenge.getLeft().equals(usingURL)) { htmlChallenge = lastChallenge.getRight(); } else { htmlChallenge = HttpStreamer.getInstance().getStringFromUrl(usingURL, HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient, null, task, false); } lastChallenge = null; Matcher challengeMatcher = Pattern.compile("name=\"c\" value=\"([\\w-]+)").matcher(htmlChallenge); if (challengeMatcher.find()) { final String challenge = challengeMatcher.group(1); HttpResponseModel responseModel = HttpStreamer.getInstance().getFromUrl( scheme + RECAPTCHA_IMAGE_URL + challenge + "&k=" + publicKey, HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient, null, task); try { InputStream imageStream = responseModel.stream; final Bitmap challengeBitmap = BitmapFactory.decodeStream(imageStream); final String message; Matcher messageMatcher = Pattern.compile("imageselect-message(?:.*?)>(.*?)</div>") .matcher(htmlChallenge); if (messageMatcher.find()) message = RegexUtils.removeHtmlTags(messageMatcher.group(1)); else message = null; final Bitmap candidateBitmap; Matcher candidateMatcher = Pattern .compile("fbc-imageselect-candidates(?:.*?)src=\"data:image/(?:.*?);base64,([^\"]*)\"") .matcher(htmlChallenge); if (candidateMatcher.find()) { Bitmap bmp = null; try { byte[] imgData = Base64.decode(candidateMatcher.group(1), Base64.DEFAULT); bmp = BitmapFactory.decodeByteArray(imgData, 0, imgData.length); } catch (Exception e) { } candidateBitmap = bmp; } else candidateBitmap = null; activity.runOnUiThread(new Runnable() { final int maxX = 3; final int maxY = 3; final boolean[] isSelected = new boolean[maxX * maxY]; @SuppressLint("InlinedApi") @Override public void run() { LinearLayout rootLayout = new LinearLayout(activity); rootLayout.setOrientation(LinearLayout.VERTICAL); if (candidateBitmap != null) { ImageView candidateView = new ImageView(activity); candidateView.setImageBitmap(candidateBitmap); int picSize = (int) (activity.getResources().getDisplayMetrics().density * 50 + 0.5f); candidateView.setLayoutParams(new LinearLayout.LayoutParams(picSize, picSize)); candidateView.setScaleType(ImageView.ScaleType.FIT_XY); rootLayout.addView(candidateView); } if (message != null) { TextView textView = new TextView(activity); textView.setText(message); CompatibilityUtils.setTextAppearance(textView, android.R.style.TextAppearance); textView.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); rootLayout.addView(textView); } FrameLayout frame = new FrameLayout(activity); frame.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); final ImageView imageView = new ImageView(activity); imageView.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageBitmap(challengeBitmap); frame.addView(imageView); final LinearLayout selector = new LinearLayout(activity); selector.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); AppearanceUtils.callWhenLoaded(imageView, new Runnable() { @Override public void run() { selector.setLayoutParams(new FrameLayout.LayoutParams(imageView.getWidth(), imageView.getHeight())); } }); selector.setOrientation(LinearLayout.VERTICAL); selector.setWeightSum(maxY); for (int y = 0; y < maxY; ++y) { LinearLayout subSelector = new LinearLayout(activity); subSelector.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)); subSelector.setOrientation(LinearLayout.HORIZONTAL); subSelector.setWeightSum(maxX); for (int x = 0; x < maxX; ++x) { FrameLayout switcher = new FrameLayout(activity); switcher.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); switcher.setTag(new int[] { x, y }); switcher.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int[] coord = (int[]) v.getTag(); int index = coord[1] * maxX + coord[0]; isSelected[index] = !isSelected[index]; v.setBackgroundColor(isSelected[index] ? Color.argb(128, 0, 255, 0) : Color.TRANSPARENT); } }); subSelector.addView(switcher); } selector.addView(subSelector); } frame.addView(selector); rootLayout.addView(frame); Button checkButton = new Button(activity); checkButton.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); checkButton.setText(android.R.string.ok); rootLayout.addView(checkButton); ScrollView dlgView = new ScrollView(activity); dlgView.addView(rootLayout); final Dialog dialog = new Dialog(activity); dialog.setTitle("Recaptcha"); dialog.setContentView(dlgView); dialog.setCanceledOnTouchOutside(false); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!task.isCancelled()) { callback.onError("Cancelled"); } } }); dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); dialog.show(); checkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (task.isCancelled()) return; Async.runAsync(new Runnable() { @Override public void run() { try { List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("c", challenge)); for (int i = 0; i < isSelected.length; ++i) if (isSelected[i]) pairs.add(new BasicNameValuePair("response", Integer.toString(i))); HttpRequestModel request = HttpRequestModel.builder() .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")) .setCustomHeaders(new Header[] { new BasicHeader(HttpHeaders.REFERER, usingURL) }) .build(); String response = HttpStreamer.getInstance().getStringFromUrl( usingURL, request, httpClient, null, task, false); String hash = ""; Matcher matcher = Pattern.compile( "fbc-verification-token(?:.*?)<textarea[^>]*>([^<]*)<", Pattern.DOTALL).matcher(response); if (matcher.find()) hash = matcher.group(1); if (hash.length() > 0) { Recaptcha2solved.push(publicKey, hash); activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); } else { lastChallenge = Pair.of(usingURL, response); throw new RecaptchaException( "incorrect answer (hash is empty)"); } } catch (final Exception e) { Logger.e(TAG, e); if (task.isCancelled()) return; handle(activity, task, callback); } } }); } }); } }); } finally { responseModel.release(); } } else throw new Exception("can't parse recaptcha challenge answer"); } catch (final Exception e) { Logger.e(TAG, e); if (!task.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onError(e.getMessage() != null ? e.getMessage() : e.toString()); } }); } } }
From source file:foam.starwisp.DrawableMap.java
public void init(int id, ViewGroup parent, StarwispActivity c, StarwispBuilder b, String mode) { m_parent = parent;/*from ww w . ja va 2 s . co m*/ map_ready = false; draw_mode = false; button_mode = false; m_Context = c; m_Builder = b; map_mode = mode; ID = id; current_polygon = new Vector<LatLng>(); polygons = new Vector<Polygon>(); centre_lat = 49.198935; centre_lon = 2.988281; centre_zoom = 4; draw_indicator = false; indicator_lat = 0; indicator_lon = 0; FrameLayout outer_map = new FrameLayout(c); outer_map.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT)); FrameLayout map_container = new FrameLayout(c); map_container.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT)); map_container.setId(ID); SupportMapFragment mapfrag = SupportMapFragment.newInstance(); FragmentTransaction fragmentTransaction = c.getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(ID, mapfrag); fragmentTransaction.commit(); outer_map.addView(map_container); fram_map = new FrameLayout(c); fram_map.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT)); outer_map.addView(fram_map); if (map_mode.equals("edit")) { map_cont = new LinearLayout(c); map_cont.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); lp.gravity = Gravity.CENTER; map_cont.setLayoutParams(lp); scribble_button = new Button(c); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER; scribble_button.setLayoutParams(lp); scribble_button.setTextSize(20); scribble_button.setTypeface(((StarwispActivity) c).m_Typeface); scribble_button.setText("Draw field"); map_cont.addView(scribble_button); m_instructions = new TextView(c); m_instructions.setLayoutParams(lp); m_instructions.setTextSize(20); m_instructions.setTypeface(m_Context.m_Typeface); m_instructions.setTextColor(Color.WHITE); // arg i18n map_cont.addView(m_instructions); fram_map.addView(map_cont); } else { //button_mode=true; } parent.addView(outer_map); mapfrag.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { map = googleMap; map.setMapType(GoogleMap.MAP_TYPE_SATELLITE); map.setMyLocationEnabled(true); map.getUiSettings().setZoomControlsEnabled(true); SetupStuff(); DrawMap(); Log.i("starwisp", "map made"); Log.i("starwisp", "updating map centre to " + centre_lat + " " + centre_lon); //CameraUpdate center_map=CameraUpdateFactory.newLatLng(new LatLng(centre_lat,centre_lon)); //CameraUpdate zoom_map=CameraUpdateFactory.zoomTo(centre_zoom); //map.moveCamera(center_map); //map.animateCamera(zoom_map); CameraPosition cameraPosition = new CameraPosition.Builder() .target(new LatLng(centre_lat, centre_lon)).zoom(centre_zoom).build(); map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); map_ready = true; } }); }
From source file:com.kakao.auth.authorization.authcode.KakaoWebViewDialog.java
@SuppressLint("SetJavaScriptEnabled") private void setUpWebView(int margin) { // TODO xml ?? FrameLayout webViewContainer = new FrameLayout(getContext()); webView = new WebView(getContext()); webView.setVerticalScrollBarEnabled(false); webView.setHorizontalScrollBarEnabled(false); webView.setWebViewClient(new DialogWebViewClient()); webView.setWebChromeClient(new KakaoWebChromeClient()); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl(url, headers);//from www.j a va2s .com webView.canGoBack(); webView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); webView.setVisibility(View.INVISIBLE); webView.getSettings().setSaveFormData(KakaoSDK.getAdapter().getSessionConfig().isSaveFormData()); webView.getSettings().setSavePassword(false); webViewContainer.setPadding(margin, margin, margin, margin); webViewContainer.addView(webView); contentFrameLayout.addView(webViewContainer); }
From source file:com.itraing.views.ActionSheet.java
private View createView() { FrameLayout parent = new FrameLayout(getActivity()); parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg = new View(getActivity()); mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg.setBackgroundColor(Color.argb(136, 0, 0, 0)); mBg.setId(ActionSheet.BG_VIEW_ID);/* w w w . ja va 2 s . co m*/ mBg.setOnClickListener(this); mPanel = new LinearLayout(getActivity()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; mPanel.setLayoutParams(params); mPanel.setOrientation(LinearLayout.VERTICAL); parent.addView(mBg); parent.addView(mPanel); return parent; }
From source file:com.example.android.animationsdemo.CameraActivity.java
private void initCamera() { if (CameraHelper.checkCameraHardware(context)) { long startTime = System.currentTimeMillis(); // Create an instance of Camera mCamera = CameraHelper.getDefaultCameraInstance(); // Create our Preview view and set it as the content of our activity. mPreview = new CameraPreview(this, mCamera); FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview); mPreview.setOnTouchListener(new View.OnTouchListener() { @Override// ww w. ja v a 2s.c o m public boolean onTouch(View v, MotionEvent event) { DKLog.d(TAG, Trace.getCurrentMethod() + event.toString()); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: int x = (int) event.getX(); int y = (int) event.getY(); DKLog.d(TAG, Trace.getCurrentMethod() + String.format("( %d , %d )", x, y)); startFocusAniamtion(x, y); startFocus(x, y); return true; } return false; } }); preview.addView(mPreview); DKLog.d(TAG, Trace.getCurrentMethod() + "take: " + (System.currentTimeMillis() - startTime) + " ms"); } }
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 {/* w w w .j ava 2s. c o 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.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java
@Override public void onCreate(Bundle savedInstanceState) { AnalyticsHelper.reportScreen(this, AnalyticsManager.SCREEN_SAMSUNG_SNOTE_EDITOR); super.onCreate(savedInstanceState); setContentView(R.layout.snote_editor); context = this; // TOOLBAR/*from w w w . j av a 2s . com*/ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); } // Retrieve information String action = getIntent().getAction(); if (Intent.ACTION_VIEW.equals(action)) { if (getIntent().getData() != null) { String filePath = BaseActionUtils.getPath(this, getIntent().getData()); file = new File(filePath); } else { AlfrescoNotificationManager.getInstance(this).showLongToast(getString(R.string.editor_error_open)); finish(); return; } } // Init Spen boolean isSpenFeatureEnabled = false; Spen spenPackage = new Spen(); try { spenPackage.initialize(this); isSpenFeatureEnabled = spenPackage.isFeatureEnabled(Spen.DEVICE_PEN); } catch (SsdkUnsupportedException e) { if (SNoteUtils.processUnsupportedException(this, e)) { return; } } catch (Exception e1) { Log.e(TAG, Log.getStackTraceString(e1)); finish(); } FrameLayout spenViewContainer = (FrameLayout) findViewById(R.id.spenViewContainer); RelativeLayout spenViewLayout = (RelativeLayout) findViewById(R.id.spenViewLayout); // PEN SETTINGS spenSettingView = new SpenSettingPenLayout(context, "", spenViewLayout); if (spenSettingView == null) { finish(); } spenViewContainer.addView(spenSettingView); // ERASER SETTINGS eraserSettingView = new SpenSettingEraserLayout(context, "", spenViewLayout); if (eraserSettingView == null) { finish(); } spenViewContainer.addView(eraserSettingView); // TEXT SETTINGS textSettingView = new SpenSettingTextLayout(context, "", new HashMap<String, String>(), spenViewLayout); if (textSettingView == null) { finish(); } spenViewContainer.addView(textSettingView); // SELECTION SETTINGS selectionSettingView = new SpenSettingSelectionLayout(context, "", spenViewLayout); if (textSettingView == null) { finish(); } spenViewContainer.addView(selectionSettingView); // SURFACE VIEW spenSurfaceView = new SpenSurfaceView(context); if (spenSurfaceView == null) { finish(); } spenViewLayout.addView(spenSurfaceView); spenSettingView.setCanvasView(spenSurfaceView); eraserSettingView.setCanvasView(spenSurfaceView); textSettingView.setCanvasView(spenSurfaceView); selectionSettingView.setCanvasView(spenSurfaceView); // NOTE DOCUMENT Display display = getWindowManager().getDefaultDisplay(); Rect mScreenRect = new Rect(); display.getRectSize(mScreenRect); try { if (file != null && file.length() > 0) { spenNoteDoc = new SpenNoteDoc(context, file.getAbsolutePath(), mScreenRect.width(), SpenNoteDoc.MODE_WRITABLE); if (spenNoteDoc.getPageCount() == 0) { spenPageDoc = spenNoteDoc.appendPage(); } else { spenPageDoc = spenNoteDoc.getPage(spenNoteDoc.getLastEditedPageIndex()); } } else { spenNoteDoc = new SpenNoteDoc(context, SpenNoteDoc.ORIENTATION_LANDSCAPE, (mScreenRect.width() > mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height(), (mScreenRect.width() < mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height()); spenPageDoc = spenNoteDoc.appendPage(); spenPageDoc.setBackgroundColor(getResources().getColor(android.R.color.white)); spenPageDoc.clearHistory(); } } catch (Exception e) { finish(); } // Display Document spenSurfaceView.setPageDoc(spenPageDoc, true); spenSurfaceView.setBlankColor(getResources().getColor(R.color.grey_light)); if (!isSpenFeatureEnabled) { mToolType = SpenSurfaceView.TOOL_FINGER; spenSurfaceView.setToolTypeAction(mToolType, SpenSurfaceView.ACTION_STROKE); // Touch listener for swipe if on Finger mode gdt = new GestureDetector(context, new GestureListener()); spenSurfaceView.setOnTouchListener(touchListener); } // Init Pages mTxtView = (TextView) findViewById(R.id.spen_page); mTxtView.setText(String.format(getString(R.string.editor_paging), String.valueOf((spenNoteDoc.getPageIndexById(spenPageDoc.getId()) + 1)), spenNoteDoc.getPageCount())); // INIT Setting & Listeners initSettingInfo(); spenSurfaceView.setTouchListener(penTouchListener); spenSurfaceView.setControlListener(controlListener); spenSurfaceView.setFlickListener(mFlickListener); }