Search in sources :

Example 76 with RelativeLayout

use of android.widget.RelativeLayout in project wigle-wifi-wardriving by wiglenet.

the class MappingFragment method setupMapView.

private void setupMapView(final View view, final LatLng oldCenter, final int oldZoom) {
    // view
    final RelativeLayout rlView = (RelativeLayout) view.findViewById(R.id.map_rl);
    if (mapView != null) {
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        mapView.setLayoutParams(params);
    }
    // conditionally replace the tile source
    final SharedPreferences prefs = getActivity().getSharedPreferences(ListFragment.SHARED_PREFS, 0);
    rlView.addView(mapView);
    // guard against not having google play services
    mapView.getMapAsync(new OnMapReadyCallback() {

        @Override
        public void onMapReady(final GoogleMap googleMap) {
            if (ActivityCompat.checkSelfPermission(MappingFragment.this.getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(MappingFragment.this.getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
                googleMap.setMyLocationEnabled(true);
            }
            googleMap.setBuildingsEnabled(true);
            final boolean showTraffic = prefs.getBoolean(ListFragment.PREF_MAP_TRAFFIC, true);
            googleMap.setTrafficEnabled(showTraffic);
            final int mapType = prefs.getInt(ListFragment.PREF_MAP_TYPE, GoogleMap.MAP_TYPE_NORMAL);
            googleMap.setMapType(mapType);
            mapRender = new MapRender(getActivity(), googleMap, false);
            googleMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {

                @Override
                public boolean onMyLocationButtonClick() {
                    if (!state.locked) {
                        state.locked = true;
                        if (menu != null) {
                            MenuItem item = menu.findItem(MENU_TOGGLE_LOCK);
                            String name = state.locked ? getString(R.string.menu_turn_off_lockon) : getString(R.string.menu_turn_on_lockon);
                            item.setTitle(name);
                            MainActivity.info("on-my-location received - activating lock");
                        }
                    }
                    return false;
                }
            });
            googleMap.setOnCameraMoveStartedListener(new GoogleMap.OnCameraMoveStartedListener() {

                @Override
                public void onCameraMoveStarted(int reason) {
                    if (reason == REASON_GESTURE) {
                        if (state.locked) {
                            state.locked = false;
                            if (menu != null) {
                                MenuItem item = menu.findItem(MENU_TOGGLE_LOCK);
                                String name = state.locked ? getString(R.string.menu_turn_off_lockon) : getString(R.string.menu_turn_on_lockon);
                                item.setTitle(name);
                            }
                        }
                    } else if (reason == REASON_API_ANIMATION) {
                    // DEBUG: MainActivity.info("Camera moved due to user tap");
                    // TODO: should we combine this case with REASON_GESTURE?
                    } else if (reason == REASON_DEVELOPER_ANIMATION) {
                    // MainActivity.info("Camera moved due to app directive");
                    }
                }
            });
            // controller
            final LatLng centerPoint = getCenter(getActivity(), oldCenter, previousLocation);
            float zoom = DEFAULT_ZOOM;
            if (oldZoom >= 0) {
                zoom = oldZoom;
            } else {
                zoom = prefs.getFloat(ListFragment.PREF_PREV_ZOOM, zoom);
            }
            final CameraPosition cameraPosition = new CameraPosition.Builder().target(centerPoint).zoom(zoom).build();
            googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
            if (!ListFragment.PREF_MAP_NO_TILE.equals(prefs.getString(ListFragment.PREF_SHOW_DISCOVERED, ListFragment.PREF_MAP_NO_TILE))) {
                final int providerTileRes = MainActivity.isHighDefinition() ? 512 : 256;
                // TODO: DRY up token composition vs AbstractApiRequest?
                String ifAuthToken = null;
                try {
                    final String authname = prefs.getString(ListFragment.PREF_AUTHNAME, null);
                    final String token = TokenAccess.getApiToken(prefs);
                    if ((null != authname) && (null != token)) {
                        final String encoded = Base64.encodeToString((authname + ":" + token).getBytes("UTF-8"), Base64.NO_WRAP);
                        ifAuthToken = "Basic " + encoded;
                    }
                } catch (UnsupportedEncodingException ueex) {
                    MainActivity.error("map tiles: unable to encode credentials for mine/others", ueex);
                } catch (UnsupportedOperationException uoex) {
                    MainActivity.error("map tiles: unable to access credentials for mine/others", uoex);
                }
                final String authToken = ifAuthToken;
                final String userAgent = AbstractApiRequest.getUserAgentString();
                TileProvider tileProvider = new TileProvider() {

                    @Override
                    public Tile getTile(int x, int y, int zoom) {
                        if (!checkTileExists(x, y, zoom)) {
                            return null;
                        }
                        final Long since = prefs.getLong(ListFragment.PREF_SHOW_DISCOVERED_SINCE, 2001);
                        int thisYear = Calendar.getInstance().get(Calendar.YEAR);
                        String tileContents = prefs.getString(ListFragment.PREF_SHOW_DISCOVERED, ListFragment.PREF_MAP_NO_TILE);
                        String sinceString = String.format("%d0000-00000", since);
                        String toString = String.format("%d0000-00000", thisYear + 1);
                        String s = String.format(MAP_TILE_URL_FORMAT, zoom, x, y, sinceString, toString);
                        if (MainActivity.isHighDefinition()) {
                            s += HIGH_RES_TILE_TRAILER;
                        }
                        // ALIBI: defaults to "ALL"
                        if (ListFragment.PREF_MAP_ONLYMINE_TILE.equals(tileContents)) {
                            s += ONLY_MINE_TILE_TRAILER;
                        } else if (ListFragment.PREF_MAP_NOTMINE_TILE.equals(tileContents)) {
                            s += NOT_MINE_TILE_TRAILER;
                        }
                        try {
                            final byte[] data = downloadData(new URL(s), userAgent, authToken);
                            if (data != null) {
                                return new Tile(providerTileRes, providerTileRes, data);
                            }
                        } catch (MalformedURLException e) {
                            throw new AssertionError(e);
                        }
                        return null;
                    }

                    /*
                         * depends on supported levels on the server
                         */
                    private boolean checkTileExists(int x, int y, int zoom) {
                        int minZoom = 0;
                        int maxZoom = 24;
                        if ((zoom < minZoom || zoom > maxZoom)) {
                            return false;
                        }
                        return true;
                    }

                    private byte[] downloadData(final URL url, final String userAgent, final String authToken) {
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        InputStream is = null;
                        try {
                            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                            if (null != authToken) {
                                conn.setRequestProperty("Authorization", authToken);
                            }
                            conn.setRequestProperty("User-Agent", userAgent);
                            is = conn.getInputStream();
                            byte[] byteChunk = new byte[4096];
                            int n;
                            while ((n = is.read(byteChunk)) > 0) {
                                baos.write(byteChunk, 0, n);
                            }
                        } catch (IOException e) {
                            MainActivity.error("Failed while reading bytes from " + url.toExternalForm() + ": " + e.getMessage());
                            e.printStackTrace();
                        } finally {
                            if (is != null) {
                                try {
                                    is.close();
                                } catch (IOException ioex) {
                                    MainActivity.error("Failed while closing InputStream " + url.toExternalForm() + ": " + ioex.getMessage());
                                    ioex.printStackTrace();
                                }
                            }
                        }
                        return baos.toByteArray();
                    }
                };
                tileOverlay = googleMap.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider).transparency(0.35f));
            }
        }
    });
    MainActivity.info("done setupMapView.");
}
Also used : MalformedURLException(java.net.MalformedURLException) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback) TileProvider(com.google.android.gms.maps.model.TileProvider) URL(java.net.URL) CameraPosition(com.google.android.gms.maps.model.CameraPosition) HttpURLConnection(java.net.HttpURLConnection) GoogleMap(com.google.android.gms.maps.GoogleMap) LatLng(com.google.android.gms.maps.model.LatLng) TileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions) SharedPreferences(android.content.SharedPreferences) ViewGroup(android.view.ViewGroup) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Tile(com.google.android.gms.maps.model.Tile) MenuItem(android.view.MenuItem) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) RelativeLayout(android.widget.RelativeLayout)

