Short (72 chars or less) summary
More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).
Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final int WRITE_EXTERNAL_STORAGE_REQUEST_CODE = 123 | |
pricate final String writeExternalStorageRationale = "You haven't given us permission to use Storage, please enable the permission to store images."; | |
@Override | |
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |
switch (requestCode){ | |
case WRITE_EXTERNAL_STORAGE_REQUEST_CODE: | |
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) | |
captureImage(); | |
else{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |
if (requestCode == WRITE_EXTERNAL_STORAGE_REQUEST_CODE){ | |
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) | |
captureImage(); | |
else{ | |
if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) | |
showRationaleDialog(); | |
else | |
Toast.makeText(MainActivity.this, "You need to allow permission to Write to External Storage", Toast.LENGTH_LONG).show(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) | |
=> ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE); | |
requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST_CODE); | |
=> ActivityCompat.requestPermissions(MainActivity.this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST_CODE); | |
shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE) | |
=> ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final int WRITE_EXTERNAL_STORAGE_REQUEST_CODE = 123 | |
private void takePhoto() { | |
//Make sure we have permission to write to external storage | |
int hasWriteExternalStoragePermission = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE); | |
if (hasWriteExternalStoragePermission == PackageManager.PERMISSION_GRANTED) | |
captureImage() | |
else | |
requestPermissionWriteToLocalStorage(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion 23 | |
buildToolsVersion "23.0.3" | |
defaultConfig { | |
applicationId "com.example.myapp" | |
minSdkVersion 10 | |
targetSdkVersion 23 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.example.myapp"> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> | |
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> | |
<application ...> | |
... | |
</application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chrome.extension.onMessage.addListener(function(message, sender, sendResponse) { | |
if(message.action == "toggle_playback"){ | |
play_pause_button = document.getElementsByClassName('ytp-play-button ytp-button')[0] | |
if(play_pause_button){ | |
play_pause_button.click(); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chrome.browserAction.onClicked.addListener(function(tab) { | |
chrome.tabs.query({}, function(tabs){ | |
for (var i=0; i < tabs.length; i++) { | |
if (/https?:\/\/www\.youtube\.com/.test(tabs[i].url)) { | |
chrome.tabs.sendMessage(tabs[i].id, {action: "toggle_playback"}, function(response) {}); | |
} | |
} | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 2, | |
"name": "YTPP", | |
"short_name": "YTPP", | |
"version": "0.1", | |
"description": "YTPP: YouTube Play/Pause without switching tabs", | |
"icons": {"128": "icon.png", "48": "icon_48.png", "16": "icon_16.png" }, | |
"author": {"name": "spidergears", "twitter_handle": "spider_gears", "github": "http://github.com/spidergears"}, | |
"browser_action": { "default_icon": "icon.png", "default_title": "YTPP"}, |
NewerOlder