Skip to content

Instantly share code, notes, and snippets.

🎧
Focusing

Ansh Sachdeva root-ansh

🎧
Focusing
Block or report user

Report or block root-ansh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View DecodingAndRotationCode.java
private static Bitmap getBitmapFromUri(Context context, Uri photoURI) {
// super cool decoding algorithm at https://stackoverflow.com/a/31720143/7500651
try {
int MAX_HEIGHT = 1024;
int MAX_WIDTH = 1024;
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
InputStream imageStream = context.getContentResolver().openInputStream(photoURI);
@root-ansh
root-ansh / MainActivity.java
Created Jun 3, 2019
Delegation to system ui camera
View MainActivity.java
public class MainActivity extends AppCompatActivity {
private static final int RQ_CAPTURE_IMG_CODE_HDPIC = 101;
private static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".provider";
private static final String TAG = "$1477$";
Uri tmpPhotoURI;
ImageView ivTemp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@root-ansh
root-ansh / MainActivity.java
Created Jun 3, 2019
Camera basics : delegating to system camera api
View MainActivity.java
public class MainActivity extends AppCompatActivity {
private static final int RQ_CAPTURE_IMG_CODE_THUMB = 100;
ImageView ivTemp;
@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" ...>
@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);
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
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 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
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);
...
@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>
You can’t perform that action at this time.