Skip to content

Commit

Permalink
Merge pull request #505 from Chooloo/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
roeiedri authored Feb 24, 2023
2 parents 8bc2730 + 565821e commit 224c6c6
Show file tree
Hide file tree
Showing 216 changed files with 3,425 additions and 2,601 deletions.
26 changes: 18 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.4.10'
ext {
sdkVersion = 33
minSdkVersion = 25
hiltVersion = "2.44"
kotlinVersion = "1.8.0"
coreKtxVersion = "1.9.0"
appCompatVersion = "1.6.0"
}

repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "https://jitpack.io" }
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'
classpath "com.android.tools.build:gradle:7.4.0"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.44.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
}
}

plugins {
id 'com.google.dagger.hilt.android' version '2.44' apply false
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "https://jitpack.io" }
}
}

task clean(type: Delete) {
tasks.register("clean") {
delete rootProject.buildDir
}
104 changes: 50 additions & 54 deletions chooloolib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,92 +1,88 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id "com.android.library"
id "kotlin-android"
id "kotlin-kapt"
id 'com.google.dagger.hilt.android'
id "org.jetbrains.kotlin.android"
}

android {
compileSdk 31
namespace "com.chooloo.www.chooloolib"
compileSdk rootProject.ext.sdkVersion

defaultConfig {
versionCode 2
versionName "2.0"

minSdk 25
targetSdk 31

targetSdk rootProject.ext.sdkVersion
minSdk rootProject.ext.minSdkVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}

dataBinding {
//noinspection DataBindingWithoutKapt
enabled = true
}

buildFeatures {
viewBinding true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_18
targetCompatibility JavaVersion.VERSION_18
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

hilt {
enableAggregatingTask true
jvmTarget = JavaVersion.VERSION_18.toString()
}

kapt {
correctErrorTypes true
}
kotlin { jvmToolchain(18) }
dataBinding { enabled true }
kapt { correctErrorTypes true }
buildFeatures { viewBinding true }
buildFeatures { viewBinding true }
hilt { enableAggregatingTask true }
}

dependencies {
kapt(
'com.google.dagger:hilt-compiler:2.38.1',
'androidx.hilt:hilt-compiler:1.0.0-alpha01'
"androidx.hilt:hilt-compiler:1.0.0-alpha01",
"com.google.dagger:hilt-compiler:${rootProject.ext.hiltVersion}"
)

testImplementation(
'junit:junit:',
'androidx.room:room-testing:2.2.6'
"junit:junit:",
"androidx.room:room-testing:2.2.6"
)

androidTestImplementation(
'androidx.test:runner:1.3.0',
'androidx.test.ext:junit:1.1.3',
"androidx.test:runner:1.3.0",
"androidx.test.ext:junit:1.1.3",
"androidx.compose.ui:ui-test-junit4:1.0.4",
'androidx.test.espresso:espresso-core:3.4.0'
"androidx.test.espresso:espresso-core:3.4.0"
)

implementation(
'com.squareup.picasso:picasso:2.5.2',
'androidx.core:core-ktx:1.7.0',
'dev.sasikanth:colorsheet:1.0.1',
'androidx.appcompat:appcompat:1.4.1',
'io.reactivex.rxjava2:rxjava:2.1.16',
'androidx.preference:preference:1.1.1',
'androidx.fragment:fragment-ktx:1.1.0',
'androidx.activity:activity-ktx:1.1.0',
'io.github.l4digital:fastscroll:2.0.1',
'io.reactivex.rxjava2:rxandroid:2.0.1',
'com.google.dagger:hilt-android:2.38.1',
'com.google.android.material:material:1.6.0',
'com.github.abdularis:circularimageview:1.5',
'com.daimajia.androidanimations:library:2.4@aar',
'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0',
'com.pushtorefresh.storio3:content-resolver:3.0.0'
// ktx
"androidx.fragment:fragment-ktx:1.5.5",
"androidx.activity:activity-ktx:1.6.1",
"androidx.preference:preference-ktx:1.2.0",
"androidx.navigation:navigation-ui-ktx:2.5.3",
"androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1",
"androidx.navigation:navigation-fragment-ktx:2.5.3",
"androidx.core:core-ktx:${rootProject.ext.coreKtxVersion}",

"androidx.compose.ui:ui:1.3.3",
"dev.sasikanth:colorsheet:1.0.1",
"com.squareup.picasso:picasso:2.5.2",
"io.reactivex.rxjava2:rxjava:2.1.16",
"androidx.preference:preference:1.1.1",
"io.github.l4digital:fastscroll:2.0.1",
"io.reactivex.rxjava2:rxandroid:2.0.1",
"com.google.android.material:material:1.6.0",
"com.github.abdularis:circularimageview:1.5",
"com.daimajia.androidanimations:library:2.4@aar",
"com.pushtorefresh.storio3:content-resolver:3.0.0",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4",
"org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9",
"com.google.dagger:hilt-android:${rootProject.ext.hiltVersion}",
"androidx.appcompat:appcompat:${rootProject.ext.appCompatVersion}",
)
}
23 changes: 14 additions & 9 deletions chooloolib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.chooloo.www.chooloolib">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission
android:name="android.permission.MODIFY_PHONE_STATE"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />

<uses-permission android:name="android.permission.VIBRATE" />

<uses-permission android:name="android.permission.VIBRATE" />

<application>
<activity
android:name=".ui.call.CallActivity"
android:exported="false"
android:configChanges="screenSize|keyboardHidden"
android:excludeFromRecents="true"
android:screenOrientation="unspecified" />
android:exported="true"
android:noHistory="true"
android:screenOrientation="unspecified"
android:showOnLockScreen="true">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name=".ui.permissions.PermissionRequestActivity"
android:screenOrientation="unspecified" />
Expand All @@ -30,7 +35,7 @@
android:resource="@array/preloaded_fonts" />

<service
android:name=".service.CallService"
android:name="com.chooloo.www.chooloolib.api.service.CallService"
android:exported="true"
android:foregroundServiceType="phoneCall"
android:permission="android.permission.BIND_INCALL_SERVICE">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.chooloo.www.chooloolib.interactor.preferences.PreferencesInteractor
import com.chooloo.www.chooloolib.interactor.theme.ThemesInteractor
import javax.inject.Inject

abstract class BaseApp : Application() {
abstract class ChoolooApp : Application() {
@Inject lateinit var themes: ThemesInteractor
@Inject lateinit var preferences: PreferencesInteractor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ package com.chooloo.www.chooloolib.adapter
import com.chooloo.www.chooloolib.R
import com.chooloo.www.chooloolib.interactor.animation.AnimationsInteractor
import com.chooloo.www.chooloolib.interactor.string.StringsInteractor
import com.chooloo.www.chooloolib.model.ListData
import com.chooloo.www.chooloolib.model.RawContactAccount
import com.chooloo.www.chooloolib.data.model.ListData
import com.chooloo.www.chooloolib.data.model.RawContactAccount
import com.chooloo.www.chooloolib.ui.widgets.listitemholder.ListItemHolder
import javax.inject.Inject

class AccountsAdapter @Inject constructor(
animations: AnimationsInteractor,
private val strings: StringsInteractor
) : ListAdapter<RawContactAccount>(animations) {
override fun onBindListItem(listItemHolder: ListItemHolder, item: RawContactAccount) {
override fun onBindListItem(
listItemHolder: ListItemHolder,
item: RawContactAccount,
position: Int
) {
listItemHolder.apply {
captionText = null
isImageVisible = false
Expand All @@ -25,6 +29,6 @@ class AccountsAdapter @Inject constructor(
}
}

override fun convertDataToListData(data: List<RawContactAccount>) =
ListData.fromRawContacts(data, accounts = true, withHeader = false)
override fun convertDataToListData(items: List<RawContactAccount>) =
ListData.fromRawContacts(items, accounts = true, withHeader = false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.chooloo.www.chooloolib.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.recyclerview.widget.RecyclerView
import com.chooloo.www.chooloolib.databinding.CallActionBinding
import com.chooloo.www.chooloolib.ui.callactions.CallAction

class CallActionsAdapter : RecyclerView.Adapter<CallActionsAdapter.ViewHolder>() {
private var _callActions: MutableList<CallAction> = mutableListOf()
private var _onCallActionClickListener: (CallAction) -> Unit = {}


override fun getItemCount() = _callActions.size

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
ViewHolder(CallActionBinding.inflate(LayoutInflater.from(parent.context), parent, false))

override fun onBindViewHolder(holder: ViewHolder, position: Int) =
holder.bind(_callActions[position], _onCallActionClickListener::invoke)


private fun getCallAction(@StringRes idRes: Int): CallAction? {
val index = _callActions.indexOfFirst { it.idRes == idRes }
if (index == -1) return null
return _callActions[index]
}

private fun changeCallAction(@StringRes idRes: Int, change: (CallAction) -> Unit) {
val index = _callActions.indexOfFirst { it.idRes == idRes }
if (index == -1) return
change.invoke(_callActions[index])
notifyItemChanged(index)
}

fun isCallActionEnabled(@StringRes idRes: Int) = getCallAction(idRes)?.isEnabled ?: false

fun isCallActionActivated(@StringRes idRes: Int) = getCallAction(idRes)?.isActivated ?: false

fun setCallActionEnabled(@StringRes idRes: Int, isEnabled: Boolean) {
changeCallAction(idRes) { it.isEnabled = isEnabled }
}

fun setCallActionActivated(@StringRes idRes: Int, isActivated: Boolean) {
changeCallAction(idRes) { it.isActivated = isActivated }
}

fun setCallActionIcon(@StringRes idRes: Int, @DrawableRes iconRes: Int) {
changeCallAction(idRes) { it.tempIconRes = iconRes }
}

fun addCallActions(callActions: List<CallAction>) {
for (callAction in callActions) {
if (_callActions.contains(callAction)) continue
_callActions.add(callAction)
notifyItemChanged(_callActions.indexOf(callAction))
}
}

fun removeCallActions(callActions: List<CallAction>) {
for (callAction in callActions) {
if (!_callActions.contains(callAction)) continue
val removedIndex = _callActions.indexOf(callAction)
_callActions.remove(callAction)
notifyItemRemoved(removedIndex)
}
}

fun setOnCallActionClickListener(onCallActionClickListener: (CallAction) -> Unit = {}) {
_onCallActionClickListener = onCallActionClickListener
}


class ViewHolder(private val binding: CallActionBinding) :
RecyclerView.ViewHolder(binding.root) {

fun bind(callAction: CallAction, onClickListener: (CallAction) -> Unit = {}) {
binding.callActionRoot.apply {
setDefaultIcon(callAction.tempIconRes ?: callAction.iconRes)
callAction.checkedIconRes?.let(::setCheckedIcon)
isEnabled = callAction.isEnabled
isActivated = callAction.isActivated
setOnClickListener { onClickListener.invoke(callAction) }
}
}
}
}
Loading

0 comments on commit 224c6c6

Please sign in to comment.