Personal Notes App Changes For Android 1.4: Click Here
Personal Notes App Changes For Android 1.4: Click Here
Android 1.4
Introduction
Eventually I will re-create the Personal Notes app videos completely for Android
Marshmallow. For now, this document is what you need to do to get the app
working with Android Marshmallow.
Extra information
I have created a video which might be of interest to you. You can watch this, or just
follow the information in this guide (note that the videos dont contain everything
int his document, so consider the document to be the most up to date).
Here are the following items to keep in mind when you are building the app in
Android Studio 1.4
build.gradle Dependencies
In the build gradle file found in ProjecName>App in the project pane window of
Android Studio. Also make sure to set the view to Project.
Then make sure to add the following dependencies after line 26 of the build.gradle
file.
compile ('com.google.apis:google-api-services-drive:v2-
rev105-1.17.0-rc') {
exclude module: 'httpclient'
}
compile('com.google.api-client:google-api-client-
android:1.17.0-rc') {
exclude module: 'httpclient'
}
compile('com.google.http-client:google-http-client-
gson:1.17.0-rc') {
exclude module: 'httpclient'
}
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
Then click on Sync Now link on the upper right corner to start syncing the
build.gradle.
There is an alternative way to adding dependencies first you have to delete the
following line from your build.gradle.
compile 'com.android.support:appcompat-v7:23.0.1'
These are the only items that should be left on your dependencies area of your
build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.0.1'
}
Next, go to your project pane, right click on the top most folder in the labeled
PersonalNotes.
In the open module settings window, select app on the left menu. Make sure that
the latest Build Tools Version is selected, which in this current time of
documentation is 23.0.1.
Click the Dependencies tab, which is where you we will add the dependencies with
correct latest versions. First click the plus sign in the lower left, and choose Library
dependency.
A small window will pop out for searching the Library depdencies we want to add.
First seach for appcompat by typing app compat in the search field and press
enter. Wait for it to finish searching. It will then bring back a list of all the
appcompats it could find.
The one you need to choose is the most latest version for the com.android.support
which in this case is 23.0.1. So select that one and press Ok, it will then get added to
the list in the dependencies tab.
Next, we need to add dependencies for cardview and Recyclerview. So search for
those again and add them. Be careful thought because you might pick the wrong
ones, so make sure the ones you have selected have the com.android.support on it.
Next we need to add the dependency for play-services so type that into the search
box and add it. Be sure to pick the one that starts with
com.google.android.gms:play-services: and of course pick the latest version.
You should now have the following have the following dependencies added in, click
on Ok to add them.
The build.gradle file will add the dependencies and it will automatically start
syncing them. Wait for it to finish the syncing process.
One last thing , please paste these following dependencies after the line 29
dependencie.
compile ('com.google.apis:google-api-services-drive:v2-
rev105-1.17.0-rc') {
exclude module: 'httpclient'
}
compile('com.google.api-client:google-api-client-
android:1.17.0-rc') {
exclude module: 'httpclient'
}
compile('com.google.http-client:google-http-client-
gson:1.17.0-rc') {
exclude module: 'httpclient'
}
Your build.gradle contents should now look like the following below.
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.timbuchalka.personalnotes"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-
android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile ('com.google.apis:google-api-services-drive:v2-
rev105-1.17.0-rc') {
exclude module: 'httpclient'
}
compile('com.google.api-client:google-api-client-
android:1.17.0-rc') {
exclude module: 'httpclient'
}
compile('com.google.http-client:google-http-client-
gson:1.17.0-rc') {
exclude module: 'httpclient'
}
}
Example if you have a created a Blank Activity called MainActivity you need to
comment out the following lines in the MainActivity.java file. Just select the lines
below and press CMD+/ or CTRL+/ if your in a Windows. Java files are stored in the
App>Src>Main>Java>Packagename of the project.
After commenting the following lines of code the current inside of your
MainActivity.java should now look like the following below.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar)
findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action
bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action
bar will
// automatically handle clicks on the Home/Up
button, so long
// as you specify a parent activity in
AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Then you need to open up the activitys corresponding activity layout file which in
this example is activity_main.xml and comment out these lines of code. Xml layout
files are always stored in App>Src>Main>Res>layout of the project.
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email"/>
You can comment them by selecting the lines of code and press CMD+/ or CTRL+/
for windows.
This is what your activity_main.xml contents should look like after commenting.
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<!--<android.support.design.widget.AppBarLayout-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_width="match_parent"-->
<!--android:theme="@style/AppTheme.AppBarOverlay">-
->
<!--<android.support.v7.widget.Toolbar-->
<!--android:id="@+id/toolbar"-->
<!--android:layout_width="match_parent"-->
<!--
android:layout_height="?attr/actionBarSize"-->
<!--android:background="?attr/colorPrimary"-->
<!--
app:popupTheme="@style/AppTheme.PopupOverlay"/>-->
<!--</android.support.design.widget.AppBarLayout>-->
<include layout="@layout/content_main"/>
<!--
<android.support.design.widget.FloatingActionButton-->
<!--android:id="@+id/fab"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="bottom|end"-->
<!--android:layout_margin="@dimen/fab_margin"-->
<!--
android:src="@android:drawable/ic_dialog_email"/>-->
</android.support.design.widget.CoordinatorLayout>
Apply this every time you create a new Blank Activity. You must comment out
the following lines of code in both the java file and the corresponding activity
xml file of it.
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN"
/>
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Delete the line of code highlighted in red and your current AndroidManifest.xml file
should only look like this for now.
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
When editing the content_main.xml file or any content xml file. Please do not
delete the following highlighted in red.
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior
"
tools:showIn="@layout/activity_main"
tools:context=".MainActivity">
<TextView
android:text="Hello World!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior
"
tools:showIn="@layout/activity_search"
tools:context="com.timbuchalka.personalnotes.SearchActivity
">
</RelativeLayout>
}
});
}
@Override
public void
onRequestDisallowInterceptTouchEvent(boolean
disallowIntercept) {
}
}