<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sampath Narayanan</title>
    <description>The latest articles on DEV Community by Sampath Narayanan (@narayanansampath).</description>
    <link>https://dev.to/narayanansampath</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F298271%2F50836706-ed2b-424a-a962-67eabe808798.jpeg</url>
      <title>DEV Community: Sampath Narayanan</title>
      <link>https://dev.to/narayanansampath</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/narayanansampath"/>
    <language>en</language>
    <item>
      <title>Publish Android Library Artifacts to  private Amazon S3 Maven repository</title>
      <dc:creator>Sampath Narayanan</dc:creator>
      <pubDate>Mon, 04 Jan 2021 09:16:59 +0000</pubDate>
      <link>https://dev.to/narayanansampath/publish-android-library-artifacts-to-private-amazon-s3-maven-repository-546f</link>
      <guid>https://dev.to/narayanansampath/publish-android-library-artifacts-to-private-amazon-s3-maven-repository-546f</guid>
      <description>&lt;p&gt;Publishing an android library benefits an organization or community in a lot of ways. This post is more behind the scenes on how-to publish library artifacts to a private amazon s3 bucket. So without further ado let's jump right into it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;In this post we'll be focusing on publishing library artifacts to amazon s3 bucket so as a prerequisite I assume that we already have an android library ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up a private Amazon S3 Maven repository
&lt;/h2&gt;

&lt;p&gt;Let's start with setting up a private amazon s3 bucket. Head over to &lt;a href="https://console.aws.amazon.com/s3"&gt;amazon s3 console&lt;/a&gt; and select s3 from services tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eujd9SOj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5t8z4uftmirs9p0mtppw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eujd9SOj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5t8z4uftmirs9p0mtppw.png" alt="Screenshot 2021-01-04 at 3.38.25 AM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then select create bucket and follow the instructions, remember the bucket name needs to be unique so we can use something like our library package name like com.organization.library. &lt;br&gt;
Now our bucket is ready and we can use it to serve dependencies.&lt;/p&gt;
&lt;h2&gt;
  
  
  Gradle script to upload artifacts
&lt;/h2&gt;

&lt;p&gt;Create a file called &lt;code&gt;gradle/gradle-library-push.gradle&lt;/code&gt; which will be used to push our artifacts to s3 bucket with gradle-maven plugin when using &lt;code&gt;./gradlew publish&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

// update these next lines to fit your specification
group = 'com.android.library'
version = '1.0'

// Add sources as an artifact
task sourceJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier "source"
}

// Loop over all variants
android.libraryVariants.all { variant -&amp;gt;
    variant.outputs.all { output -&amp;gt;
        // This creates a publication for each variant
        publishing.publications.create(variant.name, MavenPublication) {
            // The sources artifact from earlier
            artifact sourceJar

            // Variant dependent artifact, e.g. release, debug
            artifact source: output.outputFile, classifier: output.name

            // Go through all the dependencies for each variant and add them to the POM
            // file as dependencies
            pom.withXml {
                def dependencies = asNode().appendNode('dependencies')

                // Filter out anything that's not an external dependency. You shouldn't
                // be publishing artifacts that depend on local (e.g. project) dependencies,
                // but who knows...
                configurations.getByName(variant.name + "CompileClasspath").allDependencies
                        .findAll { it instanceof ExternalDependency }
                        .each {
                            def dependency = dependencies.appendNode('dependency')

                            dependency.appendNode('groupId', it.group)
                            dependency.appendNode('artifactId', it.name)
                            dependency.appendNode('version', it.version)
                        }
            }
        }
    }
}

// Ensure that the publish task depends on assembly
tasks.all { task -&amp;gt;
    if (task instanceof AbstractPublishToMaven) {
        task.dependsOn assemble
    }
}

// Configure the destination repository with
// S3 URL and access credentials
publishing {
    repositories {
        maven {
            //aws bucket link
            url "YOUR_S3_BUCKET_URL"
            //aws credentials
            credentials(AwsCredentials) {
                accessKey "YOUR_ACCESS_KEY"
                secretKey "YOUR_SECRET_KEY"
            }
        }
    }
}

