diff --git a/app/build.gradle b/app/build.gradle
index 693109d..b69e3b6 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -26,10 +26,36 @@ android {
versionNameSuffix "debug"
}
}
+
lintOptions {
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 {
@@ -89,5 +115,4 @@ dependencies {
// Runner and rules
androidTestCompile "com.android.support.test:runner:$runnerRulesVersion"
androidTestCompile "com.android.support.test:rules:$runnerRulesVersion"
-
}
diff --git a/app/src/androidTest/java/io/github/marktony/espresso/about/AboutScreenTest.java b/app/src/androidTest/java/io/github/marktony/espresso/about/AboutScreenTest.java
new file mode 100644
index 0000000..631df2b
--- /dev/null
+++ b/app/src/androidTest/java/io/github/marktony/espresso/about/AboutScreenTest.java
@@ -0,0 +1,61 @@
+package io.github.marktony.espresso.about;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import io.github.marktony.espresso.R;
+import io.github.marktony.espresso.ui.PrefsActivity;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static android.support.test.espresso.matcher.ViewMatchers.withParent;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+import static org.hamcrest.core.AllOf.allOf;
+
+/**
+ * Created by lizhaotailang on 2017/5/13.
+ * Tests for the {@link io.github.marktony.espresso.ui.AboutFragment}.
+ */
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class AboutScreenTest {
+
+ /**
+ * {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
+ *
+ *
+ * Rules are interceptors which are executed for each test method and are important building
+ * blocks of Junit tests.
+ */
+ @Rule
+ public ActivityTestRule mPrefsActivityTestRule
+ = new ActivityTestRule(PrefsActivity.class){
+ @Override
+ protected Intent getActivityIntent() {
+ Context targetContext = InstrumentationRegistry.getInstrumentation()
+ .getTargetContext();
+ Intent intent = new Intent(targetContext, PrefsActivity.class);
+ intent.putExtra(PrefsActivity.EXTRA_FLAG, PrefsActivity.FLAG_ABOUT);
+ return intent;
+ }
+ };
+
+ @Test
+ public void test_AboutScreenDisplayed() {
+ onView(allOf(withParent(withId(R.id.toolbar)),
+ withText(R.string.nav_about)))
+ .check(matches(isDisplayed()));
+ }
+
+}
diff --git a/app/src/androidTest/java/io/github/marktony/espresso/addpackage/AddPackageScreenTest.java b/app/src/androidTest/java/io/github/marktony/espresso/addpackage/AddPackageScreenTest.java
new file mode 100644
index 0000000..8e94f97
--- /dev/null
+++ b/app/src/androidTest/java/io/github/marktony/espresso/addpackage/AddPackageScreenTest.java
@@ -0,0 +1,159 @@
+package io.github.marktony.espresso.addpackage;
+
+import android.os.Build;
+import android.support.test.espresso.matcher.ViewMatchers;
+import android.support.test.filters.LargeTest;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import io.github.marktony.espresso.R;
+import io.github.marktony.espresso.mvp.addpackage.AddPackageActivity;
+
+import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static android.support.test.InstrumentationRegistry.getTargetContext;
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
+import static android.support.test.espresso.action.ViewActions.typeText;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static android.support.test.espresso.matcher.ViewMatchers.withParent;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+import static org.hamcrest.core.AllOf.allOf;
+
+/**
+ * Created by lizhaotailang on 2017/5/14.
+ * Tests the components of {@link AddPackageActivity} layout.
+ */
+
+@RunWith(AndroidJUnit4.class)
+@LargeTest
+public class AddPackageScreenTest {
+
+ private String validPackageNumber;
+ private String invalidPackageNumber;
+
+ /**
+ * {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
+ *
+ *
+ * Rules are interceptors which are executed for each test method and are important building
+ * blocks of Junit tests.
+ */
+ @Rule
+ public ActivityTestRule mAddPackageActivityTestRule
+ = new ActivityTestRule<>(AddPackageActivity.class);
+
+ @Before
+ public void initNumbers() {
+ validPackageNumber = "958381347318";
+ invalidPackageNumber = "12345";
+ }
+
+ @Before
+ public void grantCameraPermission() {
+ // In M+, trying to call a number will trigger a runtime dialog. Make sure
+ // the permission is granted before running this test.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ getInstrumentation().getUiAutomation().executeShellCommand(
+ "pm grant " + getTargetContext().getPackageName()
+ + " android.permission.CAMERA");
+ }
+ }
+
+ @Test
+ public void test_AddPackageScreenDisplayed() {
+ // Check that the toolbar title was correct.
+ onView(withText(R.string.activity_add_package))
+ .check(matches(withParent(withId(R.id.toolbar))));
+ }
+
+ @Test
+ public void clickOnFab_ShowErrorTip() {
+ // Click the floating action button without inputting anything.
+ onView(withId(R.id.fab)).perform(click());
+
+ // Check that the snack bar was displayed.
+ onView(allOf(withId(android.support.design.R.id.snackbar_text),
+ withText(R.string.wrong_number_and_check)))
+ .check(matches(isDisplayed()));
+ }
+
+ @Test
+ public void typeValidNumber_ShowHomeScreen() {
+ onView(withId(R.id.editTextNumber))
+ .check(matches(isCompletelyDisplayed()));
+
+ // Type the valid number.
+ onView(withId(R.id.editTextNumber))
+ .perform(typeText(validPackageNumber), closeSoftKeyboard());
+
+ // Click the floating action button.
+ onView(withId(R.id.fab)).perform(click());
+
+ // Check that the package name edit text was filled automatically.
+ String name = mAddPackageActivityTestRule.getActivity().getString(R.string.package_name_default_pre)
+ + validPackageNumber.substring(0, 4);
+ onView(withId(R.id.editTextName))
+ .check(matches(withText(name)));
+
+ }
+
+ @Test
+ public void typeInvalidNumber_ShowErrorTip() {
+ onView(withId(R.id.editTextNumber))
+ .check(matches(isCompletelyDisplayed()));
+
+ // Type the valid number.
+ onView(withId(R.id.editTextNumber))
+ .perform(typeText(invalidPackageNumber), closeSoftKeyboard());
+
+ // Click the floating action button.
+ onView(withId(R.id.fab)).perform(click());
+
+ // Check that the package name edit text was filled automatically.
+ String name = mAddPackageActivityTestRule.getActivity().getString(R.string.package_name_default_pre)
+ + invalidPackageNumber.substring(0, 4);
+ onView(withId(R.id.editTextName))
+ .check(matches(withText(name)));
+
+ // Check that the snack bar with error message was displayed.
+ onView(allOf(withId(android.support.design.R.id.snackbar_text),
+ withText(R.string.wrong_number_and_check)))
+ .check(matches(isDisplayed()));
+ }
+
+ @Test
+ public void typeEmptyNumber_ShowErrorTip() {
+ onView(withId(R.id.editTextNumber))
+ .check(matches(isCompletelyDisplayed()));
+
+ // Type empty.
+ onView(withId(R.id.editTextNumber))
+ .perform(typeText(""), closeSoftKeyboard());
+
+ // Click the floating action button.
+ onView(withId(R.id.fab)).perform(click());
+
+ // Check that the progress bar was gone.
+ onView(withId(R.id.progressBar))
+ .check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
+
+ // Check that the package name edit text was filled automatically.
+ onView(withId(R.id.editTextName))
+ .check(matches(withText("")));
+
+ // Check that the snack bar with error message was displayed.
+ onView(allOf(withId(android.support.design.R.id.snackbar_text),
+ withText(R.string.wrong_number_and_check)))
+ .check(matches(isDisplayed()));
+ }
+
+}
diff --git a/app/src/androidTest/java/io/github/marktony/espresso/onboarding/OnboardingScreenTest.java b/app/src/androidTest/java/io/github/marktony/espresso/onboarding/OnboardingScreenTest.java
index b454f24..4bdcf1a 100644
--- a/app/src/androidTest/java/io/github/marktony/espresso/onboarding/OnboardingScreenTest.java
+++ b/app/src/androidTest/java/io/github/marktony/espresso/onboarding/OnboardingScreenTest.java
@@ -1,14 +1,26 @@
package io.github.marktony.espresso.onboarding;
+import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
+import org.junit.Test;
import org.junit.runner.RunWith;
+import io.github.marktony.espresso.R;
import io.github.marktony.espresso.ui.onboarding.OnboardingActivity;
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.action.ViewActions.swipeLeft;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
+import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+
/**
* Created by lizhaotailang on 2017/5/13.
* Tests for the {@link android.support.v4.view.ViewPager} and
@@ -27,7 +39,63 @@ public class OnboardingScreenTest {
* blocks of Junit tests.
*/
@Rule
- ActivityTestRule mOnboardingActivityTestRule
+ public ActivityTestRule mOnboardingActivityTestRule
= new ActivityTestRule<>(OnboardingActivity.class);
+ @Test
+ public void swipeViewPager_scrollPage() {
+ // Check that the finish button was invisible.
+ onView(withId(R.id.buttonFinish))
+ .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
+
+ // Check that the previous button was not available.
+ onView(withId(R.id.imageButtonPre))
+ .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
+
+ // Check that the ViewPager was displayed.
+ onView(withId(R.id.view_pager))
+ .check(matches(isDisplayed()));
+
+ // Scroll the ViewPager
+ // Now the app is in the second position.
+ onView(withId(R.id.view_pager))
+ .perform(swipeLeft());
+
+ // Check that the finish button was gone.
+ onView(withId(R.id.buttonFinish))
+ .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
+
+ // Check that the previous button was visible.
+ onView(withId(R.id.imageButtonPre))
+ .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)));
+
+ // Check that the next button was visible.
+ onView(withId(R.id.imageButtonNext))
+ .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)));
+
+ // Click the next button to scroll the ViewPager.
+ onView(withId(R.id.imageButtonNext))
+ .perform(click()); // Now the app is in the third position.
+
+ // Check that the finish button was visible and enabled.
+ onView(withId(R.id.buttonFinish))
+ .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)));
+
+ // Check that the next button was not available.
+ onView(withId(R.id.imageButtonNext))
+ .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
+
+ // Check the finish button is enabled.
+ onView(withId(R.id.buttonFinish))
+ .check(matches(isEnabled()));
+
+ // Check the finish button is visible.
+ onView(withId(R.id.buttonFinish))
+ .perform(click());
+
+ // Check that main activity was opened.
+ onView(withId(R.id.drawer_layout))
+ .check(matches(isDisplayed()));
+ }
+
}
diff --git a/app/src/androidTest/java/io/github/marktony/espresso/packages/AppNavigationTest.java b/app/src/androidTest/java/io/github/marktony/espresso/packages/AppNavigationTest.java
index 526ac45..3ce328b 100644
--- a/app/src/androidTest/java/io/github/marktony/espresso/packages/AppNavigationTest.java
+++ b/app/src/androidTest/java/io/github/marktony/espresso/packages/AppNavigationTest.java
@@ -114,7 +114,7 @@ public void clickOnNavigationDrawerItem_ShowsAboutScreen() {
.perform(navigateTo(R.id.nav_about));
// Check that title is correct.
- onView(allOf(withParent(withId(R.id.toolbar)),
+ onView(allOf(withParent(withId(R.id.toolbar)),
withText(R.string.nav_about)))
.check(matches(isDisplayed()));
}
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 c8e8666..beca415 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
@@ -3,12 +3,25 @@
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
+import android.view.Gravity;
+import org.junit.Before;
import org.junit.Rule;
+import org.junit.Test;
import org.junit.runner.RunWith;
+import io.github.marktony.espresso.R;
import io.github.marktony.espresso.mvp.packages.MainActivity;
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.contrib.DrawerActions.open;
+import static android.support.test.espresso.contrib.DrawerMatchers.isClosed;
+import static android.support.test.espresso.contrib.NavigationViewActions.navigateTo;
+import static android.support.test.espresso.matcher.ViewMatchers.isClickable;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+
/**
* Created by lizhaotailang on 2017/5/12.
*/
@@ -21,6 +34,28 @@ public class PackagesScreenTest {
public ActivityTestRule mainActivityActivityTestRule
= new ActivityTestRule<>(MainActivity.class);
-
+ @Before
+ public void navigateToPackagesScreen() {
+ onView(withId(R.id.drawer_layout))
+ .check(matches(isClosed(Gravity.LEFT))) // Left drawer should be closed.
+ .perform(open()); // Open the drawer.
+
+ // Start packages screen
+ onView(withId(R.id.nav_view))
+ .perform(navigateTo(R.id.nav_home));
+ }
+
+ @Test
+ public void test_PackagesScreenDisplayed() {
+ // Check that the bottom navigation view was displayed.
+ onView(withId(R.id.bottomNavigationView))
+ .check(matches(isDisplayed()));
+
+ // Check that the fab was displayed.
+ onView(withId(R.id.fab))
+ .check(matches(isDisplayed()));
+ onView(withId(R.id.fab))
+ .check(matches(isClickable()));
+ }
}
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
new file mode 100644
index 0000000..cb40f27
--- /dev/null
+++ b/app/src/androidTest/java/io/github/marktony/espresso/settings/SettingsScreenTest.java
@@ -0,0 +1,60 @@
+package io.github.marktony.espresso.settings;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import io.github.marktony.espresso.R;
+import io.github.marktony.espresso.ui.PrefsActivity;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static android.support.test.espresso.matcher.ViewMatchers.withParent;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+import static org.hamcrest.core.AllOf.allOf;
+
+/**
+ * Created by lizhaotailang on 2017/5/14.
+ */
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class SettingsScreenTest {
+
+ /**
+ * {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
+ *
+ *
+ * Rules are interceptors which are executed for each test method and are important building
+ * blocks of Junit tests.
+ */
+ @Rule
+ public ActivityTestRule mPrefsActivityTestRule
+ = new ActivityTestRule(PrefsActivity.class) {
+ @Override
+ protected Intent getActivityIntent() {
+ Context targetContext = InstrumentationRegistry.getInstrumentation()
+ .getTargetContext();
+ Intent intent = new Intent(targetContext, PrefsActivity.class);
+ intent.putExtra(PrefsActivity.EXTRA_FLAG, PrefsActivity.FLAG_SETTINGS);
+ return intent;
+ }
+ };
+
+ @Test
+ public void test_SettingsScreenDisplayed() {
+ onView(allOf(withParent(withId(R.id.toolbar)),
+ withText(R.string.nav_settings)))
+ .check(matches(isDisplayed()));
+ }
+
+}
diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageActivity.java b/app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageActivity.java
index cdd58bd..b1ad178 100644
--- a/app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageActivity.java
+++ b/app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageActivity.java
@@ -21,8 +21,6 @@
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
-import android.transition.Explode;
-import android.view.animation.AccelerateDecelerateInterpolator;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.data.source.CompaniesRepository;
@@ -49,11 +47,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
- Explode explode = new Explode();
- explode.setDuration(500);
- explode.setInterpolator(new AccelerateDecelerateInterpolator());
- getWindow().setEnterTransition(explode);
-
if (savedInstanceState != null) {
fragment = (AddPackageFragment) getSupportFragmentManager().getFragment(savedInstanceState, "AddPackageFragment");
} else {
@@ -62,7 +55,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (!fragment.isAdded()) {
getSupportFragmentManager().beginTransaction()
- .replace(R.id.container, fragment, "AddPackageFragment")
+ .replace(R.id.view_pager, fragment, "AddPackageFragment")
.commit();
}
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 a70463c..9ee5be3 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
@@ -16,7 +16,6 @@
package io.github.marktony.espresso.mvp.companies;
-import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
@@ -71,7 +70,6 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
initViews(view);
-
setHasOptionsMenu(true);
return view;
@@ -98,8 +96,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_search) {
- startActivity(new Intent(getContext(), SearchActivity.class),
- ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
+ startActivity(new Intent(getContext(), SearchActivity.class));
}
return true;
}
@@ -118,7 +115,7 @@ public void setPresenter(@NonNull CompaniesContract.Presenter presenter) {
@Override
public void showGetCompaniesError() {
- Snackbar.make(recyclerView, "获取失败", Snackbar.LENGTH_SHORT).show();
+ Snackbar.make(recyclerView, R.string.something_wrong, Snackbar.LENGTH_SHORT).show();
}
@Override
@@ -130,7 +127,7 @@ public void showCompanies(final List list) {
public void OnItemClick(View v, int position) {
Intent intent = new Intent(getContext(), CompanyDetailActivity.class);
intent.putExtra(CompanyDetailActivity.COMPANY_ID, list.get(position).getId());
- startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
+ startActivity(intent);
}
});
recyclerView.setAdapter(adapter);
diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailActivity.java b/app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailActivity.java
index aea8c47..d353d86 100644
--- a/app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailActivity.java
+++ b/app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailActivity.java
@@ -48,11 +48,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
- Explode explode = new Explode();
- explode.setDuration(500);
- explode.setInterpolator(new AccelerateDecelerateInterpolator());
- getWindow().setEnterTransition(explode);
-
if (savedInstanceState != null) {
fragment = (CompanyDetailFragment) getSupportFragmentManager().getFragment(savedInstanceState, "CompanyDetailFragment");
} else {
@@ -61,7 +56,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (!fragment.isAdded()) {
getSupportFragmentManager().beginTransaction()
- .add(R.id.container, fragment, "CompanyDetailFragment")
+ .add(R.id.view_pager, fragment, "CompanyDetailFragment")
.commit();
}
diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsActivity.java b/app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsActivity.java
index 844866c..8a7b38e 100644
--- a/app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsActivity.java
+++ b/app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsActivity.java
@@ -21,8 +21,6 @@
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
-import android.transition.Explode;
-import android.view.animation.AccelerateDecelerateInterpolator;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.data.source.local.PackagesLocalDataSource;
@@ -49,11 +47,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
- Explode explode = new Explode();
- explode.setDuration(500);
- explode.setInterpolator(new AccelerateDecelerateInterpolator());
- getWindow().setEnterTransition(explode);
-
// Restore the status.
if (savedInstanceState != null) {
fragment = (PackageDetailsFragment) getSupportFragmentManager().getFragment(savedInstanceState, "PackageDetailsFragment");
@@ -62,7 +55,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}
getSupportFragmentManager().beginTransaction()
- .replace(R.id.container, fragment)
+ .replace(R.id.view_pager, fragment)
.commit();
// Create the presenter.
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 20b3be1..36e87e8 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
@@ -16,7 +16,6 @@
package io.github.marktony.espresso.mvp.packages;
-import android.app.ActivityOptions;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
@@ -32,12 +31,9 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
-import android.transition.Explode;
-import android.transition.Slide;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.view.animation.AccelerateDecelerateInterpolator;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.appwidget.AppWidgetProvider;
@@ -83,17 +79,6 @@ protected void onCreate(Bundle savedInstanceState) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
- // Begin the slide animation.
- Slide slide = new Slide();
- slide.setDuration(500);
- slide.setInterpolator(new AccelerateDecelerateInterpolator());
- getWindow().setExitTransition(slide);
-
- Explode explode = new Explode();
- explode.setDuration(500);
- explode.setInterpolator(new AccelerateDecelerateInterpolator());
- getWindow().setEnterTransition(explode);
-
initViews();
// Init the fragments.
@@ -233,13 +218,13 @@ public void onDrawerStateChanged(int newState) {
Intent intent = new Intent(MainActivity.this, PrefsActivity.class);
intent.putExtra(PrefsActivity.EXTRA_FLAG, PrefsActivity.FLAG_SETTINGS);
- startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
+ startActivity(intent);
} else if (id == R.id.nav_about) {
Intent intent = new Intent(MainActivity.this, PrefsActivity.class);
intent.putExtra(PrefsActivity.EXTRA_FLAG, PrefsActivity.FLAG_ABOUT);
- startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
+ startActivity(intent);
}
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 dd0b5ed..1627850 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
@@ -16,7 +16,6 @@
package io.github.marktony.espresso.mvp.packages;
-import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
@@ -96,8 +95,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- startActivity(new Intent(getContext(), AddPackageActivity.class),
- ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
+ startActivity(new Intent(getContext(), AddPackageActivity.class));
}
});
@@ -165,8 +163,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_search) {
- startActivity(new Intent(getContext(), SearchActivity.class),
- ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
+ startActivity(new Intent(getContext(), SearchActivity.class));
} else if (id == R.id.action_mark_all_read) {
presenter.markAllPacksRead();
}
@@ -332,7 +329,7 @@ public void showPackages(@NonNull final List list) {
public void OnItemClick(View v, int position) {
Intent intent = new Intent(getContext(), PackageDetailsActivity.class);
intent.putExtra(PackageDetailsActivity.PACKAGE_ID, list.get(position).getNumber());
- startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
+ startActivity(intent);
}
});
diff --git a/app/src/main/java/io/github/marktony/espresso/mvp/search/SearchActivity.java b/app/src/main/java/io/github/marktony/espresso/mvp/search/SearchActivity.java
index 534e160..48e382b 100644
--- a/app/src/main/java/io/github/marktony/espresso/mvp/search/SearchActivity.java
+++ b/app/src/main/java/io/github/marktony/espresso/mvp/search/SearchActivity.java
@@ -21,8 +21,6 @@
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
-import android.transition.Explode;
-import android.view.animation.AccelerateDecelerateInterpolator;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.data.source.CompaniesRepository;
@@ -45,12 +43,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
- // Set the animations.
- Explode explode = new Explode();
- explode.setDuration(500);
- explode.setInterpolator(new AccelerateDecelerateInterpolator());
- getWindow().setEnterTransition(explode);
-
if (savedInstanceState != null) {
fragment = (SearchFragment) getSupportFragmentManager().getFragment(savedInstanceState, "SearchFragment");
} else {
@@ -58,7 +50,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}
getSupportFragmentManager().beginTransaction()
- .replace(R.id.container, fragment)
+ .replace(R.id.view_pager, fragment)
.commit();
new SearchPresenter(fragment,
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 061af7d..b5acaa1 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
@@ -16,7 +16,6 @@
package io.github.marktony.espresso.mvp.search;
-import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -146,13 +145,13 @@ public void OnItemClick(View v, int position) {
Intent intent = new Intent(getContext(), PackageDetailsActivity.class);
intent.putExtra(PackageDetailsActivity.PACKAGE_ID, packages.get(adapter.getOriginalIndex(position)).getNumber());
- startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
+ startActivity(intent);
} else if (adapter.getItemViewType(position) == SearchResultsAdapter.ItemWrapper.TYPE_COMPANY) {
Intent intent = new Intent(getContext(), CompanyDetailActivity.class);
intent.putExtra(CompanyDetailActivity.COMPANY_ID, companies.get(adapter.getOriginalIndex(position)).getId());
- startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
+ startActivity(intent);
}
}
diff --git a/app/src/main/java/io/github/marktony/espresso/ui/PrefsActivity.java b/app/src/main/java/io/github/marktony/espresso/ui/PrefsActivity.java
index bf67825..3959311 100644
--- a/app/src/main/java/io/github/marktony/espresso/ui/PrefsActivity.java
+++ b/app/src/main/java/io/github/marktony/espresso/ui/PrefsActivity.java
@@ -25,9 +25,7 @@
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
-import android.transition.Explode;
import android.view.MenuItem;
-import android.view.animation.AccelerateDecelerateInterpolator;
import io.github.marktony.espresso.R;
@@ -51,11 +49,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
- Explode explode = new Explode();
- explode.setDuration(500);
- explode.setInterpolator(new AccelerateDecelerateInterpolator());
- getWindow().setEnterTransition(explode);
-
initViews();
Intent intent = getIntent();
@@ -76,7 +69,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getSupportFragmentManager()
.beginTransaction()
- .replace(R.id.container,fragment)
+ .replace(R.id.view_pager,fragment)
.commit();
}
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 20868ea..90db507 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
@@ -138,7 +138,7 @@ public void onClick(View v) {
private void initViews() {
OnboardingPagerAdapter pagerAdapter = new OnboardingPagerAdapter(getSupportFragmentManager());
- viewPager = (ViewPager) findViewById(R.id.container);
+ viewPager = (ViewPager) findViewById(R.id.view_pager);
viewPager.setAdapter(pagerAdapter);
buttonFinish = (AppCompatButton) findViewById(R.id.buttonFinish);
buttonFinish.setText(R.string.onboarding_finish_button_description_wait);
diff --git a/app/src/main/res/layout/activity_onboarding.xml b/app/src/main/res/layout/activity_onboarding.xml
index 1c16a23..880260b 100644
--- a/app/src/main/res/layout/activity_onboarding.xml
+++ b/app/src/main/res/layout/activity_onboarding.xml
@@ -24,7 +24,7 @@
tools:context=".ui.onboarding.OnboardingActivity">
diff --git a/app/src/main/res/layout/activity_scan.xml b/app/src/main/res/layout/activity_scan.xml
index 05f682a..f84ce6c 100644
--- a/app/src/main/res/layout/activity_scan.xml
+++ b/app/src/main/res/layout/activity_scan.xml
@@ -21,6 +21,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:id="@+id/layout_scan_code"
android:fitsSystemWindows="true"
tools:context=".zxing.CaptureActivity">
diff --git a/app/src/main/res/layout/container.xml b/app/src/main/res/layout/container.xml
index 4394098..f65b02c 100644
--- a/app/src/main/res/layout/container.xml
+++ b/app/src/main/res/layout/container.xml
@@ -18,5 +18,5 @@
diff --git a/app/src/main/res/xml/about_prefs.xml b/app/src/main/res/xml/about_prefs.xml
index d013ef0..e4a8bd5 100644
--- a/app/src/main/res/xml/about_prefs.xml
+++ b/app/src/main/res/xml/about_prefs.xml
@@ -16,7 +16,8 @@
-->
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/preferences_about">
diff --git a/app/src/prod/java/io/github/marktony/espresso/Injection.java b/app/src/prod/java/io/github/marktony/espresso/Injection.java
new file mode 100644
index 0000000..fdf8c27
--- /dev/null
+++ b/app/src/prod/java/io/github/marktony/espresso/Injection.java
@@ -0,0 +1,25 @@
+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()
+ );
+ }
+
+}