├── .gitignore ├── LICENSE.txt ├── README.md ├── SetMaster.iml ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── fabric.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── agna │ │ └── setmaster │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── agna │ │ └── setmaster │ │ ├── app │ │ ├── App.java │ │ ├── dagger │ │ │ ├── AppComponent.java │ │ │ ├── AppModule.java │ │ │ └── PerApplication.java │ │ ├── log │ │ │ ├── CrashlyticsTree.java │ │ │ └── RemoteLogger.java │ │ └── scheduler │ │ │ └── SchedulersProvider.java │ │ ├── domain │ │ ├── ConditionSet.java │ │ ├── DayOfWeek.java │ │ ├── Profile.java │ │ ├── condition │ │ │ ├── Condition.java │ │ │ ├── TimeCondition.java │ │ │ └── WiFiCondition.java │ │ └── setting │ │ │ ├── MediaVolumeSetting.java │ │ │ ├── RingSetting.java │ │ │ ├── Setting.java │ │ │ └── ValuableSetting.java │ │ ├── interactor │ │ ├── condition │ │ │ ├── ComplexConditionChecker.java │ │ │ ├── ConditionModule.java │ │ │ └── simple │ │ │ │ ├── ConditionStateChangedEvent.java │ │ │ │ ├── ConditionWrapper.java │ │ │ │ ├── SimpleConditionChecker.java │ │ │ │ ├── time │ │ │ │ ├── TimeBroadcastReceiver.java │ │ │ │ └── TimeConditionChecker.java │ │ │ │ └── wifi │ │ │ │ ├── WifiConditionChecker.java │ │ │ │ └── WifiStatusBroadcastReceiver.java │ │ ├── initialize │ │ │ └── InitializeAppInteractor.java │ │ ├── profile │ │ │ ├── DefaultProfileCreator.java │ │ │ ├── ProfileModule.java │ │ │ ├── ProfileService.java │ │ │ ├── event │ │ │ │ ├── ChangedStatus.java │ │ │ │ └── ProfileChangedEvent.java │ │ │ └── storage │ │ │ │ ├── ProfileStorage.java │ │ │ │ └── db │ │ │ │ ├── BaseDao.java │ │ │ │ ├── DataBaseHelper.java │ │ │ │ ├── SqlMigration.java │ │ │ │ ├── SqlMigrationStorage.java │ │ │ │ ├── dao │ │ │ │ └── ProfileDao.java │ │ │ │ └── entity │ │ │ │ └── ProfileObj.java │ │ ├── service │ │ │ ├── AppService.java │ │ │ ├── AppServiceInteractor.java │ │ │ └── DeviceBootReceiver.java │ │ └── setting │ │ │ ├── SettingManager.java │ │ │ ├── SettingModule.java │ │ │ └── applyer │ │ │ ├── MediaVolumeSettingApplier.java │ │ │ ├── RingSettingApplier.java │ │ │ └── SettingApplier.java │ │ ├── ui │ │ ├── base │ │ │ ├── BasePresenter.java │ │ │ ├── BaseView.java │ │ │ ├── HasName.java │ │ │ ├── PerScreen.java │ │ │ ├── activity │ │ │ │ ├── ActivityModule.java │ │ │ │ ├── BaseActivity.java │ │ │ │ └── BaseActivityView.java │ │ │ ├── dialog │ │ │ │ ├── ActivityDialogManager.java │ │ │ │ ├── BaseBottomSheetDialog.java │ │ │ │ ├── BaseDialog.java │ │ │ │ ├── DialogManager.java │ │ │ │ ├── FragmentDialogManager.java │ │ │ │ └── module │ │ │ │ │ ├── ActivityDialogModule.java │ │ │ │ │ └── FragmentDialogModule.java │ │ │ └── fragment │ │ │ │ ├── BaseFragmentView.java │ │ │ │ └── FragmentModule.java │ │ ├── common │ │ │ └── navigation │ │ │ │ └── Navigator.java │ │ ├── screen │ │ │ ├── condition │ │ │ │ ├── ChangeConditionBaseActivityView.java │ │ │ │ ├── time │ │ │ │ │ ├── ChangeTimeConditionActivity.java │ │ │ │ │ ├── ChangeTimeConditionComponent.java │ │ │ │ │ ├── ChangeTimeConditionPresenter.java │ │ │ │ │ ├── TimeConditionModule.java │ │ │ │ │ └── widget │ │ │ │ │ │ └── DaysOfWeekView.java │ │ │ │ └── wifi │ │ │ │ │ ├── ChangeWifiConditionActivity.java │ │ │ │ │ ├── ChangeWifiConditionComponent.java │ │ │ │ │ ├── ChangeWifiConditionModule.java │ │ │ │ │ ├── ChangeWifiConditionPresenter.java │ │ │ │ │ └── WifiNetworkAdapter.java │ │ │ ├── editprofile │ │ │ │ ├── EditProfileActivity.java │ │ │ │ ├── EditProfileComponent.java │ │ │ │ ├── EditProfilePresenter.java │ │ │ │ ├── EditProfileScreenModule.java │ │ │ │ ├── IconGridAdapter.java │ │ │ │ └── ProfileHolder.java │ │ │ ├── main │ │ │ │ ├── MainActivity.java │ │ │ │ ├── MainComponent.java │ │ │ │ ├── MainFragmentView.java │ │ │ │ ├── MainPresenter.java │ │ │ │ ├── ProfilesAdapter.java │ │ │ │ └── widget │ │ │ │ │ ├── ProfileListItemView.java │ │ │ │ │ └── SettingPreviewLayout.java │ │ │ ├── profile │ │ │ │ ├── ProfileActivity.java │ │ │ │ ├── ProfileComponent.java │ │ │ │ ├── ProfilePresenter.java │ │ │ │ ├── ProfileScreenModule.java │ │ │ │ ├── condition │ │ │ │ │ ├── ConditionListAdapter.java │ │ │ │ │ ├── ConditionSetPagerAdapter.java │ │ │ │ │ ├── ConditionSetView.java │ │ │ │ │ ├── add │ │ │ │ │ │ ├── AddConditionDialog.java │ │ │ │ │ │ ├── AddConditionListAdapter.java │ │ │ │ │ │ └── AddConditionOrConditionSetDialog.java │ │ │ │ │ └── holder │ │ │ │ │ │ ├── ConditionHolder.java │ │ │ │ │ │ ├── TimeConditionHolder.java │ │ │ │ │ │ └── WiFiConditionHolder.java │ │ │ │ └── setting │ │ │ │ │ ├── SettingGridAdapter.java │ │ │ │ │ ├── SettingGridLayoutManager.java │ │ │ │ │ ├── change │ │ │ │ │ ├── ChangeSettingDialog.java │ │ │ │ │ ├── ChangeVolumeSettingDialog.java │ │ │ │ │ ├── OnSettingChangeListener.java │ │ │ │ │ └── SettingChangeDialogFactory.java │ │ │ │ │ ├── choose │ │ │ │ │ ├── ChooseSettingDialog.java │ │ │ │ │ └── SettingListAdapter.java │ │ │ │ │ └── holder │ │ │ │ │ ├── AddSettingViewHolder.java │ │ │ │ │ ├── MediaVolumeSettingHolder.java │ │ │ │ │ ├── RingSettingHolder.java │ │ │ │ │ └── SettingGridItemPreviewProgress.java │ │ │ └── splash │ │ │ │ ├── SplashActivity.java │ │ │ │ ├── SplashComponent.java │ │ │ │ └── SplashPresenter.java │ │ └── util │ │ │ ├── ConditionViewUtil.java │ │ │ ├── DayOfWeekUtil.java │ │ │ ├── ProfileViewUtil.java │ │ │ ├── SettingUtil.java │ │ │ ├── SettingViewUtil.java │ │ │ └── StatusBarUtil.java │ │ └── util │ │ ├── CloneUtil.java │ │ ├── ProfileIconHelper.java │ │ └── TimeUtil.java │ └── res │ ├── color │ └── day_of_week_text_color.xml │ ├── drawable-xxhdpi │ ├── add_condition.png │ ├── add_condition_set.png │ ├── gear.png │ ├── ic_add_circle.png │ ├── ic_add_white_18dp.png │ ├── ic_arrow_back.png │ ├── ic_check_white.png │ ├── ic_clear.png │ ├── ic_cond_time.png │ ├── ic_cond_wifi.png │ ├── ic_delete.png │ ├── ic_do_not_disturb_white_48dp.png │ ├── ic_edit.png │ ├── ic_expand_more_white_48dp.png │ ├── ic_gps_fixed_grey600_48dp.png │ ├── ic_location.png │ ├── ic_more_vert_white_48dp.png │ ├── ic_notifications_on_white_48dp.png │ ├── ic_other_2.png │ ├── ic_phone_2.png │ ├── ic_phone_off.png │ ├── ic_phone_on.png │ ├── ic_pr_home.png │ ├── ic_profile_airplanemode_on.png │ ├── ic_profile_bagage.png │ ├── ic_profile_bar.png │ ├── ic_profile_business.png │ ├── ic_profile_city.png │ ├── ic_profile_home.png │ ├── ic_profile_library.png │ ├── ic_profile_moon.png │ ├── ic_profile_mountains.png │ ├── ic_profile_night.png │ ├── ic_profile_restaurant.png │ ├── ic_profile_school.png │ ├── ic_profile_sea.png │ ├── ic_profile_speaker.png │ ├── ic_profile_sun.png │ ├── ic_profile_world.png │ ├── ic_profile_world_2.png │ ├── ic_screen_lock_rotation_white_48dp.png │ ├── ic_screen_rotation_white_48dp.png │ ├── ic_search.png │ ├── ic_setting_media_volume_off.png │ ├── ic_setting_media_volume_on.png │ ├── ic_setting_ring_off.png │ ├── ic_setting_ring_on.png │ ├── ic_share.png │ ├── ic_signal_null.png │ ├── ic_signal_null_gray.png │ ├── ic_signal_off.png │ ├── ic_signal_on.png │ ├── ic_signal_wifi_off.png │ ├── ic_signal_wifi_on.png │ ├── ic_signal_wifi_statusbar_null_grey600_48dp.png │ ├── ic_star_white_48dp.png │ ├── ic_time.png │ ├── ic_vibration_black_48dp.png │ ├── ic_vibration_on.png │ ├── ic_vibration_white_48dp.png │ ├── ic_volume_off.png │ └── ic_volume_on.png │ ├── drawable-xxxhdpi │ ├── ic_arrow_back_white_24dp.png │ └── ic_edit_white_24dp.png │ ├── drawable │ ├── big_white_card.xml │ ├── black_card.xml │ ├── blue_circle.xml │ ├── day_of_week_blue_bg.xml │ ├── day_of_week_red_bg.xml │ ├── red_circle.xml │ ├── setting_seek_thumb.xml │ ├── small_white_card.xml │ └── transparent.xml │ ├── layout │ ├── activity_edit_profile.xml │ ├── activity_main.xml │ ├── activity_main_old.xml │ ├── activity_profile.xml │ ├── activity_splash.xml │ ├── add_condition_dialog.xml │ ├── add_condition_list_item_layout.xml │ ├── add_condition_or_condition_set_dialog.xml │ ├── add_setting_grid_item_layout.xml │ ├── change_time_condition_activity.xml │ ├── change_volume_setting_dialog.xml │ ├── change_wifi_condition_activity.xml │ ├── choose_setting_dialog.xml │ ├── codition_list_item_layout.xml │ ├── condition_set_view.xml │ ├── condition_set_view_layout.xml │ ├── days_of_week_view_layout.xml │ ├── empty_footer.xml │ ├── fragment_main.xml │ ├── icon_grid_item.xml │ ├── network_list_item.xml │ ├── profile_list_item.xml │ ├── profile_list_item_layout.xml │ ├── setting_grid_item_layout.xml │ ├── setting_list_item_layout.xml │ ├── setting_preview_layout.xml │ ├── setting_preview_layout_item.xml │ └── setting_volume_grid_item_layout.xml │ ├── menu │ ├── menu_main.xml │ └── profile_menu.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-ru │ └── strings.xml │ ├── values-v21 │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── setmaster.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | .idea/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | /*/build/ 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log -------------------------------------------------------------------------------- /SetMaster.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | maven { url 'https://maven.fabric.io/public' } 4 | } 5 | 6 | dependencies { 7 | classpath 'io.fabric.tools:gradle:1.+' 8 | } 9 | } 10 | 11 | apply plugin: 'com.android.application' 12 | apply plugin: 'io.fabric' 13 | 14 | repositories { 15 | maven { url 'https://maven.fabric.io/public' } 16 | } 17 | 18 | apply plugin: 'com.neenbedankt.android-apt' 19 | apply plugin: 'me.tatarka.retrolambda' 20 | 21 | android { 22 | compileSdkVersion 23 23 | buildToolsVersion "23.0.1" 24 | 25 | compileOptions{ 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | 30 | defaultConfig { 31 | applicationId "com.agna.setmaster" 32 | minSdkVersion 21 33 | targetSdkVersion 23 34 | versionCode 1 35 | versionName "1.0" 36 | 37 | } 38 | buildTypes { 39 | release { 40 | minifyEnabled false 41 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 42 | } 43 | } 44 | lintOptions { 45 | abortOnError false 46 | } 47 | } 48 | 49 | dependencies { 50 | compile fileTree(dir: 'libs', include: ['*.jar']) 51 | //common 52 | compile 'net.sourceforge.streamsupport:streamsupport:1.4.1' 53 | //support 54 | compile 'com.android.support:appcompat-v7:23.2.0' 55 | compile 'com.android.support:support-annotations:23.2.0' 56 | compile 'com.android.support:recyclerview-v7:23.2.0' 57 | compile 'com.android.support:design:23.2.0' 58 | //dagger 59 | compile 'com.google.dagger:dagger:2.0.2' 60 | apt "com.google.dagger:dagger-compiler:2.0.2" 61 | compile 'javax.annotation:jsr250-api:1.0' //for @Generated annotation 62 | //rx 63 | compile 'io.reactivex:rxjava:1.1.2' 64 | compile 'io.reactivex:rxandroid:1.1.0' 65 | compile 'io.reactivex:rxjava-async-util:0.21.0' 66 | compile 'com.jakewharton.rxbinding:rxbinding:0.4.0' 67 | //orm 68 | compile 'com.j256.ormlite:ormlite-core:4.48' 69 | compile 'com.j256.ormlite:ormlite-android:4.48' 70 | 71 | //log 72 | compile 'com.jakewharton.timber:timber:4.1.1' 73 | compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') { 74 | transitive = true; 75 | } 76 | //widget 77 | compile 'me.relex:circleindicator:1.1.8@aar' 78 | compile 'com.wdullaer:materialdatetimepicker:2.3.0' 79 | 80 | } 81 | -------------------------------------------------------------------------------- /app/fabric.properties: -------------------------------------------------------------------------------- 1 | #Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public. 2 | #Wed Dec 09 19:29:08 MSK 2015 3 | apiSecret=4785f555db45ea9a0eda38279534894277d9ef6388b9edbfb017cd1f0720b621 4 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\Maximus\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class value to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/agna/setmaster/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.agna.setmaster; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/app/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.app; 17 | 18 | import android.app.Application; 19 | 20 | import com.agna.setmaster.BuildConfig; 21 | import com.agna.setmaster.app.dagger.AppComponent; 22 | import com.agna.setmaster.app.dagger.AppModule; 23 | import com.agna.setmaster.app.dagger.DaggerAppComponent; 24 | import com.agna.setmaster.app.log.CrashlyticsTree; 25 | import com.crashlytics.android.Crashlytics; 26 | 27 | import io.fabric.sdk.android.Fabric; 28 | import timber.log.Timber; 29 | 30 | public class App extends Application { 31 | private AppComponent appComponent; 32 | 33 | @Override 34 | public void onCreate() { 35 | super.onCreate(); 36 | initAppComponent(); 37 | initFabric(); 38 | initLogging(); 39 | } 40 | 41 | private void initFabric() { 42 | Fabric.with(this, new Crashlytics()); 43 | } 44 | 45 | private void initAppComponent() { 46 | appComponent = DaggerAppComponent.builder() 47 | .appModule(new AppModule(this)) 48 | .build(); 49 | } 50 | 51 | public AppComponent getAppComponent() { 52 | return appComponent; 53 | } 54 | 55 | private void initLogging() { 56 | if (BuildConfig.DEBUG) { 57 | Timber.plant(new Timber.DebugTree()); 58 | } else { 59 | Timber.plant(new CrashlyticsTree()); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/app/dagger/AppModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.app.dagger; 17 | 18 | import android.content.Context; 19 | 20 | import com.agna.setmaster.interactor.condition.ConditionModule; 21 | import com.agna.setmaster.interactor.profile.ProfileModule; 22 | import com.agna.setmaster.interactor.setting.SettingModule; 23 | 24 | import dagger.Module; 25 | import dagger.Provides; 26 | 27 | @Module(includes = { 28 | ConditionModule.class, 29 | SettingModule.class, 30 | ProfileModule.class}) 31 | public class AppModule { 32 | Context appContext; 33 | 34 | public AppModule(Context appContext) { 35 | this.appContext = appContext; 36 | } 37 | 38 | @PerApplication 39 | @Provides 40 | Context provideContext() { 41 | return appContext; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/app/dagger/PerApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.app.dagger; 17 | 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.RetentionPolicy; 20 | 21 | import javax.inject.Scope; 22 | 23 | @Scope 24 | @Retention(RetentionPolicy.RUNTIME) 25 | public @interface PerApplication { 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/app/log/CrashlyticsTree.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.app.log; 17 | 18 | import android.util.Log; 19 | 20 | import com.crashlytics.android.Crashlytics; 21 | 22 | import timber.log.Timber; 23 | 24 | 25 | /** 26 | * отправляет логи в крашлитикс 27 | */ 28 | public class CrashlyticsTree extends Timber.Tree { 29 | 30 | private final int logPriority; 31 | 32 | /** 33 | * Создание экземпляра с приоритетом по умолчанию для логгирования в Crashlytics. 34 | * По умолчанию приоритет - DEBUG. 35 | */ 36 | public CrashlyticsTree() { 37 | this(Log.DEBUG); 38 | } 39 | 40 | private CrashlyticsTree(int logPriority) { 41 | Crashlytics.class.getCanonicalName(); //проверка доступности Crashlytics 42 | this.logPriority = logPriority; 43 | } 44 | 45 | 46 | @Override 47 | protected void log(int priority, String tag, String message, Throwable throwable) { 48 | if (priority < logPriority) { 49 | return; 50 | } 51 | String logMessage = message; 52 | if (tag != null) { 53 | logMessage = tag + ": " + logMessage; 54 | } 55 | if (throwable != null) { 56 | logMessage = logMessage + "\n" + throwable.getMessage() + '\n' + Log.getStackTraceString(throwable); 57 | } 58 | try { 59 | RemoteLogger.logMessage(logMessage); 60 | } catch (Exception e) { 61 | e("error " + e.getMessage() + " when send message: " + logMessage + "... with priority: " + priority); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/app/log/RemoteLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.app.log; 17 | 18 | import com.crashlytics.android.Crashlytics; 19 | import com.agna.setmaster.ui.base.HasName; 20 | 21 | 22 | /** 23 | * класс для расширенного логирования ошибок в Crashlytics 24 | * расширения: 25 | * 1. Добавляется логин пользователя 26 | * 2. Добавляется информация о создании и разрушении view 27 | * 3. Есть возможность логировать не фатальные ошибки 28 | */ 29 | public class RemoteLogger { 30 | 31 | public static void setUser(String userId, String username) { 32 | if (Crashlytics.getInstance() != null) { 33 | Crashlytics.getInstance().core.setUserIdentifier(userId); 34 | Crashlytics.getInstance().core.setUserName(username); 35 | } 36 | } 37 | 38 | public static void clearUser() { 39 | if (Crashlytics.getInstance() != null) { 40 | Crashlytics.getInstance().core.setUserIdentifier(""); 41 | Crashlytics.getInstance().core.setUserName(""); 42 | } 43 | } 44 | 45 | public static void logViewCreated(HasName view) { 46 | if (view != null) { 47 | logMessage("View " + view.getName() + " created"); 48 | } 49 | } 50 | 51 | public static void logViewDestroyed(HasName view) { 52 | if (view != null) { 53 | logMessage("View " + view.getName() + " Destroyed"); 54 | } 55 | } 56 | 57 | public static void logError(Throwable e) { 58 | try { 59 | Crashlytics.getInstance().core.logException(e); 60 | } catch (Throwable err) { 61 | //ignored 62 | } 63 | } 64 | 65 | public static void logMessage(String message) { 66 | if (Crashlytics.getInstance() != null && message != null) { 67 | Crashlytics.getInstance().core.log(message); 68 | } 69 | } 70 | 71 | public static void setCustomKey(String key, String value) { 72 | if (Crashlytics.getInstance() != null) { 73 | Crashlytics.getInstance().core.setString(key, value); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/app/scheduler/SchedulersProvider.java: -------------------------------------------------------------------------------- 1 | package com.agna.setmaster.app.scheduler; 2 | 3 | import com.agna.setmaster.app.dagger.PerApplication; 4 | 5 | import javax.inject.Inject; 6 | 7 | import rx.Scheduler; 8 | import rx.android.schedulers.AndroidSchedulers; 9 | import rx.schedulers.Schedulers; 10 | 11 | /** 12 | * provide Schedulers for rx 13 | */ 14 | @PerApplication 15 | public class SchedulersProvider { 16 | 17 | @Inject 18 | public SchedulersProvider() { 19 | } 20 | 21 | public Scheduler main(){ 22 | return AndroidSchedulers.mainThread(); 23 | } 24 | 25 | public Scheduler worker(){ 26 | return Schedulers.io(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/domain/ConditionSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.domain; 17 | 18 | import com.agna.setmaster.domain.condition.Condition; 19 | import com.agna.setmaster.util.CloneUtil; 20 | 21 | import java.io.Serializable; 22 | import java.util.ArrayList; 23 | import java.util.UUID; 24 | 25 | /** 26 | * Set of conditions 27 | */ 28 | public class ConditionSet implements Cloneable, Serializable { 29 | private ArrayList conditions = new ArrayList<>(); 30 | private boolean active; 31 | private String id; 32 | 33 | public ConditionSet() { 34 | id = UUID.randomUUID().toString(); 35 | } 36 | 37 | private ConditionSet(String id, ArrayList conditions, boolean active) { 38 | this.id = id; 39 | this.conditions = conditions; 40 | this.active = active; 41 | } 42 | 43 | public ArrayList getConditions() { 44 | return conditions; 45 | } 46 | 47 | public void setConditions(ArrayList conditions) { 48 | this.conditions = conditions; 49 | } 50 | 51 | @Override 52 | public ConditionSet clone() { 53 | return new ConditionSet(id, CloneUtil.cloneConditionList(conditions), active); 54 | } 55 | 56 | public void setActive(boolean active) { 57 | this.active = active; 58 | } 59 | 60 | public String getId() { 61 | return id; 62 | } 63 | 64 | public void addCondition(Condition condition) { 65 | conditions.add(condition); 66 | } 67 | 68 | public void delete(Condition conditionForDelete) { 69 | for (int i = 0; i < conditions.size(); i++) { 70 | Condition condition = conditions.get(i); 71 | if (condition.getId().equals(conditionForDelete.getId())) { 72 | conditions.remove(i); 73 | return; 74 | } 75 | } 76 | throw new IllegalArgumentException("Condition " + conditionForDelete + " not exist"); 77 | } 78 | 79 | public boolean isEmpty() { 80 | return conditions.size() == 0; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/domain/condition/Condition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.domain.condition; 17 | 18 | import java.io.Serializable; 19 | import java.util.UUID; 20 | 21 | /** 22 | * Base Condition entity 23 | */ 24 | public abstract class Condition implements Cloneable, Serializable { 25 | private String id; 26 | private boolean active = false; 27 | 28 | public Condition(String id, boolean active) { 29 | this.id = id; 30 | this.active = active; 31 | } 32 | 33 | @Override 34 | public abstract Condition clone(); 35 | 36 | public Condition() { 37 | this.id = UUID.randomUUID().toString(); 38 | } 39 | 40 | public String getId() { 41 | return id; 42 | } 43 | 44 | public void setActive(boolean active) { 45 | this.active = active; 46 | } 47 | 48 | public boolean isActive() { 49 | return active; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/domain/condition/TimeCondition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.domain.condition; 17 | 18 | import com.agna.setmaster.domain.DayOfWeek; 19 | 20 | import java.util.ArrayList; 21 | import java.util.Arrays; 22 | import java.util.Calendar; 23 | import java.util.Date; 24 | 25 | /** 26 | * Time Condition entity 27 | */ 28 | public class TimeCondition extends Condition { 29 | private Date from; 30 | private Date to; 31 | private ArrayList days = new ArrayList<>(Arrays.asList(DayOfWeek.ENUMS)); 32 | 33 | 34 | public TimeCondition() { 35 | Calendar calendar = Calendar.getInstance(); 36 | calendar.setTimeInMillis(0); 37 | calendar.set(Calendar.HOUR_OF_DAY, 8); 38 | calendar.set(Calendar.MINUTE, 0); 39 | from = calendar.getTime(); 40 | calendar.set(Calendar.HOUR_OF_DAY, 18); 41 | calendar.set(Calendar.MINUTE, 0); 42 | to = calendar.getTime(); 43 | } 44 | 45 | public TimeCondition(Date from, Date to, ArrayList days) { 46 | this.from = from; 47 | this.to = to; 48 | this.days = days; 49 | } 50 | 51 | private TimeCondition(String id, boolean active, Date from, Date to, ArrayList days) { 52 | super(id, active); 53 | this.from = from; 54 | this.to = to; 55 | this.days = days; 56 | } 57 | 58 | public void setFrom(Date from) { 59 | this.from = from; 60 | } 61 | 62 | public void setTo(Date to) { 63 | this.to = to; 64 | } 65 | 66 | public void setDays(ArrayList days) { 67 | this.days = days; 68 | } 69 | 70 | public Date getFrom() { 71 | return from; 72 | } 73 | 74 | public Date getTo() { 75 | return to; 76 | } 77 | 78 | public ArrayList getDays() { 79 | return days; 80 | } 81 | 82 | @Override 83 | public Condition clone() { 84 | return new TimeCondition(getId(), isActive(), getFrom(), getTo(), getDays()); 85 | } 86 | 87 | 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/domain/condition/WiFiCondition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.domain.condition; 17 | 18 | /** 19 | * Wifi Condition entity 20 | */ 21 | public class WiFiCondition extends Condition { 22 | private String networkName; 23 | 24 | public WiFiCondition() { 25 | this("Unspecified"); 26 | } 27 | 28 | public WiFiCondition(String networkName) { 29 | this.networkName = networkName; 30 | } 31 | 32 | private WiFiCondition(String id, boolean active, String networkName) { 33 | super(id, active); 34 | this.networkName = networkName; 35 | } 36 | 37 | public String getNetworkName() { 38 | return networkName; 39 | } 40 | 41 | public void setNetworkName(String networkName) { 42 | this.networkName = networkName; 43 | } 44 | 45 | @Override 46 | public Condition clone() { 47 | return new WiFiCondition(getId(), isActive(), getNetworkName()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/domain/setting/MediaVolumeSetting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.domain.setting; 17 | 18 | /** 19 | * MediaVolume setting entity 20 | */ 21 | public class MediaVolumeSetting extends ValuableSetting { 22 | 23 | public MediaVolumeSetting() { 24 | super(0); 25 | } 26 | 27 | public MediaVolumeSetting(float value) { 28 | super(value); 29 | } 30 | 31 | private MediaVolumeSetting(String id, float value) { 32 | super(id, value); 33 | } 34 | 35 | @Override 36 | public Setting clone() { 37 | return new MediaVolumeSetting(getId(), getValue()); 38 | } 39 | 40 | public boolean isEnabled() { 41 | return getValue() != 0; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/domain/setting/RingSetting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.domain.setting; 17 | 18 | /** 19 | * Ring setting entity 20 | */ 21 | public class RingSetting extends ValuableSetting { 22 | 23 | public RingSetting() { 24 | super(0); 25 | } 26 | 27 | public RingSetting(float value) { 28 | super(value); 29 | } 30 | 31 | private RingSetting(String id, float value) { 32 | super(id, value); 33 | } 34 | 35 | @Override 36 | public Setting clone() { 37 | return new RingSetting(getId(), getValue()); 38 | } 39 | 40 | public boolean isEnabled() { 41 | return getValue() != 0; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/domain/setting/Setting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.domain.setting; 17 | 18 | import java.io.Serializable; 19 | import java.util.UUID; 20 | 21 | /** 22 | * Base setting entity 23 | */ 24 | public abstract class Setting implements Cloneable, Serializable { 25 | 26 | private String id; 27 | 28 | public Setting() { 29 | id = UUID.randomUUID().toString(); 30 | } 31 | 32 | 33 | public Setting(String id) { 34 | this.id = id; 35 | } 36 | 37 | public String getId() { 38 | return id; 39 | } 40 | 41 | @Override 42 | public abstract Setting clone(); 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/domain/setting/ValuableSetting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.domain.setting; 17 | 18 | /** 19 | * Base valuable setting entity 20 | */ 21 | public abstract class ValuableSetting extends Setting { 22 | private float value; 23 | 24 | 25 | public ValuableSetting(float value) { 26 | this.value = value; 27 | } 28 | 29 | public ValuableSetting(String id, float value) { 30 | super(id); 31 | this.value = value; 32 | } 33 | 34 | public float getValue() { 35 | return value; 36 | } 37 | 38 | public void setValue(float value) { 39 | this.value = value; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/condition/ConditionModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.condition; 17 | 18 | import com.agna.setmaster.app.dagger.PerApplication; 19 | import com.agna.setmaster.domain.condition.Condition; 20 | import com.agna.setmaster.domain.condition.TimeCondition; 21 | import com.agna.setmaster.domain.condition.WiFiCondition; 22 | import com.agna.setmaster.interactor.condition.simple.SimpleConditionChecker; 23 | import com.agna.setmaster.interactor.condition.simple.time.TimeConditionChecker; 24 | import com.agna.setmaster.interactor.condition.simple.wifi.WifiConditionChecker; 25 | 26 | import java.util.ArrayList; 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | 30 | import dagger.Module; 31 | import dagger.Provides; 32 | 33 | /** 34 | * 35 | */ 36 | @Module 37 | public class ConditionModule { 38 | 39 | @Provides 40 | @PerApplication 41 | Map, SimpleConditionChecker>> provideSimpleConditionCheckers( 42 | WifiConditionChecker wifiConditionChecker, 43 | TimeConditionChecker timeConditionChecker) { 44 | Map, SimpleConditionChecker>> simpleConditionCheckers = new HashMap<>(); 45 | simpleConditionCheckers.put(WiFiCondition.class, wifiConditionChecker); 46 | simpleConditionCheckers.put(TimeCondition.class, timeConditionChecker); 47 | return simpleConditionCheckers; 48 | } 49 | 50 | @Provides 51 | @PerApplication 52 | ArrayList> provideSupportedConditions() { 53 | ArrayList> supportedConditions = new ArrayList<>(); 54 | supportedConditions.add(TimeCondition.class); 55 | supportedConditions.add(WiFiCondition.class); 56 | return supportedConditions; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/condition/simple/ConditionStateChangedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.condition.simple; 17 | 18 | /** 19 | * 20 | */ 21 | public class ConditionStateChangedEvent { 22 | private String profileId; 23 | private String conditionId; 24 | private boolean active; 25 | 26 | public ConditionStateChangedEvent(String profileId, String conditionId, boolean active) { 27 | this.profileId = profileId; 28 | this.conditionId = conditionId; 29 | this.active = active; 30 | } 31 | 32 | public String getProfileId() { 33 | return profileId; 34 | } 35 | 36 | public String getConditionId() { 37 | return conditionId; 38 | } 39 | 40 | public boolean isActive() { 41 | return active; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "ConditionStateChangedEvent{" + 47 | "profileId='" + profileId + '\'' + 48 | ", conditionId='" + conditionId + '\'' + 49 | ", active=" + active + 50 | '}'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/condition/simple/ConditionWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.condition.simple; 17 | 18 | import com.agna.setmaster.domain.condition.Condition; 19 | 20 | /** 21 | * 22 | */ 23 | public class ConditionWrapper { 24 | private C condition; 25 | private String profileId; 26 | 27 | public ConditionWrapper(C condition, String profileId) { 28 | this.condition = condition; 29 | this.profileId = profileId; 30 | } 31 | 32 | public C getCondition() { 33 | return condition; 34 | } 35 | 36 | public String getProfileId() { 37 | return profileId; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/condition/simple/SimpleConditionChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.condition.simple; 17 | 18 | import com.agna.setmaster.domain.condition.Condition; 19 | 20 | import rx.Observable; 21 | 22 | /** 23 | * Responsible for checking condition 24 | */ 25 | public interface SimpleConditionChecker { 26 | 27 | void unregister(ConditionWrapper condition); 28 | 29 | void register(ConditionWrapper condition); 30 | 31 | Observable observeConditionStateChanged(); 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/condition/simple/time/TimeBroadcastReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.condition.simple.time; 17 | 18 | import android.content.BroadcastReceiver; 19 | import android.content.Context; 20 | import android.content.Intent; 21 | 22 | import com.agna.setmaster.app.App; 23 | 24 | import javax.inject.Inject; 25 | 26 | import timber.log.Timber; 27 | 28 | /** 29 | * 30 | */ 31 | public class TimeBroadcastReceiver extends BroadcastReceiver { 32 | @Inject 33 | TimeConditionChecker timeConditionChecker; 34 | 35 | 36 | @Override 37 | public void onReceive(Context context, Intent intent) { 38 | ((App) context.getApplicationContext()).getAppComponent().inject(this); 39 | Timber.v("alarm"); 40 | timeConditionChecker.onAlarmReceived(intent); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/condition/simple/wifi/WifiStatusBroadcastReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.condition.simple.wifi; 17 | 18 | import android.content.BroadcastReceiver; 19 | import android.content.Context; 20 | import android.content.Intent; 21 | import android.net.ConnectivityManager; 22 | import android.net.NetworkInfo; 23 | import android.net.wifi.WifiManager; 24 | import android.util.Log; 25 | 26 | import com.agna.setmaster.app.App; 27 | 28 | import javax.inject.Inject; 29 | 30 | import timber.log.Timber; 31 | 32 | /** 33 | * 34 | */ 35 | public class WifiStatusBroadcastReceiver extends BroadcastReceiver { 36 | @Inject 37 | WifiConditionChecker wifiConditionChecker; 38 | 39 | @Override 40 | public void onReceive(Context context, Intent intent) { 41 | ((App) context.getApplicationContext()).getAppComponent().inject(this); 42 | Timber.d("WifiStatusBroadcastReceiver: " + intent); 43 | String action = intent.getAction(); 44 | Log.d("TEMP", action); 45 | if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { 46 | NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); 47 | if (info.getType() == ConnectivityManager.TYPE_WIFI) { 48 | if (info.isConnected()) { 49 | wifiConditionChecker.onConnected(); 50 | } else { 51 | wifiConditionChecker.onDisconnected(); 52 | } 53 | } 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/initialize/InitializeAppInteractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.initialize; 17 | 18 | import com.agna.setmaster.app.dagger.PerApplication; 19 | import com.agna.setmaster.interactor.profile.ProfileService; 20 | 21 | import javax.inject.Inject; 22 | 23 | import rx.Observable; 24 | 25 | /** 26 | * Responsible for app initialization 27 | */ 28 | @PerApplication 29 | public class InitializeAppInteractor { 30 | 31 | private final ProfileService profileService; 32 | private boolean initialized = false; 33 | 34 | @Inject 35 | public InitializeAppInteractor(ProfileService profileService) { 36 | this.profileService = profileService; 37 | } 38 | 39 | public Observable initialize() { 40 | if (initialized) { 41 | return Observable.just(null); 42 | 43 | } else { 44 | initialized = true; 45 | return profileService.initialize(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/profile/DefaultProfileCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.profile; 17 | 18 | import android.content.Context; 19 | 20 | import com.agna.setmaster.app.dagger.PerApplication; 21 | import com.agna.setmaster.domain.Profile; 22 | import com.agna.setmaster.util.ProfileIconHelper; 23 | 24 | import javax.inject.Inject; 25 | 26 | /** 27 | * 28 | */ 29 | @PerApplication 30 | public class DefaultProfileCreator { 31 | 32 | private Context appContext; 33 | 34 | @Inject 35 | public DefaultProfileCreator(Context appContext) { 36 | this.appContext = appContext; 37 | } 38 | 39 | public Profile createGlobal() { 40 | Profile globalProfile = new Profile("Global", ProfileIconHelper.getGlobalProfileIconId()); 41 | globalProfile.setPriority(Profile.PRIORITY_GLOBAL); 42 | globalProfile.setActive(true); 43 | return globalProfile; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/profile/ProfileModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.profile; 17 | 18 | import com.agna.setmaster.app.dagger.PerApplication; 19 | import com.agna.setmaster.interactor.profile.storage.db.DataBaseHelper; 20 | import com.agna.setmaster.interactor.profile.storage.db.dao.ProfileDao; 21 | import com.agna.setmaster.interactor.profile.storage.db.entity.ProfileObj; 22 | 23 | import dagger.Module; 24 | import dagger.Provides; 25 | 26 | /** 27 | * 28 | */ 29 | @Module 30 | public class ProfileModule { 31 | 32 | @Provides 33 | @PerApplication 34 | ProfileDao provideProfileDao(DataBaseHelper dataBaseHelper) { 35 | return dataBaseHelper.safeGetDao(ProfileObj.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/profile/event/ChangedStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.profile.event; 17 | 18 | /** 19 | * 20 | */ 21 | public enum ChangedStatus { 22 | UPDATED, 23 | DELETED 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/profile/event/ProfileChangedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.profile.event; 17 | 18 | import com.agna.setmaster.domain.Profile; 19 | 20 | /** 21 | * 22 | */ 23 | public class ProfileChangedEvent { 24 | private Profile profile; 25 | private final ChangedStatus status; 26 | 27 | public ProfileChangedEvent(Profile profile, ChangedStatus status) { 28 | this.profile = profile; 29 | this.status = status; 30 | } 31 | 32 | public Profile getProfile() { 33 | return profile; 34 | } 35 | 36 | public ChangedStatus getStatus() { 37 | return status; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/profile/storage/db/SqlMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.profile.storage.db; 17 | 18 | import android.content.Context; 19 | import android.database.sqlite.SQLiteDatabase; 20 | import android.util.Log; 21 | 22 | import com.j256.ormlite.support.ConnectionSource; 23 | 24 | import java.sql.SQLException; 25 | 26 | /** 27 | * 28 | */ 29 | public abstract class SqlMigration { 30 | 31 | private final static String TAG = SqlMigration.class.getSimpleName(); 32 | 33 | public int baseVersion; 34 | 35 | public SqlMigration(int value) { 36 | baseVersion = value; 37 | } 38 | 39 | public void execute(Context appContext, int oldVer, int newVer, SQLiteDatabase db, ConnectionSource connectionSource, DataBaseHelper databaseHelper) 40 | throws SQLException { 41 | if (oldVer < baseVersion && baseVersion <= newVer) { 42 | Log.d(TAG, "Executing database migration, baseVersion = " + baseVersion); 43 | apply(appContext, db, connectionSource, databaseHelper); 44 | } 45 | } 46 | 47 | protected abstract void apply(Context appContext, SQLiteDatabase db, ConnectionSource connectionSource, DataBaseHelper databaseHelper) throws SQLException; 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/profile/storage/db/SqlMigrationStorage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.profile.storage.db; 17 | 18 | /** 19 | * 20 | */ 21 | public class SqlMigrationStorage { 22 | 23 | public static final SqlMigration[] migrations = new SqlMigration[]{}; 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/profile/storage/db/dao/ProfileDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.profile.storage.db.dao; 17 | 18 | import com.j256.ormlite.support.ConnectionSource; 19 | import com.j256.ormlite.table.DatabaseTableConfig; 20 | import com.agna.setmaster.interactor.profile.storage.db.BaseDao; 21 | import com.agna.setmaster.interactor.profile.storage.db.entity.ProfileObj; 22 | 23 | import java.sql.SQLException; 24 | 25 | /** 26 | * 27 | */ 28 | public class ProfileDao extends BaseDao { 29 | 30 | public ProfileDao(Class dataClass) throws SQLException { 31 | super(dataClass); 32 | } 33 | 34 | public ProfileDao(ConnectionSource connectionSource, Class dataClass) throws SQLException { 35 | super(connectionSource, dataClass); 36 | } 37 | 38 | public ProfileDao(ConnectionSource connectionSource, DatabaseTableConfig tableConfig) throws SQLException { 39 | super(connectionSource, tableConfig); 40 | } 41 | 42 | @Override 43 | protected ProfileObj getData(String id) throws SQLException { 44 | ProfileObj profile = queryForId(id); 45 | return profile; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/profile/storage/db/entity/ProfileObj.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.profile.storage.db.entity; 17 | 18 | import com.j256.ormlite.field.DataType; 19 | import com.j256.ormlite.field.DatabaseField; 20 | import com.j256.ormlite.table.DatabaseTable; 21 | import com.agna.setmaster.domain.Profile; 22 | import com.agna.setmaster.interactor.profile.storage.db.dao.ProfileDao; 23 | 24 | /** 25 | * TODO Maks Tuev create flexible storage 26 | */ 27 | @DatabaseTable(tableName = "profiles", daoClass = ProfileDao.class) 28 | public class ProfileObj { 29 | 30 | @DatabaseField(id = true, columnName = "book_id") 31 | private String id; 32 | @DatabaseField(columnName = "profile", dataType = DataType.SERIALIZABLE) 33 | private Profile profile; 34 | 35 | public ProfileObj() { 36 | } 37 | 38 | public ProfileObj(Profile profile) { 39 | id = profile.getId(); 40 | this.profile = profile; 41 | } 42 | 43 | 44 | public Profile getProfile() { 45 | profile.clearActiveState(); 46 | return profile; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/service/AppService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.service; 17 | 18 | import android.app.Service; 19 | import android.content.Intent; 20 | import android.os.IBinder; 21 | import android.support.annotation.Nullable; 22 | 23 | import com.agna.setmaster.app.App; 24 | import com.agna.setmaster.interactor.initialize.InitializeAppInteractor; 25 | 26 | import javax.inject.Inject; 27 | 28 | /** 29 | * Responsible for holding process alive 30 | */ 31 | public class AppService extends Service { 32 | 33 | @Inject 34 | InitializeAppInteractor initializeAppInteractor; 35 | 36 | @Override 37 | public void onCreate() { 38 | super.onCreate(); 39 | ((App) this.getApplicationContext()).getAppComponent().inject(this); 40 | } 41 | 42 | @Override 43 | public int onStartCommand(Intent intent, int flags, int startId) { 44 | initializeAppInteractor.initialize() 45 | .subscribe(); 46 | return START_STICKY; 47 | } 48 | 49 | @Nullable 50 | @Override 51 | public IBinder onBind(Intent intent) { 52 | return null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/service/AppServiceInteractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.service; 17 | 18 | import android.content.Context; 19 | import android.content.Intent; 20 | 21 | import com.agna.setmaster.app.dagger.PerApplication; 22 | 23 | import javax.inject.Inject; 24 | 25 | /** 26 | * Responsible for starting {@link AppService} 27 | */ 28 | @PerApplication 29 | public class AppServiceInteractor { 30 | private Context context; 31 | 32 | @Inject 33 | public AppServiceInteractor(Context context) { 34 | this.context = context; 35 | } 36 | 37 | public void start() { 38 | Intent i = new Intent(context, AppService.class); 39 | context.startService(i); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/service/DeviceBootReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.service; 17 | 18 | import android.content.BroadcastReceiver; 19 | import android.content.Context; 20 | import android.content.Intent; 21 | 22 | import com.agna.setmaster.app.App; 23 | 24 | import javax.inject.Inject; 25 | 26 | /** 27 | * Responsible for start {@link AppService} when the device is switched on 28 | */ 29 | public class DeviceBootReceiver extends BroadcastReceiver { 30 | @Inject 31 | AppServiceInteractor appServiceInteractor; 32 | 33 | public void onReceive(Context context, Intent intent) { 34 | ((App) context.getApplicationContext()).getAppComponent().inject(this); 35 | appServiceInteractor.start(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/setting/SettingModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.setting; 17 | 18 | import com.agna.setmaster.app.dagger.PerApplication; 19 | import com.agna.setmaster.domain.setting.MediaVolumeSetting; 20 | import com.agna.setmaster.domain.setting.RingSetting; 21 | import com.agna.setmaster.domain.setting.Setting; 22 | import com.agna.setmaster.interactor.setting.applyer.MediaVolumeSettingApplier; 23 | import com.agna.setmaster.interactor.setting.applyer.RingSettingApplier; 24 | import com.agna.setmaster.interactor.setting.applyer.SettingApplier; 25 | 26 | import java.util.ArrayList; 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | 30 | import dagger.Module; 31 | import dagger.Provides; 32 | 33 | /** 34 | * 35 | */ 36 | @Module 37 | public class SettingModule { 38 | 39 | @Provides 40 | @PerApplication 41 | Map, SettingApplier> provideSettingAppliers( 42 | RingSettingApplier ringSettingApplier, 43 | MediaVolumeSettingApplier mediaVolumeSettingApplier) { 44 | Map, SettingApplier> settingAppliers = new HashMap<>(); 45 | settingAppliers.put(RingSetting.class, ringSettingApplier); 46 | settingAppliers.put(MediaVolumeSetting.class, mediaVolumeSettingApplier); 47 | return settingAppliers; 48 | } 49 | 50 | @Provides 51 | @PerApplication 52 | ArrayList> provideSettingTypes() { 53 | ArrayList> settingTypes = new ArrayList<>(); 54 | settingTypes.add(RingSetting.class); 55 | settingTypes.add(MediaVolumeSetting.class); 56 | return settingTypes; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/setting/applyer/MediaVolumeSettingApplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.setting.applyer; 17 | 18 | import android.content.Context; 19 | import android.media.AudioManager; 20 | 21 | import com.agna.setmaster.app.dagger.PerApplication; 22 | import com.agna.setmaster.domain.setting.MediaVolumeSetting; 23 | 24 | import javax.inject.Inject; 25 | 26 | /** 27 | * Responsible for applying MediaVolume setting 28 | */ 29 | @PerApplication 30 | public class MediaVolumeSettingApplier implements SettingApplier { 31 | private Context appContext; 32 | private AudioManager audioManger; 33 | 34 | @Inject 35 | public MediaVolumeSettingApplier(Context appContext) { 36 | this.appContext = appContext; 37 | audioManger = (AudioManager) appContext.getSystemService(Context.AUDIO_SERVICE); 38 | } 39 | 40 | @Override 41 | public void apply(MediaVolumeSetting setting) { 42 | int maxVolume = audioManger.getStreamMaxVolume(AudioManager.STREAM_MUSIC); 43 | int volume = (int) (maxVolume * setting.getValue() + 0.49f); 44 | audioManger.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0); 45 | } 46 | 47 | @Override 48 | public MediaVolumeSetting getCurrent() { 49 | int maxVolume = audioManger.getStreamMaxVolume(AudioManager.STREAM_MUSIC); 50 | int volume = audioManger.getStreamVolume(AudioManager.STREAM_MUSIC); 51 | MediaVolumeSetting ringSetting = new MediaVolumeSetting(1.0f * volume / maxVolume); 52 | return ringSetting; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/setting/applyer/RingSettingApplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.setting.applyer; 17 | 18 | import android.content.Context; 19 | import android.media.AudioManager; 20 | 21 | import com.agna.setmaster.app.dagger.PerApplication; 22 | import com.agna.setmaster.domain.setting.RingSetting; 23 | 24 | import javax.inject.Inject; 25 | 26 | /** 27 | * Responsible for applying Ring setting 28 | */ 29 | @PerApplication 30 | public class RingSettingApplier implements SettingApplier { 31 | private Context appContext; 32 | private AudioManager audioManger; 33 | 34 | @Inject 35 | public RingSettingApplier(Context appContext) { 36 | this.appContext = appContext; 37 | audioManger = (AudioManager) appContext.getSystemService(Context.AUDIO_SERVICE); 38 | } 39 | 40 | @Override 41 | public void apply(RingSetting setting) { 42 | int maxVolume = audioManger.getStreamMaxVolume(AudioManager.STREAM_RING); 43 | int volume = (int) (maxVolume * setting.getValue() + 0.49f); 44 | audioManger.setStreamVolume(AudioManager.STREAM_RING, volume, 0); 45 | } 46 | 47 | @Override 48 | public RingSetting getCurrent() { 49 | int maxVolume = audioManger.getStreamMaxVolume(AudioManager.STREAM_RING); 50 | int volume = audioManger.getStreamVolume(AudioManager.STREAM_RING); 51 | RingSetting ringSetting = new RingSetting(1.0f * volume / maxVolume); 52 | return ringSetting; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/interactor/setting/applyer/SettingApplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.interactor.setting.applyer; 17 | 18 | import com.agna.setmaster.domain.setting.Setting; 19 | 20 | /** 21 | * Responsible for applying setting 22 | */ 23 | public interface SettingApplier { 24 | void apply(S setting); 25 | 26 | S getCurrent(); 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base; 17 | 18 | import android.content.Intent; 19 | import android.os.Bundle; 20 | import android.support.annotation.NonNull; 21 | 22 | import rx.Subscription; 23 | import rx.subscriptions.CompositeSubscription; 24 | 25 | /** 26 | * базовый класс для презентера 27 | * 28 | * имеет методы, соответствующие жизненному циклу view 29 | * при пересоздании View, заново создается и презентер 30 | * 31 | * @param тип View 32 | * если V не интерфейс, то использование методов View, относящихся к андроид фреймворку запрещено 33 | */ 34 | public class BasePresenter { 35 | 36 | private CompositeSubscription compositeSubscription = new CompositeSubscription(); 37 | 38 | private V view; 39 | 40 | public void attachView(V view) { 41 | this.view = view; 42 | } 43 | 44 | protected V getView() { 45 | return view; 46 | } 47 | 48 | public void onLoad() { 49 | } 50 | 51 | public void onDestroy() { 52 | if (!compositeSubscription.isUnsubscribed()) { 53 | compositeSubscription.unsubscribe(); 54 | } 55 | } 56 | 57 | public void onRestore(@NonNull Bundle savedInstanceState) { 58 | } 59 | 60 | public void onSave(@NonNull Bundle outState) { 61 | } 62 | 63 | protected void addToSubscriptions(Subscription subscription) { 64 | compositeSubscription.add(subscription); 65 | } 66 | 67 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/BaseView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base; 17 | 18 | /** 19 | * 20 | */ 21 | public interface BaseView { 22 | BasePresenter getPresenter(); 23 | 24 | void initPresenter(); 25 | 26 | void goBack(); 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/HasName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base; 17 | 18 | public interface HasName { 19 | String getName(); 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/PerScreen.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base; 17 | 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.RetentionPolicy; 20 | 21 | import javax.inject.Scope; 22 | 23 | /** 24 | * 25 | */ 26 | @Scope 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface PerScreen { 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/activity/ActivityModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.activity; 17 | 18 | import android.support.v7.app.AppCompatActivity; 19 | 20 | import com.agna.setmaster.ui.base.PerScreen; 21 | 22 | import dagger.Module; 23 | import dagger.Provides; 24 | 25 | @Module 26 | public class ActivityModule { 27 | private AppCompatActivity activity; 28 | 29 | public ActivityModule(AppCompatActivity activity) { 30 | this.activity = activity; 31 | } 32 | 33 | @Provides 34 | @PerScreen 35 | AppCompatActivity provideActivity() { 36 | return activity; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/activity/BaseActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.activity; 17 | 18 | import android.os.Bundle; 19 | import android.support.v7.app.AppCompatActivity; 20 | 21 | import com.agna.setmaster.app.App; 22 | import com.agna.setmaster.app.dagger.AppComponent; 23 | 24 | 25 | /** 26 | * бызовый класс всех Activity 27 | */ 28 | public class BaseActivity extends AppCompatActivity { 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | } 34 | 35 | protected AppComponent getApplicationComponent() { 36 | return ((App) getApplication()).getAppComponent(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/ActivityDialogManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog; 17 | 18 | import android.support.v7.app.AppCompatActivity; 19 | 20 | import com.agna.setmaster.ui.base.PerScreen; 21 | 22 | import javax.inject.Inject; 23 | 24 | @PerScreen 25 | public class ActivityDialogManager implements DialogManager { 26 | private AppCompatActivity activity; 27 | 28 | @Inject 29 | public ActivityDialogManager(AppCompatActivity activity) { 30 | this.activity = activity; 31 | } 32 | 33 | @Override 34 | public void show(BaseDialog dialog) { 35 | dialog.show(activity); 36 | } 37 | 38 | @Override 39 | public void show(BaseBottomSheetDialog dialog) { 40 | dialog.show(activity); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/DialogManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog; 17 | 18 | /** 19 | * Сущность, отвечающая за показывание и скрывание диалогов 20 | */ 21 | public interface DialogManager { 22 | void show(BaseDialog dialog); 23 | 24 | void show(BaseBottomSheetDialog dialog); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/FragmentDialogManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog; 17 | 18 | 19 | import android.support.v4.app.Fragment; 20 | 21 | import com.agna.setmaster.ui.base.PerScreen; 22 | 23 | import javax.inject.Inject; 24 | 25 | @PerScreen 26 | public class FragmentDialogManager implements DialogManager { 27 | 28 | private Fragment fragment; 29 | 30 | @Inject 31 | public FragmentDialogManager(Fragment fragment) { 32 | this.fragment = fragment; 33 | } 34 | 35 | @Override 36 | public void show(BaseDialog dialog) { 37 | dialog.show(fragment); 38 | } 39 | 40 | @Override 41 | public void show(BaseBottomSheetDialog dialog) { 42 | dialog.show(fragment); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/module/ActivityDialogModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog.module; 17 | 18 | import com.agna.setmaster.ui.base.PerScreen; 19 | import com.agna.setmaster.ui.base.dialog.ActivityDialogManager; 20 | import com.agna.setmaster.ui.base.dialog.DialogManager; 21 | 22 | import dagger.Module; 23 | import dagger.Provides; 24 | 25 | /** 26 | * 27 | */ 28 | @Module 29 | public class ActivityDialogModule { 30 | @Provides 31 | @PerScreen 32 | DialogManager provideDialogManager(ActivityDialogManager dialogManager) { 33 | return dialogManager; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/module/FragmentDialogModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog.module; 17 | 18 | import com.agna.setmaster.ui.base.PerScreen; 19 | import com.agna.setmaster.ui.base.dialog.DialogManager; 20 | import com.agna.setmaster.ui.base.dialog.FragmentDialogManager; 21 | 22 | import dagger.Module; 23 | import dagger.Provides; 24 | 25 | /** 26 | * 27 | */ 28 | @Module 29 | public class FragmentDialogModule { 30 | 31 | @Provides 32 | @PerScreen 33 | DialogManager provideDialogManager(FragmentDialogManager dialogManager) { 34 | return dialogManager; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/fragment/FragmentModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.fragment; 17 | 18 | import android.support.v4.app.Fragment; 19 | import android.support.v7.app.AppCompatActivity; 20 | 21 | import com.agna.setmaster.ui.base.PerScreen; 22 | 23 | import dagger.Module; 24 | import dagger.Provides; 25 | 26 | @Module 27 | public class FragmentModule { 28 | private Fragment fragment; 29 | 30 | public FragmentModule(Fragment fragment) { 31 | this.fragment = fragment; 32 | } 33 | 34 | @Provides 35 | @PerScreen 36 | Fragment provideFragment() { 37 | return fragment; 38 | } 39 | 40 | @Provides 41 | @PerScreen 42 | AppCompatActivity provideActivity() { 43 | return (AppCompatActivity) fragment.getActivity(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/common/navigation/Navigator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.common.navigation; 17 | 18 | import android.support.v7.app.AppCompatActivity; 19 | 20 | import com.agna.setmaster.domain.Profile; 21 | import com.agna.setmaster.domain.condition.Condition; 22 | import com.agna.setmaster.domain.condition.TimeCondition; 23 | import com.agna.setmaster.domain.condition.WiFiCondition; 24 | import com.agna.setmaster.ui.base.PerScreen; 25 | import com.agna.setmaster.ui.screen.condition.time.ChangeTimeConditionActivity; 26 | import com.agna.setmaster.ui.screen.condition.wifi.ChangeWifiConditionActivity; 27 | import com.agna.setmaster.ui.screen.editprofile.EditProfileActivity; 28 | import com.agna.setmaster.ui.screen.main.MainActivity; 29 | import com.agna.setmaster.ui.screen.profile.ProfileActivity; 30 | 31 | import javax.inject.Inject; 32 | 33 | /** 34 | * 35 | */ 36 | @PerScreen 37 | public class Navigator { 38 | 39 | private AppCompatActivity activity; 40 | 41 | @Inject 42 | public Navigator(AppCompatActivity activity) { 43 | this.activity = activity; 44 | } 45 | 46 | public void openMain() { 47 | MainActivity.start(activity); 48 | } 49 | 50 | public void openNewProfile() { 51 | EditProfileActivity.start(activity, null); 52 | } 53 | 54 | public void openProfile(Profile profile) { 55 | ProfileActivity.start(activity, profile); 56 | } 57 | 58 | public void openEditProfile(Profile profile) { 59 | EditProfileActivity.start(activity, profile); 60 | } 61 | 62 | public void openChangeCondition(Condition condition, Profile profile) { 63 | if (condition instanceof TimeCondition) { 64 | ChangeTimeConditionActivity.start(activity, (TimeCondition) condition, profile); 65 | } else if (condition instanceof WiFiCondition) { 66 | ChangeWifiConditionActivity.start(activity, (WiFiCondition) condition, profile); 67 | } else { 68 | throw new IllegalArgumentException("Unsupported condition: " + condition); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/ChangeConditionBaseActivityView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition; 17 | 18 | import android.content.Intent; 19 | 20 | import com.agna.setmaster.ui.base.activity.BaseActivityView; 21 | 22 | /** 23 | * 24 | */ 25 | public abstract class ChangeConditionBaseActivityView extends BaseActivityView { 26 | public static final String EXTRA_CONDITION = "EXTRA_CONDITION"; 27 | 28 | public void goBack(int result, Intent data) { 29 | setResult(result, data); 30 | finish(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/time/ChangeTimeConditionComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.time; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | import com.agna.setmaster.ui.base.dialog.module.ActivityDialogModule; 22 | 23 | import dagger.Component; 24 | 25 | /** 26 | * 27 | */ 28 | @Component(dependencies = AppComponent.class, modules = { 29 | ActivityModule.class, 30 | ActivityDialogModule.class, 31 | TimeConditionModule.class}) 32 | @PerScreen 33 | public interface ChangeTimeConditionComponent { 34 | void inject(ChangeTimeConditionActivity activity); 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/time/ChangeTimeConditionPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.time; 17 | 18 | import android.app.Activity; 19 | import android.content.Intent; 20 | 21 | import com.agna.setmaster.domain.DayOfWeek; 22 | import com.agna.setmaster.domain.condition.TimeCondition; 23 | import com.agna.setmaster.ui.base.BasePresenter; 24 | import com.agna.setmaster.ui.base.PerScreen; 25 | import com.agna.setmaster.ui.base.dialog.DialogManager; 26 | import com.agna.setmaster.ui.screen.condition.ChangeConditionBaseActivityView; 27 | 28 | import java.util.ArrayList; 29 | import java.util.Date; 30 | 31 | import javax.inject.Inject; 32 | 33 | /** 34 | * 35 | */ 36 | @PerScreen 37 | public class ChangeTimeConditionPresenter extends BasePresenter { 38 | 39 | private DialogManager dialogManager; 40 | private TimeCondition condition; 41 | 42 | @Inject 43 | public ChangeTimeConditionPresenter(DialogManager dialogManager, TimeCondition timeCondition) { 44 | 45 | this.dialogManager = dialogManager; 46 | this.condition = timeCondition; 47 | } 48 | 49 | @Override 50 | public void onLoad() { 51 | super.onLoad(); 52 | getView().bind(condition); 53 | } 54 | 55 | public void saveCondition(Date from, Date to, ArrayList days) { 56 | condition.setFrom(from); 57 | condition.setTo(to); 58 | condition.setDays(days); 59 | Intent i = new Intent(); 60 | i.putExtra(ChangeConditionBaseActivityView.EXTRA_CONDITION, condition); 61 | getView().goBack(Activity.RESULT_OK, i); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/time/TimeConditionModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.time; 17 | 18 | import com.agna.setmaster.domain.condition.TimeCondition; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | 21 | import dagger.Module; 22 | import dagger.Provides; 23 | 24 | /** 25 | * 26 | */ 27 | @Module 28 | public class TimeConditionModule { 29 | private TimeCondition timeCondition; 30 | 31 | public TimeConditionModule(TimeCondition timeCondition) { 32 | this.timeCondition = timeCondition; 33 | } 34 | 35 | @Provides 36 | @PerScreen 37 | TimeCondition provideTimeCondition(){ 38 | return timeCondition; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/wifi/ChangeWifiConditionComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.wifi; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | import com.agna.setmaster.ui.base.dialog.module.ActivityDialogModule; 22 | 23 | import dagger.Component; 24 | 25 | /** 26 | * 27 | */ 28 | @Component(dependencies = AppComponent.class, modules = { 29 | ActivityModule.class, 30 | ChangeWifiConditionModule.class, 31 | ActivityDialogModule.class}) 32 | @PerScreen 33 | public interface ChangeWifiConditionComponent { 34 | void inject(ChangeWifiConditionActivity activity); 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/wifi/ChangeWifiConditionModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.wifi; 17 | 18 | import android.content.Context; 19 | import android.net.wifi.WifiConfiguration; 20 | import android.net.wifi.WifiManager; 21 | 22 | import com.agna.setmaster.domain.condition.WiFiCondition; 23 | import com.agna.setmaster.ui.base.PerScreen; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | import dagger.Module; 29 | import dagger.Provides; 30 | 31 | /** 32 | * 33 | */ 34 | @Module 35 | public class ChangeWifiConditionModule { 36 | 37 | private WiFiCondition condition; 38 | 39 | public ChangeWifiConditionModule(WiFiCondition condition) { 40 | this.condition = condition; 41 | } 42 | 43 | @Provides 44 | @PerScreen 45 | WiFiCondition provideWiFiCondition(){ 46 | return condition; 47 | } 48 | 49 | @Provides 50 | @PerScreen 51 | ArrayList provideWifiNetworks(Context context) { 52 | ArrayList result = new ArrayList<>(); 53 | WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); 54 | List configurations = wifiManager.getConfiguredNetworks(); 55 | result.addAll(configurations); 56 | return result; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/wifi/ChangeWifiConditionPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.wifi; 17 | 18 | import android.app.Activity; 19 | import android.content.Intent; 20 | import android.net.wifi.WifiConfiguration; 21 | 22 | import com.agna.setmaster.domain.condition.WiFiCondition; 23 | import com.agna.setmaster.ui.base.BasePresenter; 24 | import com.agna.setmaster.ui.base.PerScreen; 25 | import com.agna.setmaster.ui.base.dialog.DialogManager; 26 | import com.agna.setmaster.ui.screen.condition.ChangeConditionBaseActivityView; 27 | 28 | import java.util.ArrayList; 29 | 30 | import javax.inject.Inject; 31 | 32 | /** 33 | * 34 | */ 35 | @PerScreen 36 | public class ChangeWifiConditionPresenter extends BasePresenter { 37 | 38 | private DialogManager dialogManager; 39 | private ArrayList wifiNetworks; 40 | private WiFiCondition condition; 41 | 42 | @Inject 43 | public ChangeWifiConditionPresenter(DialogManager dialogManager, 44 | ArrayList wifiNetworks, 45 | WiFiCondition condition) { 46 | 47 | this.dialogManager = dialogManager; 48 | this.wifiNetworks = wifiNetworks; 49 | this.condition = condition; 50 | } 51 | 52 | @Override 53 | public void onLoad() { 54 | super.onLoad(); 55 | getView().showNetworks(wifiNetworks); 56 | getView().bind(condition); 57 | } 58 | 59 | public void saveCondition(WifiConfiguration wifiConfiguration) { 60 | condition.setNetworkName(wifiConfiguration.SSID); 61 | Intent i = new Intent(); 62 | i.putExtra(ChangeConditionBaseActivityView.EXTRA_CONDITION, condition); 63 | getView().goBack(Activity.RESULT_OK, i); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/editprofile/EditProfileComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.editprofile; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | 22 | import dagger.Component; 23 | 24 | /** 25 | * 26 | */ 27 | @PerScreen 28 | @Component(dependencies = AppComponent.class, modules = { 29 | ActivityModule.class, 30 | EditProfileScreenModule.class}) 31 | public interface EditProfileComponent { 32 | void inject(EditProfileActivity view); 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/editprofile/EditProfilePresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.editprofile; 17 | 18 | import com.agna.setmaster.domain.Profile; 19 | import com.agna.setmaster.interactor.profile.ProfileService; 20 | import com.agna.setmaster.ui.base.BasePresenter; 21 | import com.agna.setmaster.ui.base.PerScreen; 22 | import com.agna.setmaster.ui.common.navigation.Navigator; 23 | 24 | import javax.inject.Inject; 25 | 26 | /** 27 | * 28 | */ 29 | @PerScreen 30 | public class EditProfilePresenter extends BasePresenter { 31 | 32 | private final Navigator navigator; 33 | private final ProfileService profileService; 34 | 35 | private Profile profile; 36 | 37 | @Inject 38 | public EditProfilePresenter(ProfileService profileService, Navigator navigator, ProfileHolder profileHolder) { 39 | this.profileService = profileService; 40 | this.navigator = navigator; 41 | this.profile = profileHolder.getProfile(); 42 | } 43 | 44 | public void saveProfile(String name, int iconRes) { 45 | if (profile == null) { 46 | profile = new Profile(name, iconRes); 47 | profileService.addProfile(profile); 48 | } else { 49 | profile.setName(name); 50 | profile.setIconId(iconRes); 51 | profileService.updateProfile(profile); 52 | } 53 | getView().goBack(); 54 | navigator.openProfile(profileService.getProfile(profile.getId())); 55 | } 56 | 57 | @Override 58 | public void onLoad() { 59 | super.onLoad(); 60 | getView().bindProfile(profile); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/editprofile/EditProfileScreenModule.java: -------------------------------------------------------------------------------- 1 | package com.agna.setmaster.ui.screen.editprofile; 2 | 3 | import com.agna.setmaster.domain.Profile; 4 | import com.agna.setmaster.ui.base.PerScreen; 5 | 6 | import dagger.Module; 7 | import dagger.Provides; 8 | 9 | /** 10 | * 11 | */ 12 | @Module 13 | public class EditProfileScreenModule { 14 | private Profile profile; 15 | 16 | public EditProfileScreenModule(Profile profile) { 17 | this.profile = profile; 18 | } 19 | 20 | @Provides 21 | @PerScreen 22 | public ProfileHolder provideProfile() { 23 | return new ProfileHolder(profile); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/editprofile/ProfileHolder.java: -------------------------------------------------------------------------------- 1 | package com.agna.setmaster.ui.screen.editprofile; 2 | 3 | import com.agna.setmaster.domain.Profile; 4 | 5 | /** 6 | * 7 | */ 8 | public class ProfileHolder { 9 | private Profile profile; 10 | 11 | public ProfileHolder(Profile profile) { 12 | this.profile = profile; 13 | } 14 | 15 | public Profile getProfile() { 16 | return profile; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/main/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.main; 17 | 18 | import android.app.Activity; 19 | import android.content.Intent; 20 | import android.os.Bundle; 21 | 22 | import com.agna.setmaster.R; 23 | import com.agna.setmaster.ui.base.activity.BaseActivity; 24 | 25 | /** 26 | * 27 | */ 28 | public class MainActivity extends BaseActivity { 29 | 30 | public static void start(Activity activity) { 31 | Intent i = new Intent(activity, MainActivity.class); 32 | i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 33 | activity.finish(); 34 | activity.startActivity(i); 35 | } 36 | 37 | @Override 38 | public void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | setContentView(R.layout.activity_main); 41 | if (savedInstanceState == null) { 42 | addFragment(R.id.container, MainFragmentView.newInstance(), MainFragmentView.class.getSimpleName()); 43 | } 44 | 45 | /*AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE); 46 | Intent intent = new Intent(this, TimeBroadcastReceiver.class); 47 | //Intent i = new Intent(appContext, MainActivity.class); 48 | PendingIntent result = PendingIntent.getBroadcast(this, 1111, intent, 0); 49 | Calendar c = Calendar.getInstance(); 50 | c.add(Calendar.MILLISECOND, 2000); 51 | am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), result); 52 | 53 | Intent intent2 = new Intent(this, TimeBroadcastReceiver.class); 54 | PendingIntent result2 = PendingIntent.getBroadcast(this, 11112, intent2, 0); 55 | Calendar c2 = Calendar.getInstance(); 56 | c2.add(Calendar.MILLISECOND, 5000); 57 | am.set(AlarmManager.RTC_WAKEUP, c2.getTimeInMillis(), result2);*/ 58 | } 59 | 60 | protected void addFragment(int containerViewId, android.support.v4.app.Fragment fragment, String tag) { 61 | android.support.v4.app.FragmentTransaction fragmentTransaction = this.getSupportFragmentManager().beginTransaction(); 62 | fragmentTransaction.add(containerViewId, fragment, tag); 63 | fragmentTransaction.commit(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/main/MainComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.main; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.fragment.FragmentModule; 21 | 22 | import dagger.Component; 23 | 24 | /** 25 | * 26 | */ 27 | @Component(dependencies = AppComponent.class, modules = {FragmentModule.class}) 28 | @PerScreen 29 | public interface MainComponent { 30 | void inject(MainFragmentView view); 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/main/MainPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.main; 17 | 18 | import com.agna.setmaster.domain.Profile; 19 | import com.agna.setmaster.interactor.profile.ProfileService; 20 | import com.agna.setmaster.app.scheduler.SchedulersProvider; 21 | import com.agna.setmaster.ui.base.BasePresenter; 22 | import com.agna.setmaster.ui.base.PerScreen; 23 | import com.agna.setmaster.ui.common.navigation.Navigator; 24 | 25 | import java.util.ArrayList; 26 | 27 | import javax.inject.Inject; 28 | 29 | /** 30 | * 31 | */ 32 | @PerScreen 33 | public class MainPresenter extends BasePresenter { 34 | 35 | private ProfileService profileService; 36 | private Navigator navigator; 37 | private SchedulersProvider schedulersProvider; 38 | private ArrayList profiles = new ArrayList<>(); 39 | 40 | @Inject 41 | public MainPresenter(ProfileService profileService, 42 | Navigator navigator, 43 | SchedulersProvider schedulersProvider) { 44 | this.profileService = profileService; 45 | this.navigator = navigator; 46 | this.schedulersProvider = schedulersProvider; 47 | } 48 | 49 | @Override 50 | public void onLoad() { 51 | super.onLoad(); 52 | showData(); 53 | observeChanges(); 54 | } 55 | 56 | private void observeChanges() { 57 | profileService.observeProfileChanged() 58 | .observeOn(schedulersProvider.main()) 59 | .subscribe(event -> showData()); 60 | } 61 | 62 | private void showData() { 63 | profiles = profileService.getAllProfiles(); 64 | getView().showProfiles(profiles); 65 | } 66 | 67 | public void createNewProfile() { 68 | navigator.openNewProfile(); 69 | } 70 | 71 | public void onStart() { 72 | showData(); 73 | } 74 | 75 | public void openProfile(Profile profile) { 76 | navigator.openProfile(profile); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/ProfileComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | import com.agna.setmaster.ui.base.dialog.module.ActivityDialogModule; 22 | 23 | import dagger.Component; 24 | 25 | /** 26 | * 27 | */ 28 | @Component(dependencies = AppComponent.class, modules = { 29 | ActivityModule.class, 30 | ProfileScreenModule.class, 31 | ActivityDialogModule.class}) 32 | @PerScreen 33 | public interface ProfileComponent { 34 | void inject(ProfileActivity activity); 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/ProfileScreenModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile; 17 | 18 | import com.agna.setmaster.domain.Profile; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | 21 | import dagger.Module; 22 | import dagger.Provides; 23 | 24 | /** 25 | * 26 | */ 27 | @Module 28 | public class ProfileScreenModule { 29 | private Profile profile; 30 | 31 | public ProfileScreenModule(Profile profile) { 32 | this.profile = profile; 33 | } 34 | 35 | @Provides 36 | @PerScreen 37 | public Profile provideProfile() { 38 | return profile; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/condition/holder/ConditionHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.condition.holder; 17 | 18 | import com.agna.setmaster.domain.condition.Condition; 19 | 20 | /** 21 | * 22 | */ 23 | public interface ConditionHolder { 24 | void bind(C condition); 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/SettingGridLayoutManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting; 17 | 18 | import android.content.Context; 19 | import android.support.v7.widget.GridLayoutManager; 20 | import android.util.AttributeSet; 21 | 22 | /** 23 | * 24 | */ 25 | public class SettingGridLayoutManager extends GridLayoutManager { 26 | 27 | public SettingGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 28 | super(context, attrs, defStyleAttr, defStyleRes); 29 | } 30 | 31 | public SettingGridLayoutManager(Context context, int spanCount) { 32 | super(context, spanCount); 33 | } 34 | 35 | public SettingGridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) { 36 | super(context, spanCount, orientation, reverseLayout); 37 | } 38 | 39 | @Override 40 | public boolean canScrollVertically() { 41 | return false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/change/ChangeSettingDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.change; 17 | 18 | import android.app.Dialog; 19 | import android.content.Context; 20 | import android.os.Bundle; 21 | import android.view.ViewGroup; 22 | 23 | /** 24 | * 25 | */ 26 | public class ChangeSettingDialog extends Dialog { 27 | public ChangeSettingDialog(Context context) { 28 | super(context); 29 | } 30 | 31 | public ChangeSettingDialog(Context context, int themeResId) { 32 | super(context, themeResId); 33 | } 34 | 35 | protected ChangeSettingDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { 36 | super(context, cancelable, cancelListener); 37 | } 38 | 39 | @Override 40 | protected void onCreate(Bundle savedInstanceState) { 41 | super.onCreate(savedInstanceState); 42 | getWindow().setLayout( 43 | ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/change/OnSettingChangeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.change; 17 | 18 | import com.agna.setmaster.domain.setting.Setting; 19 | 20 | /** 21 | * 22 | */ 23 | public interface OnSettingChangeListener { 24 | void onSettingChanged(Setting setting); 25 | 26 | void onSettingDeleted(Setting setting); 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/change/SettingChangeDialogFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.change; 17 | 18 | import android.content.Context; 19 | import android.support.annotation.ColorInt; 20 | 21 | import com.agna.setmaster.domain.Profile; 22 | import com.agna.setmaster.domain.setting.Setting; 23 | import com.agna.setmaster.domain.setting.ValuableSetting; 24 | import com.agna.setmaster.ui.base.PerScreen; 25 | import com.agna.setmaster.ui.base.dialog.BaseDialog; 26 | import com.agna.setmaster.ui.util.ProfileViewUtil; 27 | 28 | import javax.inject.Inject; 29 | 30 | /** 31 | * 32 | */ 33 | @PerScreen 34 | public class SettingChangeDialogFactory { 35 | private Context context; 36 | 37 | @Inject 38 | public SettingChangeDialogFactory(Context context) { 39 | 40 | this.context = context; 41 | } 42 | 43 | public BaseDialog createDialog(Profile profile, Setting setting) { 44 | @ColorInt int accentColor = ProfileViewUtil.getProfileAccentColor(context, profile); 45 | if (setting instanceof ValuableSetting) { 46 | return ChangeVolumeSettingDialog.newInstance((ValuableSetting) setting, accentColor); 47 | } else { 48 | throw new IllegalArgumentException("Unsupported setting: " + setting.getClass().getSimpleName()); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/holder/AddSettingViewHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.holder; 17 | 18 | import android.support.v7.widget.RecyclerView; 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | 23 | import com.agna.setmaster.R; 24 | import com.agna.setmaster.ui.screen.profile.setting.SettingGridAdapter; 25 | 26 | /** 27 | * 28 | */ 29 | public class AddSettingViewHolder extends RecyclerView.ViewHolder { 30 | public AddSettingViewHolder(View itemView, SettingGridAdapter.OnAddSettingClickListener listener) { 31 | super(itemView); 32 | View conatiner = itemView.findViewById(R.id.setting_container); 33 | conatiner.setOnClickListener(v -> listener.onClick()); 34 | 35 | 36 | } 37 | 38 | public static AddSettingViewHolder newInstance(ViewGroup parent, SettingGridAdapter.OnAddSettingClickListener listener) { 39 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.add_setting_grid_item_layout, parent, false); 40 | return new AddSettingViewHolder(v, listener); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/holder/MediaVolumeSettingHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.holder; 17 | 18 | import android.support.v7.widget.RecyclerView; 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.ImageView; 23 | import android.widget.TextView; 24 | 25 | import com.agna.setmaster.R; 26 | import com.agna.setmaster.domain.setting.MediaVolumeSetting; 27 | import com.agna.setmaster.ui.screen.profile.setting.SettingGridAdapter; 28 | 29 | /** 30 | * 31 | */ 32 | public class MediaVolumeSettingHolder extends RecyclerView.ViewHolder { 33 | protected final SettingGridItemPreviewProgress value; 34 | protected final TextView name; 35 | protected final ImageView icon; 36 | private final View conatiner; 37 | 38 | public MediaVolumeSettingHolder(View itemView, SettingGridAdapter.OnSettingHolderClickListener listener) { 39 | super(itemView); 40 | conatiner = itemView.findViewById(R.id.setting_container); 41 | icon = (ImageView) itemView.findViewById(R.id.setting_icon); 42 | name = (TextView) itemView.findViewById(R.id.setting_name); 43 | value = (SettingGridItemPreviewProgress) itemView.findViewById(R.id.setting_value); 44 | conatiner.setOnClickListener(v -> listener.onClick(v, getAdapterPosition())); 45 | } 46 | 47 | public void bind(MediaVolumeSetting setting) { 48 | icon.setImageResource(setting.isEnabled() 49 | ? R.drawable.ic_setting_media_volume_on 50 | : R.drawable.ic_setting_media_volume_off); 51 | name.setText(R.string.setting_name_media_volume); 52 | value.setValue(setting.getValue()); 53 | } 54 | 55 | public static MediaVolumeSettingHolder newInstance(ViewGroup parent, SettingGridAdapter.OnSettingHolderClickListener listener) { 56 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.setting_volume_grid_item_layout, parent, false); 57 | return new MediaVolumeSettingHolder(v, listener); 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/holder/RingSettingHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.holder; 17 | 18 | import android.support.v7.widget.RecyclerView; 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.ImageView; 23 | import android.widget.TextView; 24 | 25 | import com.agna.setmaster.R; 26 | import com.agna.setmaster.domain.setting.RingSetting; 27 | import com.agna.setmaster.ui.screen.profile.setting.SettingGridAdapter; 28 | 29 | /** 30 | * 31 | */ 32 | public class RingSettingHolder extends RecyclerView.ViewHolder { 33 | protected final SettingGridItemPreviewProgress value; 34 | protected final TextView name; 35 | protected final ImageView icon; 36 | private final View container; 37 | 38 | public RingSettingHolder(View itemView, SettingGridAdapter.OnSettingHolderClickListener listener) { 39 | super(itemView); 40 | container = itemView.findViewById(R.id.setting_container); 41 | icon = (ImageView) itemView.findViewById(R.id.setting_icon); 42 | name = (TextView) itemView.findViewById(R.id.setting_name); 43 | value = (SettingGridItemPreviewProgress) itemView.findViewById(R.id.setting_value); 44 | container.setOnClickListener(v -> listener.onClick(v, getAdapterPosition())); 45 | } 46 | 47 | public void bind(RingSetting setting) { 48 | icon.setImageResource(setting.isEnabled() 49 | ? R.drawable.ic_setting_ring_on 50 | : R.drawable.ic_setting_ring_off); 51 | name.setText(R.string.setting_name_ring); 52 | value.setValue(setting.getValue()); 53 | } 54 | 55 | public static RingSettingHolder newInstance(ViewGroup parent, SettingGridAdapter.OnSettingHolderClickListener listener) { 56 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.setting_volume_grid_item_layout, parent, false); 57 | return new RingSettingHolder(v, listener); 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/holder/SettingGridItemPreviewProgress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.holder; 17 | 18 | import android.content.Context; 19 | import android.graphics.Canvas; 20 | import android.graphics.Paint; 21 | import android.util.AttributeSet; 22 | import android.view.View; 23 | 24 | /** 25 | * 26 | */ 27 | public class SettingGridItemPreviewProgress extends View { 28 | private int w; 29 | private int h; 30 | private Paint paint = new Paint(); 31 | private float value; 32 | 33 | public SettingGridItemPreviewProgress(Context context) { 34 | super(context); 35 | } 36 | 37 | public SettingGridItemPreviewProgress(Context context, AttributeSet attrs) { 38 | super(context, attrs); 39 | } 40 | 41 | public SettingGridItemPreviewProgress(Context context, AttributeSet attrs, int defStyleAttr) { 42 | super(context, attrs, defStyleAttr); 43 | } 44 | 45 | public SettingGridItemPreviewProgress(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 46 | super(context, attrs, defStyleAttr, defStyleRes); 47 | } 48 | 49 | public void setValue(float value) { 50 | this.value = value; 51 | invalidate(); 52 | } 53 | 54 | @Override 55 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 56 | this.w = w; 57 | this.h = h; 58 | super.onSizeChanged(w, h, oldw, oldh); 59 | } 60 | 61 | @Override 62 | protected void onDraw(Canvas canvas) { 63 | canvas.drawColor(0x66ffffff); 64 | paint.setColor(0xffffffff); 65 | canvas.drawRect(0, 0, w * value, h, paint); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/splash/SplashActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.splash; 17 | 18 | import android.os.Bundle; 19 | 20 | import com.agna.setmaster.R; 21 | import com.agna.setmaster.ui.base.BasePresenter; 22 | import com.agna.setmaster.ui.base.activity.ActivityModule; 23 | import com.agna.setmaster.ui.base.activity.BaseActivityView; 24 | 25 | import javax.inject.Inject; 26 | 27 | public class SplashActivity extends BaseActivityView { 28 | 29 | @Inject 30 | SplashPresenter splashPresenter; 31 | 32 | @Override 33 | protected void satisfyDependencies() { 34 | DaggerSplashComponent.builder() 35 | .activityModule(new ActivityModule(this)) 36 | .appComponent(getApplicationComponent()) 37 | .build() 38 | .inject(this); 39 | } 40 | 41 | @Override 42 | protected int getContentView() { 43 | return R.layout.activity_splash; 44 | } 45 | 46 | @Override 47 | public void onCreate(Bundle savedInstanceState) { 48 | super.onCreate(savedInstanceState); 49 | } 50 | 51 | @Override 52 | public String getName() { 53 | return "Splash"; 54 | } 55 | 56 | @Override 57 | public BasePresenter getPresenter() { 58 | return splashPresenter; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/splash/SplashComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.splash; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | 22 | import dagger.Component; 23 | 24 | @PerScreen 25 | @Component(dependencies = AppComponent.class, modules = ActivityModule.class) 26 | public interface SplashComponent { 27 | void inject(SplashActivity fragment); 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/splash/SplashPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.splash; 17 | 18 | import com.agna.setmaster.interactor.initialize.InitializeAppInteractor; 19 | import com.agna.setmaster.app.scheduler.SchedulersProvider; 20 | import com.agna.setmaster.interactor.service.AppServiceInteractor; 21 | import com.agna.setmaster.ui.base.BasePresenter; 22 | import com.agna.setmaster.ui.base.PerScreen; 23 | import com.agna.setmaster.ui.common.navigation.Navigator; 24 | 25 | import java.util.concurrent.TimeUnit; 26 | 27 | import javax.inject.Inject; 28 | 29 | import rx.Observable; 30 | 31 | /** 32 | * presenter экрана сплеша 33 | */ 34 | @PerScreen 35 | public class SplashPresenter extends BasePresenter { 36 | 37 | private InitializeAppInteractor initializeAppInteractor; 38 | private AppServiceInteractor appServiceInteractor; 39 | private Navigator navigator; 40 | private final SchedulersProvider schedulersProvider; 41 | 42 | @Inject 43 | public SplashPresenter(InitializeAppInteractor initializeAppInteractor, 44 | AppServiceInteractor appServiceInteractor, 45 | Navigator navigator, 46 | SchedulersProvider schedulersProvider) { 47 | this.initializeAppInteractor = initializeAppInteractor; 48 | this.appServiceInteractor = appServiceInteractor; 49 | this.navigator = navigator; 50 | this.schedulersProvider = schedulersProvider; 51 | } 52 | 53 | @Override 54 | public void onLoad() { 55 | super.onLoad(); 56 | appServiceInteractor.start(); 57 | Observable.zip( 58 | initializeAppInteractor.initialize(), 59 | Observable.timer(500, TimeUnit.MILLISECONDS), 60 | (o1, o2) -> null) 61 | .observeOn(schedulersProvider.main()) 62 | .subscribe(this::onInitialized); 63 | } 64 | 65 | private void onInitialized(Object o) { 66 | navigator.openMain(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/ConditionViewUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.util; 17 | 18 | import com.agna.setmaster.R; 19 | import com.agna.setmaster.domain.condition.Condition; 20 | import com.agna.setmaster.domain.condition.TimeCondition; 21 | import com.agna.setmaster.domain.condition.WiFiCondition; 22 | 23 | /** 24 | * 25 | */ 26 | public class ConditionViewUtil { 27 | public static int getConditionImage(Class extends Condition> conditionClass) { 28 | if (conditionClass == TimeCondition.class) { 29 | return R.drawable.ic_cond_time; 30 | } else if (conditionClass == WiFiCondition.class) { 31 | return R.drawable.ic_cond_wifi; 32 | } else { 33 | throw new IllegalArgumentException("Unsupported condition " + conditionClass.getSimpleName()); 34 | } 35 | } 36 | 37 | public static int getConditionName(Class extends Condition> conditionClass) { 38 | if (conditionClass == TimeCondition.class) { 39 | return R.string.condition_name_time; 40 | } else if (conditionClass == WiFiCondition.class) { 41 | return R.string.condition_name_wifi; 42 | } else { 43 | throw new IllegalArgumentException("Unsupported condition " + conditionClass.getSimpleName()); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/ProfileViewUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.util; 17 | 18 | import android.content.Context; 19 | import android.support.v4.content.ContextCompat; 20 | 21 | import com.agna.setmaster.R; 22 | import com.agna.setmaster.domain.Profile; 23 | 24 | public class ProfileViewUtil { 25 | public static int getProfileStatusText(Profile profile) { 26 | if (profile.isActive()) { 27 | return R.string.profile_status_active; 28 | } else { 29 | return R.string.profile_status_inactive; 30 | } 31 | } 32 | 33 | public static int getProfileAccentColor(Context context, Profile profile) { 34 | boolean activeProfile = profile != null && profile.isActive(); 35 | int backgroundColor = activeProfile 36 | ? ContextCompat.getColor(context, R.color.profile_active_bg) 37 | : ContextCompat.getColor(context, R.color.profile_inactive_bg); 38 | return backgroundColor; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/SettingUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.util; 17 | 18 | import com.agna.setmaster.domain.setting.Setting; 19 | 20 | /** 21 | * 22 | */ 23 | public class SettingUtil { 24 | public static Setting newInstance(Class extends Setting> settingClass) { 25 | try { 26 | return settingClass.newInstance(); 27 | } catch (InstantiationException e) { 28 | throw new RuntimeException(e); 29 | } catch (IllegalAccessException e) { 30 | throw new RuntimeException(e); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/SettingViewUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.util; 17 | 18 | import com.agna.setmaster.R; 19 | import com.agna.setmaster.domain.setting.MediaVolumeSetting; 20 | import com.agna.setmaster.domain.setting.RingSetting; 21 | import com.agna.setmaster.domain.setting.Setting; 22 | 23 | /** 24 | * 25 | */ 26 | public class SettingViewUtil { 27 | 28 | public static int getSettingImage(Class extends Setting> settingClass) { 29 | if (settingClass == RingSetting.class) { 30 | return R.drawable.ic_setting_ring_on; 31 | } else if (settingClass == MediaVolumeSetting.class) { 32 | return R.drawable.ic_setting_media_volume_on; 33 | } else { 34 | throw new IllegalArgumentException("Unsupported setting " + settingClass.getSimpleName()); 35 | } 36 | } 37 | 38 | public static int getSettingName(Class extends Setting> settingClass) { 39 | if (settingClass == RingSetting.class) { 40 | return R.string.setting_name_ring; 41 | } else if (settingClass == MediaVolumeSetting.class) { 42 | return R.string.setting_name_media_volume; 43 | } else { 44 | throw new IllegalArgumentException("Unsupported setting " + settingClass.getSimpleName()); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/StatusBarUtil.java: -------------------------------------------------------------------------------- 1 | package com.agna.setmaster.ui.util; 2 | 3 | import android.os.Build; 4 | import android.support.v4.content.ContextCompat; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.Window; 7 | import android.view.WindowManager; 8 | 9 | import com.agna.setmaster.R; 10 | 11 | /** 12 | * 13 | */ 14 | public class StatusBarUtil { 15 | public static void changeColor(AppCompatActivity activity, boolean active) { 16 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 17 | int colorRes = active 18 | ? R.color.status_bar_active 19 | : R.color.status_bar_inactive; 20 | Window window = activity.getWindow(); 21 | int color = ContextCompat.getColor(activity, colorRes); 22 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 23 | window.setStatusBarColor(color); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/util/CloneUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.util; 17 | 18 | import com.agna.setmaster.domain.ConditionSet; 19 | import com.agna.setmaster.domain.Profile; 20 | import com.agna.setmaster.domain.condition.Condition; 21 | import com.agna.setmaster.domain.setting.Setting; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | /** 27 | * 28 | */ 29 | public class CloneUtil { 30 | 31 | public static ArrayList cloneSettingList(List collection) { 32 | ArrayList clone = new ArrayList<>(collection.size()); 33 | for (Setting item : collection) clone.add(item.clone()); 34 | return clone; 35 | } 36 | 37 | public static ArrayList cloneConditionSetList(List collection) { 38 | ArrayList clone = new ArrayList<>(collection.size()); 39 | for (ConditionSet item : collection) clone.add(item.clone()); 40 | return clone; 41 | } 42 | 43 | public static ArrayList cloneConditionList(List collection) { 44 | ArrayList clone = new ArrayList<>(collection.size()); 45 | for (Condition item : collection) clone.add(item.clone()); 46 | return clone; 47 | } 48 | 49 | public static ArrayList cloneProfiles(List collection) { 50 | ArrayList clone = new ArrayList<>(collection.size()); 51 | for (Profile item : collection) clone.add(item.clone()); 52 | return clone; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/util/ProfileIconHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.util; 17 | 18 | import android.support.annotation.DrawableRes; 19 | 20 | import com.agna.setmaster.R; 21 | 22 | import java.util.Arrays; 23 | import java.util.List; 24 | 25 | /** 26 | * 27 | */ 28 | public class ProfileIconHelper { 29 | 30 | private static List icons = Arrays.asList( 31 | 32 | R.drawable.ic_profile_world, 33 | R.drawable.ic_profile_city, 34 | R.drawable.ic_profile_home, 35 | R.drawable.ic_profile_moon, 36 | R.drawable.ic_profile_mountains, 37 | R.drawable.ic_profile_school, 38 | R.drawable.ic_profile_sun, 39 | R.drawable.ic_profile_speaker, 40 | R.drawable.ic_profile_sea, 41 | R.drawable.ic_profile_restaurant, 42 | R.drawable.ic_profile_night, 43 | R.drawable.ic_profile_world_2, 44 | R.drawable.ic_profile_library, 45 | R.drawable.ic_profile_business, 46 | R.drawable.ic_profile_bar, 47 | R.drawable.ic_profile_bagage, 48 | R.drawable.ic_profile_airplanemode_on 49 | ); 50 | 51 | @DrawableRes 52 | public static int getIconRes(int iconId){ 53 | return icons.get(iconId); 54 | } 55 | 56 | public static List getAll() { 57 | return icons; 58 | } 59 | 60 | public static int getGlobalProfileIconId() { 61 | return 0; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/util/TimeUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.util; 17 | 18 | import com.agna.setmaster.domain.DayOfWeek; 19 | 20 | import java.util.Calendar; 21 | 22 | /** 23 | * 24 | */ 25 | public class TimeUtil { 26 | public static DayOfWeek getCurrentDayOfWeek() { 27 | Calendar calendar = Calendar.getInstance(); 28 | int day = calendar.get(Calendar.DAY_OF_WEEK); 29 | if (day == 1) { //sunday 30 | day = 8; 31 | } 32 | day -= 2; //start from 0 33 | return DayOfWeek.ENUMS[day]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/res/color/day_of_week_text_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/add_condition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/add_condition.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/add_condition_set.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/add_condition_set.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/gear.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_add_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_add_circle.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_add_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_add_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_check_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_check_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_clear.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_cond_time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_cond_time.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_cond_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_cond_wifi.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_do_not_disturb_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_do_not_disturb_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_edit.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_expand_more_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_expand_more_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_gps_fixed_grey600_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_gps_fixed_grey600_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_location.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_more_vert_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_notifications_on_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_notifications_on_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_other_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_other_2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_phone_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_phone_2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_phone_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_phone_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_phone_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_phone_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_pr_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_pr_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_airplanemode_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_airplanemode_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_bagage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_bagage.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_bar.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_business.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_business.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_city.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_city.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_library.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_library.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_moon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_moon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_mountains.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_mountains.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_night.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_restaurant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_restaurant.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_school.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_school.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_sea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_sea.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_speaker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_speaker.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_sun.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_world.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_world_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_world_2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_screen_lock_rotation_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_screen_lock_rotation_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting_media_volume_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_setting_media_volume_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting_media_volume_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_setting_media_volume_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting_ring_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_setting_ring_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting_ring_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_setting_ring_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_null.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_null.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_null_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_null_gray.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_wifi_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_wifi_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_wifi_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_wifi_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_wifi_statusbar_null_grey600_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_wifi_statusbar_null_grey600_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_star_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_star_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_time.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_vibration_black_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_vibration_black_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_vibration_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_vibration_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_vibration_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_vibration_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_volume_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_volume_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_volume_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_volume_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_edit_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxxhdpi/ic_edit_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/big_white_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/black_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/blue_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/day_of_week_blue_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/day_of_week_red_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/red_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/setting_seek_thumb.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/small_white_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/transparent.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main_old.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 17 | 22 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_condition_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 17 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_condition_list_item_layout.xml: -------------------------------------------------------------------------------- 1 | 4 | 11 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_condition_or_condition_set_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 19 | 20 | 25 | 26 | 36 | 37 | 38 | 39 | 46 | 47 | 52 | 53 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_setting_grid_item_layout.xml: -------------------------------------------------------------------------------- 1 | 3 | 10 | 16 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/change_volume_setting_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 27 | 28 | 37 | 38 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /app/src/main/res/layout/change_wifi_condition_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 18 | 19 | 26 | 27 | 37 | 38 | 39 | 50 | 51 | 52 | 59 | -------------------------------------------------------------------------------- /app/src/main/res/layout/choose_setting_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/codition_list_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 20 | 26 | 33 | 42 | 43 | 50 | 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/condition_set_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/condition_set_view_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/days_of_week_view_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 15 | 16 | 17 | 21 | 22 | 26 | 27 | 28 | 32 | 33 | 37 | 38 | 39 | 43 | 44 | 48 | 49 | 50 | 54 | 55 | 59 | 60 | 61 | 65 | 66 | 70 | 71 | 72 | 76 | 77 | 81 | 82 | -------------------------------------------------------------------------------- /app/src/main/res/layout/empty_footer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 16 | 24 | 25 | 31 | 32 | 33 | 45 | -------------------------------------------------------------------------------- /app/src/main/res/layout/icon_grid_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/network_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/profile_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 24 | 25 | 36 | 49 | 50 | 59 | 60 | -------------------------------------------------------------------------------- /app/src/main/res/layout/profile_list_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_grid_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 11 | 16 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_list_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_preview_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_preview_layout_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_volume_grid_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 11 | 16 | 22 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/menu/profile_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Settings 4 | Активен 5 | Неактивен 6 | СОХРАНИТЬ 7 | Название профиля 8 | Профиль 9 | Громкость медиа 10 | Громкость звонка 11 | Добавить настройку 12 | Удалить 13 | Содать набор условий 14 | Добавить условие 15 | Время / день недели 16 | Подключение к Wi-Fi 17 | Активно 18 | пн 19 | вт 20 | ср 21 | чт 22 | пт 23 | сб 24 | вс 25 | от 26 | Дни недели 27 | до 28 | Профили -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #e04658 4 | #4a5591 5 | #11FFFFFF 6 | #e03654 7 | #ffffffff 8 | #252930 9 | #aaaaaa 10 | #424242 11 | #2f353d 12 | #c03648 13 | #3a4581 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 47dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CleanApp 3 | 4 | Settings 5 | Active 6 | Inactive 7 | SAVE 8 | Profile name 9 | Profile 10 | Media volume 11 | Ring volume 12 | Add setting 13 | Delete 14 | Create condition set 15 | Add condition 16 | Time / day of week 17 | Connecting to Wi-Fi 18 | Active 19 | mo 20 | tu 21 | we 22 | th 23 | fr 24 | sa 25 | su 26 | from 27 | Days of week 28 | to 29 | Profiles 30 | SetMaster 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 21 | 22 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | jcenter() 7 | mavenCentral() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:2.1.2' 11 | classpath 'me.tatarka:gradle-retrolambda:3.2.0' 12 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | repositories { 20 | mavenCentral() 21 | } 22 | 23 | 24 | allprojects { 25 | repositories { 26 | jcenter() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /setmaster.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/setmaster.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------
28 | * имеет методы, соответствующие жизненному циклу view 29 | * при пересоздании View, заново создается и презентер 30 | * 31 | * @param тип View 32 | * если V не интерфейс, то использование методов View, относящихся к андроид фреймворку запрещено 33 | */ 34 | public class BasePresenter { 35 | 36 | private CompositeSubscription compositeSubscription = new CompositeSubscription(); 37 | 38 | private V view; 39 | 40 | public void attachView(V view) { 41 | this.view = view; 42 | } 43 | 44 | protected V getView() { 45 | return view; 46 | } 47 | 48 | public void onLoad() { 49 | } 50 | 51 | public void onDestroy() { 52 | if (!compositeSubscription.isUnsubscribed()) { 53 | compositeSubscription.unsubscribe(); 54 | } 55 | } 56 | 57 | public void onRestore(@NonNull Bundle savedInstanceState) { 58 | } 59 | 60 | public void onSave(@NonNull Bundle outState) { 61 | } 62 | 63 | protected void addToSubscriptions(Subscription subscription) { 64 | compositeSubscription.add(subscription); 65 | } 66 | 67 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/BaseView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base; 17 | 18 | /** 19 | * 20 | */ 21 | public interface BaseView { 22 | BasePresenter getPresenter(); 23 | 24 | void initPresenter(); 25 | 26 | void goBack(); 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/HasName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base; 17 | 18 | public interface HasName { 19 | String getName(); 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/PerScreen.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base; 17 | 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.RetentionPolicy; 20 | 21 | import javax.inject.Scope; 22 | 23 | /** 24 | * 25 | */ 26 | @Scope 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface PerScreen { 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/activity/ActivityModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.activity; 17 | 18 | import android.support.v7.app.AppCompatActivity; 19 | 20 | import com.agna.setmaster.ui.base.PerScreen; 21 | 22 | import dagger.Module; 23 | import dagger.Provides; 24 | 25 | @Module 26 | public class ActivityModule { 27 | private AppCompatActivity activity; 28 | 29 | public ActivityModule(AppCompatActivity activity) { 30 | this.activity = activity; 31 | } 32 | 33 | @Provides 34 | @PerScreen 35 | AppCompatActivity provideActivity() { 36 | return activity; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/activity/BaseActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.activity; 17 | 18 | import android.os.Bundle; 19 | import android.support.v7.app.AppCompatActivity; 20 | 21 | import com.agna.setmaster.app.App; 22 | import com.agna.setmaster.app.dagger.AppComponent; 23 | 24 | 25 | /** 26 | * бызовый класс всех Activity 27 | */ 28 | public class BaseActivity extends AppCompatActivity { 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | } 34 | 35 | protected AppComponent getApplicationComponent() { 36 | return ((App) getApplication()).getAppComponent(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/ActivityDialogManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog; 17 | 18 | import android.support.v7.app.AppCompatActivity; 19 | 20 | import com.agna.setmaster.ui.base.PerScreen; 21 | 22 | import javax.inject.Inject; 23 | 24 | @PerScreen 25 | public class ActivityDialogManager implements DialogManager { 26 | private AppCompatActivity activity; 27 | 28 | @Inject 29 | public ActivityDialogManager(AppCompatActivity activity) { 30 | this.activity = activity; 31 | } 32 | 33 | @Override 34 | public void show(BaseDialog dialog) { 35 | dialog.show(activity); 36 | } 37 | 38 | @Override 39 | public void show(BaseBottomSheetDialog dialog) { 40 | dialog.show(activity); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/DialogManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog; 17 | 18 | /** 19 | * Сущность, отвечающая за показывание и скрывание диалогов 20 | */ 21 | public interface DialogManager { 22 | void show(BaseDialog dialog); 23 | 24 | void show(BaseBottomSheetDialog dialog); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/FragmentDialogManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog; 17 | 18 | 19 | import android.support.v4.app.Fragment; 20 | 21 | import com.agna.setmaster.ui.base.PerScreen; 22 | 23 | import javax.inject.Inject; 24 | 25 | @PerScreen 26 | public class FragmentDialogManager implements DialogManager { 27 | 28 | private Fragment fragment; 29 | 30 | @Inject 31 | public FragmentDialogManager(Fragment fragment) { 32 | this.fragment = fragment; 33 | } 34 | 35 | @Override 36 | public void show(BaseDialog dialog) { 37 | dialog.show(fragment); 38 | } 39 | 40 | @Override 41 | public void show(BaseBottomSheetDialog dialog) { 42 | dialog.show(fragment); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/module/ActivityDialogModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog.module; 17 | 18 | import com.agna.setmaster.ui.base.PerScreen; 19 | import com.agna.setmaster.ui.base.dialog.ActivityDialogManager; 20 | import com.agna.setmaster.ui.base.dialog.DialogManager; 21 | 22 | import dagger.Module; 23 | import dagger.Provides; 24 | 25 | /** 26 | * 27 | */ 28 | @Module 29 | public class ActivityDialogModule { 30 | @Provides 31 | @PerScreen 32 | DialogManager provideDialogManager(ActivityDialogManager dialogManager) { 33 | return dialogManager; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/dialog/module/FragmentDialogModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.dialog.module; 17 | 18 | import com.agna.setmaster.ui.base.PerScreen; 19 | import com.agna.setmaster.ui.base.dialog.DialogManager; 20 | import com.agna.setmaster.ui.base.dialog.FragmentDialogManager; 21 | 22 | import dagger.Module; 23 | import dagger.Provides; 24 | 25 | /** 26 | * 27 | */ 28 | @Module 29 | public class FragmentDialogModule { 30 | 31 | @Provides 32 | @PerScreen 33 | DialogManager provideDialogManager(FragmentDialogManager dialogManager) { 34 | return dialogManager; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/base/fragment/FragmentModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.base.fragment; 17 | 18 | import android.support.v4.app.Fragment; 19 | import android.support.v7.app.AppCompatActivity; 20 | 21 | import com.agna.setmaster.ui.base.PerScreen; 22 | 23 | import dagger.Module; 24 | import dagger.Provides; 25 | 26 | @Module 27 | public class FragmentModule { 28 | private Fragment fragment; 29 | 30 | public FragmentModule(Fragment fragment) { 31 | this.fragment = fragment; 32 | } 33 | 34 | @Provides 35 | @PerScreen 36 | Fragment provideFragment() { 37 | return fragment; 38 | } 39 | 40 | @Provides 41 | @PerScreen 42 | AppCompatActivity provideActivity() { 43 | return (AppCompatActivity) fragment.getActivity(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/common/navigation/Navigator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.common.navigation; 17 | 18 | import android.support.v7.app.AppCompatActivity; 19 | 20 | import com.agna.setmaster.domain.Profile; 21 | import com.agna.setmaster.domain.condition.Condition; 22 | import com.agna.setmaster.domain.condition.TimeCondition; 23 | import com.agna.setmaster.domain.condition.WiFiCondition; 24 | import com.agna.setmaster.ui.base.PerScreen; 25 | import com.agna.setmaster.ui.screen.condition.time.ChangeTimeConditionActivity; 26 | import com.agna.setmaster.ui.screen.condition.wifi.ChangeWifiConditionActivity; 27 | import com.agna.setmaster.ui.screen.editprofile.EditProfileActivity; 28 | import com.agna.setmaster.ui.screen.main.MainActivity; 29 | import com.agna.setmaster.ui.screen.profile.ProfileActivity; 30 | 31 | import javax.inject.Inject; 32 | 33 | /** 34 | * 35 | */ 36 | @PerScreen 37 | public class Navigator { 38 | 39 | private AppCompatActivity activity; 40 | 41 | @Inject 42 | public Navigator(AppCompatActivity activity) { 43 | this.activity = activity; 44 | } 45 | 46 | public void openMain() { 47 | MainActivity.start(activity); 48 | } 49 | 50 | public void openNewProfile() { 51 | EditProfileActivity.start(activity, null); 52 | } 53 | 54 | public void openProfile(Profile profile) { 55 | ProfileActivity.start(activity, profile); 56 | } 57 | 58 | public void openEditProfile(Profile profile) { 59 | EditProfileActivity.start(activity, profile); 60 | } 61 | 62 | public void openChangeCondition(Condition condition, Profile profile) { 63 | if (condition instanceof TimeCondition) { 64 | ChangeTimeConditionActivity.start(activity, (TimeCondition) condition, profile); 65 | } else if (condition instanceof WiFiCondition) { 66 | ChangeWifiConditionActivity.start(activity, (WiFiCondition) condition, profile); 67 | } else { 68 | throw new IllegalArgumentException("Unsupported condition: " + condition); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/ChangeConditionBaseActivityView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition; 17 | 18 | import android.content.Intent; 19 | 20 | import com.agna.setmaster.ui.base.activity.BaseActivityView; 21 | 22 | /** 23 | * 24 | */ 25 | public abstract class ChangeConditionBaseActivityView extends BaseActivityView { 26 | public static final String EXTRA_CONDITION = "EXTRA_CONDITION"; 27 | 28 | public void goBack(int result, Intent data) { 29 | setResult(result, data); 30 | finish(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/time/ChangeTimeConditionComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.time; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | import com.agna.setmaster.ui.base.dialog.module.ActivityDialogModule; 22 | 23 | import dagger.Component; 24 | 25 | /** 26 | * 27 | */ 28 | @Component(dependencies = AppComponent.class, modules = { 29 | ActivityModule.class, 30 | ActivityDialogModule.class, 31 | TimeConditionModule.class}) 32 | @PerScreen 33 | public interface ChangeTimeConditionComponent { 34 | void inject(ChangeTimeConditionActivity activity); 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/time/ChangeTimeConditionPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.time; 17 | 18 | import android.app.Activity; 19 | import android.content.Intent; 20 | 21 | import com.agna.setmaster.domain.DayOfWeek; 22 | import com.agna.setmaster.domain.condition.TimeCondition; 23 | import com.agna.setmaster.ui.base.BasePresenter; 24 | import com.agna.setmaster.ui.base.PerScreen; 25 | import com.agna.setmaster.ui.base.dialog.DialogManager; 26 | import com.agna.setmaster.ui.screen.condition.ChangeConditionBaseActivityView; 27 | 28 | import java.util.ArrayList; 29 | import java.util.Date; 30 | 31 | import javax.inject.Inject; 32 | 33 | /** 34 | * 35 | */ 36 | @PerScreen 37 | public class ChangeTimeConditionPresenter extends BasePresenter { 38 | 39 | private DialogManager dialogManager; 40 | private TimeCondition condition; 41 | 42 | @Inject 43 | public ChangeTimeConditionPresenter(DialogManager dialogManager, TimeCondition timeCondition) { 44 | 45 | this.dialogManager = dialogManager; 46 | this.condition = timeCondition; 47 | } 48 | 49 | @Override 50 | public void onLoad() { 51 | super.onLoad(); 52 | getView().bind(condition); 53 | } 54 | 55 | public void saveCondition(Date from, Date to, ArrayList days) { 56 | condition.setFrom(from); 57 | condition.setTo(to); 58 | condition.setDays(days); 59 | Intent i = new Intent(); 60 | i.putExtra(ChangeConditionBaseActivityView.EXTRA_CONDITION, condition); 61 | getView().goBack(Activity.RESULT_OK, i); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/time/TimeConditionModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.time; 17 | 18 | import com.agna.setmaster.domain.condition.TimeCondition; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | 21 | import dagger.Module; 22 | import dagger.Provides; 23 | 24 | /** 25 | * 26 | */ 27 | @Module 28 | public class TimeConditionModule { 29 | private TimeCondition timeCondition; 30 | 31 | public TimeConditionModule(TimeCondition timeCondition) { 32 | this.timeCondition = timeCondition; 33 | } 34 | 35 | @Provides 36 | @PerScreen 37 | TimeCondition provideTimeCondition(){ 38 | return timeCondition; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/wifi/ChangeWifiConditionComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.wifi; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | import com.agna.setmaster.ui.base.dialog.module.ActivityDialogModule; 22 | 23 | import dagger.Component; 24 | 25 | /** 26 | * 27 | */ 28 | @Component(dependencies = AppComponent.class, modules = { 29 | ActivityModule.class, 30 | ChangeWifiConditionModule.class, 31 | ActivityDialogModule.class}) 32 | @PerScreen 33 | public interface ChangeWifiConditionComponent { 34 | void inject(ChangeWifiConditionActivity activity); 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/wifi/ChangeWifiConditionModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.wifi; 17 | 18 | import android.content.Context; 19 | import android.net.wifi.WifiConfiguration; 20 | import android.net.wifi.WifiManager; 21 | 22 | import com.agna.setmaster.domain.condition.WiFiCondition; 23 | import com.agna.setmaster.ui.base.PerScreen; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | import dagger.Module; 29 | import dagger.Provides; 30 | 31 | /** 32 | * 33 | */ 34 | @Module 35 | public class ChangeWifiConditionModule { 36 | 37 | private WiFiCondition condition; 38 | 39 | public ChangeWifiConditionModule(WiFiCondition condition) { 40 | this.condition = condition; 41 | } 42 | 43 | @Provides 44 | @PerScreen 45 | WiFiCondition provideWiFiCondition(){ 46 | return condition; 47 | } 48 | 49 | @Provides 50 | @PerScreen 51 | ArrayList provideWifiNetworks(Context context) { 52 | ArrayList result = new ArrayList<>(); 53 | WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); 54 | List configurations = wifiManager.getConfiguredNetworks(); 55 | result.addAll(configurations); 56 | return result; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/condition/wifi/ChangeWifiConditionPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.condition.wifi; 17 | 18 | import android.app.Activity; 19 | import android.content.Intent; 20 | import android.net.wifi.WifiConfiguration; 21 | 22 | import com.agna.setmaster.domain.condition.WiFiCondition; 23 | import com.agna.setmaster.ui.base.BasePresenter; 24 | import com.agna.setmaster.ui.base.PerScreen; 25 | import com.agna.setmaster.ui.base.dialog.DialogManager; 26 | import com.agna.setmaster.ui.screen.condition.ChangeConditionBaseActivityView; 27 | 28 | import java.util.ArrayList; 29 | 30 | import javax.inject.Inject; 31 | 32 | /** 33 | * 34 | */ 35 | @PerScreen 36 | public class ChangeWifiConditionPresenter extends BasePresenter { 37 | 38 | private DialogManager dialogManager; 39 | private ArrayList wifiNetworks; 40 | private WiFiCondition condition; 41 | 42 | @Inject 43 | public ChangeWifiConditionPresenter(DialogManager dialogManager, 44 | ArrayList wifiNetworks, 45 | WiFiCondition condition) { 46 | 47 | this.dialogManager = dialogManager; 48 | this.wifiNetworks = wifiNetworks; 49 | this.condition = condition; 50 | } 51 | 52 | @Override 53 | public void onLoad() { 54 | super.onLoad(); 55 | getView().showNetworks(wifiNetworks); 56 | getView().bind(condition); 57 | } 58 | 59 | public void saveCondition(WifiConfiguration wifiConfiguration) { 60 | condition.setNetworkName(wifiConfiguration.SSID); 61 | Intent i = new Intent(); 62 | i.putExtra(ChangeConditionBaseActivityView.EXTRA_CONDITION, condition); 63 | getView().goBack(Activity.RESULT_OK, i); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/editprofile/EditProfileComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.editprofile; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | 22 | import dagger.Component; 23 | 24 | /** 25 | * 26 | */ 27 | @PerScreen 28 | @Component(dependencies = AppComponent.class, modules = { 29 | ActivityModule.class, 30 | EditProfileScreenModule.class}) 31 | public interface EditProfileComponent { 32 | void inject(EditProfileActivity view); 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/editprofile/EditProfilePresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.editprofile; 17 | 18 | import com.agna.setmaster.domain.Profile; 19 | import com.agna.setmaster.interactor.profile.ProfileService; 20 | import com.agna.setmaster.ui.base.BasePresenter; 21 | import com.agna.setmaster.ui.base.PerScreen; 22 | import com.agna.setmaster.ui.common.navigation.Navigator; 23 | 24 | import javax.inject.Inject; 25 | 26 | /** 27 | * 28 | */ 29 | @PerScreen 30 | public class EditProfilePresenter extends BasePresenter { 31 | 32 | private final Navigator navigator; 33 | private final ProfileService profileService; 34 | 35 | private Profile profile; 36 | 37 | @Inject 38 | public EditProfilePresenter(ProfileService profileService, Navigator navigator, ProfileHolder profileHolder) { 39 | this.profileService = profileService; 40 | this.navigator = navigator; 41 | this.profile = profileHolder.getProfile(); 42 | } 43 | 44 | public void saveProfile(String name, int iconRes) { 45 | if (profile == null) { 46 | profile = new Profile(name, iconRes); 47 | profileService.addProfile(profile); 48 | } else { 49 | profile.setName(name); 50 | profile.setIconId(iconRes); 51 | profileService.updateProfile(profile); 52 | } 53 | getView().goBack(); 54 | navigator.openProfile(profileService.getProfile(profile.getId())); 55 | } 56 | 57 | @Override 58 | public void onLoad() { 59 | super.onLoad(); 60 | getView().bindProfile(profile); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/editprofile/EditProfileScreenModule.java: -------------------------------------------------------------------------------- 1 | package com.agna.setmaster.ui.screen.editprofile; 2 | 3 | import com.agna.setmaster.domain.Profile; 4 | import com.agna.setmaster.ui.base.PerScreen; 5 | 6 | import dagger.Module; 7 | import dagger.Provides; 8 | 9 | /** 10 | * 11 | */ 12 | @Module 13 | public class EditProfileScreenModule { 14 | private Profile profile; 15 | 16 | public EditProfileScreenModule(Profile profile) { 17 | this.profile = profile; 18 | } 19 | 20 | @Provides 21 | @PerScreen 22 | public ProfileHolder provideProfile() { 23 | return new ProfileHolder(profile); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/editprofile/ProfileHolder.java: -------------------------------------------------------------------------------- 1 | package com.agna.setmaster.ui.screen.editprofile; 2 | 3 | import com.agna.setmaster.domain.Profile; 4 | 5 | /** 6 | * 7 | */ 8 | public class ProfileHolder { 9 | private Profile profile; 10 | 11 | public ProfileHolder(Profile profile) { 12 | this.profile = profile; 13 | } 14 | 15 | public Profile getProfile() { 16 | return profile; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/main/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.main; 17 | 18 | import android.app.Activity; 19 | import android.content.Intent; 20 | import android.os.Bundle; 21 | 22 | import com.agna.setmaster.R; 23 | import com.agna.setmaster.ui.base.activity.BaseActivity; 24 | 25 | /** 26 | * 27 | */ 28 | public class MainActivity extends BaseActivity { 29 | 30 | public static void start(Activity activity) { 31 | Intent i = new Intent(activity, MainActivity.class); 32 | i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 33 | activity.finish(); 34 | activity.startActivity(i); 35 | } 36 | 37 | @Override 38 | public void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | setContentView(R.layout.activity_main); 41 | if (savedInstanceState == null) { 42 | addFragment(R.id.container, MainFragmentView.newInstance(), MainFragmentView.class.getSimpleName()); 43 | } 44 | 45 | /*AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE); 46 | Intent intent = new Intent(this, TimeBroadcastReceiver.class); 47 | //Intent i = new Intent(appContext, MainActivity.class); 48 | PendingIntent result = PendingIntent.getBroadcast(this, 1111, intent, 0); 49 | Calendar c = Calendar.getInstance(); 50 | c.add(Calendar.MILLISECOND, 2000); 51 | am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), result); 52 | 53 | Intent intent2 = new Intent(this, TimeBroadcastReceiver.class); 54 | PendingIntent result2 = PendingIntent.getBroadcast(this, 11112, intent2, 0); 55 | Calendar c2 = Calendar.getInstance(); 56 | c2.add(Calendar.MILLISECOND, 5000); 57 | am.set(AlarmManager.RTC_WAKEUP, c2.getTimeInMillis(), result2);*/ 58 | } 59 | 60 | protected void addFragment(int containerViewId, android.support.v4.app.Fragment fragment, String tag) { 61 | android.support.v4.app.FragmentTransaction fragmentTransaction = this.getSupportFragmentManager().beginTransaction(); 62 | fragmentTransaction.add(containerViewId, fragment, tag); 63 | fragmentTransaction.commit(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/main/MainComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.main; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.fragment.FragmentModule; 21 | 22 | import dagger.Component; 23 | 24 | /** 25 | * 26 | */ 27 | @Component(dependencies = AppComponent.class, modules = {FragmentModule.class}) 28 | @PerScreen 29 | public interface MainComponent { 30 | void inject(MainFragmentView view); 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/main/MainPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.main; 17 | 18 | import com.agna.setmaster.domain.Profile; 19 | import com.agna.setmaster.interactor.profile.ProfileService; 20 | import com.agna.setmaster.app.scheduler.SchedulersProvider; 21 | import com.agna.setmaster.ui.base.BasePresenter; 22 | import com.agna.setmaster.ui.base.PerScreen; 23 | import com.agna.setmaster.ui.common.navigation.Navigator; 24 | 25 | import java.util.ArrayList; 26 | 27 | import javax.inject.Inject; 28 | 29 | /** 30 | * 31 | */ 32 | @PerScreen 33 | public class MainPresenter extends BasePresenter { 34 | 35 | private ProfileService profileService; 36 | private Navigator navigator; 37 | private SchedulersProvider schedulersProvider; 38 | private ArrayList profiles = new ArrayList<>(); 39 | 40 | @Inject 41 | public MainPresenter(ProfileService profileService, 42 | Navigator navigator, 43 | SchedulersProvider schedulersProvider) { 44 | this.profileService = profileService; 45 | this.navigator = navigator; 46 | this.schedulersProvider = schedulersProvider; 47 | } 48 | 49 | @Override 50 | public void onLoad() { 51 | super.onLoad(); 52 | showData(); 53 | observeChanges(); 54 | } 55 | 56 | private void observeChanges() { 57 | profileService.observeProfileChanged() 58 | .observeOn(schedulersProvider.main()) 59 | .subscribe(event -> showData()); 60 | } 61 | 62 | private void showData() { 63 | profiles = profileService.getAllProfiles(); 64 | getView().showProfiles(profiles); 65 | } 66 | 67 | public void createNewProfile() { 68 | navigator.openNewProfile(); 69 | } 70 | 71 | public void onStart() { 72 | showData(); 73 | } 74 | 75 | public void openProfile(Profile profile) { 76 | navigator.openProfile(profile); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/ProfileComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | import com.agna.setmaster.ui.base.dialog.module.ActivityDialogModule; 22 | 23 | import dagger.Component; 24 | 25 | /** 26 | * 27 | */ 28 | @Component(dependencies = AppComponent.class, modules = { 29 | ActivityModule.class, 30 | ProfileScreenModule.class, 31 | ActivityDialogModule.class}) 32 | @PerScreen 33 | public interface ProfileComponent { 34 | void inject(ProfileActivity activity); 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/ProfileScreenModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile; 17 | 18 | import com.agna.setmaster.domain.Profile; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | 21 | import dagger.Module; 22 | import dagger.Provides; 23 | 24 | /** 25 | * 26 | */ 27 | @Module 28 | public class ProfileScreenModule { 29 | private Profile profile; 30 | 31 | public ProfileScreenModule(Profile profile) { 32 | this.profile = profile; 33 | } 34 | 35 | @Provides 36 | @PerScreen 37 | public Profile provideProfile() { 38 | return profile; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/condition/holder/ConditionHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.condition.holder; 17 | 18 | import com.agna.setmaster.domain.condition.Condition; 19 | 20 | /** 21 | * 22 | */ 23 | public interface ConditionHolder { 24 | void bind(C condition); 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/SettingGridLayoutManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting; 17 | 18 | import android.content.Context; 19 | import android.support.v7.widget.GridLayoutManager; 20 | import android.util.AttributeSet; 21 | 22 | /** 23 | * 24 | */ 25 | public class SettingGridLayoutManager extends GridLayoutManager { 26 | 27 | public SettingGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 28 | super(context, attrs, defStyleAttr, defStyleRes); 29 | } 30 | 31 | public SettingGridLayoutManager(Context context, int spanCount) { 32 | super(context, spanCount); 33 | } 34 | 35 | public SettingGridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) { 36 | super(context, spanCount, orientation, reverseLayout); 37 | } 38 | 39 | @Override 40 | public boolean canScrollVertically() { 41 | return false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/change/ChangeSettingDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.change; 17 | 18 | import android.app.Dialog; 19 | import android.content.Context; 20 | import android.os.Bundle; 21 | import android.view.ViewGroup; 22 | 23 | /** 24 | * 25 | */ 26 | public class ChangeSettingDialog extends Dialog { 27 | public ChangeSettingDialog(Context context) { 28 | super(context); 29 | } 30 | 31 | public ChangeSettingDialog(Context context, int themeResId) { 32 | super(context, themeResId); 33 | } 34 | 35 | protected ChangeSettingDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { 36 | super(context, cancelable, cancelListener); 37 | } 38 | 39 | @Override 40 | protected void onCreate(Bundle savedInstanceState) { 41 | super.onCreate(savedInstanceState); 42 | getWindow().setLayout( 43 | ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/change/OnSettingChangeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.change; 17 | 18 | import com.agna.setmaster.domain.setting.Setting; 19 | 20 | /** 21 | * 22 | */ 23 | public interface OnSettingChangeListener { 24 | void onSettingChanged(Setting setting); 25 | 26 | void onSettingDeleted(Setting setting); 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/change/SettingChangeDialogFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.change; 17 | 18 | import android.content.Context; 19 | import android.support.annotation.ColorInt; 20 | 21 | import com.agna.setmaster.domain.Profile; 22 | import com.agna.setmaster.domain.setting.Setting; 23 | import com.agna.setmaster.domain.setting.ValuableSetting; 24 | import com.agna.setmaster.ui.base.PerScreen; 25 | import com.agna.setmaster.ui.base.dialog.BaseDialog; 26 | import com.agna.setmaster.ui.util.ProfileViewUtil; 27 | 28 | import javax.inject.Inject; 29 | 30 | /** 31 | * 32 | */ 33 | @PerScreen 34 | public class SettingChangeDialogFactory { 35 | private Context context; 36 | 37 | @Inject 38 | public SettingChangeDialogFactory(Context context) { 39 | 40 | this.context = context; 41 | } 42 | 43 | public BaseDialog createDialog(Profile profile, Setting setting) { 44 | @ColorInt int accentColor = ProfileViewUtil.getProfileAccentColor(context, profile); 45 | if (setting instanceof ValuableSetting) { 46 | return ChangeVolumeSettingDialog.newInstance((ValuableSetting) setting, accentColor); 47 | } else { 48 | throw new IllegalArgumentException("Unsupported setting: " + setting.getClass().getSimpleName()); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/holder/AddSettingViewHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.holder; 17 | 18 | import android.support.v7.widget.RecyclerView; 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | 23 | import com.agna.setmaster.R; 24 | import com.agna.setmaster.ui.screen.profile.setting.SettingGridAdapter; 25 | 26 | /** 27 | * 28 | */ 29 | public class AddSettingViewHolder extends RecyclerView.ViewHolder { 30 | public AddSettingViewHolder(View itemView, SettingGridAdapter.OnAddSettingClickListener listener) { 31 | super(itemView); 32 | View conatiner = itemView.findViewById(R.id.setting_container); 33 | conatiner.setOnClickListener(v -> listener.onClick()); 34 | 35 | 36 | } 37 | 38 | public static AddSettingViewHolder newInstance(ViewGroup parent, SettingGridAdapter.OnAddSettingClickListener listener) { 39 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.add_setting_grid_item_layout, parent, false); 40 | return new AddSettingViewHolder(v, listener); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/holder/MediaVolumeSettingHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.holder; 17 | 18 | import android.support.v7.widget.RecyclerView; 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.ImageView; 23 | import android.widget.TextView; 24 | 25 | import com.agna.setmaster.R; 26 | import com.agna.setmaster.domain.setting.MediaVolumeSetting; 27 | import com.agna.setmaster.ui.screen.profile.setting.SettingGridAdapter; 28 | 29 | /** 30 | * 31 | */ 32 | public class MediaVolumeSettingHolder extends RecyclerView.ViewHolder { 33 | protected final SettingGridItemPreviewProgress value; 34 | protected final TextView name; 35 | protected final ImageView icon; 36 | private final View conatiner; 37 | 38 | public MediaVolumeSettingHolder(View itemView, SettingGridAdapter.OnSettingHolderClickListener listener) { 39 | super(itemView); 40 | conatiner = itemView.findViewById(R.id.setting_container); 41 | icon = (ImageView) itemView.findViewById(R.id.setting_icon); 42 | name = (TextView) itemView.findViewById(R.id.setting_name); 43 | value = (SettingGridItemPreviewProgress) itemView.findViewById(R.id.setting_value); 44 | conatiner.setOnClickListener(v -> listener.onClick(v, getAdapterPosition())); 45 | } 46 | 47 | public void bind(MediaVolumeSetting setting) { 48 | icon.setImageResource(setting.isEnabled() 49 | ? R.drawable.ic_setting_media_volume_on 50 | : R.drawable.ic_setting_media_volume_off); 51 | name.setText(R.string.setting_name_media_volume); 52 | value.setValue(setting.getValue()); 53 | } 54 | 55 | public static MediaVolumeSettingHolder newInstance(ViewGroup parent, SettingGridAdapter.OnSettingHolderClickListener listener) { 56 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.setting_volume_grid_item_layout, parent, false); 57 | return new MediaVolumeSettingHolder(v, listener); 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/holder/RingSettingHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.holder; 17 | 18 | import android.support.v7.widget.RecyclerView; 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.ImageView; 23 | import android.widget.TextView; 24 | 25 | import com.agna.setmaster.R; 26 | import com.agna.setmaster.domain.setting.RingSetting; 27 | import com.agna.setmaster.ui.screen.profile.setting.SettingGridAdapter; 28 | 29 | /** 30 | * 31 | */ 32 | public class RingSettingHolder extends RecyclerView.ViewHolder { 33 | protected final SettingGridItemPreviewProgress value; 34 | protected final TextView name; 35 | protected final ImageView icon; 36 | private final View container; 37 | 38 | public RingSettingHolder(View itemView, SettingGridAdapter.OnSettingHolderClickListener listener) { 39 | super(itemView); 40 | container = itemView.findViewById(R.id.setting_container); 41 | icon = (ImageView) itemView.findViewById(R.id.setting_icon); 42 | name = (TextView) itemView.findViewById(R.id.setting_name); 43 | value = (SettingGridItemPreviewProgress) itemView.findViewById(R.id.setting_value); 44 | container.setOnClickListener(v -> listener.onClick(v, getAdapterPosition())); 45 | } 46 | 47 | public void bind(RingSetting setting) { 48 | icon.setImageResource(setting.isEnabled() 49 | ? R.drawable.ic_setting_ring_on 50 | : R.drawable.ic_setting_ring_off); 51 | name.setText(R.string.setting_name_ring); 52 | value.setValue(setting.getValue()); 53 | } 54 | 55 | public static RingSettingHolder newInstance(ViewGroup parent, SettingGridAdapter.OnSettingHolderClickListener listener) { 56 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.setting_volume_grid_item_layout, parent, false); 57 | return new RingSettingHolder(v, listener); 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/profile/setting/holder/SettingGridItemPreviewProgress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.profile.setting.holder; 17 | 18 | import android.content.Context; 19 | import android.graphics.Canvas; 20 | import android.graphics.Paint; 21 | import android.util.AttributeSet; 22 | import android.view.View; 23 | 24 | /** 25 | * 26 | */ 27 | public class SettingGridItemPreviewProgress extends View { 28 | private int w; 29 | private int h; 30 | private Paint paint = new Paint(); 31 | private float value; 32 | 33 | public SettingGridItemPreviewProgress(Context context) { 34 | super(context); 35 | } 36 | 37 | public SettingGridItemPreviewProgress(Context context, AttributeSet attrs) { 38 | super(context, attrs); 39 | } 40 | 41 | public SettingGridItemPreviewProgress(Context context, AttributeSet attrs, int defStyleAttr) { 42 | super(context, attrs, defStyleAttr); 43 | } 44 | 45 | public SettingGridItemPreviewProgress(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 46 | super(context, attrs, defStyleAttr, defStyleRes); 47 | } 48 | 49 | public void setValue(float value) { 50 | this.value = value; 51 | invalidate(); 52 | } 53 | 54 | @Override 55 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 56 | this.w = w; 57 | this.h = h; 58 | super.onSizeChanged(w, h, oldw, oldh); 59 | } 60 | 61 | @Override 62 | protected void onDraw(Canvas canvas) { 63 | canvas.drawColor(0x66ffffff); 64 | paint.setColor(0xffffffff); 65 | canvas.drawRect(0, 0, w * value, h, paint); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/splash/SplashActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.splash; 17 | 18 | import android.os.Bundle; 19 | 20 | import com.agna.setmaster.R; 21 | import com.agna.setmaster.ui.base.BasePresenter; 22 | import com.agna.setmaster.ui.base.activity.ActivityModule; 23 | import com.agna.setmaster.ui.base.activity.BaseActivityView; 24 | 25 | import javax.inject.Inject; 26 | 27 | public class SplashActivity extends BaseActivityView { 28 | 29 | @Inject 30 | SplashPresenter splashPresenter; 31 | 32 | @Override 33 | protected void satisfyDependencies() { 34 | DaggerSplashComponent.builder() 35 | .activityModule(new ActivityModule(this)) 36 | .appComponent(getApplicationComponent()) 37 | .build() 38 | .inject(this); 39 | } 40 | 41 | @Override 42 | protected int getContentView() { 43 | return R.layout.activity_splash; 44 | } 45 | 46 | @Override 47 | public void onCreate(Bundle savedInstanceState) { 48 | super.onCreate(savedInstanceState); 49 | } 50 | 51 | @Override 52 | public String getName() { 53 | return "Splash"; 54 | } 55 | 56 | @Override 57 | public BasePresenter getPresenter() { 58 | return splashPresenter; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/splash/SplashComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.splash; 17 | 18 | import com.agna.setmaster.app.dagger.AppComponent; 19 | import com.agna.setmaster.ui.base.PerScreen; 20 | import com.agna.setmaster.ui.base.activity.ActivityModule; 21 | 22 | import dagger.Component; 23 | 24 | @PerScreen 25 | @Component(dependencies = AppComponent.class, modules = ActivityModule.class) 26 | public interface SplashComponent { 27 | void inject(SplashActivity fragment); 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/screen/splash/SplashPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.screen.splash; 17 | 18 | import com.agna.setmaster.interactor.initialize.InitializeAppInteractor; 19 | import com.agna.setmaster.app.scheduler.SchedulersProvider; 20 | import com.agna.setmaster.interactor.service.AppServiceInteractor; 21 | import com.agna.setmaster.ui.base.BasePresenter; 22 | import com.agna.setmaster.ui.base.PerScreen; 23 | import com.agna.setmaster.ui.common.navigation.Navigator; 24 | 25 | import java.util.concurrent.TimeUnit; 26 | 27 | import javax.inject.Inject; 28 | 29 | import rx.Observable; 30 | 31 | /** 32 | * presenter экрана сплеша 33 | */ 34 | @PerScreen 35 | public class SplashPresenter extends BasePresenter { 36 | 37 | private InitializeAppInteractor initializeAppInteractor; 38 | private AppServiceInteractor appServiceInteractor; 39 | private Navigator navigator; 40 | private final SchedulersProvider schedulersProvider; 41 | 42 | @Inject 43 | public SplashPresenter(InitializeAppInteractor initializeAppInteractor, 44 | AppServiceInteractor appServiceInteractor, 45 | Navigator navigator, 46 | SchedulersProvider schedulersProvider) { 47 | this.initializeAppInteractor = initializeAppInteractor; 48 | this.appServiceInteractor = appServiceInteractor; 49 | this.navigator = navigator; 50 | this.schedulersProvider = schedulersProvider; 51 | } 52 | 53 | @Override 54 | public void onLoad() { 55 | super.onLoad(); 56 | appServiceInteractor.start(); 57 | Observable.zip( 58 | initializeAppInteractor.initialize(), 59 | Observable.timer(500, TimeUnit.MILLISECONDS), 60 | (o1, o2) -> null) 61 | .observeOn(schedulersProvider.main()) 62 | .subscribe(this::onInitialized); 63 | } 64 | 65 | private void onInitialized(Object o) { 66 | navigator.openMain(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/ConditionViewUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.util; 17 | 18 | import com.agna.setmaster.R; 19 | import com.agna.setmaster.domain.condition.Condition; 20 | import com.agna.setmaster.domain.condition.TimeCondition; 21 | import com.agna.setmaster.domain.condition.WiFiCondition; 22 | 23 | /** 24 | * 25 | */ 26 | public class ConditionViewUtil { 27 | public static int getConditionImage(Class extends Condition> conditionClass) { 28 | if (conditionClass == TimeCondition.class) { 29 | return R.drawable.ic_cond_time; 30 | } else if (conditionClass == WiFiCondition.class) { 31 | return R.drawable.ic_cond_wifi; 32 | } else { 33 | throw new IllegalArgumentException("Unsupported condition " + conditionClass.getSimpleName()); 34 | } 35 | } 36 | 37 | public static int getConditionName(Class extends Condition> conditionClass) { 38 | if (conditionClass == TimeCondition.class) { 39 | return R.string.condition_name_time; 40 | } else if (conditionClass == WiFiCondition.class) { 41 | return R.string.condition_name_wifi; 42 | } else { 43 | throw new IllegalArgumentException("Unsupported condition " + conditionClass.getSimpleName()); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/ProfileViewUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.util; 17 | 18 | import android.content.Context; 19 | import android.support.v4.content.ContextCompat; 20 | 21 | import com.agna.setmaster.R; 22 | import com.agna.setmaster.domain.Profile; 23 | 24 | public class ProfileViewUtil { 25 | public static int getProfileStatusText(Profile profile) { 26 | if (profile.isActive()) { 27 | return R.string.profile_status_active; 28 | } else { 29 | return R.string.profile_status_inactive; 30 | } 31 | } 32 | 33 | public static int getProfileAccentColor(Context context, Profile profile) { 34 | boolean activeProfile = profile != null && profile.isActive(); 35 | int backgroundColor = activeProfile 36 | ? ContextCompat.getColor(context, R.color.profile_active_bg) 37 | : ContextCompat.getColor(context, R.color.profile_inactive_bg); 38 | return backgroundColor; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/SettingUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.util; 17 | 18 | import com.agna.setmaster.domain.setting.Setting; 19 | 20 | /** 21 | * 22 | */ 23 | public class SettingUtil { 24 | public static Setting newInstance(Class extends Setting> settingClass) { 25 | try { 26 | return settingClass.newInstance(); 27 | } catch (InstantiationException e) { 28 | throw new RuntimeException(e); 29 | } catch (IllegalAccessException e) { 30 | throw new RuntimeException(e); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/SettingViewUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.ui.util; 17 | 18 | import com.agna.setmaster.R; 19 | import com.agna.setmaster.domain.setting.MediaVolumeSetting; 20 | import com.agna.setmaster.domain.setting.RingSetting; 21 | import com.agna.setmaster.domain.setting.Setting; 22 | 23 | /** 24 | * 25 | */ 26 | public class SettingViewUtil { 27 | 28 | public static int getSettingImage(Class extends Setting> settingClass) { 29 | if (settingClass == RingSetting.class) { 30 | return R.drawable.ic_setting_ring_on; 31 | } else if (settingClass == MediaVolumeSetting.class) { 32 | return R.drawable.ic_setting_media_volume_on; 33 | } else { 34 | throw new IllegalArgumentException("Unsupported setting " + settingClass.getSimpleName()); 35 | } 36 | } 37 | 38 | public static int getSettingName(Class extends Setting> settingClass) { 39 | if (settingClass == RingSetting.class) { 40 | return R.string.setting_name_ring; 41 | } else if (settingClass == MediaVolumeSetting.class) { 42 | return R.string.setting_name_media_volume; 43 | } else { 44 | throw new IllegalArgumentException("Unsupported setting " + settingClass.getSimpleName()); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/ui/util/StatusBarUtil.java: -------------------------------------------------------------------------------- 1 | package com.agna.setmaster.ui.util; 2 | 3 | import android.os.Build; 4 | import android.support.v4.content.ContextCompat; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.Window; 7 | import android.view.WindowManager; 8 | 9 | import com.agna.setmaster.R; 10 | 11 | /** 12 | * 13 | */ 14 | public class StatusBarUtil { 15 | public static void changeColor(AppCompatActivity activity, boolean active) { 16 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 17 | int colorRes = active 18 | ? R.color.status_bar_active 19 | : R.color.status_bar_inactive; 20 | Window window = activity.getWindow(); 21 | int color = ContextCompat.getColor(activity, colorRes); 22 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 23 | window.setStatusBarColor(color); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/util/CloneUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.util; 17 | 18 | import com.agna.setmaster.domain.ConditionSet; 19 | import com.agna.setmaster.domain.Profile; 20 | import com.agna.setmaster.domain.condition.Condition; 21 | import com.agna.setmaster.domain.setting.Setting; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | /** 27 | * 28 | */ 29 | public class CloneUtil { 30 | 31 | public static ArrayList cloneSettingList(List collection) { 32 | ArrayList clone = new ArrayList<>(collection.size()); 33 | for (Setting item : collection) clone.add(item.clone()); 34 | return clone; 35 | } 36 | 37 | public static ArrayList cloneConditionSetList(List collection) { 38 | ArrayList clone = new ArrayList<>(collection.size()); 39 | for (ConditionSet item : collection) clone.add(item.clone()); 40 | return clone; 41 | } 42 | 43 | public static ArrayList cloneConditionList(List collection) { 44 | ArrayList clone = new ArrayList<>(collection.size()); 45 | for (Condition item : collection) clone.add(item.clone()); 46 | return clone; 47 | } 48 | 49 | public static ArrayList cloneProfiles(List collection) { 50 | ArrayList clone = new ArrayList<>(collection.size()); 51 | for (Profile item : collection) clone.add(item.clone()); 52 | return clone; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/util/ProfileIconHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.util; 17 | 18 | import android.support.annotation.DrawableRes; 19 | 20 | import com.agna.setmaster.R; 21 | 22 | import java.util.Arrays; 23 | import java.util.List; 24 | 25 | /** 26 | * 27 | */ 28 | public class ProfileIconHelper { 29 | 30 | private static List icons = Arrays.asList( 31 | 32 | R.drawable.ic_profile_world, 33 | R.drawable.ic_profile_city, 34 | R.drawable.ic_profile_home, 35 | R.drawable.ic_profile_moon, 36 | R.drawable.ic_profile_mountains, 37 | R.drawable.ic_profile_school, 38 | R.drawable.ic_profile_sun, 39 | R.drawable.ic_profile_speaker, 40 | R.drawable.ic_profile_sea, 41 | R.drawable.ic_profile_restaurant, 42 | R.drawable.ic_profile_night, 43 | R.drawable.ic_profile_world_2, 44 | R.drawable.ic_profile_library, 45 | R.drawable.ic_profile_business, 46 | R.drawable.ic_profile_bar, 47 | R.drawable.ic_profile_bagage, 48 | R.drawable.ic_profile_airplanemode_on 49 | ); 50 | 51 | @DrawableRes 52 | public static int getIconRes(int iconId){ 53 | return icons.get(iconId); 54 | } 55 | 56 | public static List getAll() { 57 | return icons; 58 | } 59 | 60 | public static int getGlobalProfileIconId() { 61 | return 0; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/com/agna/setmaster/util/TimeUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Maxim Tuev. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.agna.setmaster.util; 17 | 18 | import com.agna.setmaster.domain.DayOfWeek; 19 | 20 | import java.util.Calendar; 21 | 22 | /** 23 | * 24 | */ 25 | public class TimeUtil { 26 | public static DayOfWeek getCurrentDayOfWeek() { 27 | Calendar calendar = Calendar.getInstance(); 28 | int day = calendar.get(Calendar.DAY_OF_WEEK); 29 | if (day == 1) { //sunday 30 | day = 8; 31 | } 32 | day -= 2; //start from 0 33 | return DayOfWeek.ENUMS[day]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/res/color/day_of_week_text_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/add_condition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/add_condition.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/add_condition_set.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/add_condition_set.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/gear.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_add_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_add_circle.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_add_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_add_white_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_check_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_check_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_clear.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_cond_time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_cond_time.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_cond_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_cond_wifi.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_do_not_disturb_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_do_not_disturb_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_edit.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_expand_more_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_expand_more_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_gps_fixed_grey600_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_gps_fixed_grey600_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_location.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_more_vert_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_notifications_on_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_notifications_on_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_other_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_other_2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_phone_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_phone_2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_phone_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_phone_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_phone_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_phone_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_pr_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_pr_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_airplanemode_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_airplanemode_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_bagage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_bagage.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_bar.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_business.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_business.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_city.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_city.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_library.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_library.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_moon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_moon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_mountains.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_mountains.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_night.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_restaurant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_restaurant.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_school.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_school.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_sea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_sea.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_speaker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_speaker.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_sun.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_world.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_profile_world_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_profile_world_2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_screen_lock_rotation_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_screen_lock_rotation_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting_media_volume_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_setting_media_volume_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting_media_volume_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_setting_media_volume_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting_ring_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_setting_ring_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting_ring_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_setting_ring_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_null.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_null.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_null_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_null_gray.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_wifi_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_wifi_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_wifi_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_wifi_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_signal_wifi_statusbar_null_grey600_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_signal_wifi_statusbar_null_grey600_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_star_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_star_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_time.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_vibration_black_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_vibration_black_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_vibration_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_vibration_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_vibration_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_vibration_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_volume_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_volume_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_volume_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxhdpi/ic_volume_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_edit_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/drawable-xxxhdpi/ic_edit_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/big_white_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/black_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/blue_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/day_of_week_blue_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/day_of_week_red_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/red_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/setting_seek_thumb.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/small_white_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/transparent.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main_old.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 17 | 22 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_condition_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 17 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_condition_list_item_layout.xml: -------------------------------------------------------------------------------- 1 | 4 | 11 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_condition_or_condition_set_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 19 | 20 | 25 | 26 | 36 | 37 | 38 | 39 | 46 | 47 | 52 | 53 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_setting_grid_item_layout.xml: -------------------------------------------------------------------------------- 1 | 3 | 10 | 16 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/change_volume_setting_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 27 | 28 | 37 | 38 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /app/src/main/res/layout/change_wifi_condition_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 18 | 19 | 26 | 27 | 37 | 38 | 39 | 50 | 51 | 52 | 59 | -------------------------------------------------------------------------------- /app/src/main/res/layout/choose_setting_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/codition_list_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 20 | 26 | 33 | 42 | 43 | 50 | 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/condition_set_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/condition_set_view_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/days_of_week_view_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 15 | 16 | 17 | 21 | 22 | 26 | 27 | 28 | 32 | 33 | 37 | 38 | 39 | 43 | 44 | 48 | 49 | 50 | 54 | 55 | 59 | 60 | 61 | 65 | 66 | 70 | 71 | 72 | 76 | 77 | 81 | 82 | -------------------------------------------------------------------------------- /app/src/main/res/layout/empty_footer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 16 | 24 | 25 | 31 | 32 | 33 | 45 | -------------------------------------------------------------------------------- /app/src/main/res/layout/icon_grid_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/network_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/profile_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 24 | 25 | 36 | 49 | 50 | 59 | 60 | -------------------------------------------------------------------------------- /app/src/main/res/layout/profile_list_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_grid_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 11 | 16 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_list_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_preview_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_preview_layout_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_volume_grid_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 11 | 16 | 22 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/menu/profile_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Settings 4 | Активен 5 | Неактивен 6 | СОХРАНИТЬ 7 | Название профиля 8 | Профиль 9 | Громкость медиа 10 | Громкость звонка 11 | Добавить настройку 12 | Удалить 13 | Содать набор условий 14 | Добавить условие 15 | Время / день недели 16 | Подключение к Wi-Fi 17 | Активно 18 | пн 19 | вт 20 | ср 21 | чт 22 | пт 23 | сб 24 | вс 25 | от 26 | Дни недели 27 | до 28 | Профили -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #e04658 4 | #4a5591 5 | #11FFFFFF 6 | #e03654 7 | #ffffffff 8 | #252930 9 | #aaaaaa 10 | #424242 11 | #2f353d 12 | #c03648 13 | #3a4581 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 47dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CleanApp 3 | 4 | Settings 5 | Active 6 | Inactive 7 | SAVE 8 | Profile name 9 | Profile 10 | Media volume 11 | Ring volume 12 | Add setting 13 | Delete 14 | Create condition set 15 | Add condition 16 | Time / day of week 17 | Connecting to Wi-Fi 18 | Active 19 | mo 20 | tu 21 | we 22 | th 23 | fr 24 | sa 25 | su 26 | from 27 | Days of week 28 | to 29 | Profiles 30 | SetMaster 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 21 | 22 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | jcenter() 7 | mavenCentral() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:2.1.2' 11 | classpath 'me.tatarka:gradle-retrolambda:3.2.0' 12 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | repositories { 20 | mavenCentral() 21 | } 22 | 23 | 24 | allprojects { 25 | repositories { 26 | jcenter() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /setmaster.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaksTuev/clean_app/6499770959ed46e01773567c42274590f854c476/setmaster.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------