Skip to content

Commit 1850140

Browse files
committed
Update all API to be compatible with Android 11 and build with latest stable version
1 parent 7ff75d8 commit 1850140

25 files changed

+384
-155
lines changed

BeRoadsProject/.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# built application files
2+
*.apk
3+
*.ap_
4+
5+
# files for the dex VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
11+
# generated files
12+
bin/
13+
gen/
14+
15+
# Local configuration file (sdk path, etc)
16+
local.properties
17+
18+
# Android Studio
19+
.idea/
20+
.gradle
21+
/*/local.properties
22+
/*/out
23+
/*/*/build
24+
/*/*/production
25+
*.iml
26+
*.iws
27+
*.ipr
28+
*~
29+
*.swp

BeRoadsProject/BeRoads/build.gradle

+88-20
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,56 @@
1-
buildscript {
2-
repositories {
3-
mavenCentral()
4-
}
5-
dependencies {
6-
classpath 'com.android.tools.build:gradle:0.9.+'
7-
}
8-
}
1+
/**
2+
* The first line in the build configuration applies the Android plugin for
3+
* Gradle to this build and makes the android block available to specify
4+
* Android-specific build options.
5+
*/
96

7+
apply plugin: 'com.android.application'
8+
apply plugin: 'com.google.gms.google-services'
109

11-
repositories {
12-
mavenCentral()
13-
}
14-
15-
apply plugin: 'android'
10+
/**
11+
* The dependencies block in the module-level build configuration file
12+
* specifies dependencies required to build only the module itself.
13+
* To learn more, go to Add build dependencies.
14+
*/
1615

1716
dependencies {
18-
compile 'com.google.code.gson:gson:2.2.4'
19-
compile 'com.squareup.picasso:picasso:2.1.1'
20-
compile 'com.android.support:support-v4:13.0.0', 'com.google.android.gms:play-services:3.1.36'
17+
implementation platform('com.google.firebase:firebase-bom:28.3.0')
18+
implementation 'com.google.firebase:firebase-messaging'
19+
implementation 'com.google.firebase:firebase-analytics'
20+
21+
implementation 'com.google.code.gson:gson:2.8.7'
22+
implementation 'com.squareup.picasso:picasso:2.1.1'
23+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
24+
implementation 'com.google.android.gms:play-services-location:18.0.0'
25+
implementation 'com.google.android.gms:play-services-maps:17.0.1'
26+
27+
//implementation project(":lib")
28+
implementation 'androidx.appcompat:appcompat:1.3.1'
29+
implementation fileTree(dir: 'libs', include: ['*.jar'])
30+
implementation 'com.google.android.material:material:1.3.0'
2131
}
2232

2333
android {
24-
compileSdkVersion 18
25-
buildToolsVersion "19.0.3"
34+
35+
useLibrary 'org.apache.http.legacy'
36+
37+
/**
38+
* compileSdkVersion specifies the Android API level Gradle should use to
39+
* compile your app. This means your app can use the API features included in
40+
* this API level and lower.
41+
*/
42+
43+
compileSdkVersion 30
44+
/**
45+
* buildToolsVersion specifies the version of the SDK build tools, command-line
46+
* utilities, and compiler that Gradle should use to build your app. You need to
47+
* download the build tools using the SDK Manager.
48+
*
49+
* This property is optional because the plugin uses a recommended version of
50+
* the build tools by default.
51+
*/
52+
53+
buildToolsVersion "30.0.2"
2654

2755
signingConfigs {
2856
debug {
@@ -32,7 +60,47 @@ android {
3260
}
3361

3462
defaultConfig {
35-
minSdkVersion 14
36-
targetSdkVersion 18
63+
64+
/**
65+
* applicationId uniquely identifies the package for publishing.
66+
* However, your source code should still reference the package name
67+
* defined by the package attribute in the main/AndroidManifest.xml file.
68+
*/
69+
70+
applicationId 'com.beroads.beroads'
71+
72+
// Defines the minimum API level required to run the app.
73+
minSdkVersion 16
74+
75+
// Specifies the API level used to test the app.
76+
targetSdkVersion 30
77+
78+
// Defines the version number of your app.
79+
versionCode 1
80+
81+
// Defines a user-friendly version name for your app.
82+
versionName "1.0"
83+
}
84+
85+
/**
86+
* The buildTypes block is where you can configure multiple build types.
87+
* By default, the build system defines two build types: debug and release. The
88+
* debug build type is not explicitly shown in the default build configuration,
89+
* but it includes debugging tools and is signed with the debug key. The release
90+
* build type applies Proguard settings and is not signed by default.
91+
*/
92+
93+
buildTypes {
94+
95+
/**
96+
* By default, Android Studio configures the release build type to enable code
97+
* shrinking, using minifyEnabled, and specifies the default Proguard rules file.
98+
*/
99+
100+
release {
101+
minifyEnabled true // Enables code shrinking for the release build type.
102+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
103+
}
37104
}
105+
38106
}
-186 KB
Binary file not shown.

BeRoadsProject/BeRoads/src/main/AndroidManifest.xml

+11-16
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
android:versionName="3.03B1">
66

77
<uses-sdk
8-
android:minSdkVersion="14"
9-
android:targetSdkVersion="18"/>
8+
android:minSdkVersion="16"
9+
android:targetSdkVersion="30"/>
1010

1111
<uses-permission android:name="android.permission.INTERNET"/>
1212
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
@@ -18,11 +18,6 @@
1818
android:protectionLevel="signature"/>
1919
<uses-permission android:name="com.profete162.WebcamWallonnes.permission.MAPS_RECEIVE"/>
2020
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
21-
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
22-
23-
<permission android:name="com.profete162.WebcamWallonnes.permission.C2D_MESSAGE"
24-
android:protectionLevel="signature" />
25-
<uses-permission android:name="com.profete162.WebcamWallonnes.permission.C2D_MESSAGE" />
2621

2722
<uses-feature
2823
android:glEsVersion="0x00020000"
@@ -48,19 +43,19 @@
4843
android:name=".NotifConfigActivity"
4944
android:label="@string/app_name">
5045
</activity>
51-
<receiver
52-
android:name=".MyBroadcastReceiver"
53-
android:permission="com.google.android.c2dm.permission.SEND" >
54-
<intent-filter>
55-
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
56-
<category android:name="com.profete162.WebcamWallonnes" />
57-
</intent-filter>
58-
</receiver>
59-
6046

6147
<meta-data
6248
android:name="com.google.android.maps.v2.API_KEY"
6349
android:value="AIzaSyCSeALfuUrujaNPWh6Jy4lMeVb3clh5OMw"/>
50+
51+
<service
52+
android:name=".MyBroadcastReceiver"
53+
android:exported="false">
54+
<intent-filter>
55+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
56+
</intent-filter>
57+
</service>
58+
6459
</application>
6560

6661
</manifest>

BeRoadsProject/BeRoads/src/main/java/com/profete162/WebcamWallonnes/CamFragment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import android.os.Bundle;
88
import android.os.Parcelable;
99
import android.preference.PreferenceManager;
10-
import android.support.v4.view.PagerAdapter;
11-
import android.support.v4.view.ViewPager;
10+
import androidx.viewpager.widget.PagerAdapter;
11+
import androidx.viewpager.widget.ViewPager;
1212
import android.view.LayoutInflater;
1313
import android.view.View;
1414
import android.view.ViewGroup;

BeRoadsProject/BeRoads/src/main/java/com/profete162/WebcamWallonnes/DrawerActivity.java

+54-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.profete162.WebcamWallonnes;
22

3+
import android.Manifest;
34
import android.content.Context;
45
import android.content.Intent;
56
import android.content.SharedPreferences;
@@ -14,12 +15,15 @@
1415
import android.net.Uri;
1516
import android.os.Bundle;
1617
import android.preference.PreferenceManager;
17-
import android.support.v4.app.ActionBarDrawerToggle;
18-
import android.support.v4.app.Fragment;
19-
import android.support.v4.app.FragmentActivity;
20-
import android.support.v4.app.FragmentManager;
21-
import android.support.v4.app.FragmentTransaction;
22-
import android.support.v4.widget.DrawerLayout;
18+
19+
import androidx.core.app.ActivityCompat;
20+
import androidx.legacy.app.ActionBarDrawerToggle;
21+
import androidx.fragment.app.Fragment;
22+
import androidx.fragment.app.FragmentActivity;
23+
import androidx.fragment.app.FragmentManager;
24+
import androidx.fragment.app.FragmentTransaction;
25+
import androidx.drawerlayout.widget.DrawerLayout;
26+
2327
import android.text.format.DateUtils;
2428
import android.util.Log;
2529
import android.view.Menu;
@@ -30,7 +34,8 @@
3034
import android.widget.FrameLayout;
3135
import android.widget.ListView;
3236

33-
import com.google.android.gms.gcm.GoogleCloudMessaging;
37+
import com.google.android.material.snackbar.Snackbar;
38+
import com.google.firebase.messaging.FirebaseMessaging;
3439
import com.profete162.WebcamWallonnes.Adapter.MenuAdapter;
3540
import com.profete162.WebcamWallonnes.Utils.GPS;
3641
import com.profete162.WebcamWallonnes.Utils.NumberedFragment;
@@ -41,7 +46,7 @@
4146
public class DrawerActivity extends FragmentActivity {
4247

4348
public static final String TAG = "WazaBe";
44-
int count=0;
49+
int count = 0;
4550
public static final String EXTRA_MESSAGE = "message";
4651
public static final String PROPERTY_REG_ID = "registration_id";
4752
public static final String PROPERTY_APP_VERSION = "appVersion";
@@ -62,7 +67,7 @@ public class DrawerActivity extends FragmentActivity {
6267
* Substitute you own sender ID here.
6368
*/
6469
String SENDER_ID = "570622304067";
65-
GoogleCloudMessaging gcm;
70+
FirebaseMessaging fcm;
6671
AtomicInteger msgId = new AtomicInteger();
6772
SharedPreferences prefs;
6873
String regid;
@@ -106,10 +111,10 @@ public void onDrawerClosed(View view) {
106111
/** Called when a drawer has settled in a completely open state. */
107112
public void onDrawerOpened(View drawerView) {
108113
count++;
109-
if(count>5){
114+
if (count > 5) {
110115
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=dQw4w9WgXcQ"));
111116
startActivity(browserIntent);
112-
count=0;
117+
count = 0;
113118
}
114119
getActionBar().setTitle(getString(R.string.app_name));
115120
getActionBar().setIcon(R.drawable.ic_launcher);
@@ -147,7 +152,7 @@ public void onClick(View view) {
147152

148153
}
149154
});
150-
// mDrawerList.addFooterView(b);
155+
// mDrawerList.addFooterView(b);
151156
mDrawerList.setAdapter(new MenuAdapter(this,
152157
R.layout.row_menu, mMenuTitles));
153158

@@ -204,9 +209,43 @@ public void onProviderDisabled(String provider) {
204209
}
205210
};
206211

207-
// Register the listener with the Location Manager to receive location updates
212+
// Register the listener with the Location Manager to receive location updates
208213

209214
try {
215+
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
216+
// TODO: Consider calling
217+
// ActivityCompat#requestPermissions
218+
// here to request the missing permissions, and then overriding
219+
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
220+
// int[] grantResults)
221+
// to handle the case where the user grants the permission. See the documentation
222+
// for ActivityCompat#requestPermissions for more details.
223+
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
224+
Manifest.permission.READ_CONTACTS)
225+
|| ActivityCompat.shouldShowRequestPermissionRationale(this,
226+
Manifest.permission.WRITE_CONTACTS)) {
227+
228+
// Provide an additional rationale to the user if the permission was not granted
229+
// and the user would benefit from additional context for the use of the permission.
230+
// For example, if the request has been denied previously.
231+
Log.i(TAG,
232+
"Displaying contacts permission rationale to provide additional context.");
233+
234+
// Display a SnackBar with an explanation and a button to trigger the request.
235+
Snackbar.make(mDrawerLayout, R.string.permission_location_rationale,
236+
Snackbar.LENGTH_INDEFINITE)
237+
.setAction(R.string.ok, new View.OnClickListener() {
238+
@Override
239+
public void onClick(View view) {
240+
ActivityCompat.requestPermissions(DrawerActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 0);
241+
}
242+
})
243+
.show();
244+
} else {
245+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 0);
246+
}
247+
return;
248+
}
210249
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
211250
} catch (Exception e) {
212251
e.printStackTrace();
@@ -239,8 +278,9 @@ public void onBackStackChanged() {
239278
if (f instanceof MyMapFragment) {
240279
DrawerActivity.this.mapFragment = (MyMapFragment) f;
241280
show = true;
242-
} else
281+
} else {
243282
show = false;
283+
}
244284

245285
Log.e("", "STACK: " + mapFragment);
246286

0 commit comments

Comments
 (0)