Skip to content

Commit

Permalink
WIP: update to more recent SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
SingingBush committed Feb 22, 2024
1 parent 63c803e commit cb8155a
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 140 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: 11
cache: gradle

- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 8512546
# packages: 'tools platform-tools' # this is the default

- name: Build with Gradle
run: ./gradlew --no-daemon build
Expand Down
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

103 changes: 58 additions & 45 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
apply plugin: 'com.android.application'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileSdk 33
//buildTools '33.0.2'
namespace 'me.samael.android.calllocation'

defaultConfig {
applicationId "me.samael.android.calllocation"
minSdkVersion 15
targetSdkVersion 21
minSdk 32
targetSdkVersion 33

versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
lintOptions {
abortOnError false
htmlReport true
Expand All @@ -37,48 +48,50 @@ android {
}

dependencies {
// compile fileTree(dir: 'libs', include: '*.jar')
//compile 'com.android.support:support-v4:18.+'
//compile 'com.android.support:appcompat-v7:18.+'
// implementation fileTree(dir: 'libs', include: '*.jar')
//implementation 'com.android.support:support-v4:18.+'
//implementation 'com.android.support:appcompat-v7:18.+'
implementation 'androidx.core:core:1.12.0'

compile 'com.google.android.gms:play-services-maps:8.4.0'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
}

import groovy.swing.SwingBuilder

gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(':app:assembleRelease')) {
def storePass = ''
def keyPass = ''
if (System.console() == null) {
new SwingBuilder().edt {
dialog(modal: true, title: 'Enter password', alwaysOnTop: true, resizable: false, locationRelativeTo: null, pack: true, show: true) {
vbox { // Put everything below each other
label(text: "Please enter store passphrase:")
def input1 = passwordField()
label(text: "Please enter key passphrase:")
def input2 = passwordField()
button(defaultButton: true, text: 'OK', actionPerformed: {
storePass = input1.password;
keyPass = input2.password;
dispose();
})
}
}
}
} else {
storePass = System.console().readPassword("\nPlease enter store passphrase: ")
keyPass = System.console().readPassword("\nPlease enter key passphrase: ")
}
//import groovy.swing.SwingBuilder

if (storePass.size() <= 0 || keyPass.size() <= 0) {
throw new InvalidUserDataException("You must enter the passwords to proceed.")
}

storePass = new String(storePass)
keyPass = new String(keyPass)

android.signingConfigs.release.storePassword = storePass
android.signingConfigs.release.keyPassword = keyPass
}
}
//gradle.taskGraph.whenReady { taskGraph ->
// if (taskGraph.hasTask(':app:assembleRelease')) {
// def storePass = ''
// def keyPass = ''
// if (System.console() == null) {
// new SwingBuilder().edt {
// dialog(modal: true, title: 'Enter password', alwaysOnTop: true, resizable: false, locationRelativeTo: null, pack: true, show: true) {
// vbox { // Put everything below each other
// label(text: "Please enter store passphrase:")
// def input1 = passwordField()
// label(text: "Please enter key passphrase:")
// def input2 = passwordField()
// button(defaultButton: true, text: 'OK', actionPerformed: {
// storePass = input1.password;
// keyPass = input2.password;
// dispose();
// })
// }
// }
// }
// } else {
// storePass = System.console().readPassword("\nPlease enter store passphrase: ")
// keyPass = System.console().readPassword("\nPlease enter key passphrase: ")
// }
//
// if (storePass.size() <= 0 || keyPass.size() <= 0) {
// throw new InvalidUserDataException("You must enter the passwords to proceed.")
// }
//
// storePass = new String(storePass)
// keyPass = new String(keyPass)
//
// android.signingConfigs.release.storePassword = storePass
// android.signingConfigs.release.keyPassword = keyPass
// }
//}
13 changes: 10 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@
android:glEsVersion="0x00020000"
android:required="true" />

<uses-feature
android:name="android.hardware.telephony"
android:required="true" />