Example 77 with RelativeLayout

use of android.widget.RelativeLayout in project fuckView by w568w.

the class WelcomeFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.welcome_fragment, null);
    layout.findViewById(R.id.welcome_guide).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://w568.wodemo.net/entry/467891")));
            } catch (ActivityNotFoundException a) {
                a.printStackTrace();
                Toast.makeText(getActivity(), getString(R.string.unsupport_of_package), Toast.LENGTH_SHORT).show();
            }
        }
    });
    layout.findViewById(R.id.welcome_pass).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (getActivity() instanceof MainActivity) {
                ((MainActivity) getActivity()).setFragmentWithoutBack(new SelectAppWizard());
            }
        }
    });
    return layout;
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) RelativeLayout(android.widget.RelativeLayout) Intent(android.content.Intent) MainActivity(ml.qingsu.fuckview.ui.activities.MainActivity) View(android.view.View) SelectAppWizard(ml.qingsu.fuckview.ui.fragments.select_app.SelectAppWizard) Nullable(android.support.annotation.Nullable)

Example 78 with RelativeLayout

use of android.widget.RelativeLayout in project Pix-Art-Messenger by kriztan.

the class AudioPlayer method onProgressChanged.

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    synchronized (AudioPlayer.LOCK) {
        final RelativeLayout audioPlayer = (RelativeLayout) seekBar.getParent();
        final Message message = (Message) audioPlayer.getTag();
        if (fromUser && message == AudioPlayer.currentlyPlayingMessage) {
            float percent = progress / 100f;
            int duration = AudioPlayer.player.getDuration();
            int seekTo = Math.round(duration * percent);
            AudioPlayer.player.seekTo(seekTo);
        }
    }
}
Also used : Message(de.pixart.messenger.entities.Message) RelativeLayout(android.widget.RelativeLayout)

