Skip to content

Instantly share code, notes, and snippets.

@bdiegel
bdiegel / couchbase_change_password.sh
Created February 14, 2015 23:47
Change Couchbase password
./couchbase-cli cluster-init -c 127.0.0.1:8091 --user=[CURRENT_USERNAME] --password=[CURRENT_PASSWORD] --cluster-init-username=[NEW_USERNAME] --cluster-init-password=[NEW_PASSWORD]
@bdiegel
bdiegel / android_hierarchyviewer
Created February 17, 2015 19:13
Android Hierarchy Viewer
# Hierarchy Viewer only works by default with phones running a developer version of the Android OS.
#
# 1. Phone running Jellybean or higher: add the environment variable: ANDROID_HVPROTO=ddm
# 2. You can run Hierarchy Viewer on an emulated phone.
# 3. Use the ViewServer library for pre Jellybean phone
# https://github.com/romainguy/ViewServer
# set this environment variable
$ export ANDROID_HVPROTO=ddm;
@bdiegel
bdiegel / android_toolbar_home.java
Created February 26, 2015 22:03
Android Toolbar Home Button
# To add navigation back to the main activity using the
# Toolbar (material design), we do three things:
# 1. Declare the parent activity in the AndroidManifest.xml
#
# <activity android:name=".MySubActivity" android:label="@string/title_sub_activity" >
# <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity" />
# </activity>
# 2. Configure the Toolbar in MySubActivity:
@bdiegel
bdiegel / Android_Parcelable
Created March 14, 2015 13:48
Android Parcelables with Intents
/**
* Creating and passing a Parcelable with an Intent
*/
// Creating an instance of Student class with user input data
Student student = new Student(mNameTV.getText().toString(),
Integer.parseInt(mAgeTV.getText().toString()),
mAddressTV.getText().toString(),
mCourseTV.getText().toString());
// Creating an intent to open the activity StudentViewActivity
@bdiegel
bdiegel / Android_Tools
Last active August 29, 2015 14:17
Android Tools and Resources
// Assets and Icons
http://romannurik.github.io/AndroidAssetStudio/
https://github.com/google/material-design-icons
http://developer.android.com/design/downloads/index.html
// Material Design
http://www.materialpalette.com/
http://www.google.com/design/spec/material-design/introduction.html
@bdiegel
bdiegel / android_bmgr_help
Created May 16, 2015 15:20
Android bmgr tool
// ensure backup manager is enabled (emulator)
adb shell bmgr enable true
// request a backup from manager
adb shell bmgr backup your.package.name
// force backup manager to run queued requests
adb shell bmgr run
// uninstall app
@bdiegel
bdiegel / android_color_transparency.md
Last active October 28, 2015 14:30
Android Color Transparency

Set transparent color in android

Set color to #AARRGGBB where AA is the alpha channel.

  • #00000000 - full transparency
  • #80FFFFFF - 50% white
  • #CCFFFFFF - 80% white

Alpha channel values:

100% — FF

@bdiegel
bdiegel / android_transp_statusbar.md
Created October 28, 2015 14:37
Android Transparent Status Bar Fix

Fix status bar transparency

Note the adjusting the insets is a specific workaround for views that do not respect layout settings. View Pager has such problems.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setStatusBarTransparent() {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().getDecorView().setSystemUiVisibility(
          View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);

getWindow().setStatusBarColor(Color.TRANSPARENT);

@bdiegel
bdiegel / android_searchview_style.md
Last active October 28, 2015 14:44
Android SearchView Styling

SearchView styles

Two good resources philio.me novoda

v21 example:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="searchViewStyle">@style/AppTheme.SearchView</item>
@bdiegel
bdiegel / android_maps_mylocation_button.md
Last active October 6, 2021 18:05
Android Maps v2 MyLocation Button Position

Change MyLocation button position

It's easy to enable Zoom and MyLocation buttons but annoying to change where they overlay the Map.

Options

  1. Use Map padding (are that will not overlap map controls)
  2. Disable them and implement your own (probably safer than hack below)
  3. Find the buttons by id and alter the layout params

Resources: