-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
1,070 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
apply plugin: 'kotlin-android' | ||
|
||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "com.dgunia.calllogpicker" | ||
minSdkVersion 15 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
vectorDrawables.useSupportLibrary = true | ||
} | ||
signingConfigs { | ||
configDefault { | ||
keyAlias 'key0' | ||
keyPassword 'calllogpicker' | ||
storeFile file('../../calllog-picker.keystore') | ||
storePassword 'calllogpicker' | ||
} | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled true | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
signingConfig signingConfigs.configDefault | ||
} | ||
debug { | ||
signingConfig signingConfigs.configDefault | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
implementation 'com.android.support:support-v4:28.0.0' | ||
implementation 'com.android.support:support-vector-drawable:28.0.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.dgunia.calllogpicker"> | ||
|
||
<uses-permission android:name="android.permission.READ_CALL_LOG"/> | ||
<uses-permission android:name="android.permission.READ_CONTACTS"/> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/CallLogPickerTheme" | ||
tools:ignore="GoogleAppIndexingWarning"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/maintitle"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.intent.action.PICK"/> | ||
|
||
<category android:name="android.intent.category.DEFAULT"/> | ||
|
||
<data | ||
android:host="call_log" | ||
android:scheme="content"/> | ||
</intent-filter> | ||
</activity> | ||
|
||
<receiver android:name=".IncomingCallReceiver"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.PHONE_STATE"/> | ||
|
||
<category android:name="android.intent.category.DEFAULT"/> | ||
</intent-filter> | ||
</receiver> | ||
|
||
<activity | ||
android:name=".SettingsActivity" | ||
android:label="@string/settings"> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions
90
app/src/main/java/com/dgunia/calllogpicker/AppCompatPreferenceActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.dgunia.calllogpicker | ||
|
||
import android.content.res.Configuration | ||
import android.os.Bundle | ||
import android.preference.PreferenceActivity | ||
import android.support.annotation.LayoutRes | ||
import android.support.v7.app.ActionBar | ||
import android.support.v7.app.AppCompatDelegate | ||
import android.support.v7.widget.Toolbar | ||
import android.view.MenuInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
|
||
/** | ||
* A [android.preference.PreferenceActivity] which implements and proxies the necessary calls | ||
* to be used with AppCompat. | ||
*/ | ||
abstract class AppCompatPreferenceActivity : PreferenceActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
delegate.installViewFactory() | ||
delegate.onCreate(savedInstanceState) | ||
super.onCreate(savedInstanceState) | ||
} | ||
|
||
override fun onPostCreate(savedInstanceState: Bundle?) { | ||
super.onPostCreate(savedInstanceState) | ||
delegate.onPostCreate(savedInstanceState) | ||
} | ||
|
||
val supportActionBar: ActionBar? | ||
get() = delegate.supportActionBar | ||
|
||
fun setSupportActionBar(toolbar: Toolbar?) { | ||
delegate.setSupportActionBar(toolbar) | ||
} | ||
|
||
override fun getMenuInflater(): MenuInflater { | ||
return delegate.menuInflater | ||
} | ||
|
||
override fun setContentView(@LayoutRes layoutResID: Int) { | ||
delegate.setContentView(layoutResID) | ||
} | ||
|
||
override fun setContentView(view: View) { | ||
delegate.setContentView(view) | ||
} | ||
|
||
override fun setContentView(view: View, params: ViewGroup.LayoutParams) { | ||
delegate.setContentView(view, params) | ||
} | ||
|
||
override fun addContentView(view: View, params: ViewGroup.LayoutParams) { | ||
delegate.addContentView(view, params) | ||
} | ||
|
||
override fun onPostResume() { | ||
super.onPostResume() | ||
delegate.onPostResume() | ||
} | ||
|
||
override fun onTitleChanged(title: CharSequence, color: Int) { | ||
super.onTitleChanged(title, color) | ||
delegate.setTitle(title) | ||
} | ||
|
||
override fun onConfigurationChanged(newConfig: Configuration) { | ||
super.onConfigurationChanged(newConfig) | ||
delegate.onConfigurationChanged(newConfig) | ||
} | ||
|
||
override fun onStop() { | ||
super.onStop() | ||
delegate.onStop() | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
delegate.onDestroy() | ||
} | ||
|
||
override fun invalidateOptionsMenu() { | ||
delegate.invalidateOptionsMenu() | ||
} | ||
|
||
private val delegate: AppCompatDelegate by lazy { | ||
AppCompatDelegate.create(this, null) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/dgunia/calllogpicker/BroadcastActions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.dgunia.calllogpicker | ||
|
||
object BroadcastActions { | ||
val REFRESH = BuildConfig.APPLICATION_ID + ".REFRESH" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.dgunia.calllogpicker | ||
|
||
class Contact { | ||
var contactId: String | ||
var displayName: String | ||
var givenName: String? = null | ||
var middleName: String? = null | ||
var familyName: String? = null | ||
|
||
constructor(contactId: String, displayName: String) { | ||
this.contactId = contactId | ||
this.displayName = displayName | ||
} | ||
|
||
constructor(contactId: String, displayName: String, givenName: String, middleName: String, familyName: String) { | ||
this.contactId = contactId | ||
this.displayName = displayName | ||
this.givenName = givenName | ||
this.middleName = middleName | ||
this.familyName = familyName | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/dgunia/calllogpicker/IncomingCallReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.dgunia.calllogpicker | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.telephony.TelephonyManager | ||
|
||
/** | ||
* Gets the number of the currently active call. | ||
*/ | ||
class IncomingCallReceiver : BroadcastReceiver() { | ||
companion object { | ||
var currentlyActiveCallNumber: String? = null | ||
} | ||
|
||
override fun onReceive(context: Context?, intent: Intent?) { | ||
context?.let { context -> | ||
when (intent?.action) { | ||
TelephonyManager.ACTION_PHONE_STATE_CHANGED -> { | ||
val state = intent.getStringExtra(TelephonyManager.EXTRA_STATE) | ||
|
||
when (state) { | ||
TelephonyManager.EXTRA_STATE_RINGING -> { | ||
context.getSharedPreferences("incomingcallreceiver", Context.MODE_PRIVATE).edit() | ||
.putBoolean("ringing", true) | ||
.putBoolean("offhook", false) | ||
.apply() | ||
} | ||
TelephonyManager.EXTRA_STATE_OFFHOOK -> { | ||
context.getSharedPreferences("incomingcallreceiver", Context.MODE_PRIVATE).edit() | ||
.putBoolean("offhook", true) | ||
.apply() | ||
currentlyActiveCallNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER) | ||
} | ||
TelephonyManager.EXTRA_STATE_IDLE -> { | ||
val prefs = context.getSharedPreferences("incomingcallreceiver", Context.MODE_PRIVATE) | ||
val ringing = prefs.getBoolean("ringing", false) | ||
val offhook = prefs.getBoolean("offhook", false) | ||
currentlyActiveCallNumber = null | ||
|
||
val phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER) | ||
if (ringing && !offhook && phoneNumber != null && phoneNumber.isNotBlank()) { | ||
onMissedCall(context, phoneNumber) | ||
} | ||
} | ||
} | ||
|
||
context.sendBroadcast(Intent(BroadcastActions.REFRESH).apply { setPackage(BuildConfig.APPLICATION_ID) }) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun onMissedCall(context: Context, phoneNumber: String) { | ||
} | ||
} |
Oops, something went wrong.