Example 79 with RelativeLayout

use of android.widget.RelativeLayout in project MifareClassicTool by ikarus23.

the class DiffTool method runDiff.

/**
 * Run diff if there are two dumps and show the result in the GUI.
 * @see MCDiffUtils#diffIndices(SparseArray, SparseArray)
 */
private void runDiff() {
    // Check if both dumps are there.
    if (mDump1 != null && mDump2 != null) {
        mDiffContent.removeAllViews();
        SparseArray<Integer[][]> diff = MCDiffUtils.diffIndices(mDump1, mDump2);
        // order will be guaranteed).
        for (int sector = 0; sector < 40; sector++) {
            Integer[][] blocks = diff.get(sector);
            if (blocks == null) {
                // No such sector.
                continue;
            }
            // Add sector header.
            TextView header = new TextView(this);
            header.setTextAppearance(this, android.R.style.TextAppearance_Medium);
            header.setPadding(0, Common.dpToPx(20), 0, 0);
            header.setTextColor(Color.WHITE);
            header.setText(getString(R.string.text_sector) + ": " + sector);
            mDiffContent.addView(header);
            if (blocks.length == 0 || blocks.length == 1) {
                TextView tv = new TextView(this);
                if (blocks.length == 0) {
                    // Sector exists only in dump1.
                    tv.setText(getString(R.string.text_only_in_dump1));
                } else {
                    // Sector exists only in dump2.
                    tv.setText(getString(R.string.text_only_in_dump2));
                }
                mDiffContent.addView(tv);
                continue;
            }
            // Walk through all blocks.
            for (int block = 0; block < blocks.length; block++) {
                // Initialize diff entry.
                RelativeLayout rl = (RelativeLayout) getLayoutInflater().inflate(R.layout.list_item_diff_block, (ViewGroup) findViewById(android.R.id.content), false);
                TextView dump1 = (TextView) rl.findViewById(R.id.textViewDiffBlockDump1);
                TextView dump2 = (TextView) rl.findViewById(R.id.textViewDiffBlockDump2);
                TextView diffIndex = (TextView) rl.findViewById(R.id.textViewDiffBlockDiff);
                // This is a (ugly) fix for a bug in Android 5.0+
                // https://code.google.com/p/android-developer-preview
                // /issues/detail?id=110
                // (All three TextViews have the monospace typeface
                // property set via XML. But Android ignores it...)
                dump1.setTypeface(Typeface.MONOSPACE);
                dump2.setTypeface(Typeface.MONOSPACE);
                diffIndex.setTypeface(Typeface.MONOSPACE);
                StringBuilder diffString;
                diffIndex.setTextColor(Color.RED);
                // Populate the blocks of the diff entry.
                dump1.setText(mDump1.get(sector)[block]);
                dump2.setText(mDump2.get(sector)[block]);
                if (blocks[block].length == 0) {
                    // Set diff line for identical blocks.
                    diffIndex.setTextColor(Color.GREEN);
                    diffString = new StringBuilder(getString(R.string.text_identical_data));
                } else {
                    diffString = new StringBuilder("                                ");
                    // Walk through all symbols to populate the diff line.
                    for (int i : blocks[block]) {
                        diffString.setCharAt(i, 'X');
                    }
                }
                // Add diff entry.
                diffIndex.setText(diffString);
                mDiffContent.addView(rl);
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView)

Example 80 with RelativeLayout

use of android.widget.RelativeLayout in project XRichText by sendtion.

the class RichTextEditor method buildEditData.

/**
 * 对外提供的接口, 生成编辑数据上传
 */
public List<EditData> buildEditData() {
    List<EditData> dataList = new ArrayList<EditData>();
    int num = allLayout.getChildCount();
    for (int index = 0; index < num; index++) {
        View itemView = allLayout.getChildAt(index);
        EditData itemData = new EditData();
        if (itemView instanceof EditText) {
            EditText item = (EditText) itemView;
            itemData.inputStr = item.getText().toString();
        } else if (itemView instanceof RelativeLayout) {
            DataImageView item = (DataImageView) itemView.findViewById(R.id.edit_imageView);
            itemData.imagePath = item.getAbsolutePath();
        // itemData.bitmap = item.getBitmap();//去掉这个防止bitmap一直被占用,导致内存溢出
        }
        dataList.add(itemData);
    }
    return dataList;
}
Also used : EditText(android.widget.EditText) ArrayList(java.util.ArrayList) RelativeLayout(android.widget.RelativeLayout) ImageView(android.widget.ImageView) View(android.view.View) ScrollView(android.widget.ScrollView) SuppressLint(android.annotation.SuppressLint)

Aggregations

RelativeLayout (android.widget.RelativeLayout)396 TextView (android.widget.TextView)180 View (android.view.View)164 ImageView (android.widget.ImageView)109 LinearLayout (android.widget.LinearLayout)67 ViewGroup (android.view.ViewGroup)61 Intent (android.content.Intent)31 AdapterView (android.widget.AdapterView)29 Button (android.widget.Button)29 FrameLayout (android.widget.FrameLayout)28 SuppressLint (android.annotation.SuppressLint)26 LayoutInflater (android.view.LayoutInflater)22 OnClickListener (android.view.View.OnClickListener)22 ScrollView (android.widget.ScrollView)22 Paint (android.graphics.Paint)20 CardView (android.support.v7.widget.CardView)19 Context (android.content.Context)18 Point (android.graphics.Point)18 ListView (android.widget.ListView)18 RadioButton (android.widget.RadioButton)17