Skip to content

Commit

Permalink
Support for Kitkat (API 19)
Browse files Browse the repository at this point in the history
Material Theme changed to AppCompat Theme
Custom Toolbar used as ActionBar instead of Default one
Code cleaned
  • Loading branch information
amanmehara committed Dec 22, 2015
1 parent 42c78b9 commit 0c48666
Show file tree
Hide file tree
Showing 21 changed files with 247 additions and 198 deletions.
11 changes: 6 additions & 5 deletions android/android.iml
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="recyclerview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
</component>
</module>
13 changes: 7 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ repositories {
}

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.amanmehara.programming.android"
minSdkVersion 21
targetSdkVersion 22
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
Expand All @@ -33,7 +33,8 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.amanmehara.programming.android;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
Expand All @@ -14,9 +14,7 @@
import org.json.JSONObject;


public class DetailActivity extends Activity {

private Context context;
public class DetailActivity extends AppCompatActivity {

private RecyclerView detailRecyclerView;
private RecyclerView.Adapter detailAdapter;
Expand All @@ -31,9 +29,12 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);

bundle = getIntent().getExtras();
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);

getActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

bundle = getIntent().getExtras();

programDetails = null;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.amanmehara.programming.android;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -18,7 +19,7 @@
import java.util.concurrent.ExecutionException;


public class LanguageActivity extends Activity implements LanguageAdapter.ListClickListener {
public class LanguageActivity extends AppCompatActivity implements LanguageAdapter.ListClickListener {

private Context context;

Expand All @@ -33,6 +34,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_language);

Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

languageRecyclerView = (RecyclerView) findViewById(R.id.language_recycler_view);
languageRecyclerView.setHasFixedSize(true);

Expand Down Expand Up @@ -69,7 +75,6 @@ protected void onCreate(Bundle savedInstanceState) {
languageAdapter = new LanguageAdapter(languages);
((LanguageAdapter) languageAdapter).setListClickListener(this);

//languageAdapter = new LanguageAdapter(new String[]{hello, "Hello","Bye", "Aman", "Today", "Hi", String.valueOf(new WebServiceClient().execute("http://programmingwebapp.azurewebsites.net/api/languages"))});
languageRecyclerView.setAdapter(languageAdapter);
} else {

Expand Down Expand Up @@ -141,7 +146,5 @@ public void listItemClicked(View view, int position) {

startActivity(intent);
}


}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package com.amanmehara.programming.android;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;


public class MainActivity extends Activity {

private Context context;
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.amanmehara.programming.android;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;


public class NoConnectionActivity extends Activity {
public class NoConnectionActivity extends AppCompatActivity {

private Context context;
private Bundle bundle;
Expand All @@ -22,6 +23,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_no_connection);

Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

bundle = getIntent().getExtras();
activitiesAsEnum = (ActivitiesAsEnum) bundle.getSerializable("activityInfo");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.amanmehara.programming.android;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -18,7 +19,7 @@
import java.util.concurrent.ExecutionException;


public class ProgramsActivity extends Activity implements ProgramsAdapter.ListClickListener {
public class ProgramsActivity extends AppCompatActivity implements ProgramsAdapter.ListClickListener {

private Context context;
private Bundle bundle;
Expand All @@ -34,6 +35,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_programs);

Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

bundle = getIntent().getExtras();
String language = bundle.getString("language");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
Expand All @@ -18,15 +17,12 @@ public class WebServiceClient extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
//super.onPreExecute();


}

@Override
protected String doInBackground(String... params) {

String responseEntity = null;
InputStream inputStream;
try {
URL url = new URL(params[0]);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
Expand Down
54 changes: 31 additions & 23 deletions android/src/main/res/layout/activity_detail.xml
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.amanmehara.programming.android.DetailActivity"
android:orientation="vertical">

<include android:id="@+id/my_toolbar"
layout="@layout/my_toolbar"/>

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
card_view:cardCornerRadius="4dp">
<TextView android:id="@+id/program_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="@color/primary_text"
android:padding="16dp"/>
</android.support.v7.widget.CardView>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="16dp"
android:paddingBottom="16dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
card_view:cardCornerRadius="4dp">
<TextView android:id="@+id/program_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="@color/primary_text"
android:padding="16dp"/>
</android.support.v7.widget.CardView>

<android.support.v7.widget.RecyclerView
android:id="@+id/files_recycler_view"
android:scrollbars="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/files_recycler_view"
android:scrollbars="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</LinearLayout>
22 changes: 13 additions & 9 deletions android/src/main/res/layout/activity_language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.amanmehara.programming.android.LanguageActivity">

<android.support.v7.widget.RecyclerView
android:id="@+id/language_recycler_view"
android:scrollbars="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<include android:id="@+id/my_toolbar"
layout="@layout/my_toolbar"/>

<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/language_recycler_view"
android:scrollbars="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
Loading

0 comments on commit 0c48666

Please sign in to comment.