Skip to content

Instantly share code, notes, and snippets.

🌟
Focusing

Ansh Sachdeva root-ansh

🌟
Focusing
View GitHub Profile
@root-ansh
root-ansh / LoginActivity.java
Created Nov 25, 2017 — forked from cutiko/LoginActivity.java
How to customize firebase-ui-auth for Android
View LoginActivity.java
public class LoginActivity extends AppCompatActivity {
private static final int RC_SIGN_IN = 343;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@root-ansh
root-ansh / ToolbarAlphaScrollBehavior
Created Apr 14, 2018 — forked from NikolaDespotoski/ToolbarAlphaScrollBehavior.java
Toggle Toolbar background alpha and alpha of its title view.
View ToolbarAlphaScrollBehavior
public class ToolbarAlphaScrollBehavior extends CoordinatorLayout.Behavior<android.support.v7.widget.Toolbar> {
private ColorDrawable mStatusBarColorDrawable;
private int mStatusBarColor;
private TextView mTitleView;
private boolean searchedForTitleView = false;
public ToolbarAlphaScrollBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
mStatusBarColor = ContextCompat.getColor(context, R.color.primary_dark);
mStatusBarColor = getColorWithAlpha(0, mStatusBarColor);
View NougatNotifications.java
class NougatNotifications {
/*===============================================================================================*
*========================================== STEP 1 =============================================*
* Bundled notification only works on Android N (API level 24) and above.
* So, you may want to check the platform version everywhere.
*===============================================================================================*/
void step1() {
boolean isBundledNotification = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
@root-ansh
root-ansh / AllStyles.xml
Created Jul 1, 2018
Default generated files for the navigation drawer
View AllStyles.xml
<!-- styles.xml -->
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
@root-ansh
root-ansh / MainActivity.java
Last active Jul 1, 2018
CustomizingNavigationDrawer1
View MainActivity.java
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
...
View MainActivity.java
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
...
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
final LinearLayout holder=findViewById(R.id.holder);
@root-ansh
root-ansh / MainActivity.java
Last active Jul 1, 2018
CustomNavDrawer 1.4 hack
View MainActivity.java
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
View app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
...
>
<com.google.android.material.appbar.AppBarLayout
...
>
@root-ansh
root-ansh / MainActivity.java
Created Jun 2, 2019
Camera basics:Delegating to system cam
View MainActivity.java
public class MainActivity extends AppCompatActivity {
ImageView ivTemp;
Button btCallCameraThumbnail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ivTemp = findViewById(R.id.iv_tmpcheck);
@root-ansh
root-ansh / manifest.xml
Created Jun 2, 2019
Camera basics : delegating to system camera api
View manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="z.y.x.camera">
<uses-feature
android:name="android.hardware.camera.any"
android:required="true" />
...
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher" ...>
You can’t perform that action at this time.