This file contains 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 | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_alarm); | |
// Retrieve object to check for from initiating intent | |
object = getIntent().getStringExtra(MainActivity.EXTRA_MESSAGE); | |
info = findViewById(R.id.infoText); | |
} |
This file contains 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 onResume() { | |
super.onResume(); | |
// If we've taken a photo, send it off to Clarifai to check | |
if (photoPath != null) { | |
new ClarifaiTask().execute(new File(photoPath)); | |
} | |
} |
This file contains 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 | |
protected void onStart() { | |
super.onStart(); | |
// Retrieve default ringtone file URI | |
Uri myUri = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE); | |
// Set up MediaPlayer asynchronously | |
mediaPlayer = new MediaPlayer(); | |
class Listener implements MediaPlayer.OnPreparedListener { |
This file contains 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 | |
protected void onStop() { | |
super.onStop(); | |
// Release MediaPlayer | |
if (mediaPlayer != null) { | |
mediaPlayer.release(); | |
mediaPlayer = null; | |
} | |
} |
This file contains 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
public void takePicture(View view) { | |
// Create intent to open camera app | |
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
// Proceed only if there is a camera app | |
if (takePictureIntent.resolveActivity(getPackageManager()) != null) { | |
// Attempt to allocate a file to store the photo | |
File photoFile; | |
try { | |
File storageDir = getFilesDir(); |
This file contains 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
// Use Clarifai to find the image color scheme | |
function getColors(file) { | |
app.models.predict(Clarifai.COLOR_MODEL, {base64: file}).then( | |
// Response handler | |
function (response) { | |
// Get colors from response and sort by descending prevalence | |
const colors = response.outputs[0].data.colors; | |
colors.sort((a, b) => (a.value > b.value) ? -1 : ((b.value > a.value) ? 1 : 0)); | |
const holder = $('#colors'); |
This file contains 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
<!-- Include JS !--> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinycolor/1.4.1/tinycolor.min.js"></script> | |
<script src="https://sdk.clarifai.com/js/clarifai-latest.js"></script> | |
<script src="colors.js"></script> | |
<!-- Include Styles !--> | |
<link rel="stylesheet" href="style.css"> |
This file contains 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
$(document).ready(function () { | |
// Ensure body resizes appropriately | |
$('body').css('height', $(window).height()); | |
$(window).resize(function () {$('body').css('height', $(window).height());}); | |
// Connect to Clarifai | |
const app = new Clarifai.App({ | |
apiKey: 'YOUR_API_KEY' | |
}); |
This file contains 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
* { | |
box-sizing: border-box; | |
} | |
body { | |
background-size: cover; | |
background-repeat: no-repeat; | |
font-family: "Open Sans", sans-serif; | |
font-size: 14pt; |
This file contains 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
// Image upload handler | |
$('#upload').change(function () { | |
const file = this.files[0]; | |
const reader = new FileReader(); | |
reader.readAsDataURL(file); | |
reader.onload = function () { | |
$('body').css('background-image', 'url("' + reader.result + '")'); | |
$('#colors').html('<h2>Processing...</h2>'); |