Skip to content

Instantly share code, notes, and snippets.

View AndroidBullOfficial's full-sized avatar

Waqas Younis AndroidBullOfficial

View GitHub Profile
// Only a user can upload their profile picture, but anyone can view it
match /users/{userId}/profilePicture.png {
allow read;
allow write: if request.auth.uid == userId;
}
// Require authentication on all internal image reads
match /internal/{imageId} {
allow read: if request.auth != null;
}
// Anyone to read a public image if the file is less than 100kB
// Anyone can upload a public file ending in '.txt'
match /public/{imageId} {
allow read: if resource.size < 100 * 1024;
allow write: if imageId.matches(".*\\.txt");
}
// Partial match for files that start with "images"
match /images {
// Exact match for "images/*"
// e.g. images/profilePhoto.png is matched
match /{imageId} {
// This rule only matches a single path segment (*)
// imageId is a string that contains the specific segment matched
allow read: if <condition>;
}
// Partial match for files that start with "images"
match /images {
// Exact match for "images/profilePhoto.png"
match /profilePhoto.png {
allow write: if <condition>;
}
// Exact match for "images/croppedProfilePhoto.png"
match /croppedProfilePhoto.png {
allow write: if <other_condition>;
// Exact match for "images/profilePhoto.png"
match /images/profilePhoto.png {
allow write: if <condition>;
}
// Exact match for "images/croppedProfilePhoto.png"
match /images/croppedProfilePhoto.png {
allow write: if <other_condition>;
}
// If no condition is specified, the rule evaluates to true
allow read;
// Rules can optionally specify a condition
allow write: if <condition>;
// Rules can also specify multiple request methods
allow read, write: if <condition>;
service firebase.storage {
match /b/{bucket}/o {
match /images/{imageId} {
// Only allow uploads of any image file that's less than 5MB
allow write: if request.resource.size < 5 * 1024 * 1024
&& request.resource.contentType.matches('image/.*');
}
}
}
package com.example.demodemo;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
//put these in the beginning of the MainActivity class
CallbackManager callbackManager;
LoginButton loginButton;