diff --git a/app/build.gradle b/app/build.gradle index b69e3b6..ea195c2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,13 +3,13 @@ apply plugin: 'com.android.application' apply plugin: 'realm-android' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 'android-O' + buildToolsVersion '26.0.0 rc2' defaultConfig { applicationId "io.github.marktony.espresso" minSdkVersion 21 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -31,35 +31,10 @@ android { abortOnError false } - productFlavors { - mock { - applicationIdSuffix = ".mock" - } - prod { - - } - } - - // Remove mockRelease as it's not needed. - android.variantFilter { variant -> - if (variant.buildType.name == 'release' - && variant.getFlavors().get(0).name == 'mock') { - variant.setIgnore(true); - } - } - - // Always show the result of every unit test, even if it passes. - testOptions.unitTests.all { - testLogging { - events 'passed', 'skipped', 'failed', 'standardOut', 'standardError' - } - } - - sourceSets { prod { java.srcDirs = ['src/prod/java', 'src/prod/java/'] } } } ext { - supportLibVersion = '25.3.1' + supportLibVersion = '26.0.0-beta1' rxjavaVersion = '2.0.1' retrofitVersion = '2.2.0' zxingLibVersion = '3.3.0' @@ -92,15 +67,15 @@ dependencies { // Zxing compile "com.google.zxing:core:$zxingLibVersion" // Material date time picker - compile "com.wdullaer:materialdatetimepicker:$datetimePickerVersion" + compile("com.wdullaer:materialdatetimepicker:$datetimePickerVersion"){ + exclude group:'com.android.support' + } // CircleImageView - compile "de.hdodenhof:circleimageview:$circleimageviewVersion" + compile("de.hdodenhof:circleimageview:$circleimageviewVersion"){ + exclude group:'com.android.support' + } testCompile "junit:junit:$junitVersion" - testCompile "org.mockito:mockito-all:$mockitoVersion" - - // Mockito - androidTestCompile "org.mockito:mockito-core:$mockitoVersion" // Espresso androidTestCompile "com.android.support:support-annotations:$supportLibVersion" diff --git a/app/src/androidTest/java/io/github/marktony/espresso/packages/PackagesScreenTest.java b/app/src/androidTest/java/io/github/marktony/espresso/packages/PackagesScreenTest.java index beca415..da9dce2 100644 --- a/app/src/androidTest/java/io/github/marktony/espresso/packages/PackagesScreenTest.java +++ b/app/src/androidTest/java/io/github/marktony/espresso/packages/PackagesScreenTest.java @@ -24,6 +24,7 @@ /** * Created by lizhaotailang on 2017/5/12. + * The tests for {@link io.github.marktony.espresso.mvp.packages.PackagesFragment}. */ @RunWith(AndroidJUnit4.class) diff --git a/app/src/androidTest/java/io/github/marktony/espresso/settings/SettingsScreenTest.java b/app/src/androidTest/java/io/github/marktony/espresso/settings/SettingsScreenTest.java index cb40f27..ee17c75 100644 --- a/app/src/androidTest/java/io/github/marktony/espresso/settings/SettingsScreenTest.java +++ b/app/src/androidTest/java/io/github/marktony/espresso/settings/SettingsScreenTest.java @@ -24,6 +24,7 @@ /** * Created by lizhaotailang on 2017/5/14. + * The tests for {@link io.github.marktony.espresso.ui.SettingsFragment}. */ @RunWith(AndroidJUnit4.class) diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageFragment.java b/app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageFragment.java index 3abacf1..634223f 100644 --- a/app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageFragment.java +++ b/app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageFragment.java @@ -212,12 +212,12 @@ public void initViews(View view) { activity.setSupportActionBar((Toolbar) view.findViewById(R.id.toolbar)); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); - editTextName = (TextInputEditText) view.findViewById(R.id.editTextName); - editTextNumber = (TextInputEditText) view.findViewById(R.id.editTextNumber); - textViewScanCode = (AppCompatTextView) view.findViewById(R.id.textViewScanCode); - fab = (FloatingActionButton) view.findViewById(R.id.fab); - progressBar = (ProgressBar) view.findViewById(R.id.progressBar); - scrollView = (NestedScrollView) view.findViewById(R.id.scrollView); + editTextName = view.findViewById(R.id.editTextName); + editTextNumber = view.findViewById(R.id.editTextNumber); + textViewScanCode = view.findViewById(R.id.textViewScanCode); + fab = view.findViewById(R.id.fab); + progressBar = view.findViewById(R.id.progressBar); + scrollView = view.findViewById(R.id.scrollView); } diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesFragment.java b/app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesFragment.java index 9ee5be3..1e01261 100644 --- a/app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesFragment.java +++ b/app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesFragment.java @@ -103,7 +103,7 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void initViews(View view) { - recyclerView = (RecyclerView) view.findViewById(R.id.recyclerViewCompaniesList); + recyclerView = view.findViewById(R.id.recyclerViewCompaniesList); final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); recyclerView.setLayoutManager(layoutManager); } diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailFragment.java b/app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailFragment.java index a37543b..928f815 100644 --- a/app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailFragment.java +++ b/app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailFragment.java @@ -136,10 +136,10 @@ public void initViews(View view) { activity.setSupportActionBar((Toolbar) view.findViewById(R.id.toolbar)); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); - fab = (FloatingActionButton) view.findViewById(R.id.fab); - textViewCompanyName = (AppCompatTextView) view.findViewById(R.id.textViewCompany); - textViewTel = (AppCompatTextView) view.findViewById(R.id.textViewCompanyPhoneNumber); - textViewWebsite = (AppCompatTextView) view.findViewById(R.id.textViewCompanyWebsite); + fab = view.findViewById(R.id.fab); + textViewCompanyName = view.findViewById(R.id.textViewCompany); + textViewTel = view.findViewById(R.id.textViewCompanyPhoneNumber); + textViewWebsite = view.findViewById(R.id.textViewCompanyWebsite); } @Override diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsFragment.java b/app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsFragment.java index cea7254..86ed830 100644 --- a/app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsFragment.java +++ b/app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsFragment.java @@ -166,12 +166,12 @@ public void initViews(View view) { activity.setSupportActionBar((Toolbar) view.findViewById(R.id.toolbar)); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); - recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); + recyclerView = view.findViewById(R.id.recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - fab = (FloatingActionButton) view.findViewById(R.id.fab); - swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout); + fab = view.findViewById(R.id.fab); + swipeRefreshLayout = view.findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(getContext(), R.color.colorPrimary)); - toolbarLayout = (CollapsingToolbarLayout) view.findViewById(R.id.toolbar_layout); + toolbarLayout = view.findViewById(R.id.toolbar_layout); } diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/packages/MainActivity.java b/app/src/main/java/io/github/marktony/espresso/mvp/packages/MainActivity.java index 36e87e8..b3c56c5 100644 --- a/app/src/main/java/io/github/marktony/espresso/mvp/packages/MainActivity.java +++ b/app/src/main/java/io/github/marktony/espresso/mvp/packages/MainActivity.java @@ -228,7 +228,7 @@ public void onDrawerStateChanged(int newState) { } - drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + drawer = findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; } @@ -261,10 +261,10 @@ protected void onSaveInstanceState(Bundle outState) { */ private void initViews() { - toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); - drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + drawer = findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, @@ -273,7 +273,7 @@ private void initViews() { drawer.setDrawerListener(toggle); toggle.syncState(); - navigationView = (NavigationView) findViewById(R.id.nav_view); + navigationView = findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); } diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesFragment.java b/app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesFragment.java index 1627850..142b32d 100644 --- a/app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesFragment.java +++ b/app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesFragment.java @@ -201,12 +201,12 @@ public boolean onContextItemSelected(MenuItem item) { @Override public void initViews(View view) { - fab = (FloatingActionButton) view.findViewById(R.id.fab); - bottomNavigationView = (BottomNavigationView) view.findViewById(R.id.bottomNavigationView); - emptyView = (LinearLayout) view.findViewById(R.id.emptyView); - recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); + fab = view.findViewById(R.id.fab); + bottomNavigationView = view.findViewById(R.id.bottomNavigationView); + emptyView = view.findViewById(R.id.emptyView); + recyclerView = view.findViewById(R.id.recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refreshLayout); + refreshLayout = view.findViewById(R.id.refreshLayout); refreshLayout.setColorSchemeColors(ContextCompat.getColor(getContext(), R.color.colorPrimary)); // ItemTouchHelper helps to handle the drag or swipe action. diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/search/SearchFragment.java b/app/src/main/java/io/github/marktony/espresso/mvp/search/SearchFragment.java index b5acaa1..90395e5 100644 --- a/app/src/main/java/io/github/marktony/espresso/mvp/search/SearchFragment.java +++ b/app/src/main/java/io/github/marktony/espresso/mvp/search/SearchFragment.java @@ -119,9 +119,9 @@ public void initViews(View view) { activity.setSupportActionBar((Toolbar) view.findViewById(R.id.toolbar)); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); - searchView = (SearchView) view.findViewById(R.id.searchView); + searchView = view.findViewById(R.id.searchView); searchView.setIconified(false); - recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); + recyclerView = view.findViewById(R.id.recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); } diff --git a/app/src/main/java/io/github/marktony/espresso/ui/LicensesFragment.java b/app/src/main/java/io/github/marktony/espresso/ui/LicensesFragment.java index 3c04085..137cc0f 100644 --- a/app/src/main/java/io/github/marktony/espresso/ui/LicensesFragment.java +++ b/app/src/main/java/io/github/marktony/espresso/ui/LicensesFragment.java @@ -43,7 +43,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_licenses, container, false); - WebView webView = (WebView) view.findViewById(R.id.webView); + WebView webView = view.findViewById(R.id.webView); webView.loadUrl("file:///android_asset/license.html"); return view; diff --git a/app/src/main/java/io/github/marktony/espresso/ui/onboarding/OnboardingActivity.java b/app/src/main/java/io/github/marktony/espresso/ui/onboarding/OnboardingActivity.java index 90db507..502a207 100644 --- a/app/src/main/java/io/github/marktony/espresso/ui/onboarding/OnboardingActivity.java +++ b/app/src/main/java/io/github/marktony/espresso/ui/onboarding/OnboardingActivity.java @@ -61,6 +61,8 @@ public class OnboardingActivity extends AppCompatActivity { private static final int MSG_DATA_INSERT_FINISH = 1; + private Handler handler = new Handler(new HandlerCallback()); + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -138,16 +140,17 @@ public void onClick(View v) { private void initViews() { OnboardingPagerAdapter pagerAdapter = new OnboardingPagerAdapter(getSupportFragmentManager()); - viewPager = (ViewPager) findViewById(R.id.view_pager); + viewPager = findViewById(R.id.view_pager); viewPager.setAdapter(pagerAdapter); - buttonFinish = (AppCompatButton) findViewById(R.id.buttonFinish); + buttonFinish = findViewById(R.id.buttonFinish); buttonFinish.setText(R.string.onboarding_finish_button_description_wait); buttonFinish.setEnabled(false); - buttonNext = (ImageButton) findViewById(R.id.imageButtonNext); - buttonPre = (ImageButton) findViewById(R.id.imageButtonPre); - indicators = new ImageView[] {(ImageView) findViewById(R.id.imageViewIndicator0), - (ImageView) findViewById(R.id.imageViewIndicator1), - (ImageView) findViewById(R.id.imageViewIndicator2)}; + buttonNext = findViewById(R.id.imageButtonNext); + buttonPre = findViewById(R.id.imageButtonPre); + indicators = new ImageView[] { + findViewById(R.id.imageViewIndicator0), + findViewById(R.id.imageViewIndicator1), + findViewById(R.id.imageViewIndicator2) }; } private void initData() { @@ -164,17 +167,20 @@ private void updateIndicators(int position) { } } - private Handler handler = new Handler() { + private class HandlerCallback implements Handler.Callback { + @Override - public void handleMessage(Message msg) { - switch (msg.what) { + public boolean handleMessage(Message message) { + switch (message.what) { case MSG_DATA_INSERT_FINISH: + buttonFinish.setText(R.string.onboarding_finish_button_description); buttonFinish.setEnabled(true); break; } + return true; } - }; + } private class InitCompaniesDataTask extends AsyncTask { diff --git a/app/src/main/java/io/github/marktony/espresso/ui/onboarding/OnboardingFragment.java b/app/src/main/java/io/github/marktony/espresso/ui/onboarding/OnboardingFragment.java index 8bb1ea0..52a2d86 100644 --- a/app/src/main/java/io/github/marktony/espresso/ui/onboarding/OnboardingFragment.java +++ b/app/src/main/java/io/github/marktony/espresso/ui/onboarding/OnboardingFragment.java @@ -89,9 +89,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa } private void initViews(View view) { - sectionLabel = (AppCompatTextView) view.findViewById(R.id.section_label); - sectionIntro = (AppCompatTextView) view.findViewById(R.id.section_intro); - sectionImg = (ImageView) view.findViewById(R.id.section_img); + sectionLabel = view.findViewById(R.id.section_label); + sectionIntro = view.findViewById(R.id.section_intro); + sectionImg = view.findViewById(R.id.section_img); } } diff --git a/app/src/prod/java/io/github/marktony/espresso/Injection.java b/app/src/prod/java/io/github/marktony/espresso/Injection.java deleted file mode 100644 index fdf8c27..0000000 --- a/app/src/prod/java/io/github/marktony/espresso/Injection.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.marktony.espresso; - -import android.content.Context; -import android.support.annotation.NonNull; - -import io.github.marktony.espresso.data.source.PackagesRepository; -import io.github.marktony.espresso.data.source.local.PackagesLocalDataSource; -import io.github.marktony.espresso.data.source.remote.PackagesRemoteDataSource; - -/** - * Created by lizhaotailang on 2017/5/14. - * Enables injection of production implementations for - * {@link PackagesRepository} at compile time. - */ - -public class Injection { - - public static PackagesRepository providePackagesRepository(@NonNull Context context) { - return PackagesRepository.getInstance( - PackagesRemoteDataSource.getInstance(), - PackagesLocalDataSource.getInstance() - ); - } - -} diff --git a/build.gradle b/build.gradle index dfb47b3..4126c15 100644 --- a/build.gradle +++ b/build.gradle @@ -2,13 +2,14 @@ buildscript { repositories { + maven { url 'https://maven.google.com' } jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.1' + classpath 'com.android.tools.build:gradle:3.0.0-alpha1' // Realm database - classpath "io.realm:realm-gradle-plugin:3.0.0" + classpath "io.realm:realm-gradle-plugin:3.2.1" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -17,6 +18,7 @@ buildscript { allprojects { repositories { jcenter() + maven { url 'https://maven.google.com' } } } diff --git a/gradle.properties b/gradle.properties index aac7c9b..ede038c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m +org.gradle.jvmargs=-Xmx1000m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index dc28a0a..8b71aca 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip