Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #141 from alexstyl/static_analysis
Browse files Browse the repository at this point in the history
Static analysis
  • Loading branch information
alexstyl committed Aug 10, 2017
2 parents 5b8f092 + 7c145d7 commit 67c68c3
Show file tree
Hide file tree
Showing 170 changed files with 1,440 additions and 1,281 deletions.
27 changes: 25 additions & 2 deletions android_mobile/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
buildscript {
dependencies {
classpath 'com.novoda:build-properties-plugin:1.2.1'
}
}

plugins {
id "io.gitlab.arturbosch.detekt" version "1.0.0.M13.2"
}

apply from: '../versions.gradle'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'com.novoda.build-properties'

detekt {
version = "1.0.0.M13.2"

profile("main") {
input = "$projectDir/src/main/java"
config = "$rootDir/team-props/static-analysis/detekt-config.yml"
filters = ".*test.*,.*/resources/.*,.*/tmp/.*"
output = "$projectDir/build/reports/detekt.xml"
}
}

project.afterEvaluate {
check.dependsOn tasks['detektCheck']
}

android {
compileSdkVersion androidCompileSdkVersion
Expand Down Expand Up @@ -105,6 +130,4 @@ dependencies {
androidTestCompile 'junit:junit:4.12'
}

// This must be applied after the dependencies closure in order to avoid conflicts ¯\_(ツ)_/¯
// see http://stackoverflow.com/questions/38127053/google-play-services-gcm-9-2-0-asks-to-update-back-to-9-0-0
apply plugin: 'com.google.gms.google-services'
9 changes: 0 additions & 9 deletions android_mobile/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@
</intent-filter>
</activity>

<activity
android:name=".person.PlayGroundActivity"
android:label="Test and stuff">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.alexstyl.specialdates;

import com.alexstyl.specialdates.debug.DebugFragment;
import com.alexstyl.specialdates.events.namedays.NamedayModule;

import javax.inject.Singleton;

import dagger.Component;

@Singleton
@Component(modules = {NamedayModule.class})
public interface DebugAppComponent {

void inject(DebugFragment fragment);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
package com.alexstyl.specialdates;

import android.content.Context;

import com.alexstyl.specialdates.events.namedays.NamedayModule;

public class DebugApplication extends MementoApplication {

private DebugAppComponent debugAppComponent;

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
debugAppComponent =
DaggerDebugAppComponent.builder()
.namedayModule(new NamedayModule(this))
.build();
}

@Override
protected void initialiseDependencies() {
super.initialiseDependencies();
new OptionalDependencies(this).initialise();
}

public DebugAppComponent getDebugAppComponent() {
return debugAppComponent;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
import android.widget.DatePicker;
import android.widget.Toast;

import com.alexstyl.specialdates.DebugAppComponent;
import com.alexstyl.specialdates.DebugApplication;
import com.alexstyl.specialdates.R;
import com.alexstyl.specialdates.dailyreminder.DailyReminderDebugPreferences;
import com.alexstyl.specialdates.dailyreminder.DailyReminderIntentService;
import com.alexstyl.specialdates.date.Date;
import com.alexstyl.specialdates.donate.DebugDonationPreferences;
import com.alexstyl.specialdates.events.namedays.NamedayUserSettings;
import com.alexstyl.specialdates.events.peopleevents.DebugPeopleEventsUpdater;
import com.alexstyl.specialdates.events.peopleevents.PeopleEventsViewRefresher;
import com.alexstyl.specialdates.facebook.friendimport.FacebookFriendsIntentService;
Expand All @@ -23,30 +26,37 @@
import com.alexstyl.specialdates.ui.base.MementoPreferenceFragment;
import com.alexstyl.specialdates.wear.WearSyncPeopleEventsView;

import javax.inject.Inject;
import java.util.Calendar;

public class DebugFragment extends MementoPreferenceFragment {

private DailyReminderDebugPreferences dailyReminderDebugPreferences;
@Inject
NamedayUserSettings namedayUserSettings;

@Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);

DebugAppComponent debugAppComponent = ((DebugApplication) getActivity().getApplication()).getDebugAppComponent();
debugAppComponent.inject(this);

addPreferencesFromResource(R.xml.preference_debug);
dailyReminderDebugPreferences = DailyReminderDebugPreferences.newInstance(getActivity());
findPreference(R.string.key_debug_refresh_db).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
DebugPeopleEventsUpdater.newInstance(getActivity()).refresh();
Toast.makeText(getActivity(), "Refreshing Database", Toast.LENGTH_SHORT).show();
DebugPeopleEventsUpdater.newInstance(getActivity(), namedayUserSettings).refresh();
showToast("Refreshing Database");
return true;
}
});
findPreference(R.string.key_debug_refresh_widget).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
PeopleEventsViewRefresher.get(getActivity()).updateAllViews();
Toast.makeText(getActivity(), "Widget(s) refreshed", Toast.LENGTH_SHORT).show();
showToast("Widget(s) refreshed");
return true;
}
});
Expand Down Expand Up @@ -76,7 +86,7 @@ public boolean onPreferenceClick(Preference preference) {
@Override
public boolean onPreferenceClick(Preference preference) {
DailyReminderIntentService.startService(getActivity());
Toast.makeText(getActivity(), "Daily Reminder Triggered", Toast.LENGTH_SHORT).show();
showToast("Daily Reminder Triggered");
return true;
}
});
Expand Down Expand Up @@ -109,7 +119,8 @@ public boolean onPreferenceClick(Preference preference) {
public boolean onPreferenceClick(Preference preference) {
DebugPreferences.newInstance(preference.getContext(), R.string.pref_call_to_rate).wipe();
new AskForSupport(preference.getContext()).requestForRatingSooner();
Toast.makeText(preference.getContext(), "Support triggered. You should now see a prompt to rate the app when you launch it", Toast.LENGTH_SHORT).show();
String message = "Support triggered. You should now see a prompt to rate the app when you launch it";
showToast(message);
return true;
}
});
Expand All @@ -131,6 +142,10 @@ public boolean onPreferenceClick(Preference preference) {
});
}

