Skip to content

Commit c239203

Browse files
committed
Adding Compatibility for Android Jelly Bean and above (SDK 16)
Warning, I've only been able to test with the emulator for Jelly Bean, so cannot guarentee that it's bug free on real hardware. Signed-off-by: James Sutton <james.sutton@uk.ibm.com>
1 parent a4f4cd8 commit c239203

10 files changed

Lines changed: 13 additions & 20 deletions

File tree

org.eclipse.paho.android.service/org.eclipse.paho.android.sample/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010

1111
defaultConfig {
1212
applicationId "org.eclipse.paho.android.sample"
13-
minSdkVersion 22
13+
minSdkVersion 16
1414
targetSdkVersion 22
1515
versionCode 1
1616
versionName "0.1"

org.eclipse.paho.android.service/org.eclipse.paho.android.sample/src/main/java/org/eclipse/paho/android/sample/activity/HelpFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
9393
.getConnections();
9494
if(!connections.isEmpty()){
9595
Map.Entry<String, Connection> entry = connections.entrySet().iterator().next();
96-
Connection connection = (Connection) entry.getValue();
96+
Connection connection = entry.getValue();
9797
connection.getClient().setTraceEnabled(isChecked);
9898
if(isChecked){
9999
connection.getClient().setTraceCallback(new MqttTraceCallback());

org.eclipse.paho.android.service/org.eclipse.paho.android.sample/src/main/java/org/eclipse/paho/android/sample/activity/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private void displayDeleteView(int position){
138138
fragment.setArguments(bundle);
139139
Map<String, Connection> connections = Connections.getInstance(this)
140140
.getConnections();
141-
Connection connection = (Connection) connections.get(connectionMap.get(position));
141+
Connection connection = connections.get(connectionMap.get(position));
142142
String title = connection.getId();
143143
displayFragment(fragment, "");
144144
}
@@ -155,7 +155,7 @@ private void displayView(int position){
155155
fragment.setArguments(bundle);
156156
Map<String, Connection> connections = Connections.getInstance(this)
157157
.getConnections();
158-
Connection connection = (Connection) connections.get(connectionMap.get(position));
158+
Connection connection = connections.get(connectionMap.get(position));
159159
String title = connection.getId();
160160
displayFragment(fragment, title);
161161
}

org.eclipse.paho.android.service/org.eclipse.paho.android.sample/src/main/java/org/eclipse/paho/android/sample/activity/SubscriptionFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import android.content.DialogInterface;
66
import android.os.Bundle;
77
import android.support.v4.app.Fragment;
8+
import android.support.v7.app.ActionBarActivity;
89
import android.support.v7.app.AlertDialog;
10+
import android.support.v7.app.AppCompatActivity;
911
import android.view.LayoutInflater;
1012
import android.view.View;
1113
import android.view.ViewGroup;
@@ -108,7 +110,7 @@ public void onNothingSelected(AdapterView<?> parent) {
108110
}
109111
});
110112

111-
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this.getActivity());
113+
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext());
112114
alertDialogBuilder.setView(promptView);
113115
alertDialogBuilder.setCancelable(true).setPositiveButton("OK", new DialogInterface.OnClickListener() {
114116
public void onClick(DialogInterface dialog, int id) {

org.eclipse.paho.android.service/org.eclipse.paho.android.sample/src/main/java/org/eclipse/paho/android/sample/adapter/NavigationDrawerAdapter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.graphics.ColorFilter;
77
import android.graphics.drawable.Drawable;
88
import android.media.Image;
9+
import android.support.v4.content.ContextCompat;
910
import android.support.v7.widget.RecyclerView;
1011
import android.view.LayoutInflater;
1112
import android.view.View;
@@ -35,8 +36,8 @@ public void delete(int position) {
3536
}
3637

3738
private void setConnected(ImageView image){
38-
Drawable doneCloud = context.getDrawable(R.drawable.ic_cloud_done_dark);
39-
Drawable offCloud = context.getDrawable(R.drawable.ic_cloud_off_dark);
39+
Drawable doneCloud = ContextCompat.getDrawable(context, R.drawable.ic_cloud_done_dark);
40+
Drawable offCloud = ContextCompat.getDrawable(context, R.drawable.ic_cloud_off_dark);
4041
image.setImageDrawable(doneCloud);
4142
}
4243

@@ -51,8 +52,8 @@ public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
5152
public void onBindViewHolder(MyViewHolder holder, int position) {
5253
NavDrawerItem current = data.get(position);
5354
holder.title.setText(current.getTitle());
54-
Drawable doneCloud = context.getDrawable(R.drawable.ic_cloud_done_dark);
55-
Drawable offCloud = context.getDrawable(R.drawable.ic_cloud_off_dark);
55+
Drawable doneCloud = ContextCompat.getDrawable(context, R.drawable.ic_cloud_done_dark);
56+
Drawable offCloud = ContextCompat.getDrawable(context, R.drawable.ic_cloud_off_dark);
5657
holder.icon.setImageDrawable(doneCloud);
5758
}
5859

org.eclipse.paho.android.service/org.eclipse.paho.android.sample/src/main/res/layout/activity_add_connection.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:app="http://schemas.android.com/apk/res-auto"
32
xmlns:paho="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools"
53
android:id="@+id/drawer_layout"
64
android:layout_width="match_parent"
75
android:layout_height="match_parent">

org.eclipse.paho.android.service/org.eclipse.paho.android.sample/src/main/res/layout/fragment_edit_connection.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:paho="http://schemas.android.com/apk/res-auto"
32
xmlns:tools="http://schemas.android.com/tools"
43
android:layout_width="match_parent"
54
android:layout_height="match_parent"

org.eclipse.paho.android.service/org.eclipse.paho.android.sample/src/main/res/layout/fragment_manage.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
xmlns:tools="http://schemas.android.com/tools"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
5-
xmlns:paho="http://schemas.android.com/apk/res-auto"
65
android:orientation="vertical"
76
tools:context="org.eclipse.paho.android.sample.activity.MessagesFragment">
87

org.eclipse.paho.android.service/org.eclipse.paho.android.sample/src/main/res/layout/fragment_publish.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
xmlns:tools="http://schemas.android.com/tools"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
5-
xmlns:paho="http://schemas.android.com/apk/res-auto"
65
android:orientation="vertical"
76
tools:context="org.eclipse.paho.android.sample.activity.MessagesFragment"
87
android:layout_marginTop="56dp">
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
<menu xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
1+
<menu xmlns:tools="http://schemas.android.com/tools"
42
tools:context=".MainActivity">
5-
6-
7-
83
</menu>
94

0 commit comments

Comments
 (0)