<uses-permission android:name="me.samael.android.calllocation.maps.permission.MAPS_RECEIVE" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:icon="@drawable/icon_launcher"
Expand All @@ -40,7 +45,8 @@
<activity
android:label="@string/app_name"
android:name=".MainActivity"
android:screenOrientation="portrait" >
android:screenOrientation="portrait"
android:exported="true">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -65,7 +71,8 @@
<activity
android:label="@string/settingsactivity_title"
android:name=".SettingsActivity"
android:screenOrientation="portrait" >
android:screenOrientation="portrait"
android:exported="false">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
Expand All @@ -24,10 +25,13 @@
import android.util.Log;
import android.widget.Toast;

import androidx.core.app.ActivityCompat;

public class CallLocationService extends Service {

private static final String TAG = CallLocationService.class.getSimpleName();

private static final String CHANNEL_ID = "3984275";
private static final int LOCATION_REQUEST_CODE = 45367452;
private static final boolean DEBUG_MODE = true;

private static LocationManager locationManager = null;
Expand Down Expand Up @@ -79,7 +83,9 @@ CallLocationService getService() {

@Override
public IBinder onBind(Intent intent) {
if(DEBUG_MODE) Log.d(TAG, "[SERVICE] onBind");
if(DEBUG_MODE) {
Log.d(TAG, "[SERVICE] onBind");
}
return serviceBinder;
}

Expand Down Expand Up @@ -116,7 +122,20 @@ public void onCreate() {
if(DEBUG_MODE) Log.d(TAG, "Inner Location Listener instantiated");

settings = SharedPrefs.getCallLocationPrefs(this);


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) {

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, settings.getGpsTimeInterval(), settings.getGpsDistance(), locationListener);

//ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION}, 111);
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
locationManager.requestLocationUpdates(provider, settings.getGpsTimeInterval(), settings.getGpsDistance(), locationListener);

// exceptions will be thrown if provider is not permitted.
Expand Down Expand Up @@ -247,7 +266,7 @@ public void onCallStateChanged(int state, String incomingNumber) {
break;
case TelephonyManager.CALL_STATE_RINGING:
//phone is ringing
Log.d("CallLocationService PhoneStateListener", "Phone Call from: " + incomingNumber);
Log.d("PhoneStateListener", "Phone Call from: " + incomingNumber);
addCallToDatabase(incomingNumber, getCurrentLocation());
break;
default:
Expand All @@ -262,7 +281,10 @@ private Location getCurrentLocation() {
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String provider = locationManager.getBestProvider(criteria, true);
Log.d(TAG, "Best Provider: " + provider);


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){
return new Location(provider); // todo: fix this
}
Location location = locationManager.getLastKnownLocation(provider);
return (location != null) ? location : new Location(provider);
}
Expand All @@ -279,16 +301,21 @@ public void onLocationUpdated(Location location) {
* Shows a notification in the status bar while service is running.
*/
private void showNotification() {
CharSequence appName = getText(R.string.app_name);
CharSequence notificationSubText = getText(R.string.service_subtext);

Notification notification = new Notification(R.drawable.icon_launcher, appName, System.currentTimeMillis());
final Notification notification = new Notification.Builder(getApplicationContext(), CHANNEL_ID)
.setSmallIcon(R.drawable.icon_launcher)
.setTicker(getText(R.string.app_name))
.setSubText(getText(R.string.service_subtext))
.setWhen(System.currentTimeMillis())
.build();

notification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;

//Context context = getApplicationContext();
Intent mainActivityIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, mainActivityIntent, 0);
notification.setLatestEventInfo(this, appName, notificationSubText, contentIntent);
// Intent mainActivityIntent = new Intent(this, MainActivity.class);
// PendingIntent contentIntent = PendingIntent.getActivity(this, 0, mainActivityIntent, 0);

// todo: fix this:
//notification.setLatestEventInfo(this, appName, notificationSubText, contentIntent);

notificationManager.notify(R.string.app_name, notification);
}
Expand Down
Loading

0 comments on commit cb8155a

Please sign in to comment.