// Top-level build file where you can add configuration
options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = '1.4.10'
    repositories {
        google()
        jcenter()
        maven {
            url = uri("https://plugins.gradle.org/m2/")
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we will include it in our library's build.gradle file.&lt;br&gt;
&lt;code&gt;apply from: rootProject.file('gradle/gradle-library-push.gradle')&lt;/code&gt;&lt;br&gt;
Now that we have our gradle script and amazon bucket ready, let's get ready for action. Execute the following command from terminal &lt;code&gt;./gradlew library:publish&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Using new dependency in projects.
&lt;/h2&gt;

&lt;p&gt;Include the following in your root build.gradle file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "YOUR_S3_BUCKET_URL"
            credentials(AwsCredentials) {
                accessKey "YOUR-ACCESS-KEY"
                secretKey "YOUR-SECRET-KEY"
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/codepath/android_guides/wiki/Building-your-own-Android-library#setting-up-a-private-amazon-s3-maven-repository"&gt;https://github.com/codepath/android_guides/wiki/Building-your-own-Android-library#setting-up-a-private-amazon-s3-maven-repository&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/@porten/publishing-android-library-artifacts-to-amazon-s3-buckets-8db4231e844f"&gt;https://medium.com/@porten/publishing-android-library-artifacts-to-amazon-s3-buckets-8db4231e844f&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>android</category>
      <category>aws</category>
      <category>gradle</category>
    </item>
    <item>
      <title>The Social Dilemma! Why we really need to talk about it</title>
      <dc:creator>Sampath Narayanan</dc:creator>
      <pubDate>Mon, 05 Oct 2020 04:19:15 +0000</pubDate>
      <link>https://dev.to/narayanansampath/the-social-dilemma-why-we-really-need-to-talk-about-it-1nl1</link>
      <guid>https://dev.to/narayanansampath/the-social-dilemma-why-we-really-need-to-talk-about-it-1nl1</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KA2Ukpwe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ko7xwsyhcrktdw0ng74x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KA2Ukpwe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ko7xwsyhcrktdw0ng74x.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recently Netflix released a movie named "The Social Dilemma" which made many heads turn and left the audience with a thoughtful question. I usually don't consume much content on the internet apart from learning resources for my projects but many of my friends were insisting on watching this movie and I started hearing about it almost everywhere and when I watched the movie, it almost had everything I wanted to know. More specifically, the film can be brought down to the context as "When you are not paying for the product, you are the product!". &lt;/p&gt;

&lt;p&gt;Apps like Facebook, Whatsapp, Snapchat, Instagram elevate the same neural activities as a drug addiction. The system is so complex that when you actually see it it's hard to believe that all your actions are actually predictable with the data you provide to these so called social media. When we say we should care more about our privacy and have control over our data not many people get the real idea of what is at stake. I've heard numerous times from my friends and family when I talk about data protection and privacy concerns. They simply say "I'm not a celebrity or I have nothing to hide, what can they possibly do with my data?". Well, they certainly can do a lot with your data like predicting your every single move like a robot. Humans are not predictable subjects but these well developed algorithms and apps say a different side of story. &lt;/p&gt;

&lt;p&gt;All the material inventions before the birth of social media needed some kind of human interest and involvement to execute appropriate tasks but the SMART devices play a different game, they call you all the time with some beeps or flashing lights. Maybe it all happened when we tried making machines smarter and ended up being dumber. If you have ever misplaced your phone, you may have experienced a subtle panic attack. This shows how significant smartphones have become in our life style. About 73% of people accept this unique flavour of anxiety. We have become so intimately entwined with the digital life that sometimes we feel the phones vibrating in our pockets even when they are not present. Before the age of digital life we had a social structure we thrived on tend to contain 150 individuals but today we carry 2 billion connections in our pockets everyday. &lt;/p&gt;

&lt;h1&gt;
  
  
  What exactly can they do with my data?
&lt;/h1&gt;

&lt;p&gt;Let's start with why your data in the first place. From times when we had barter system the transaction was based on some value. You share something with the interested party in return for something else and that's it, the transaction is over but it's not the same with social media business model. You consume some content and they wait till the right time to show you an ad with complex calculations on the possibility of you clicking the advertisement. You don't pay anything right away nor do they charge you anything but there is a catch they'll make you do what they want you to do and most of the times their prediction works and it's just getting better at it everyday. Let's say you are casually checking out a cloth wear in some mall, the system has become so advanced that you mobile so much information every minuscule of second you spend there. Following information can be easily retrieved from your device even if the screen is locked:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GPS (location based data)&lt;/li&gt;
&lt;li&gt;Bluetooth signals&lt;/li&gt;
&lt;li&gt;Wifi signals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a company called &lt;a href="https://cosmose.co/"&gt;cosmose&lt;/a&gt; which tracks footprints on offline stores via your smartphone and displays ads based on your data. I recommend watching a quick video about how it works. &lt;a href="https://www.youtube.com/watch?v=oLedMqa_uGo"&gt;How this company tracks your movements?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is just a simple example of what can be done with your data but there are many other events including political elections and spreading misinformation on the internet which can cause absolute havoc in this world. I do not want to get into detail about every horrendous event that happened because of misinformation but it is very easy to spread fake news in this digital age.&lt;/p&gt;

&lt;h1&gt;
  
  
  What's the solution?
&lt;/h1&gt;

&lt;p&gt;Social media is not going away anytime soon but it's up to us as users to decide what has to be done. Try the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Question yourself "is it really worth my time?", "is it benefitting me in some way?", "am I learning something?"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Turn down the notifications, don't let the smartphone control you. Turn of notifications of apps like whatsapp, facebook, instagram, snapchat, youtube etc. If there is something important that needs to be addressed prefer a traditional method like sms or call.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use widgets like digital wellbeing and track your daily time spent on these apps.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Draw a line! make a schedule to include non-digital activity during the day and keep your mobile far far away from your bed at night.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Be conscious when you use your device, don't scroll through meaningless memes and images on the internet. Take a moment and understand the purpose of your session with the device.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get busy, if you find yourself spending lot of time on your phone but you got nothing to do when you are away from it maybe it's time you write that story you always wanted to write about or the discussion you wanted to have with your family or friend who is actually present with you.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are not the only options, there are lot more available and many research are being done about this. Head over to &lt;a href="https://datadetoxkit.org/en/families/screentime/"&gt;The Detox Kit&lt;/a&gt; to learn more. Unfortunately the amount of money and minds spent on fixing this dilemma is only a fraction of features planned to increase user engagement but with our conscious choice and awareness we can overcome this.&lt;/p&gt;

&lt;p&gt;Checkout the movie here: &lt;a href="https://www.netflix.com/title/81254224"&gt;The Social Dilemma&lt;/a&gt;&lt;/p&gt;

</description>
      <category>socialmedia</category>
      <category>socialdilemma</category>
      <category>awareness</category>
      <category>information</category>
    </item>
    <item>
      <title>Design flutter app for different screen sizes using MediaQuery</title>
      <dc:creator>Sampath Narayanan</dc:creator>
      <pubDate>Wed, 30 Sep 2020 04:19:14 +0000</pubDate>
      <link>https://dev.to/narayanansampath/design-flutter-app-for-different-screen-sizes-using-mediaquery-23kg</link>
      <guid>https://dev.to/narayanansampath/design-flutter-app-for-different-screen-sizes-using-mediaquery-23kg</guid>
      <description>&lt;p&gt;So recently I have been working with flutter and I still can't believe how powerful and efficient this framework is. Kudos to flutter team for providing a great documentation and amazing support.&lt;br&gt;
Let's dive right into the topic now!&lt;br&gt;
When I was designing an app I came across a situation where I had to make the app look same on different screen sizes and I'm pretty sure all the app developers want their application to look fantastic in devices with different screen sizes. Fortunately, flutter provides amazing widgets to achieve this result without much effort. &lt;/p&gt;

&lt;p&gt;# MediaQuery&lt;br&gt;
MediaQuery is a great widget to make your app responsive across devices with different screen sizes. Let's get our hands dirty with some code!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Container(
  width: MediaQuery.of(context).size.width,
  color: Colors.blue,
  child: Text('I cover the whole width of the screen!')
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code block will give us something like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyg7nri1el8iz1omf1qs1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyg7nri1el8iz1omf1qs1.png" alt="Screenshot 2020-09-29 at 23.40.26"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's understand the code now. We have a container with a text widget as a child and we set the width of container as&lt;br&gt;
&lt;code&gt;MediaQuery.of(context).size.width&lt;/code&gt;&lt;br&gt;
this line makes the widget cover the whole width of the screen from end to end but what if we don't want our widget to cover only half of the screen's width or some percentage of if, well that's pretty easy too!&lt;br&gt;
We just use some math to achieve this (don't worry it's not complex)&lt;br&gt;
&lt;code&gt;MediaQuery.of(context).size.width / 2&lt;/code&gt;&lt;br&gt;
or&lt;br&gt;
&lt;code&gt;MediaQuery.of(context).size.width / 0.30&lt;/code&gt;&lt;br&gt;
the above line will use 30% of the screen's width, pretty easy right? &lt;br&gt;
Let's look at the height now, well it is same as width but one thing to consider here is the height includes everything from appbar to bottom of the screen so if you need to consider the whole screen height to decide the placement of your widget.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Container(
  width: MediaQuery.of(context).size.height,
  color: Colors.red,
  child: Center(
           child: Text('I cover the whole width of the screen!')
         )
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdmspfsrq2me9kayg6jq3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdmspfsrq2me9kayg6jq3.png" alt="Screenshot 2020-09-29 at 23.50.54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's see some real use cases using MediaQuery. We are going to design a button which has a width matching the screen size with some padding.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Container(
            width: MediaQuery.of(context).size.width,
            padding: EdgeInsets.symmetric(horizontal: 16),
            child: RaisedButton(
                child: Text("I'm a responsive button!",
                    style: Theme.of(context).textTheme.headline5,
                    textAlign: TextAlign.center)),
          ),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4d99ola5rjz4zkm76axf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4d99ola5rjz4zkm76axf.png" alt="Screenshot 2020-09-30 at 00.01.04"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Complete example with code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: MyWidget(),
    ),
  );
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: &amp;lt;Widget&amp;gt;[
              Container(
            width: MediaQuery.of(context).size.width,
            height: MediaQuery.of(context).size.height * 0.30,
            color: Colors.blue,
            child: Center(child:  Text("I cover 30% of the screen height and 100% of screen width!",
                    style: Theme.of(context).textTheme.headline5,
                    textAlign: TextAlign.center)),
          ),
          Container(
            width: MediaQuery.of(context).size.width,
            padding: EdgeInsets.symmetric(horizontal: 16),
            child: RaisedButton(
                child: Text("I'm a responsive button!",
                    style: Theme.of(context).textTheme.headline5,
                    textAlign: TextAlign.center)),
          ),
        ]));
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvqq3gvqw1s9nj2txlnt7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvqq3gvqw1s9nj2txlnt7.png" alt="Screenshot 2020-09-30 at 00.09.14"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can checkout the live example at codepen here:&lt;br&gt;
&lt;a href="https://codepen.io/sampath98/pen/LYNoepV" rel="noopener noreferrer"&gt;Codepen workspace&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading and like this article if you found it helpful!&lt;br&gt;
Feel free to reach out to me through any of the following mediums.&lt;br&gt;
&lt;a href="mailto:sampathnarayanan72@gmail.com"&gt;sampathnarayanan72@gmail.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/narayanan-sampath/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/narayanansampath" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy HacktoberFest :)&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>mobile</category>
      <category>ui</category>
      <category>ux</category>
    </item>
  </channel>
</rss>
