Skip to content

Commit

Permalink
Switch to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlecat committed Dec 28, 2024
1 parent 3d3ca75 commit f1e7d90
Show file tree
Hide file tree
Showing 31 changed files with 1,860 additions and 1,947 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Generated files
.gradle
.kotlin
/build
bin/
gen/
Expand Down
25 changes: 12 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ buildscript {
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

apply plugin: 'idea'


dependencies {

implementation 'androidx.appcompat:appcompat-resources:1.6.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core:1.15.0'
implementation 'androidx.preference:preference:1.2.1'
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.material:material:1.12.0'

Expand All @@ -27,8 +31,8 @@ dependencies {

compileOnly 'javax.annotation:jsr250-api:1.0'

annotationProcessor 'com.google.dagger:dagger-compiler:2.53'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.53'
kapt 'com.google.dagger:dagger-compiler:2.53'
kapt 'com.google.dagger:dagger-android-processor:2.53'
api 'com.google.dagger:dagger-android-support:2.53'
api 'com.google.dagger:dagger-android:2.53'
api 'com.google.dagger:dagger:2.53'
Expand Down Expand Up @@ -72,15 +76,6 @@ android {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

// proguardFiles
// getDefaultProguardFile('proguard-android-optimize.txt')
//
// // List additional ProGuard rules for the given build type here. By default,
// // Android Studio creates and includes an empty rules file for you (located
// // at the root directory of each module).
// 'proguard-rules.pro'
// testProguardFiles
}
}

Expand All @@ -96,6 +91,10 @@ android {
}
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}

}

idea {
Expand Down
25 changes: 14 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto">
android:installLocation="auto">

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

<application
android:name=".CounterApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:name=".CounterApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name=".activities.MainActivity"
android:exported="true">
android:name=".activities.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".activities.SettingsActivity"
android:label="@string/settings_title" />
android:name=".activities.SettingsActivity"
android:label="@string/settings_title" />

</application>

</manifest>
51 changes: 27 additions & 24 deletions app/src/main/java/me/tsukanov/counter/CounterApplication.kt
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
package me.tsukanov.counter;
package me.tsukanov.counter

import android.app.Activity;
import android.app.Application;
import com.google.android.material.color.DynamicColors;
import dagger.android.DispatchingAndroidInjector;
import javax.inject.Inject;
import me.tsukanov.counter.domain.CounterApplicationComponent;
import me.tsukanov.counter.domain.CounterModule;
import me.tsukanov.counter.domain.DaggerCounterApplicationComponent;
import android.app.Activity
import android.app.Application
import com.google.android.material.color.DynamicColors
import dagger.android.DispatchingAndroidInjector
import me.tsukanov.counter.domain.CounterApplicationComponent
import me.tsukanov.counter.domain.CounterModule
import me.tsukanov.counter.domain.DaggerCounterApplicationComponent
import javax.inject.Inject

public class CounterApplication extends Application {
public static String PACKAGE_NAME;
class CounterApplication : Application() {

@Inject DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;
@JvmField
@Inject
var dispatchingAndroidInjector: DispatchingAndroidInjector<Activity>? = null

private static CounterApplicationComponent component;
override fun onCreate() {
super.onCreate()

@Override
public void onCreate() {
super.onCreate();
DynamicColors.applyToActivitiesIfAvailable(this)

DynamicColors.applyToActivitiesIfAvailable(this);
component = DaggerCounterApplicationComponent.builder()
.counterModule(CounterModule(this))
.build()

component =
DaggerCounterApplicationComponent.builder().counterModule(new CounterModule(this)).build();
PACKAGE_NAME = applicationContext.packageName
}

PACKAGE_NAME = getApplicationContext().getPackageName();
}
companion object {
var PACKAGE_NAME: String? = null

var component: CounterApplicationComponent? = null
private set
}

public static CounterApplicationComponent getComponent() {
return component;
}
}
33 changes: 10 additions & 23 deletions app/src/main/java/me/tsukanov/counter/SharedPrefKeys.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
package me.tsukanov.counter;

import androidx.annotation.NonNull;

public enum SharedPrefKeys {
ACTIVE_COUNTER("activeKey"),
KEEP_SCREEN_ON("keepScreenOn"),
LABEL_CONTROL_ON("labelControlOn"),
HARDWARE_BTN_CONTROL_ON("hardControlOn"),
VIBRATION_ON("vibrationOn"),
SOUNDS_ON("soundsOn"),
THEME("theme");

@NonNull private final String name;

SharedPrefKeys(@NonNull final String name) {
this.name = name;
}

@NonNull
public String getName() {
return name;
}
package me.tsukanov.counter

enum class SharedPrefKeys(val key: String) {
ACTIVE_COUNTER("activeKey"),
KEEP_SCREEN_ON("keepScreenOn"),
LABEL_CONTROL_ON("labelControlOn"),
HARDWARE_BTN_CONTROL_ON("hardControlOn"),
VIBRATION_ON("vibrationOn"),
SOUNDS_ON("soundsOn"),
THEME("theme"),
}
Loading

0 comments on commit f1e7d90

Please sign in to comment.