private void showToast(String message) {
Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
}

private void startDateIntent() {
Calendar cal = Calendar.getInstance();
Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import com.alexstyl.specialdates.EasyPreferences;

class DebugPreferences {
final class DebugPreferences {

private final EasyPreferences preferences;

public static DebugPreferences newInstance(Context context, @StringRes int prefKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,33 @@
import com.alexstyl.specialdates.contact.ContactsProvider;
import com.alexstyl.specialdates.events.database.EventSQLiteOpenHelper;
import com.alexstyl.specialdates.events.namedays.NamedayDatabaseRefresher;
import com.alexstyl.specialdates.events.namedays.NamedayPreferences;
import com.alexstyl.specialdates.events.namedays.NamedayUserSettings;
import com.alexstyl.specialdates.events.namedays.calendar.resource.NamedayCalendarProvider;
import com.alexstyl.specialdates.util.DateParser;

import static com.alexstyl.specialdates.contact.ContactSource.SOURCE_DEVICE;

public class DebugPeopleEventsUpdater {
public final class DebugPeopleEventsUpdater {

private final DeviceEventsDatabaseRefresher deviceEventsDatabaseRefresher;
private final NamedayDatabaseRefresher namedayDatabaseRefresher;

public static DebugPeopleEventsUpdater newInstance(Context context) {
public static DebugPeopleEventsUpdater newInstance(Context context, NamedayUserSettings namedayUserSettings) {
ContactsProvider contactsProvider = ContactsProvider.get(context);
AndroidEventsRepository repository = new AndroidEventsRepository(context.getContentResolver(), contactsProvider, DateParser.INSTANCE);
ContactEventsMarshaller deviceMarshaller = new ContactEventsMarshaller(SOURCE_DEVICE);
PeopleEventsPersister databaseProvider = new PeopleEventsPersister(new EventSQLiteOpenHelper(context));

DeviceEventsDatabaseRefresher databaseRefresher = new DeviceEventsDatabaseRefresher(repository, deviceMarshaller, databaseProvider);

NamedayPreferences namedayPreferences = NamedayPreferences.newInstance(context);
NamedayCalendarProvider namedayCalendarProvider = NamedayCalendarProvider.newInstance(context.getResources());
PeopleNamedaysCalculator peopleNamedaysCalculator = new PeopleNamedaysCalculator(namedayPreferences, namedayCalendarProvider, contactsProvider);
PeopleNamedaysCalculator peopleNamedaysCalculator = new PeopleNamedaysCalculator(
namedayUserSettings,
namedayCalendarProvider,
contactsProvider
);
return new DebugPeopleEventsUpdater(databaseRefresher, new NamedayDatabaseRefresher(
namedayPreferences,
namedayUserSettings,
databaseProvider,
deviceMarshaller,
peopleNamedaysCalculator
Expand Down

This file was deleted.

Loading

0 comments on commit 67c68c3

Please sign in to comment.