From b568858e89adb19482a5af4c2498352e0293f735 Mon Sep 17 00:00:00 2001 From: Pranav Nair Date: Tue, 24 May 2016 22:45:34 +0530 Subject: [PATCH 1/6] Added permission support for Android 6.0+ For all Android 6.0+ devices , dynamic permission is asked to access contacts. --- app/src/main/java/com/google/ytdl/Auth.java | 2 +- .../main/java/com/google/ytdl/Constants.java | 2 +- .../java/com/google/ytdl/MainActivity.java | 27 ++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/google/ytdl/Auth.java b/app/src/main/java/com/google/ytdl/Auth.java index c0c826e..5f5fe24 100644 --- a/app/src/main/java/com/google/ytdl/Auth.java +++ b/app/src/main/java/com/google/ytdl/Auth.java @@ -19,7 +19,7 @@ public class Auth { // Register an API key here: https://console.developers.google.com - public static final String KEY = "Replace me with your API key"; + public static final String KEY = "AIzaSyAJ6WxPuRxLoOCTxrpxx3DNm8To38z-Xyg"; public static final String[] SCOPES = {Scopes.PROFILE, YouTubeScopes.YOUTUBE}; } diff --git a/app/src/main/java/com/google/ytdl/Constants.java b/app/src/main/java/com/google/ytdl/Constants.java index 8b9ffbc..e1cbcff 100644 --- a/app/src/main/java/com/google/ytdl/Constants.java +++ b/app/src/main/java/com/google/ytdl/Constants.java @@ -24,6 +24,6 @@ public class Constants { public static final String DEFAULT_KEYWORD = "ytdl"; // A playlist ID is a string that begins with PL. You must replace this string with the correct // playlist ID for the app to work - public static final String UPLOAD_PLAYLIST = "Replace me with the playlist ID you want to upload into"; + public static final String UPLOAD_PLAYLIST = "PLUNZIK3bUsNeXDBKJ-u-ZnNgHWv8bAItN"; public static final String APP_NAME = "ytd-android"; } diff --git a/app/src/main/java/com/google/ytdl/MainActivity.java b/app/src/main/java/com/google/ytdl/MainActivity.java index 00d7cf7..0f944ba 100644 --- a/app/src/main/java/com/google/ytdl/MainActivity.java +++ b/app/src/main/java/com/google/ytdl/MainActivity.java @@ -22,13 +22,18 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.net.Uri; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import android.provider.MediaStore; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.support.v4.content.LocalBroadcastManager; import android.text.TextUtils; +import android.text.style.MetricAffectingSpan; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; @@ -41,7 +46,7 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; - +import android.Manifest; import com.android.volley.toolbox.ImageLoader; import com.google.android.gms.common.GooglePlayServicesUtil; import com.google.api.client.extensions.android.http.AndroidHttp; @@ -105,9 +110,16 @@ public class MainActivity extends Activity implements @Override protected void onCreate(Bundle savedInstanceState) { + if (Build.VERSION.SDK_INT > 22) { + // if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION != PackageManager.PERMISSION_GRANTED) {// if you want to check if permission has been given from before + final String[] permissions = new String[]{Manifest.permission.GET_ACCOUNTS}; + ActivityCompat.requestPermissions(this, permissions, 0); + //} + } getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); + mUploadsListFragment = new UploadsListFragment(getApplicationContext()); // Check to see if the proper keys and playlist IDs have been set up @@ -645,4 +657,17 @@ public void onReceive(Context context, Intent intent) { } } } + + @Override + + public void onRequestPermissionsResult(int permsRequestCode, String[] permissions, int[] grantResults) { + + switch (permsRequestCode) { + + case 200: + boolean audioAccepted = grantResults[0] == PackageManager.PERMISSION_GRANTED; + break; + + } + } } From 7224efcb0417f3cb6ede2981a804fc9605e47285 Mon Sep 17 00:00:00 2001 From: Pranav Nair Date: Tue, 24 May 2016 22:51:03 +0530 Subject: [PATCH 2/6] Update Auth.java --- app/src/main/java/com/google/ytdl/Auth.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/google/ytdl/Auth.java b/app/src/main/java/com/google/ytdl/Auth.java index 5f5fe24..59ed63f 100644 --- a/app/src/main/java/com/google/ytdl/Auth.java +++ b/app/src/main/java/com/google/ytdl/Auth.java @@ -19,7 +19,7 @@ public class Auth { // Register an API key here: https://console.developers.google.com - public static final String KEY = "AIzaSyAJ6WxPuRxLoOCTxrpxx3DNm8To38z-Xyg"; + public static final String KEY = "Enter your API key here"; public static final String[] SCOPES = {Scopes.PROFILE, YouTubeScopes.YOUTUBE}; } From 9feb1e70135f117744b9b987f3c257da282ea369 Mon Sep 17 00:00:00 2001 From: Pranav Nair Date: Tue, 24 May 2016 22:52:04 +0530 Subject: [PATCH 3/6] Update Auth.java --- app/src/main/java/com/google/ytdl/Auth.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/google/ytdl/Auth.java b/app/src/main/java/com/google/ytdl/Auth.java index 59ed63f..c0c826e 100644 --- a/app/src/main/java/com/google/ytdl/Auth.java +++ b/app/src/main/java/com/google/ytdl/Auth.java @@ -19,7 +19,7 @@ public class Auth { // Register an API key here: https://console.developers.google.com - public static final String KEY = "Enter your API key here"; + public static final String KEY = "Replace me with your API key"; public static final String[] SCOPES = {Scopes.PROFILE, YouTubeScopes.YOUTUBE}; } From 812eadcc517c80cf2387879b8f35519ec9d37790 Mon Sep 17 00:00:00 2001 From: Pranav Nair Date: Tue, 24 May 2016 22:53:22 +0530 Subject: [PATCH 4/6] Update Constants.java --- app/src/main/java/com/google/ytdl/Constants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/google/ytdl/Constants.java b/app/src/main/java/com/google/ytdl/Constants.java index e1cbcff..8b9ffbc 100644 --- a/app/src/main/java/com/google/ytdl/Constants.java +++ b/app/src/main/java/com/google/ytdl/Constants.java @@ -24,6 +24,6 @@ public class Constants { public static final String DEFAULT_KEYWORD = "ytdl"; // A playlist ID is a string that begins with PL. You must replace this string with the correct // playlist ID for the app to work - public static final String UPLOAD_PLAYLIST = "PLUNZIK3bUsNeXDBKJ-u-ZnNgHWv8bAItN"; + public static final String UPLOAD_PLAYLIST = "Replace me with the playlist ID you want to upload into"; public static final String APP_NAME = "ytd-android"; } From 17e5439a450f4fe0b926acc84f32685c3b74c7e0 Mon Sep 17 00:00:00 2001 From: Pranav Nair Date: Tue, 24 May 2016 23:08:54 +0530 Subject: [PATCH 5/6] Update MainActivity.java --- app/src/main/java/com/google/ytdl/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/google/ytdl/MainActivity.java b/app/src/main/java/com/google/ytdl/MainActivity.java index 0f944ba..2f2f788 100644 --- a/app/src/main/java/com/google/ytdl/MainActivity.java +++ b/app/src/main/java/com/google/ytdl/MainActivity.java @@ -660,7 +660,7 @@ public void onReceive(Context context, Intent intent) { @Override - public void onRequestPermissionsResult(int permsRequestCode, String[] permissions, int[] grantResults) { + public void onRequestPermissionsResult(int permsRequestCode, String[] permissions, int[] grantResults) { // here for reference , can be commented out if required switch (permsRequestCode) { From a0601c1f1a6e9b9919287fcb5058d304047d6514 Mon Sep 17 00:00:00 2001 From: Pranav Nair Date: Wed, 25 May 2016 11:33:19 +0530 Subject: [PATCH 6/6] Update MainActivity.java --- app/src/main/java/com/google/ytdl/MainActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/google/ytdl/MainActivity.java b/app/src/main/java/com/google/ytdl/MainActivity.java index 2f2f788..35c9abd 100644 --- a/app/src/main/java/com/google/ytdl/MainActivity.java +++ b/app/src/main/java/com/google/ytdl/MainActivity.java @@ -111,10 +111,10 @@ public class MainActivity extends Activity implements @Override protected void onCreate(Bundle savedInstanceState) { if (Build.VERSION.SDK_INT > 22) { - // if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION != PackageManager.PERMISSION_GRANTED) {// if you want to check if permission has been given from before + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {// if you want to check if permission has been given from before final String[] permissions = new String[]{Manifest.permission.GET_ACCOUNTS}; ActivityCompat.requestPermissions(this, permissions, 0); - //} + } } getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); @@ -658,7 +658,7 @@ public void onReceive(Context context, Intent intent) { } } - @Override + /* @Override public void onRequestPermissionsResult(int permsRequestCode, String[] permissions, int[] grantResults) { // here for reference , can be commented out if required @@ -669,5 +669,5 @@ public void onRequestPermissionsResult(int permsRequestCode, String[] permission break; } - } + }*/ }